[llvm-commits] [llvm] r141695 - in /llvm/trunk/lib/Target/Mips: Mips64InstrInfo.td MipsInstrInfo.td

Akira Hatanaka ahatanaka at mips.com
Tue Oct 11 11:53:46 PDT 2011


Author: ahatanak
Date: Tue Oct 11 13:53:46 2011
New Revision: 141695

URL: http://llvm.org/viewvc/llvm-project?rev=141695&view=rev
Log:
Add support for 64-bit set-on-less-than instructions.


Modified:
    llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td
    llvm/trunk/lib/Target/Mips/MipsInstrInfo.td

Modified: llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td?rev=141695&r1=141694&r2=141695&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td (original)
+++ llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td Tue Oct 11 13:53:46 2011
@@ -131,12 +131,16 @@
 /// Arithmetic Instructions (ALU Immediate)
 def DADDiu   : ArithI64<0x19, "daddiu", add, simm16_64, immSExt16>;
 def DANDi    : LogicI64<0x0c, "andi", and>;
+def SLTi64   : SetCC_I<0x0a, "slti", setlt, simm16_64, immSExt16, CPU64Regs>;
+def SLTiu64  : SetCC_I<0x0b, "sltiu", setult, simm16_64, immSExt16, CPU64Regs>;
 def DORi     : LogicI64<0x0d, "ori",  or>;
 def DXORi    : 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 SLT64    : SetCC_R<0x00, 0x2a, "slt", setlt, CPU64Regs>;
+def SLTu64   : SetCC_R<0x00, 0x2b, "sltu", setult, CPU64Regs>;
 def DAND     : LogicR64<0x24, "and", and>;
 def DOR      : LogicR64<0x25, "or", or>;
 def DXOR     : LogicR64<0x26, "xor", xor>;
@@ -232,3 +236,29 @@
 
 // hi/lo relocs
 def : Pat<(i64 (MipsLo tglobaladdr:$in)), (DADDiu ZERO_64, tglobaladdr:$in)>;
+
+// setcc patterns
+def : Pat<(seteq CPU64Regs:$lhs, CPU64Regs:$rhs),
+          (SLTu64 (DXOR CPU64Regs:$lhs, CPU64Regs:$rhs), 1)>;
+def : Pat<(setne CPU64Regs:$lhs, CPU64Regs:$rhs),
+          (SLTu64 ZERO_64, (DXOR CPU64Regs:$lhs, CPU64Regs:$rhs))>;
+
+def : Pat<(setle CPU64Regs:$lhs, CPU64Regs:$rhs),
+          (XORi (SLT64 CPU64Regs:$rhs, CPU64Regs:$lhs), 1)>;
+def : Pat<(setule CPU64Regs:$lhs, CPU64Regs:$rhs),
+          (XORi (SLTu64 CPU64Regs:$rhs, CPU64Regs:$lhs), 1)>;
+
+def : Pat<(setgt CPU64Regs:$lhs, CPU64Regs:$rhs),
+          (SLT64 CPU64Regs:$rhs, CPU64Regs:$lhs)>;
+def : Pat<(setugt CPU64Regs:$lhs, CPU64Regs:$rhs),
+          (SLTu64 CPU64Regs:$rhs, CPU64Regs:$lhs)>;
+
+def : Pat<(setge CPU64Regs:$lhs, CPU64Regs:$rhs),
+          (XORi (SLT64 CPU64Regs:$lhs, CPU64Regs:$rhs), 1)>;
+def : Pat<(setuge CPU64Regs:$lhs, CPU64Regs:$rhs),
+          (XORi (SLTu64 CPU64Regs:$lhs, CPU64Regs:$rhs), 1)>;
+
+def : Pat<(setge CPU64Regs:$lhs, immSExt16:$rhs),
+          (XORi (SLTi64 CPU64Regs:$lhs, immSExt16:$rhs), 1)>;
+def : Pat<(setuge CPU64Regs:$lhs, immSExt16:$rhs),
+          (XORi (SLTiu64 CPU64Regs:$lhs, immSExt16:$rhs), 1)>;

Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.td?rev=141695&r1=141694&r2=141695&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsInstrInfo.td (original)
+++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Tue Oct 11 13:53:46 2011
@@ -406,18 +406,18 @@
 }
 
 // SetCC
-class SetCC_R<bits<6> op, bits<6> func, string instr_asm,
-      PatFrag cond_op>:
-  FR<op, func, (outs CPURegs:$dst), (ins CPURegs:$b, CPURegs:$c),
-     !strconcat(instr_asm, "\t$dst, $b, $c"),
-     [(set CPURegs:$dst, (cond_op CPURegs:$b, CPURegs:$c))],
+class SetCC_R<bits<6> op, bits<6> func, string instr_asm, PatFrag cond_op,
+              RegisterClass RC>:
+  FR<op, func, (outs CPURegs:$rd), (ins RC:$rs, RC:$rt),
+     !strconcat(instr_asm, "\t$rd, $rs, $rt"),
+     [(set CPURegs:$rd, (cond_op RC:$rs, RC:$rt))],
      IIAlu>;
 
-class SetCC_I<bits<6> op, string instr_asm, PatFrag cond_op,
-      Operand Od, PatLeaf imm_type>:
-  FI<op, (outs CPURegs:$dst), (ins CPURegs:$b, Od:$c),
-     !strconcat(instr_asm, "\t$dst, $b, $c"),
-     [(set CPURegs:$dst, (cond_op CPURegs:$b, imm_type:$c))],
+class SetCC_I<bits<6> op, string instr_asm, PatFrag cond_op, Operand Od,
+              PatLeaf imm_type, RegisterClass RC>:
+  FI<op, (outs CPURegs:$rd), (ins RC:$rs, Od:$i),
+     !strconcat(instr_asm, "\t$rd, $rs, $i"),
+     [(set CPURegs:$rd, (cond_op RC:$rs, imm_type:$i))],
      IIAlu>;
 
 // Unconditional branch
@@ -615,8 +615,8 @@
 /// Arithmetic Instructions (ALU Immediate)
 def ADDiu   : ArithI<0x09, "addiu", add, simm16, immSExt16>;
 def ADDi    : ArithOverflowI<0x08, "addi",  add, simm16, immSExt16>;
-def SLTi    : SetCC_I<0x0a, "slti", setlt, simm16, immSExt16>;
-def SLTiu   : SetCC_I<0x0b, "sltiu", setult, simm16, immSExt16>;
+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>;
@@ -627,8 +627,8 @@
 def SUBu    : ArithR<0x00, 0x23, "subu", sub, IIAlu>;
 def ADD     : ArithOverflowR<0x00, 0x20, "add", 1>;
 def SUB     : ArithOverflowR<0x00, 0x22, "sub">;
-def SLT     : SetCC_R<0x00, 0x2a, "slt", setlt>;
-def SLTu    : SetCC_R<0x00, 0x2b, "sltu", setult>;
+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>;





More information about the llvm-commits mailing list