diff --git a/lib/Target/X86/X86InstrArithmetic.td b/lib/Target/X86/X86InstrArithmetic.td index 73a4fcc3085..e131538352e 100644 --- a/lib/Target/X86/X86InstrArithmetic.td +++ b/lib/Target/X86/X86InstrArithmetic.td @@ -598,7 +598,7 @@ class ITy opcode, Format f, X86TypeInfo typeinfo, dag outs, dag ins, let hasREX_WPrefix = typeinfo.HasREX_WPrefix; } - +// BinOpRR - Instructions like "add reg, reg, reg". class BinOpRR opcode, string mnemonic, X86TypeInfo typeinfo, SDNode opnode> : ITy opcode, string mnemonic, X86TypeInfo typeinfo, [(set typeinfo.RegClass:$dst, EFLAGS, (opnode typeinfo.RegClass:$src1, typeinfo.RegClass:$src2))]>; +// BinOpRR_Rev - Instructions like "add reg, reg, reg" (reversed encoding). class BinOpRR_Rev opcode, string mnemonic, X86TypeInfo typeinfo> : ITy opcode, string mnemonic, X86TypeInfo typeinfo> let isCodeGenOnly = 1; } +// BinOpRM - Instructions like "add reg, reg, [mem]". class BinOpRM opcode, string mnemonic, X86TypeInfo typeinfo, SDNode opnode> : ITy opcode, string mnemonic, X86TypeInfo typeinfo, let ImmT = Imm8; // Always 8-bit immediate. } +// BinOpMR - Instructions like "add [mem], reg". +class BinOpMR opcode, string mnemonic, X86TypeInfo typeinfo, + SDNode opnode> + : ITy; + +// BinOpMI - Instructions like "add [mem], imm". +class BinOpMI opcode, string mnemonic, X86TypeInfo typeinfo, + SDNode opnode, Format f> + : ITy { + let ImmT = typeinfo.ImmEncoding; +} + +// BinOpMI8 - Instructions like "add [mem], imm8". +class BinOpMI8 opcode, string mnemonic, X86TypeInfo typeinfo, + SDNode opnode, Format f> + : ITy { + let ImmT = Imm8; // Always 8-bit immediate. +} + // Logical operators. let Defs = [EFLAGS] in { @@ -687,68 +722,24 @@ def AND32ri8 : BinOpRI8<0x82, "and", Xi32, X86and_flag, MRM4r>; def AND64ri8 : BinOpRI8<0x82, "and", Xi64, X86and_flag, MRM4r>; } // Constraints = "$src1 = $dst" -def AND8mr : I<0x20, MRMDestMem, - (outs), (ins i8mem :$dst, GR8 :$src), - "and{b}\t{$src, $dst|$dst, $src}", - [(store (and (load addr:$dst), GR8:$src), addr:$dst), - (implicit EFLAGS)]>; -def AND16mr : I<0x21, MRMDestMem, - (outs), (ins i16mem:$dst, GR16:$src), - "and{w}\t{$src, $dst|$dst, $src}", - [(store (and (load addr:$dst), GR16:$src), addr:$dst), - (implicit EFLAGS)]>, - OpSize; -def AND32mr : I<0x21, MRMDestMem, - (outs), (ins i32mem:$dst, GR32:$src), - "and{l}\t{$src, $dst|$dst, $src}", - [(store (and (load addr:$dst), GR32:$src), addr:$dst), - (implicit EFLAGS)]>; -def AND64mr : RI<0x21, MRMDestMem, - (outs), (ins i64mem:$dst, GR64:$src), - "and{q}\t{$src, $dst|$dst, $src}", - [(store (and (load addr:$dst), GR64:$src), addr:$dst), - (implicit EFLAGS)]>; -def AND8mi : Ii8<0x80, MRM4m, - (outs), (ins i8mem :$dst, i8imm :$src), - "and{b}\t{$src, $dst|$dst, $src}", - [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst), - (implicit EFLAGS)]>; -def AND16mi : Ii16<0x81, MRM4m, - (outs), (ins i16mem:$dst, i16imm:$src), - "and{w}\t{$src, $dst|$dst, $src}", - [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst), - (implicit EFLAGS)]>, - OpSize; -def AND32mi : Ii32<0x81, MRM4m, - (outs), (ins i32mem:$dst, i32imm:$src), - "and{l}\t{$src, $dst|$dst, $src}", - [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst), - (implicit EFLAGS)]>; -def AND64mi32 : RIi32<0x81, MRM4m, - (outs), (ins i64mem:$dst, i64i32imm:$src), - "and{q}\t{$src, $dst|$dst, $src}", - [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst), - (implicit EFLAGS)]>; +def AND8mr : BinOpMR<0x20, "and", Xi8 , and>; +def AND16mr : BinOpMR<0x20, "and", Xi16, and>; +def AND32mr : BinOpMR<0x20, "and", Xi32, and>; +def AND64mr : BinOpMR<0x20, "and", Xi64, and>; -def AND16mi8 : Ii8<0x83, MRM4m, - (outs), (ins i16mem:$dst, i16i8imm :$src), - "and{w}\t{$src, $dst|$dst, $src}", - [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst), - (implicit EFLAGS)]>, - OpSize; -def AND32mi8 : Ii8<0x83, MRM4m, - (outs), (ins i32mem:$dst, i32i8imm :$src), - "and{l}\t{$src, $dst|$dst, $src}", - [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst), - (implicit EFLAGS)]>; -def AND64mi8 : RIi8<0x83, MRM4m, - (outs), (ins i64mem:$dst, i64i8imm :$src), - "and{q}\t{$src, $dst|$dst, $src}", - [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst), - (implicit EFLAGS)]>; -// FIXME: Implicitly modifiers AL. +def AND8mi : BinOpMI<0x80, "and", Xi8 , and, MRM4m>; +def AND16mi : BinOpMI<0x80, "and", Xi16, and, MRM4m>; +def AND32mi : BinOpMI<0x80, "and", Xi32, and, MRM4m>; +def AND64mi32 : BinOpMI<0x80, "and", Xi64, and, MRM4m>; + +def AND16mi8 : BinOpMI8<0x82, "and", Xi16, and, MRM4m>; +def AND32mi8 : BinOpMI8<0x82, "and", Xi32, and, MRM4m>; +def AND64mi8 : BinOpMI8<0x82, "and", Xi64, and, MRM4m>; + + +// FIXME: Implicitly modifies AL. def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src), "and{b}\t{$src, %al|%al, $src}", []>; def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),