x86instr.sml 1.9 KB
structure X86Instr : MACHINE_INSTR = struct

  datatype UnaryInstr = PUSH
                      | POP
                      | NEG
                      | NOT
                      | INC
                      | DEC
                      | IDIV

  datatype BinayInstr = MOV
                      | ADD
                      | SUB
                      | SHL
                      | SHR
                      | SAL
                      | SAR
                      | AND
                      | OR
                      | XOR
                      | TEST
                      | CMP
                      | LEA
                      | IMUL

  datatype Cond = E | NE | L | LE | G | GE | Z

  (* possible scaling values for effective addressing *)
  datatype Scale = S1 | S2 | S4 | S8

  type EffectiveAddress = { base : Temp.t option,
                            indexScale : (Temp.t * Scale) option,
                            displacement : int }

  datatype Operand = Imm of int
                   | Reg of Temp.t
                   | Mem of EffectiveAddress

  datatype t = Unary of UnaryInstr * Operand
             | Binary of BinayInstr * Operand * Operand
             | LABEL of Label.t
             | CDQ
             | JMP of Label.t
             | J of Cond * Label.t
             | CALL of Label.t
             | RET of unit
             | NOP of unit

  fun use i = raise (Fail "needed later for register allocation")
  fun def i = raise (Fail "needed later for register allocation")
  fun jumps i = raise (Fail "needed later for register allocation")
  fun isFallThrough i = raise (Fail "needed later for register allocation")
  fun isMoveBetweenTemps i = raise (Fail "needed later for register allocation")
  fun isAssignmentToTemp i = raise (Fail "needed later for register allocation")
  fun isLabel i = raise (Fail "needed later for register allocation")
  fun renameInstr i = raise (Fail "needed later for register allocation")

end