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]