Skip to content

Instantly share code, notes, and snippets.

@maekawatoshiki
Created March 22, 2020 12:45
Show Gist options
  • Save maekawatoshiki/7b1bebf0fffa34fdeccfec60f3624026 to your computer and use it in GitHub Desktop.
Save maekawatoshiki/7b1bebf0fffa34fdeccfec60f3624026 to your computer and use it in GitHub Desktop.
理想の命令選択パターンマッチ構文を考える
%c = (%a + %b) => addrr
%c = add(%a, $imm) => addri
%c = %a + %b
: %c i32/f32
: %a i32/f32
: %b i32/f32
=> addrr / faddrr
(add a, b
:( a GR32 => :( b GR32 => ADDrr a, b )
:( b i32 => ADDri a, b ) ) )
add a, b:
GR32 a:
i32 b => (ADDri a, b)
GR32 b => (ADDrr a, b)
[add a, b]:
GR32 a:
i32 b => [ADDri a, b]
GR32 b => [ADDrr a, b]
(load (add a, b)):
frame_index a:
i32 b => (mov [a + b])
GR32 b => (mov [a + b])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment