From 2dfd3a978936c39194246676af5c4791e65e5001 Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Tue, 11 Oct 2011 23:38:52 +0000 Subject: [PATCH] Define class ArithLogicI. Make 32-bit and 64-bit arithmetic and logical instructions with two register operands derive from it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141742 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Mips/Mips64InstrInfo.td | 21 +++++-------------- lib/Target/Mips/MipsInstrInfo.td | 33 +++++++++++++----------------- 2 files changed, 19 insertions(+), 35 deletions(-) diff --git a/lib/Target/Mips/Mips64InstrInfo.td b/lib/Target/Mips/Mips64InstrInfo.td index 68de90a45f2..f38ddc2d925 100644 --- a/lib/Target/Mips/Mips64InstrInfo.td +++ b/lib/Target/Mips/Mips64InstrInfo.td @@ -37,19 +37,7 @@ def imm32_63 : ImmLeaf op, string instr_asm, SDNode OpNode, - Operand Od, PatLeaf imm_type> : - FI; - // Logical -class LogicI64 op, string instr_asm, SDNode OpNode>: - FI; - let isCommutable = 1 in class LogicNOR64 op, bits<6> func, string instr_asm>: FR func, string instr_asm, list pattern>: //===----------------------------------------------------------------------===// /// Arithmetic Instructions (ALU Immediate) -def DADDiu : ArithI64<0x19, "daddiu", add, simm16_64, immSExt16>; -def DANDi : LogicI64<0x0c, "andi", and>; +def DADDiu : ArithLogicI<0x19, "daddiu", add, simm16_64, immSExt16, + CPU64Regs>; +def DANDi : ArithLogicI<0x0c, "andi", and, uimm16_64, immZExt16, CPU64Regs>; def SLTi64 : SetCC_I<0x0a, "slti", setlt, simm16_64, immSExt16, CPU64Regs>; def SLTiu64 : SetCC_I<0x0b, "sltiu", setult, simm16_64, immSExt16, CPU64Regs>; -def ORi64 : LogicI64<0x0d, "ori", or>; -def XORi64 : LogicI64<0x0e, "xori", xor>; +def ORi64 : ArithLogicI<0x0d, "ori", or, uimm16_64, immZExt16, CPU64Regs>; +def XORi64 : ArithLogicI<0x0e, "xori", xor, uimm16_64, immZExt16, CPU64Regs>; /// Arithmetic Instructions (3-Operand, R-Type) def DADDu : ArithLogicR<0x00, 0x2d, "daddu", add, IIAlu, CPU64Regs, 1>; diff --git a/lib/Target/Mips/MipsInstrInfo.td b/lib/Target/Mips/MipsInstrInfo.td index 7b34a40c261..4938cf8bc94 100644 --- a/lib/Target/Mips/MipsInstrInfo.td +++ b/lib/Target/Mips/MipsInstrInfo.td @@ -268,17 +268,17 @@ class ArithLogicOfR op, bits<6> func, string instr_asm, let isCommutable = isComm; } -// Arithmetic 2 register operands -class ArithI op, string instr_asm, SDNode OpNode, - Operand Od, PatLeaf imm_type> : - FI; +// Arithmetic and logical instructions with 2 register operands. +class ArithLogicI op, string instr_asm, SDNode OpNode, + Operand Od, PatLeaf imm_type, RegisterClass RC> : + FI; class ArithOverflowI op, string instr_asm, SDNode OpNode, - Operand Od, PatLeaf imm_type> : - FI; + Operand Od, PatLeaf imm_type, RegisterClass RC> : + FI; // Arithmetic Multiply ADD/SUB let rd = 0, shamt = 0, Defs = [HI, LO], Uses = [HI, LO] in @@ -290,11 +290,6 @@ class MArithR func, string instr_asm, SDNode op, bit isComm = 0> : } // Logical -class LogicI op, string instr_asm, SDNode OpNode>: - FI; - let isCommutable = 1 in class LogicNOR op, bits<6> func, string instr_asm>: FR; -def ADDi : ArithOverflowI<0x08, "addi", add, simm16, immSExt16>; +def ADDiu : ArithLogicI<0x09, "addiu", add, simm16, immSExt16, CPURegs>; +def ADDi : ArithOverflowI<0x08, "addi", add, simm16, immSExt16, CPURegs>; def SLTi : SetCC_I<0x0a, "slti", setlt, simm16, immSExt16, CPURegs>; def SLTiu : SetCC_I<0x0b, "sltiu", setult, simm16, immSExt16, CPURegs>; -def ANDi : LogicI<0x0c, "andi", and>; -def ORi : LogicI<0x0d, "ori", or>; -def XORi : LogicI<0x0e, "xori", xor>; +def ANDi : ArithLogicI<0x0c, "andi", and, uimm16, immZExt16, CPURegs>; +def ORi : ArithLogicI<0x0d, "ori", or, uimm16, immZExt16, CPURegs>; +def XORi : ArithLogicI<0x0e, "xori", xor, uimm16, immZExt16, CPURegs>; def LUi : LoadUpper<0x0f, "lui">; /// Arithmetic Instructions (3-Operand, R-Type)