diff options
| author | Andrew Chambers <[email protected]> | 2021-10-11 16:57:19 +1300 |
|---|---|---|
| committer | Andrew Chambers <[email protected]> | 2021-10-11 16:57:19 +1300 |
| commit | 79f7dab1793f38773bb7570322488a887a9693dc (patch) | |
| tree | 9ca81f94b05157e3da5ec781e4be9ea7ccb8471e /asm.peg | |
| parent | 9e3472e4899c83a6a078db0b8881eead671fb7da (diff) | |
Work on floating point support.
Diffstat (limited to 'asm.peg')
| -rw-r--r-- | asm.peg | 116 |
1 files changed, 85 insertions, 31 deletions
@@ -56,37 +56,42 @@ label = instr = # XXX Order the rules by frequency to get better lookup time. - "nop" { $$.kind = ASM_NOP; } - | "leave" { $$.kind = ASM_LEAVE; } - | "ret" { $$.kind = ASM_RET; } - | "cltd" { $$.kind = ASM_CLTD; } - | "cqto" { $$.kind = ASM_CQTO; } - | i:push { $$ = i; } - | i:pop { $$ = i; } - | i:call { $$ = i; } - | i:jmp { $$ = i; } - | i:add { $$ = i; } - | i:and { $$ = i; } - | i:cmp { $$ = i; } - | i:div { $$ = i; } - | i:idiv { $$ = i; } - | i:lea { $$ = i; } - | i:mul { $$ = i; } - | i:imul { $$ = i; } - | i:neg { $$ = i; } - | i:movsx { $$ = i; } - | i:movzx { $$ = i; } - | i:mov { $$ = i; } - | i:or { $$ = i; } - | i:set { $$ = i; } - | i:sub { $$ = i; } - | i:sal { $$ = i; } - | i:sar { $$ = i; } - | i:shl { $$ = i; } - | i:shr { $$ = i; } - | i:test { $$ = i; } - | i:xchg { $$ = i; } - | i:xor { $$ = i; } + "nop" { $$.kind = ASM_NOP; } + | "leave" { $$.kind = ASM_LEAVE; } + | "ret" { $$.kind = ASM_RET; } + | "cltd" { $$.kind = ASM_CLTD; } + | "cqto" { $$.kind = ASM_CQTO; } + | i:push { $$ = i; } + | i:pop { $$ = i; } + | i:call { $$ = i; } + | i:jmp { $$ = i; } + | i:add { $$ = i; } + | i:and { $$ = i; } + | i:cmp { $$ = i; } + | i:div { $$ = i; } + | i:idiv { $$ = i; } + | i:lea { $$ = i; } + | i:mulsd { $$ = i; } + | i:mulss { $$ = i; } + | i:mul { $$ = i; } + | i:imul { $$ = i; } + | i:neg { $$ = i; } + | i:movsx { $$ = i; } + | i:movzx { $$ = i; } + | i:mov { $$ = i; } + | i:or { $$ = i; } + | i:set { $$ = i; } + | i:sub { $$ = i; } + | i:sal { $$ = i; } + | i:sar { $$ = i; } + | i:shl { $$ = i; } + | i:shr { $$ = i; } + | i:test { $$ = i; } + | i:ucomisd { $$ = i; } + | i:ucomiss { $$ = i; } + | i:test { $$ = i; } + | i:xchg { $$ = i; } + | i:xor { $$ = i; } push = "push" ( @@ -160,6 +165,26 @@ idiv = "idiv" ( | args:r-opargs { args.instr.variant += 4 ; $$ = args; } ) { $$.instr.kind = ASM_IDIV; } +mulsd = "mulsd" ( + ws s:r-xmm ws? ',' ws? d:r-xmm { $$ = INSTR2(0, s, d); } + | ws s:m ws? ',' ws? d:r-xmm { $$ = INSTR2(1, s, d); } +) { $$.instr.kind = ASM_MULSD; } + +mulss = "mulss" ( + ws s:r-xmm ws? ',' ws? d:r-xmm { $$ = INSTR2(0, s, d); } + | ws s:m ws? ',' ws? d:r-xmm { $$ = INSTR2(1, s, d); } +) { $$.instr.kind = ASM_MULSS; } + +ucomiss = "ucomiss" ( + ws s:r-xmm ws? ',' ws? d:r-xmm { $$ = INSTR2(0, s, d); } + | ws s:m ws? ',' ws? d:r-xmm { $$ = INSTR2(1, s, d); } +) { $$.instr.kind = ASM_UCOMISS; } + +ucomisd = "ucomisd" ( + ws s:r-xmm ws? ',' ws? d:r-xmm { $$ = INSTR2(0, s, d); } + | ws s:m ws? ',' ws? d:r-xmm { $$ = INSTR2(1, s, d); } +) { $$.instr.kind = ASM_UCOMISD; } + mul = "mul" ( args:m-opargs { $$ = args; } | args:r-opargs { args.instr.variant += 4 ; $$ = args; } @@ -440,6 +465,35 @@ r64 = | "%r14" ![lwb] { $$ = REG(ASM_R14); } | "%r15" ![lwb] { $$ = REG(ASM_R15); } +r-mm = + "%mm0" { $$ = REG(ASM_MM0); } + | "%mm1" { $$ = REG(ASM_MM1); } + | "%mm2" { $$ = REG(ASM_MM2); } + | "%mm3" { $$ = REG(ASM_MM3); } + | "%mm4" { $$ = REG(ASM_MM4); } + | "%mm5" { $$ = REG(ASM_MM5); } + | "%mm6" { $$ = REG(ASM_MM6); } + | "%mm7" { $$ = REG(ASM_MM7); } + +r-xmm = + # Reverse order due to peg ordering. + "%xmm15" { $$ = REG(ASM_XMM15); } + | "%xmm14" { $$ = REG(ASM_XMM14); } + | "%xmm13" { $$ = REG(ASM_XMM13); } + | "%xmm12" { $$ = REG(ASM_XMM12); } + | "%xmm11" { $$ = REG(ASM_XMM11); } + | "%xmm10" { $$ = REG(ASM_XMM10); } + | "%xmm9" { $$ = REG(ASM_XMM7); } + | "%xmm8" { $$ = REG(ASM_XMM7); } + | "%xmm7" { $$ = REG(ASM_XMM7); } + | "%xmm6" { $$ = REG(ASM_XMM6); } + | "%xmm5" { $$ = REG(ASM_XMM5); } + | "%xmm4" { $$ = REG(ASM_XMM4); } + | "%xmm3" { $$ = REG(ASM_XMM3); } + | "%xmm2" { $$ = REG(ASM_XMM2); } + | "%xmm1" { $$ = REG(ASM_XMM1); } + | "%xmm0" { $$ = REG(ASM_XMM0); } + # We disallow newlines in our strings, it is simpler for lineno tracking. string = '"' <(string-escape | ( ! '\n' ! '\\' !'"' .))*> '"' { $$.string = decodestring(yytext); } |
