From: Akira Hatanaka Date: Tue, 11 Oct 2011 23:05:46 +0000 (+0000) Subject: Define classes ArithLogicR and ArithLogicOfR and make 32-bit and 64-bit X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c2f3ac9de2596df2af8b85245b987476a773d4ad;p=oota-llvm.git Define classes ArithLogicR and ArithLogicOfR and make 32-bit and 64-bit arithmetic and logical instructions with three register operands derive from them. Fix instruction encoding too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141736 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/Mips/Mips64InstrInfo.td b/lib/Target/Mips/Mips64InstrInfo.td index 90cdf92daae..68de90a45f2 100644 --- a/lib/Target/Mips/Mips64InstrInfo.td +++ b/lib/Target/Mips/Mips64InstrInfo.td @@ -37,15 +37,6 @@ def imm32_63 : ImmLeaf op, bits<6> func, string instr_asm, SDNode OpNode, - InstrItinClass itin, bit isComm = 0>: - FR { - let isCommutable = isComm; -} - // Arithmetic 2 register operands class ArithI64 op, string instr_asm, SDNode OpNode, Operand Od, PatLeaf imm_type> : @@ -54,12 +45,6 @@ class ArithI64 op, string instr_asm, SDNode OpNode, [(set CPU64Regs:$dst, (OpNode CPU64Regs:$b, imm_type:$c))], IIAlu>; // Logical -let isCommutable = 1 in -class LogicR64 func, string instr_asm, SDNode OpNode>: - FR<0x00, func, (outs CPU64Regs:$dst), (ins CPU64Regs:$b, CPU64Regs:$c), - !strconcat(instr_asm, "\t$dst, $b, $c"), - [(set CPU64Regs:$dst, (OpNode CPU64Regs:$b, CPU64Regs:$c))], IIAlu>; - class LogicI64 op, string instr_asm, SDNode OpNode>: FI; def XORi64 : LogicI64<0x0e, "xori", xor>; /// Arithmetic Instructions (3-Operand, R-Type) -def DADDu : ArithR64<0x00, 0x2d, "daddu", add, IIAlu, 1>; -def DSUBu : ArithR64<0x00, 0x2f, "dsubu", sub, IIAlu>; +def DADDu : ArithLogicR<0x00, 0x2d, "daddu", add, IIAlu, CPU64Regs, 1>; +def DSUBu : ArithLogicR<0x00, 0x2f, "dsubu", sub, IIAlu, CPU64Regs>; def SLT64 : SetCC_R<0x00, 0x2a, "slt", setlt, CPU64Regs>; def SLTu64 : SetCC_R<0x00, 0x2b, "sltu", setult, CPU64Regs>; -def AND64 : LogicR64<0x24, "and", and>; -def OR64 : LogicR64<0x25, "or", or>; -def XOR64 : LogicR64<0x26, "xor", xor>; +def AND64 : ArithLogicR<0x00, 0x24, "and", and, IIAlu, CPU64Regs, 1>; +def OR64 : ArithLogicR<0x00, 0x25, "or", or, IIAlu, CPU64Regs, 1>; +def XOR64 : ArithLogicR<0x00, 0x26, "xor", xor, IIAlu, CPU64Regs, 1>; def NOR64 : LogicNOR64<0x00, 0x27, "nor">; /// Shift Instructions diff --git a/lib/Target/Mips/MipsInstrInfo.td b/lib/Target/Mips/MipsInstrInfo.td index a47d0320aa3..fe6d2f4ba2c 100644 --- a/lib/Target/Mips/MipsInstrInfo.td +++ b/lib/Target/Mips/MipsInstrInfo.td @@ -251,18 +251,20 @@ def truncstorei32_u : UnalignedStore; //===----------------------------------------------------------------------===// // Arithmetic 3 register operands -class ArithR op, bits<6> func, string instr_asm, SDNode OpNode, - InstrItinClass itin, bit isComm = 0>: - FR { +class ArithLogicR op, bits<6> func, string instr_asm, SDNode OpNode, + InstrItinClass itin, RegisterClass RC, bit isComm = 0>: + FR { + let shamt = 0; let isCommutable = isComm; } -class ArithOverflowR op, bits<6> func, string instr_asm, - bit isComm = 0>: - FR { +class ArithLogicOfR op, bits<6> func, string instr_asm, + InstrItinClass itin, RegisterClass RC, bit isComm = 0>: + FR { + let shamt = 0; let isCommutable = isComm; } @@ -288,12 +290,6 @@ class MArithR func, string instr_asm, SDNode op, bit isComm = 0> : } // Logical -let isCommutable = 1 in -class LogicR func, string instr_asm, SDNode OpNode>: - FR<0x00, func, (outs CPURegs:$dst), (ins CPURegs:$b, CPURegs:$c), - !strconcat(instr_asm, "\t$dst, $b, $c"), - [(set CPURegs:$dst, (OpNode CPURegs:$b, CPURegs:$c))], IIAlu>; - class LogicI op, string instr_asm, SDNode OpNode>: FI; def LUi : LoadUpper<0x0f, "lui">; /// Arithmetic Instructions (3-Operand, R-Type) -def ADDu : ArithR<0x00, 0x21, "addu", add, IIAlu, 1>; -def SUBu : ArithR<0x00, 0x23, "subu", sub, IIAlu>; -def ADD : ArithOverflowR<0x00, 0x20, "add", 1>; -def SUB : ArithOverflowR<0x00, 0x22, "sub">; +def ADDu : ArithLogicR<0x00, 0x21, "addu", add, IIAlu, CPURegs, 1>; +def SUBu : ArithLogicR<0x00, 0x23, "subu", sub, IIAlu, CPURegs>; +def ADD : ArithLogicOfR<0x00, 0x20, "add", IIAlu, CPURegs, 1>; +def SUB : ArithLogicOfR<0x00, 0x22, "sub", IIAlu, CPURegs>; def SLT : SetCC_R<0x00, 0x2a, "slt", setlt, CPURegs>; def SLTu : SetCC_R<0x00, 0x2b, "sltu", setult, CPURegs>; -def AND : LogicR<0x24, "and", and>; -def OR : LogicR<0x25, "or", or>; -def XOR : LogicR<0x26, "xor", xor>; +def AND : ArithLogicR<0x00, 0x24, "and", and, IIAlu, CPURegs, 1>; +def OR : ArithLogicR<0x00, 0x25, "or", or, IIAlu, CPURegs, 1>; +def XOR : ArithLogicR<0x00, 0x26, "xor", xor, IIAlu, CPURegs, 1>; def NOR : LogicNOR<0x00, 0x27, "nor">; /// Shift Instructions @@ -779,7 +775,8 @@ def MSUBU : MArithR<5, "msubu", MipsMSubu>; // MUL is a assembly macro in the current used ISAs. In recent ISA's // it is a real instruction. -def MUL : ArithR<0x1c, 0x02, "mul", mul, IIImul, 1>, Requires<[HasMips32]>; +def MUL : ArithLogicR<0x1c, 0x02, "mul", mul, IIImul, CPURegs, 1>, + Requires<[HasMips32]>; def RDHWR : ReadHardware;