Changes in directory llvm/lib/Target/ARM:
ARMISelDAGToDAG.cpp updated: 1.45 -> 1.46 --- Log message: if a constant can't be an immediate, add it to the constant pool --- Diffs of the changes: (+34 -4) ARMISelDAGToDAG.cpp | 38 ++++++++++++++++++++++++++++++++++---- 1 files changed, 34 insertions(+), 4 deletions(-) Index: llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp diff -u llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp:1.45 llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp:1.46 --- llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp:1.45 Wed Sep 13 07:09:43 2006 +++ llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp Thu Sep 21 06:29:52 2006 @@ -16,6 +16,7 @@ #include "llvm/CallingConv.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" +#include "llvm/Constants.h" #include "llvm/Intrinsics.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" @@ -466,7 +467,7 @@ return false; int32_t t = cast<ConstantSDNode>(N)->getValue(); - int max = 2<<12 - 1; + int max = 1<<12; int min = -max; if (t > min && t < max) { Imm = t; @@ -480,15 +481,44 @@ return isInt12Immediate(Op.Val, Imm); } +static uint32_t rotateL(uint32_t x) { + uint32_t bit31 = (x & (1 << 31)) >> 31; + uint32_t t = x << 1; + return t | bit31; +} + +static bool isUInt8Immediate(uint32_t x) { + return x < (1 << 8); +} + +static bool isRotInt8Immediate(uint32_t x) { + int r; + for (r = 0; r < 16; r++) { + if (isUInt8Immediate(x)) + return true; + x = rotateL(rotateL(x)); + } + return false; +} + bool ARMDAGToDAGISel::SelectAddrMode1(SDOperand N, SDOperand &Arg, SDOperand &Shift, SDOperand &ShiftType) { switch(N.getOpcode()) { case ISD::Constant: { - //TODO:check that we have a valid constant - int32_t t = cast<ConstantSDNode>(N)->getValue(); - Arg = CurDAG->getTargetConstant(t, MVT::i32); + uint32_t val = cast<ConstantSDNode>(N)->getValue(); + if(!isRotInt8Immediate(val)) { + const Type *t = MVT::getTypeForValueType(MVT::i32); + Constant *C = ConstantUInt::get(t, val); + int alignment = 2; + SDOperand Addr = CurDAG->getTargetConstantPool(C, MVT::i32, alignment); + SDOperand Z = CurDAG->getTargetConstant(0, MVT::i32); + SDNode *n = CurDAG->getTargetNode(ARM::ldr, MVT::i32, Z, Addr); + Arg = SDOperand(n, 0); + } else + Arg = CurDAG->getTargetConstant(val, MVT::i32); + Shift = CurDAG->getTargetConstant(0, MVT::i32); ShiftType = CurDAG->getTargetConstant(ARMShift::LSL, MVT::i32); return true; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits