diff options
Diffstat (limited to 'X64Optimiser.hs')
-rw-r--r-- | X64Optimiser.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/X64Optimiser.hs b/X64Optimiser.hs new file mode 100644 index 0000000..9cae96d --- /dev/null +++ b/X64Optimiser.hs @@ -0,0 +1,15 @@ +module X64Optimiser(x64Optimise) where + +import Defs +import X64 + + +x64Optimise :: Asm -> Error Asm +x64Optimise (Asm funcs) = return $ Asm [(name, concat $ map goI inss) | (name, inss) <- funcs] + where + goI :: Ins -> [Ins] + goI (MOV (RegMem a) (RegMem b)) | a == b = [] + goI (MOVi (RegMem a) (Imm (XImm 0))) | isXReg a = [XOR (RegMem a) (RegMemImm a)] + goI (MOVi64 (Reg a) (Imm (XImm 0))) = [XOR (RegMem a) (RegMemImm a)] + goI (MOVSX (Reg a) (RegMem b)) | a == b = [] + goI ins = [ins] |