diff options
author | Chris Lattner <sabre@nondot.org> | 2005-12-17 21:25:27 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-12-17 21:25:27 +0000 |
commit | 9034b883a463b37dbc4766ff7243dac3a27d0b11 (patch) | |
tree | 7b756be5183c6103cb1430803b2b91e330b6544c /lib/Target/Sparc/SparcISelDAGToDAG.cpp | |
parent | 87a63f812c824116bef0aaa5a034bd7adf77eae8 (diff) |
Make the addressing modes smarter
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24795 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Sparc/SparcISelDAGToDAG.cpp')
-rw-r--r-- | lib/Target/Sparc/SparcISelDAGToDAG.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/Target/Sparc/SparcISelDAGToDAG.cpp b/lib/Target/Sparc/SparcISelDAGToDAG.cpp index a17637a46a..0e9210dcfe 100644 --- a/lib/Target/Sparc/SparcISelDAGToDAG.cpp +++ b/lib/Target/Sparc/SparcISelDAGToDAG.cpp @@ -235,18 +235,33 @@ void SparcV8DAGToDAGISel::InstructionSelectBasicBlock(SelectionDAG &DAG) { ScheduleAndEmitDAG(DAG); } -bool SparcV8DAGToDAGISel::SelectADDRrr(SDOperand N, SDOperand &R1, +bool SparcV8DAGToDAGISel::SelectADDRrr(SDOperand Addr, SDOperand &R1, SDOperand &R2) { - // FIXME: This should obviously be smarter. - R1 = Select(N); + if (Addr.getOpcode() == ISD::ADD) { + if (isa<ConstantSDNode>(Addr.getOperand(1)) && + Predicate_simm13(Addr.getOperand(1).Val)) + return false; // Let the reg+imm pattern catch this! + R1 = Addr.getOperand(0); + R2 = Addr.getOperand(1); + return true; + } + + R1 = Select(Addr); R2 = CurDAG->getRegister(V8::G0, MVT::i32); return true; } -bool SparcV8DAGToDAGISel::SelectADDRri(SDOperand N, SDOperand &Base, +bool SparcV8DAGToDAGISel::SelectADDRri(SDOperand Addr, SDOperand &Base, SDOperand &Offset) { - // FIXME: This should obviously be smarter. - Base = Select(N); + if (Addr.getOpcode() == ISD::ADD) { + if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Addr.getOperand(1))) + if (Predicate_simm13(CN)) { + Base = Addr.getOperand(0); + Offset = CurDAG->getTargetConstant(CN->getValue(), MVT::i32); + return true; + } + } + Base = Select(Addr); Offset = CurDAG->getTargetConstant(0, MVT::i32); return true; } |