For PR950:

The long awaited CAST patch. This introduces 12 new instructions into LLVM
to replace the cast instruction. Corresponding changes throughout LLVM are
provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the
exception of 175.vpr which fails only on a slight floating point output
difference.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31931 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer
2006-11-27 01:05:10 +00:00
parent 5fed9b9044
commit 3da59db637
105 changed files with 6737 additions and 3700 deletions

View File

@@ -139,13 +139,15 @@ bool LowerGC::doInitialization(Module &M) {
}
/// Coerce - If the specified operand number of the specified instruction does
/// not have the specified type, insert a cast.
/// not have the specified type, insert a cast. Note that this only uses BitCast
/// because the types involved are all pointers.
static void Coerce(Instruction *I, unsigned OpNum, Type *Ty) {
if (I->getOperand(OpNum)->getType() != Ty) {
if (Constant *C = dyn_cast<Constant>(I->getOperand(OpNum)))
I->setOperand(OpNum, ConstantExpr::getCast(C, Ty));
I->setOperand(OpNum, ConstantExpr::getBitCast(C, Ty));
else {
CastInst *CI = new CastInst(I->getOperand(OpNum), Ty, "", I);
CastInst *CI =
CastInst::createInferredCast(I->getOperand(OpNum), Ty, "", I);
I->setOperand(OpNum, CI);
}
}
@@ -196,7 +198,9 @@ bool LowerGC::runOnFunction(Function &F) {
CallInst *NC = new CallInst(GCRead, CI->getOperand(1),
CI->getOperand(2),
CI->getName(), CI);
Value *NV = new CastInst(NC, CI->getType(), "", CI);
// These functions only deal with ptr type results so BitCast
// is the correct kind of cast (no-op cast).
Value *NV = new BitCastInst(NC, CI->getType(), "", CI);
CI->replaceAllUsesWith(NV);
BB->getInstList().erase(CI);
CI = NC;
@@ -273,7 +277,7 @@ bool LowerGC::runOnFunction(Function &F) {
// Now that the record is all initialized, store the pointer into the global
// pointer.
Value *C = new CastInst(AI, PointerType::get(MainRootRecordType), "", IP);
Value *C = new BitCastInst(AI, PointerType::get(MainRootRecordType), "", IP);
new StoreInst(C, RootChain, IP);
// On exit from the function we have to remove the entry from the GC root