Changes in directory llvm/lib/Transforms/Utils:
CodeExtractor.cpp updated: 1.40 -> 1.41 Local.cpp updated: 1.58 -> 1.59 LowerAllocations.cpp updated: 1.61 -> 1.62 LowerInvoke.cpp updated: 1.41 -> 1.42 LowerSwitch.cpp updated: 1.24 -> 1.25 SimplifyCFG.cpp updated: 1.100 -> 1.101 --- Log message: For PR950: http://llvm.org/PR950 : This patch implements the first increment for the Signless Types feature. All changes pertain to removing the ConstantSInt and ConstantUInt classes in favor of just using ConstantInt. --- Diffs of the changes: (+27 -26) CodeExtractor.cpp | 14 +++++++------- Local.cpp | 14 +++++++------- LowerAllocations.cpp | 4 ++-- LowerInvoke.cpp | 8 ++++---- LowerSwitch.cpp | 11 ++++++----- SimplifyCFG.cpp | 2 +- 6 files changed, 27 insertions(+), 26 deletions(-) Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.40 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.41 --- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.40 Thu Sep 28 17:58:25 2006 +++ llvm/lib/Transforms/Utils/CodeExtractor.cpp Fri Oct 20 02:07:24 2006 @@ -305,7 +305,7 @@ if (AggregateArgs) { std::vector<Value*> Indices; Indices.push_back(Constant::getNullValue(Type::UIntTy)); - Indices.push_back(ConstantUInt::get(Type::UIntTy, i)); + Indices.push_back(ConstantInt::get(Type::UIntTy, i)); std::string GEPname = "gep_" + inputs[i]->getName(); TerminatorInst *TI = newFunction->begin()->getTerminator(); GetElementPtrInst *GEP = new GetElementPtrInst(AI, Indices, GEPname, TI); @@ -392,7 +392,7 @@ for (unsigned i = 0, e = inputs.size(); i != e; ++i) { std::vector<Value*> Indices; Indices.push_back(Constant::getNullValue(Type::UIntTy)); - Indices.push_back(ConstantUInt::get(Type::UIntTy, i)); + Indices.push_back(ConstantInt::get(Type::UIntTy, i)); GetElementPtrInst *GEP = new GetElementPtrInst(Struct, Indices, "gep_" + StructValues[i]->getName()); @@ -418,7 +418,7 @@ if (AggregateArgs) { std::vector<Value*> Indices; Indices.push_back(Constant::getNullValue(Type::UIntTy)); - Indices.push_back(ConstantUInt::get(Type::UIntTy, FirstOut + i)); + Indices.push_back(ConstantInt::get(Type::UIntTy, FirstOut + i)); GetElementPtrInst *GEP = new GetElementPtrInst(Struct, Indices, "gep_reload_" + outputs[i]->getName()); @@ -439,7 +439,7 @@ // Now we can emit a switch statement using the call as a value. SwitchInst *TheSwitch = - new SwitchInst(ConstantUInt::getNullValue(Type::UShortTy), + new SwitchInst(ConstantInt::getNullValue(Type::UShortTy), codeReplacer, 0, codeReplacer); // Since there may be multiple exits from the original region, make the new @@ -473,14 +473,14 @@ brVal = ConstantBool::get(!SuccNum); break; default: - brVal = ConstantUInt::get(Type::UShortTy, SuccNum); + brVal = ConstantInt::get(Type::UShortTy, SuccNum); break; } ReturnInst *NTRet = new ReturnInst(brVal, NewTarget); // Update the switch instruction. - TheSwitch->addCase(ConstantUInt::get(Type::UShortTy, SuccNum), + TheSwitch->addCase(ConstantInt::get(Type::UShortTy, SuccNum), OldTarget); // Restore values just before we exit @@ -519,7 +519,7 @@ if (AggregateArgs) { std::vector<Value*> Indices; Indices.push_back(Constant::getNullValue(Type::UIntTy)); - Indices.push_back(ConstantUInt::get(Type::UIntTy,FirstOut+out)); + Indices.push_back(ConstantInt::get(Type::UIntTy,FirstOut+out)); GetElementPtrInst *GEP = new GetElementPtrInst(OAI, Indices, "gep_" + outputs[out]->getName(), Index: llvm/lib/Transforms/Utils/Local.cpp diff -u llvm/lib/Transforms/Utils/Local.cpp:1.58 llvm/lib/Transforms/Utils/Local.cpp:1.59 --- llvm/lib/Transforms/Utils/Local.cpp:1.58 Fri May 26 20:18:04 2006 +++ llvm/lib/Transforms/Utils/Local.cpp Fri Oct 20 02:07:24 2006 @@ -272,10 +272,10 @@ gep_type_iterator I = gep_type_begin(CE), E = gep_type_end(CE); for (++I; I != E; ++I) if (const StructType *STy = dyn_cast<StructType>(*I)) { - ConstantUInt *CU = cast<ConstantUInt>(I.getOperand()); - assert(CU->getValue() < STy->getNumElements() && + ConstantInt *CU = cast<ConstantInt>(I.getOperand()); + assert(CU->getZExtValue() < STy->getNumElements() && "Struct index out of range!"); - unsigned El = (unsigned)CU->getValue(); + unsigned El = (unsigned)CU->getZExtValue(); if (ConstantStruct *CS = dyn_cast<ConstantStruct>(C)) { C = CS->getOperand(El); } else if (isa<ConstantAggregateZero>(C)) { @@ -287,10 +287,10 @@ } } else if (ConstantInt *CI = dyn_cast<ConstantInt>(I.getOperand())) { if (const ArrayType *ATy = dyn_cast<ArrayType>(*I)) { - if ((uint64_t)CI->getRawValue() >= ATy->getNumElements()) + if (CI->getZExtValue() >= ATy->getNumElements()) return 0; if (ConstantArray *CA = dyn_cast<ConstantArray>(C)) - C = CA->getOperand((unsigned)CI->getRawValue()); + C = CA->getOperand(CI->getZExtValue()); else if (isa<ConstantAggregateZero>(C)) C = Constant::getNullValue(ATy->getElementType()); else if (isa<UndefValue>(C)) @@ -298,10 +298,10 @@ else return 0; } else if (const PackedType *PTy = dyn_cast<PackedType>(*I)) { - if ((uint64_t)CI->getRawValue() >= PTy->getNumElements()) + if (CI->getZExtValue() >= PTy->getNumElements()) return 0; if (ConstantPacked *CP = dyn_cast<ConstantPacked>(C)) - C = CP->getOperand((unsigned)CI->getRawValue()); + C = CP->getOperand(CI->getZExtValue()); else if (isa<ConstantAggregateZero>(C)) C = Constant::getNullValue(PTy->getElementType()); else if (isa<UndefValue>(C)) Index: llvm/lib/Transforms/Utils/LowerAllocations.cpp diff -u llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.61 llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.62 --- llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.61 Sun Aug 27 17:42:52 2006 +++ llvm/lib/Transforms/Utils/LowerAllocations.cpp Fri Oct 20 02:07:24 2006 @@ -119,14 +119,14 @@ // malloc(type) becomes sbyte *malloc(size) Value *MallocArg; if (LowerMallocArgToInteger) - MallocArg = ConstantUInt::get(Type::ULongTy, TD.getTypeSize(AllocTy)); + MallocArg = ConstantInt::get(Type::ULongTy, TD.getTypeSize(AllocTy)); else MallocArg = ConstantExpr::getSizeOf(AllocTy); MallocArg = ConstantExpr::getCast(cast<Constant>(MallocArg), IntPtrTy); if (MI->isArrayAllocation()) { if (isa<ConstantInt>(MallocArg) && - cast<ConstantInt>(MallocArg)->getRawValue() == 1) { + cast<ConstantInt>(MallocArg)->getZExtValue() == 1) { MallocArg = MI->getOperand(0); // Operand * 1 = Operand } else if (Constant *CO = dyn_cast<Constant>(MI->getOperand(0))) { CO = ConstantExpr::getCast(CO, IntPtrTy); Index: llvm/lib/Transforms/Utils/LowerInvoke.cpp diff -u llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.41 llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.42 --- llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.41 Tue Sep 5 12:48:07 2006 +++ llvm/lib/Transforms/Utils/LowerInvoke.cpp Fri Oct 20 02:07:24 2006 @@ -269,7 +269,7 @@ void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo, AllocaInst *InvokeNum, SwitchInst *CatchSwitch) { - ConstantUInt *InvokeNoC = ConstantUInt::get(Type::UIntTy, InvokeNo); + ConstantInt *InvokeNoC = ConstantInt::get(Type::UIntTy, InvokeNo); // Insert a store of the invoke num before the invoke and store zero into the // location afterward. @@ -461,7 +461,7 @@ std::vector<Value*> Idx; Idx.push_back(Constant::getNullValue(Type::IntTy)); - Idx.push_back(ConstantUInt::get(Type::UIntTy, 1)); + Idx.push_back(ConstantInt::get(Type::UIntTy, 1)); OldJmpBufPtr = new GetElementPtrInst(JmpBuf, Idx, "OldBuf", EntryBB->getTerminator()); @@ -500,7 +500,7 @@ BasicBlock *ContBlock = EntryBB->splitBasicBlock(EntryBB->getTerminator(), "setjmp.cont"); - Idx[1] = ConstantUInt::get(Type::UIntTy, 0); + Idx[1] = ConstantInt::get(Type::UIntTy, 0); Value *JmpBufPtr = new GetElementPtrInst(JmpBuf, Idx, "TheJmpBuf", EntryBB->getTerminator()); Value *SJRet = new CallInst(SetJmpFn, JmpBufPtr, "sjret", @@ -550,7 +550,7 @@ // Get a pointer to the jmpbuf and longjmp. std::vector<Value*> Idx; Idx.push_back(Constant::getNullValue(Type::IntTy)); - Idx.push_back(ConstantUInt::get(Type::UIntTy, 0)); + Idx.push_back(ConstantInt::get(Type::UIntTy, 0)); Idx[0] = new GetElementPtrInst(BufPtr, Idx, "JmpBuf", UnwindBlock); Idx[1] = ConstantInt::get(Type::IntTy, 1); new CallInst(LongJmpFn, Idx, "", UnwindBlock); Index: llvm/lib/Transforms/Utils/LowerSwitch.cpp diff -u llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.24 llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.25 --- llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.24 Sun Aug 27 17:42:52 2006 +++ llvm/lib/Transforms/Utils/LowerSwitch.cpp Fri Oct 20 02:07:24 2006 @@ -60,11 +60,12 @@ struct CaseCmp { bool operator () (const LowerSwitch::Case& C1, const LowerSwitch::Case& C2) { - if (const ConstantUInt* U1 = dyn_cast<const ConstantUInt>(C1.first)) - return U1->getValue() < cast<const ConstantUInt>(C2.first)->getValue(); - const ConstantSInt* S1 = dyn_cast<const ConstantSInt>(C1.first); - return S1->getValue() < cast<const ConstantSInt>(C2.first)->getValue(); + const ConstantInt* CI1 = cast<const ConstantInt>(C1.first); + const ConstantInt* CI2 = cast<const ConstantInt>(C2.first); + if (CI1->getType()->isUnsigned()) + return CI1->getZExtValue() < CI2->getZExtValue(); + return CI1->getSExtValue() < CI2->getSExtValue(); } }; @@ -129,7 +130,7 @@ Case& Pivot = *(Begin + Mid); DEBUG(std::cerr << "Pivot ==> " - << (int64_t)cast<ConstantInt>(Pivot.first)->getRawValue() + << cast<ConstantInt>(Pivot.first)->getSExtValue() << "\n"); BasicBlock* LBranch = switchConvert(LHS.begin(), LHS.end(), Val, Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.100 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.101 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.100 Thu Oct 19 19:42:07 2006 +++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Fri Oct 20 02:07:24 2006 @@ -1160,7 +1160,7 @@ /// applications that sort ConstantInt's to ensure uniqueness. struct ConstantIntOrdering { bool operator()(const ConstantInt *LHS, const ConstantInt *RHS) const { - return LHS->getRawValue() < RHS->getRawValue(); + return LHS->getZExtValue() < RHS->getZExtValue(); } }; } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits