define the IntBinOp class and use it to implement the multiply instructions

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30978 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2006-10-16 17:57:20 +00:00
parent bb1e2fbc68
commit 15a6c3e976

View File

@ -36,9 +36,8 @@ def iaddr : ComplexPattern<iPTR, 2, "SelectAddrRegImm", [frameindex], []>;
//def raddr : ComplexPattern<iPTR, 2, "SelectAddrRegReg", [], []>; //def raddr : ComplexPattern<iPTR, 2, "SelectAddrRegReg", [], []>;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Instructions // Instruction Class Templates
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
class InstARM<dag ops, string asmstr, list<dag> pattern> : Instruction { class InstARM<dag ops, string asmstr, list<dag> pattern> : Instruction {
let Namespace = "ARM"; let Namespace = "ARM";
@ -47,6 +46,15 @@ class InstARM<dag ops, string asmstr, list<dag> pattern> : Instruction {
let Pattern = pattern; let Pattern = pattern;
} }
class IntBinOp<string OpcStr, SDNode OpNode> :
InstARM<(ops IntRegs:$dst, IntRegs:$a, IntRegs:$b),
!strconcat(OpcStr, " $dst, $a, $b"),
[(set IntRegs:$dst, (OpNode IntRegs:$a, IntRegs:$b))]>;
//===----------------------------------------------------------------------===//
// Instructions
//===----------------------------------------------------------------------===//
def brtarget : Operand<OtherVT>; def brtarget : Operand<OtherVT>;
// Operand for printing out a condition code. // Operand for printing out a condition code.
@ -186,18 +194,11 @@ let isTwoAddress = 1 in {
IntRegs:$false, imm:$cc))]>; IntRegs:$false, imm:$cc))]>;
} }
def MUL : InstARM<(ops IntRegs:$dst, IntRegs:$a, IntRegs:$b), def MUL : IntBinOp<"mul", mul>;
"mul $dst, $a, $b",
[(set IntRegs:$dst, (mul IntRegs:$a, IntRegs:$b))]>;
let Defs = [R0] in { let Defs = [R0] in {
def SMULL : InstARM<(ops IntRegs:$dst, IntRegs:$a, IntRegs:$b), def SMULL : IntBinOp<"smull r12,", mulhs>;
"smull r12, $dst, $a, $b", def UMULL : IntBinOp<"umull r12,", mulhu>;
[(set IntRegs:$dst, (mulhs IntRegs:$a, IntRegs:$b))]>;
def UMULL : InstARM<(ops IntRegs:$dst, IntRegs:$a, IntRegs:$b),
"umull r12, $dst, $a, $b",
[(set IntRegs:$dst, (mulhu IntRegs:$a, IntRegs:$b))]>;
} }
def bcond : InstARM<(ops brtarget:$dst, CCOp:$cc), def bcond : InstARM<(ops brtarget:$dst, CCOp:$cc),