aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-10-20 07:07:24 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-10-20 07:07:24 +0000
commitb83eb6447ba155342598f0fabe1f08f5baa9164a (patch)
treea5822f5fdac89033b7b16ba8e5aaf1ae10833b1c /lib/Transforms/Utils
parent6e7dd9db6bf677c9161a6ecc12f90651cf1231e0 (diff)
For 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31063 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/CodeExtractor.cpp14
-rw-r--r--lib/Transforms/Utils/Local.cpp14
-rw-r--r--lib/Transforms/Utils/LowerAllocations.cpp4
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp8
-rw-r--r--lib/Transforms/Utils/LowerSwitch.cpp11
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp2
6 files changed, 27 insertions, 26 deletions
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp
index f264cff472..ba403450a7 100644
--- a/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/lib/Transforms/Utils/CodeExtractor.cpp
@@ -305,7 +305,7 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
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 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
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 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
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 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
// 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 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
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 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
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(),
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
index 3d1faff018..28864fd613 100644
--- a/lib/Transforms/Utils/Local.cpp
+++ b/lib/Transforms/Utils/Local.cpp
@@ -272,10 +272,10 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C,
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 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C,
}
} 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 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C,
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))
diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp
index 451df70fef..d08235cd9d 100644
--- a/lib/Transforms/Utils/LowerAllocations.cpp
+++ b/lib/Transforms/Utils/LowerAllocations.cpp
@@ -119,14 +119,14 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
// 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);
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index 918055722d..1816144fff 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -269,7 +269,7 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) {
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 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
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 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
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 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
// 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);
diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp
index 12a32f19cb..724499d1ba 100644
--- a/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/lib/Transforms/Utils/LowerSwitch.cpp
@@ -60,11 +60,12 @@ namespace {
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 @@ BasicBlock* LowerSwitch::switchConvert(CaseItr Begin, CaseItr End,
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,
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 867455e3e7..de2ab0645c 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1160,7 +1160,7 @@ namespace {
/// 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();
}
};
}