From: Chris Lattner Date: Thu, 9 Feb 2006 05:06:36 +0000 (+0000) Subject: add an option to turn on LSR. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=9413678f91f4789902b69c4dc18b7205e95b0224;p=oota-llvm.git add an option to turn on LSR. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26080 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/Sparc/SparcInstrInfo.td b/lib/Target/Sparc/SparcInstrInfo.td index d2d3f35c3df..499d2c14808 100644 --- a/lib/Target/Sparc/SparcInstrInfo.td +++ b/lib/Target/Sparc/SparcInstrInfo.td @@ -493,6 +493,7 @@ def UMULrr : F3_1<2, 0b001010, def UMULri : F3_2<2, 0b001010, (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "umul $b, $c, $dst", []>; + def SMULrr : F3_1<2, 0b001011, (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c), "smul $b, $c, $dst", @@ -502,6 +503,61 @@ def SMULri : F3_2<2, 0b001011, "smul $b, $c, $dst", [(set IntRegs:$dst, (mul IntRegs:$b, simm13:$c))]>; +/* +//===------------------------- +// Sparc Example +defm intinst { + def OPC1 : F3_1<2, Opc, asmstr, (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c), + [(set IntRegs:$dst, (code IntRegs:$b, IntRegs:$c))]>; + def OPC2 : F3_2<2, Opc, asmstr, (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), + [(set IntRegs:$dst, (code IntRegs:$b, simm13:$c))]>; +} +defm intinst_np { + def OPC1 : F3_1<2, Opc, asmstr, (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c), + []>; + def OPC2 : F3_2<2, Opc, asmstr, (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), + []>; +} + +def intinstnp< ADDXrr, ADDXri, 0b001000, "addx $b, $c, $dst">; +def intinst < SUBrr, SUBri, 0b000100, "sub $b, $c, $dst", sub>; +def intinstnp< SUBXrr, SUBXri, 0b001100, "subx $b, $c, $dst">; +def intinst ; +def intinst < SMULrr, SMULri, 0b001011, "smul $b, $c, $dst", mul>; + +//===------------------------- +// X86 Example +defm cmov32 { + def OPC1 : I, TB; + def OPC2 : I, TB; +} + +def cmov; +def cmov; + +//===------------------------- +// PPC Example + +def fpunop { + def OPC1 : FORM; + def OPC2 : FORM; +} + +def fpunop< FABSS, FABSD, XForm_26, 63, 63, 264, "fabs", fabs>; +def fpunop; +def fpunop< FNEGS, FNEGD, XForm_26, 63, 63, 40, "fneg", fneg>; +*/ + // Section B.19 - Divide Instructions, p. 115 def UDIVrr : F3_1<2, 0b001110, (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c), diff --git a/lib/Target/Sparc/SparcTargetMachine.cpp b/lib/Target/Sparc/SparcTargetMachine.cpp index 2a2e9b47583..b66ed02c166 100644 --- a/lib/Target/Sparc/SparcTargetMachine.cpp +++ b/lib/Target/Sparc/SparcTargetMachine.cpp @@ -27,6 +27,8 @@ using namespace llvm; namespace { // Register the target. RegisterTarget X("sparc", " SPARC"); + + cl::opt EnableLSR("enable-sparc-lsr", cl::Hidden); } /// SparcTargetMachine ctor - Create an ILP32 architecture model @@ -65,6 +67,9 @@ bool SparcTargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out, bool Fast) { if (FileType != TargetMachine::AssemblyFile) return true; + // Run loop strength reduction before anything else. + if (EnableLSR && !Fast) PM.add(createLoopStrengthReducePass()); + // FIXME: Implement efficient support for garbage collection intrinsics. PM.add(createLowerGCPass()); @@ -73,7 +78,7 @@ bool SparcTargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out, // FIXME: implement the switch instruction in the instruction selector. PM.add(createLowerSwitchPass()); - + // Print LLVM code input to instruction selector: if (PrintMachineCode) PM.add(new PrintFunctionPass());