diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-12-12 01:17:41 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-12-12 01:17:41 +0000 |
commit | 3c49edcaa11f056c58f70e7374932625a4019f3a (patch) | |
tree | 337fff3f0006e6a46ae307f7b6941f98b14849c4 /llvm/lib/CodeGen | |
parent | 9fa0a268082d11c09275cd0770dcb3aaec08e833 (diff) | |
download | bcm5719-llvm-3c49edcaa11f056c58f70e7374932625a4019f3a.tar.gz bcm5719-llvm-3c49edcaa11f056c58f70e7374932625a4019f3a.zip |
Change inferred cast creation calls to more specific cast creations.
llvm-svn: 32460
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/IntrinsicLowering.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineDebugInfo.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 2 |
4 files changed, 12 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter.cpp index 4caa2c1be1e..498339c014e 100644 --- a/llvm/lib/CodeGen/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter.cpp @@ -446,7 +446,11 @@ void AsmPrinter::EmitConstantValueOnly(const Constant *CV) { // integer type. This promotes constant folding and simplifies this code. if (isa<PointerType>(Ty)) { const Type *IntPtrTy = TD->getIntPtrType(); - Op = ConstantExpr::getCast(Op, IntPtrTy); + Instruction::CastOps opcode = Instruction::CastOps(CE->getOpcode()); + if (opcode == Instruction::IntToPtr) + Op = ConstantExpr::getIntegerCast(Op, IntPtrTy, false /*ZExt*/); + else + Op = ConstantExpr::getCast(Instruction::PtrToInt, Op, IntPtrTy); return EmitConstantValueOnly(Op); } diff --git a/llvm/lib/CodeGen/IntrinsicLowering.cpp b/llvm/lib/CodeGen/IntrinsicLowering.cpp index 753f4591c63..55f1c3c0ba3 100644 --- a/llvm/lib/CodeGen/IntrinsicLowering.cpp +++ b/llvm/lib/CodeGen/IntrinsicLowering.cpp @@ -239,7 +239,7 @@ static Value *LowerCTPOP(Value *V, Instruction *IP) { for (unsigned i = 1, ct = 0; i != BitSize; i <<= 1, ++ct) { Value *MaskCst = - ConstantExpr::getCast(ConstantInt::get(Type::ULongTy, MaskValues[ct]), + ConstantExpr::getTruncOrBitCast(ConstantInt::get(Type::ULongTy, MaskValues[ct]), V->getType()); Value *LHS = BinaryOperator::createAnd(V, MaskCst, "cppop.and1", IP); Value *VShift = new ShiftInst(Instruction::LShr, V, diff --git a/llvm/lib/CodeGen/MachineDebugInfo.cpp b/llvm/lib/CodeGen/MachineDebugInfo.cpp index bc75ccb7a65..d3b6ecb4699 100644 --- a/llvm/lib/CodeGen/MachineDebugInfo.cpp +++ b/llvm/lib/CodeGen/MachineDebugInfo.cpp @@ -292,7 +292,7 @@ public: if (GV) { // Set to pointer to global. - Elements.push_back(ConstantExpr::getCast(GV, EmptyTy)); + Elements.push_back(ConstantExpr::getBitCast(GV, EmptyTy)); } else { // Use NULL. Elements.push_back(ConstantPointerNull::get(EmptyTy)); @@ -301,7 +301,7 @@ public: virtual void Apply(GlobalVariable *&Field) { const PointerType *EmptyTy = SR.getEmptyStructPtrType(); if (Field) { - Elements.push_back(ConstantExpr::getCast(Field, EmptyTy)); + Elements.push_back(ConstantExpr::getBitCast(Field, EmptyTy)); } else { Elements.push_back(ConstantPointerNull::get(EmptyTy)); } @@ -315,7 +315,7 @@ public: for (unsigned i = 0, N = Field.size(); i < N; ++i) { if (DebugInfoDesc *Element = Field[i]) { GlobalVariable *GVE = SR.Serialize(Element); - Constant *CE = ConstantExpr::getCast(GVE, EmptyTy); + Constant *CE = ConstantExpr::getBitCast(GVE, EmptyTy); ArrayElements.push_back(cast<Constant>(CE)); } else { ArrayElements.push_back(ConstantPointerNull::get(EmptyTy)); @@ -328,7 +328,7 @@ public: CA, "llvm.dbg.array", SR.getModule()); CAGV->setSection("llvm.metadata"); - Constant *CAE = ConstantExpr::getCast(CAGV, EmptyTy); + Constant *CAE = ConstantExpr::getBitCast(CAGV, EmptyTy); Elements.push_back(CAE); } }; @@ -1323,7 +1323,7 @@ Constant *DISerializer::getString(const std::string &String) { ConstStr, "str", M); StrGV->setSection("llvm.metadata"); // Convert to generic string pointer. - Slot = ConstantExpr::getCast(StrGV, getStrPtrType()); + Slot = ConstantExpr::getBitCast(StrGV, getStrPtrType()); } return Slot; diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 4d5d3da8ce9..4cbc9fe4ecf 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -790,7 +790,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { // Only do this if the target has a native EXTLOAD instruction from // f32. TLI.isLoadXLegal(ISD::EXTLOAD, MVT::f32)) { - LLVMC = cast<ConstantFP>(ConstantExpr::getCast(LLVMC, Type::FloatTy)); + LLVMC = cast<ConstantFP>(ConstantExpr::getFPCast(LLVMC, Type::FloatTy)); VT = MVT::f32; Extend = true; } |