mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-22 10:33:23 +00:00
If a value is cast to its own type, then the cast
is not needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49210 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8ac66c122b
commit
b51a0d87ac
@ -615,20 +615,24 @@ public:
|
||||
const char *Name = "") {
|
||||
return CreateCast(Instruction::BitCast, V, DestTy, Name);
|
||||
}
|
||||
|
||||
|
||||
Value *CreateCast(Instruction::CastOps Op, Value *V, const Type *DestTy,
|
||||
const char *Name = "") {
|
||||
if (V->getType() == DestTy)
|
||||
return V;
|
||||
if (Constant *VC = dyn_cast<Constant>(V))
|
||||
return ConstantExpr::getCast(Op, VC, DestTy);
|
||||
return LLVMBuilder::CreateCast(Op, V, DestTy, Name);
|
||||
}
|
||||
Value *CreateIntCast(Value *V, const Type *DestTy, bool isSigned,
|
||||
const char *Name = "") {
|
||||
if (V->getType() == DestTy)
|
||||
return V;
|
||||
if (Constant *VC = dyn_cast<Constant>(V))
|
||||
return ConstantExpr::getIntegerCast(VC, DestTy, isSigned);
|
||||
return LLVMBuilder::CreateIntCast(V, DestTy, isSigned, Name);
|
||||
}
|
||||
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Instruction creation methods: Compare Instructions
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
Loading…
x
Reference in New Issue
Block a user