X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FSparcV9%2FSparcV9InstrInfo.cpp;h=662c80a357701d959f2f7ab817eb4eea7f811172;hb=bb6b1216894159f68604a7777854148ce1b252df;hp=993f2a2ffa131312f87e767644470d768d8693bc;hpb=5cededee9217804de91a5a55c9e38df06a239a4e;p=oota-llvm.git diff --git a/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/lib/Target/SparcV9/SparcV9InstrInfo.cpp index 993f2a2ffa1..662c80a3577 100644 --- a/lib/Target/SparcV9/SparcV9InstrInfo.cpp +++ b/lib/Target/SparcV9/SparcV9InstrInfo.cpp @@ -266,15 +266,15 @@ CreateIntSetInstruction(const TargetMachine& target, // Entry == 0 ==> no immediate constant field exists at all. // Entry > 0 ==> abs(immediate constant) <= Entry // -vector MaxConstantsTable(Instruction::NumOtherOps); +vector MaxConstantsTable(Instruction::OtherOpsEnd); static int MaxConstantForInstr(unsigned llvmOpCode) { int modelOpCode = -1; - if (llvmOpCode >= Instruction::FirstBinaryOp && - llvmOpCode < Instruction::NumBinaryOps) + if (llvmOpCode >= Instruction::BinaryOpsBegin && + llvmOpCode < Instruction::BinaryOpsEnd) modelOpCode = ADD; else switch(llvmOpCode) { @@ -300,15 +300,15 @@ static void InitializeMaxConstantsTable() { unsigned op; - assert(MaxConstantsTable.size() == Instruction::NumOtherOps && + assert(MaxConstantsTable.size() == Instruction::OtherOpsEnd && "assignments below will be illegal!"); - for (op = Instruction::FirstTermOp; op < Instruction::NumTermOps; ++op) + for (op = Instruction::TermOpsBegin; op < Instruction::TermOpsEnd; ++op) MaxConstantsTable[op] = MaxConstantForInstr(op); - for (op = Instruction::FirstBinaryOp; op < Instruction::NumBinaryOps; ++op) + for (op = Instruction::BinaryOpsBegin; op < Instruction::BinaryOpsEnd; ++op) MaxConstantsTable[op] = MaxConstantForInstr(op); - for (op = Instruction::FirstMemoryOp; op < Instruction::NumMemoryOps; ++op) + for (op = Instruction::MemoryOpsBegin; op < Instruction::MemoryOpsEnd; ++op) MaxConstantsTable[op] = MaxConstantForInstr(op); - for (op = Instruction::FirstOtherOp; op < Instruction::NumOtherOps; ++op) + for (op = Instruction::OtherOpsBegin; op < Instruction::OtherOpsEnd; ++op) MaxConstantsTable[op] = MaxConstantForInstr(op); } @@ -343,13 +343,14 @@ UltraSparcInstrInfo::ConstantMayNotFitInImmedField(const Constant* CV, return false; if (const ConstantUInt* U = dyn_cast(CV)) - return (U->getValue() > MaxConstantsTable[I->getOpcode()]); + /* Large unsigned longs may really just be small negative signed longs */ + return (labs((int64_t) U->getValue()) > MaxConstantsTable[I->getOpcode()]); if (const ConstantSInt* S = dyn_cast(CV)) - return (labs(S->getValue()) > (int) MaxConstantsTable[I->getOpcode()]); + return (labs(S->getValue()) > MaxConstantsTable[I->getOpcode()]); if (isa(CV)) - return (1U > MaxConstantsTable[I->getOpcode()]); + return (1 > MaxConstantsTable[I->getOpcode()]); return true; } @@ -380,6 +381,11 @@ UltraSparcInstrInfo::CreateCodeToLoadConst(const TargetMachine& target, // const Type* valType = val->getType(); + // Unfortunate special case: a ConstantPointerRef is just a + // reference to GlobalValue. + if (isa(val)) + val = cast(val)->getValue(); + if (isa(val)) { TmpInstruction* tmpReg =