[llvm-commits] CVS: llvm/lib/Transforms/Utils/CodeExtractor.cpp InlineFunction.cpp LowerAllocations.cpp LowerInvoke.cpp LowerSwitch.cpp
Reid Spencer
reid at x10sys.com
Sat Dec 30 21:49:03 PST 2006
Changes in directory llvm/lib/Transforms/Utils:
CodeExtractor.cpp updated: 1.43 -> 1.44
InlineFunction.cpp updated: 1.47 -> 1.48
LowerAllocations.cpp updated: 1.68 -> 1.69
LowerInvoke.cpp updated: 1.48 -> 1.49
LowerSwitch.cpp updated: 1.31 -> 1.32
---
Log message:
For PR950: http://llvm.org/PR950 :
This patch replaces signed integer types with signless ones:
1. [US]Byte -> Int8
2. [U]Short -> Int16
3. [U]Int -> Int32
4. [U]Long -> Int64.
5. Removal of isSigned, isUnsigned, getSignedVersion, getUnsignedVersion
and other methods related to signedness. In a few places this warranted
identifying the signedness information from other sources.
---
Diffs of the changes: (+36 -38)
CodeExtractor.cpp | 24 ++++++++++++------------
InlineFunction.cpp | 2 +-
LowerAllocations.cpp | 6 +++---
LowerInvoke.cpp | 38 +++++++++++++++++++-------------------
LowerSwitch.cpp | 4 +---
5 files changed, 36 insertions(+), 38 deletions(-)
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.43 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.44
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.43 Wed Dec 6 19:30:31 2006
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp Sat Dec 30 23:48:39 2006
@@ -252,7 +252,7 @@
case 0:
case 1: RetTy = Type::VoidTy; break;
case 2: RetTy = Type::BoolTy; break;
- default: RetTy = Type::UShortTy; break;
+ default: RetTy = Type::Int16Ty; break;
}
std::vector<const Type*> paramTy;
@@ -304,8 +304,8 @@
Value *RewriteVal;
if (AggregateArgs) {
std::vector<Value*> Indices;
- Indices.push_back(Constant::getNullValue(Type::UIntTy));
- Indices.push_back(ConstantInt::get(Type::UIntTy, i));
+ Indices.push_back(Constant::getNullValue(Type::Int32Ty));
+ Indices.push_back(ConstantInt::get(Type::Int32Ty, i));
std::string GEPname = "gep_" + inputs[i]->getName();
TerminatorInst *TI = newFunction->begin()->getTerminator();
GetElementPtrInst *GEP = new GetElementPtrInst(AI, Indices, GEPname, TI);
@@ -391,8 +391,8 @@
for (unsigned i = 0, e = inputs.size(); i != e; ++i) {
std::vector<Value*> Indices;
- Indices.push_back(Constant::getNullValue(Type::UIntTy));
- Indices.push_back(ConstantInt::get(Type::UIntTy, i));
+ Indices.push_back(Constant::getNullValue(Type::Int32Ty));
+ Indices.push_back(ConstantInt::get(Type::Int32Ty, i));
GetElementPtrInst *GEP =
new GetElementPtrInst(Struct, Indices,
"gep_" + StructValues[i]->getName());
@@ -417,8 +417,8 @@
Value *Output = 0;
if (AggregateArgs) {
std::vector<Value*> Indices;
- Indices.push_back(Constant::getNullValue(Type::UIntTy));
- Indices.push_back(ConstantInt::get(Type::UIntTy, FirstOut + i));
+ Indices.push_back(Constant::getNullValue(Type::Int32Ty));
+ Indices.push_back(ConstantInt::get(Type::Int32Ty, 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(ConstantInt::getNullValue(Type::UShortTy),
+ new SwitchInst(ConstantInt::getNullValue(Type::Int16Ty),
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 = ConstantInt::get(Type::UShortTy, SuccNum);
+ brVal = ConstantInt::get(Type::Int16Ty, SuccNum);
break;
}
ReturnInst *NTRet = new ReturnInst(brVal, NewTarget);
// Update the switch instruction.
- TheSwitch->addCase(ConstantInt::get(Type::UShortTy, SuccNum),
+ TheSwitch->addCase(ConstantInt::get(Type::Int16Ty, SuccNum),
OldTarget);
// Restore values just before we exit
@@ -518,8 +518,8 @@
if (DominatesDef) {
if (AggregateArgs) {
std::vector<Value*> Indices;
- Indices.push_back(Constant::getNullValue(Type::UIntTy));
- Indices.push_back(ConstantInt::get(Type::UIntTy,FirstOut+out));
+ Indices.push_back(Constant::getNullValue(Type::Int32Ty));
+ Indices.push_back(ConstantInt::get(Type::Int32Ty,FirstOut+out));
GetElementPtrInst *GEP =
new GetElementPtrInst(OAI, Indices,
"gep_" + outputs[out]->getName(),
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.47 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.48
--- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.47 Wed Sep 13 14:23:57 2006
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp Sat Dec 30 23:48:39 2006
@@ -274,7 +274,7 @@
// code with llvm.stacksave/llvm.stackrestore intrinsics.
if (InlinedFunctionInfo.ContainsDynamicAllocas) {
Module *M = Caller->getParent();
- const Type *SBytePtr = PointerType::get(Type::SByteTy);
+ const Type *SBytePtr = PointerType::get(Type::Int8Ty);
// Get the two intrinsics we care about.
Function *StackSave, *StackRestore;
StackSave = M->getOrInsertFunction("llvm.stacksave", SBytePtr, NULL);
Index: llvm/lib/Transforms/Utils/LowerAllocations.cpp
diff -u llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.68 llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.69
--- llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.68 Tue Dec 19 16:17:40 2006
+++ llvm/lib/Transforms/Utils/LowerAllocations.cpp Sat Dec 30 23:48:39 2006
@@ -84,7 +84,7 @@
// This function is always successful.
//
bool LowerAllocations::doInitialization(Module &M) {
- const Type *SBPTy = PointerType::get(Type::SByteTy);
+ const Type *SBPTy = PointerType::get(Type::Int8Ty);
MallocFunc = M.getNamedFunction("malloc");
FreeFunc = M.getNamedFunction("free");
@@ -120,7 +120,7 @@
// malloc(type) becomes sbyte *malloc(size)
Value *MallocArg;
if (LowerMallocArgToInteger)
- MallocArg = ConstantInt::get(Type::ULongTy, TD.getTypeSize(AllocTy));
+ MallocArg = ConstantInt::get(Type::Int64Ty, TD.getTypeSize(AllocTy));
else
MallocArg = ConstantExpr::getSizeOf(AllocTy);
MallocArg = ConstantExpr::getTruncOrBitCast(cast<Constant>(MallocArg),
@@ -154,7 +154,7 @@
MallocArg = CastInst::createIntegerCast(MallocArg, IntPtrTy,
false /*ZExt*/, "", I);
} else if (MallocFTy->getNumParams() > 0 &&
- MallocFTy->getParamType(0) != Type::UIntTy)
+ MallocFTy->getParamType(0) != Type::Int32Ty)
MallocArg = CastInst::createIntegerCast(
MallocArg, MallocFTy->getParamType(0), false/*ZExt*/, "",I);
MallocArgs.push_back(MallocArg);
Index: llvm/lib/Transforms/Utils/LowerInvoke.cpp
diff -u llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.48 llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.49
--- llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.48 Sat Dec 23 00:05:41 2006
+++ llvm/lib/Transforms/Utils/LowerInvoke.cpp Sat Dec 30 23:48:39 2006
@@ -110,7 +110,7 @@
// doInitialization - Make sure that there is a prototype for abort in the
// current module.
bool LowerInvoke::doInitialization(Module &M) {
- const Type *VoidPtrTy = PointerType::get(Type::SByteTy);
+ const Type *VoidPtrTy = PointerType::get(Type::Int8Ty);
AbortMessage = 0;
if (ExpensiveEHSupport) {
// Insert a type for the linked list of jump buffers.
@@ -139,11 +139,11 @@
Constant::getNullValue(PtrJBList),
"llvm.sjljeh.jblist", &M);
}
- SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::IntTy,
+ SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::Int32Ty,
PointerType::get(JmpBufTy), (Type *)0);
LongJmpFn = M.getOrInsertFunction("llvm.longjmp", Type::VoidTy,
PointerType::get(JmpBufTy),
- Type::IntTy, (Type *)0);
+ Type::Int32Ty, (Type *)0);
}
// We need the 'write' and 'abort' functions for both models.
@@ -163,8 +163,8 @@
else
WriteFn = 0;
} else {
- WriteFn = M.getOrInsertFunction("write", Type::VoidTy, Type::IntTy,
- VoidPtrTy, Type::IntTy, (Type *)0);
+ WriteFn = M.getOrInsertFunction("write", Type::VoidTy, Type::Int32Ty,
+ VoidPtrTy, Type::Int32Ty, (Type *)0);
}
return true;
}
@@ -181,7 +181,7 @@
GlobalVariable *MsgGV = new GlobalVariable(Msg->getType(), true,
GlobalValue::InternalLinkage,
Msg, "abortmsg", &M);
- std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::IntTy));
+ std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::Int32Ty));
AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, GEPIdx);
} else {
// The abort message for cheap EH support tells the user that EH is not
@@ -194,7 +194,7 @@
GlobalVariable *MsgGV = new GlobalVariable(Msg->getType(), true,
GlobalValue::InternalLinkage,
Msg, "abortmsg", &M);
- std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::IntTy));
+ std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::Int32Ty));
AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, GEPIdx);
}
}
@@ -206,9 +206,9 @@
// These are the arguments we WANT...
std::vector<Value*> Args;
- Args.push_back(ConstantInt::get(Type::IntTy, 2));
+ Args.push_back(ConstantInt::get(Type::Int32Ty, 2));
Args.push_back(AbortMessage);
- Args.push_back(ConstantInt::get(Type::IntTy, AbortMessageLength));
+ Args.push_back(ConstantInt::get(Type::Int32Ty, AbortMessageLength));
// If the actual declaration of write disagrees, insert casts as
// appropriate.
@@ -274,7 +274,7 @@
void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo,
AllocaInst *InvokeNum,
SwitchInst *CatchSwitch) {
- ConstantInt *InvokeNoC = ConstantInt::get(Type::UIntTy, InvokeNo);
+ ConstantInt *InvokeNoC = ConstantInt::get(Type::Int32Ty, InvokeNo);
// Insert a store of the invoke num before the invoke and store zero into the
// location afterward.
@@ -283,7 +283,7 @@
BasicBlock::iterator NI = II->getNormalDest()->begin();
while (isa<PHINode>(NI)) ++NI;
// nonvolatile.
- new StoreInst(Constant::getNullValue(Type::UIntTy), InvokeNum, false, NI);
+ new StoreInst(Constant::getNullValue(Type::Int32Ty), InvokeNum, false, NI);
// Add a switch case to our unwind block.
CatchSwitch->addCase(InvokeNoC, II->getUnwindDest());
@@ -470,8 +470,8 @@
new AllocaInst(JBLinkTy, 0, Align, "jblink", F.begin()->begin());
std::vector<Value*> Idx;
- Idx.push_back(Constant::getNullValue(Type::IntTy));
- Idx.push_back(ConstantInt::get(Type::UIntTy, 1));
+ Idx.push_back(Constant::getNullValue(Type::Int32Ty));
+ Idx.push_back(ConstantInt::get(Type::Int32Ty, 1));
OldJmpBufPtr = new GetElementPtrInst(JmpBuf, Idx, "OldBuf",
EntryBB->getTerminator());
@@ -489,9 +489,9 @@
// Create an alloca which keeps track of which invoke is currently
// executing. For normal calls it contains zero.
- AllocaInst *InvokeNum = new AllocaInst(Type::UIntTy, 0, "invokenum",
+ AllocaInst *InvokeNum = new AllocaInst(Type::Int32Ty, 0, "invokenum",
EntryBB->begin());
- new StoreInst(ConstantInt::get(Type::UIntTy, 0), InvokeNum, true,
+ new StoreInst(ConstantInt::get(Type::Int32Ty, 0), InvokeNum, true,
EntryBB->getTerminator());
// Insert a load in the Catch block, and a switch on its value. By default,
@@ -510,7 +510,7 @@
BasicBlock *ContBlock = EntryBB->splitBasicBlock(EntryBB->getTerminator(),
"setjmp.cont");
- Idx[1] = ConstantInt::get(Type::UIntTy, 0);
+ Idx[1] = ConstantInt::get(Type::Int32Ty, 0);
Value *JmpBufPtr = new GetElementPtrInst(JmpBuf, Idx, "TheJmpBuf",
EntryBB->getTerminator());
Value *SJRet = new CallInst(SetJmpFn, JmpBufPtr, "sjret",
@@ -559,10 +559,10 @@
// Create the block to do the longjmp.
// Get a pointer to the jmpbuf and longjmp.
std::vector<Value*> Idx;
- Idx.push_back(Constant::getNullValue(Type::IntTy));
- Idx.push_back(ConstantInt::get(Type::UIntTy, 0));
+ Idx.push_back(Constant::getNullValue(Type::Int32Ty));
+ Idx.push_back(ConstantInt::get(Type::Int32Ty, 0));
Idx[0] = new GetElementPtrInst(BufPtr, Idx, "JmpBuf", UnwindBlock);
- Idx[1] = ConstantInt::get(Type::IntTy, 1);
+ Idx[1] = ConstantInt::get(Type::Int32Ty, 1);
new CallInst(LongJmpFn, Idx, "", UnwindBlock);
new UnreachableInst(UnwindBlock);
Index: llvm/lib/Transforms/Utils/LowerSwitch.cpp
diff -u llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.31 llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.32
--- llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.31 Sat Dec 23 00:05:41 2006
+++ llvm/lib/Transforms/Utils/LowerSwitch.cpp Sat Dec 30 23:48:39 2006
@@ -59,9 +59,7 @@
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();
+ return CI1->getZExtValue() < CI2->getZExtValue();
}
};
More information about the llvm-commits
mailing list