[llvm-commits] [llvm] r140806 - in /llvm/trunk: lib/Target/Mips/Mips64InstrInfo.td test/CodeGen/Mips/mips64instrs.ll
Akira Hatanaka
ahatanaka at mips.com
Thu Sep 29 13:37:56 PDT 2011
Author: ahatanak
Date: Thu Sep 29 15:37:56 2011
New Revision: 140806
URL: http://llvm.org/viewvc/llvm-project?rev=140806&view=rev
Log:
Mips64 arithmetic and logical instructions with two source registers.
Added:
llvm/trunk/test/CodeGen/Mips/mips64instrs.ll
Modified:
llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td
Modified: llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td?rev=140806&r1=140805&r2=140806&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td (original)
+++ llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td Thu Sep 29 15:37:56 2011
@@ -17,3 +17,33 @@
def HasMips64 : Predicate<"Subtarget.hasMips64()">;
def HasMips64r2 : Predicate<"Subtarget.hasMips64r2()">;
+//===----------------------------------------------------------------------===//
+// Instructions specific format
+//===----------------------------------------------------------------------===//
+
+// Arithmetic 3 register operands
+class ArithR64<bits<6> op, bits<6> func, string instr_asm, SDNode OpNode,
+ InstrItinClass itin, bit isComm = 0>:
+ FR<op, func, (outs CPU64Regs:$dst), (ins CPU64Regs:$b, CPU64Regs:$c),
+ !strconcat(instr_asm, "\t$dst, $b, $c"),
+ [(set CPU64Regs:$dst, (OpNode CPU64Regs:$b, CPU64Regs:$c))], itin> {
+ let isCommutable = isComm;
+}
+
+// Logical
+let isCommutable = 1 in
+class LogicR64<bits<6> 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>;
+
+//===----------------------------------------------------------------------===//
+// Instruction definition
+//===----------------------------------------------------------------------===//
+
+/// Arithmetic Instructions (3-Operand, R-Type)
+def DADDu : ArithR64<0x00, 0x2d, "daddu", add, IIAlu, 1>;
+def DSUBu : ArithR64<0x00, 0x2f, "dsubu", sub, IIAlu, 1>;
+def DAND : LogicR64<0x24, "and", and>;
+def DOR : LogicR64<0x25, "or", or>;
+def DXOR : LogicR64<0x26, "xor", xor>;
Added: llvm/trunk/test/CodeGen/Mips/mips64instrs.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/mips64instrs.ll?rev=140806&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/mips64instrs.ll (added)
+++ llvm/trunk/test/CodeGen/Mips/mips64instrs.ll Thu Sep 29 15:37:56 2011
@@ -0,0 +1,36 @@
+; RUN: llc -march=mips64el -mcpu=mips64r1 < %s | FileCheck %s
+
+define i64 @f0(i64 %a0, i64 %a1) nounwind readnone {
+entry:
+; CHECK: daddu
+ %add = add nsw i64 %a1, %a0
+ ret i64 %add
+}
+
+define i64 @f1(i64 %a0, i64 %a1) nounwind readnone {
+entry:
+; CHECK: dsubu
+ %sub = sub nsw i64 %a0, %a1
+ ret i64 %sub
+}
+
+define i64 @f4(i64 %a0, i64 %a1) nounwind readnone {
+entry:
+; CHECK: and
+ %and = and i64 %a1, %a0
+ ret i64 %and
+}
+
+define i64 @f5(i64 %a0, i64 %a1) nounwind readnone {
+entry:
+; CHECK: or
+ %or = or i64 %a1, %a0
+ ret i64 %or
+}
+
+define i64 @f6(i64 %a0, i64 %a1) nounwind readnone {
+entry:
+; CHECK: xor
+ %xor = xor i64 %a1, %a0
+ ret i64 %xor
+}
More information about the llvm-commits
mailing list