From 2b8d30d08087aa053822250d6e9f866f9fbbfe8a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 7 Oct 2010 00:12:45 +0000 Subject: [PATCH] Define a new BinOpRI8 class and use it to define the imm8 versions of and. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115880 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86InstrArithmetic.td | 70 +++++++++++++++++----------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/lib/Target/X86/X86InstrArithmetic.td b/lib/Target/X86/X86InstrArithmetic.td index c98f98f6fc1..73a4fcc3085 100644 --- a/lib/Target/X86/X86InstrArithmetic.td +++ b/lib/Target/X86/X86InstrArithmetic.td @@ -500,9 +500,9 @@ let CodeSize = 2 in { /// information about value types. For example, it can tell you what the /// register class and preferred load to use. class X86TypeInfo { /// VT - This is the value type itself. ValueType VT = vt; @@ -539,6 +539,15 @@ class X86TypeInfo , i16 -> i16i8imm, i32 -> i32i8imm. This is + /// only used for instructions that have a sign-extended imm8 field form. + Operand Imm8Operand = imm8operand; + + /// Imm8Operator - This is the operator that should be used to match an 8-bit + /// sign extended immediate of this kind in a pattern (e.g. imm16immSExt8). + SDPatternOperator Imm8Operator = imm8operator; + /// HasOddOpcode - This bit is true if the instruction should have an odd (as /// opposed to even) opcode. Operations on i8 are usually even, operations on /// other datatypes are odd. @@ -553,14 +562,21 @@ class X86TypeInfo; -def Xi16 : X86TypeInfo; -def Xi32 : X86TypeInfo; -def Xi64 : X86TypeInfo; +def invalid_node : SDNode<"<>", SDTIntLeaf,[],"<>">; + + +def Xi8 : X86TypeInfo; +def Xi16 : X86TypeInfo; +def Xi32 : X86TypeInfo; +def Xi64 : X86TypeInfo; /// ITy - This instruction base class takes the type info for the instruction. /// Using this, it: @@ -610,6 +626,7 @@ class BinOpRM opcode, string mnemonic, X86TypeInfo typeinfo, [(set typeinfo.RegClass:$dst, EFLAGS, (opnode typeinfo.RegClass:$src1, (typeinfo.LoadNode addr:$src2)))]>; +// BinOpRI - Instructions like "add reg, reg, imm". class BinOpRI opcode, string mnemonic, X86TypeInfo typeinfo, SDNode opnode, Format f> : ITy opcode, string mnemonic, X86TypeInfo typeinfo, } +// BinOpRI8 - Instructions like "add reg, reg, imm8". +class BinOpRI8 opcode, string mnemonic, X86TypeInfo typeinfo, + SDNode opnode, Format f> + : ITy { + let ImmT = Imm8; // Always 8-bit immediate. +} + // Logical operators. let Defs = [EFLAGS] in { @@ -653,22 +682,9 @@ def AND16ri : BinOpRI<0x80, "and", Xi16, X86and_flag, MRM4r>; def AND32ri : BinOpRI<0x80, "and", Xi32, X86and_flag, MRM4r>; def AND64ri32: BinOpRI<0x80, "and", Xi64, X86and_flag, MRM4r>; -def AND16ri8 : Ii8<0x83, MRM4r, - (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2), - "and{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1, - i16immSExt8:$src2))]>, - OpSize; -def AND32ri8 : Ii8<0x83, MRM4r, - (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2), - "and{l}\t{$src2, $dst|$dst, $src2}", - [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1, - i32immSExt8:$src2))]>; -def AND64ri8 : RIi8<0x83, MRM4r, - (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), - "and{q}\t{$src2, $dst|$dst, $src2}", - [(set GR64:$dst, EFLAGS, - (X86and_flag GR64:$src1, i64immSExt8:$src2))]>; +def AND16ri8 : BinOpRI8<0x82, "and", Xi16, X86and_flag, MRM4r>; +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,