diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-12-31 05:48:39 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-12-31 05:48:39 +0000 |
commit | c5b206b6be61d0d933b98b6af5e22f42edd48ad1 (patch) | |
tree | 9e6a1e6d3b90890de3d1464a44a7cef8d30fe1ae /lib/Transforms/ExprTypeConvert.cpp | |
parent | 05e52a1b35e7feb359a176af462591697c4d9647 (diff) |
For 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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32785 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/ExprTypeConvert.cpp')
-rw-r--r-- | lib/Transforms/ExprTypeConvert.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp index 5f6b6aebf9..9f99f95642 100644 --- a/lib/Transforms/ExprTypeConvert.cpp +++ b/lib/Transforms/ExprTypeConvert.cpp @@ -210,8 +210,9 @@ Value *llvm::ConvertExpressionToType(Value *V, const Type *Ty, Constant *CPV = cast<Constant>(V); // Constants are converted by constant folding the cast that is required. // We assume here that all casts are implemented for constant prop. - Instruction::CastOps opcode = CastInst::getCastOpcode(CPV, - CPV->getType()->isSigned(), Ty, Ty->isSigned()); + // FIXME: This seems to work, but it is unclear why ZEXT is always the + // right choice here. + Instruction::CastOps opcode = CastInst::getCastOpcode(CPV, false, Ty,false); Value *Result = ConstantExpr::getCast(opcode, CPV, Ty); // Add the instruction to the expression map //VMC.ExprMap[V] = Result; @@ -231,7 +232,7 @@ Value *llvm::ConvertExpressionToType(Value *V, const Type *Ty, case Instruction::BitCast: { assert(VMC.NewCasts.count(ValueHandle(VMC, I)) == 0); Instruction::CastOps opcode = CastInst::getCastOpcode(I->getOperand(0), - I->getOperand(0)->getType()->isSigned(), Ty, Ty->isSigned()); + false, Ty, false); Res = CastInst::create(opcode, I->getOperand(0), Ty, Name); VMC.NewCasts.insert(ValueHandle(VMC, Res)); break; @@ -473,8 +474,6 @@ static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty, } case Instruction::LShr: case Instruction::AShr: - if (Ty->isSigned() != V->getType()->isSigned()) return false; - // FALL THROUGH case Instruction::Shl: if (I->getOperand(1) == V) return false; // Cannot change shift amount type if (!Ty->isInteger()) return false; @@ -713,8 +712,8 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, switch (I->getOpcode()) { case Instruction::BitCast: { - Instruction::CastOps opcode = CastInst::getCastOpcode(NewVal, - NewVal->getType()->isSigned(), I->getType(), I->getType()->isSigned()); + Instruction::CastOps opcode = CastInst::getCastOpcode(NewVal, false, + I->getType(), false); Res = CastInst::create(opcode, NewVal, I->getType(), Name); break; } @@ -768,7 +767,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, if (const CompositeType *CT = dyn_cast<CompositeType>(LoadedTy)) { std::vector<Value*> Indices; - Indices.push_back(Constant::getNullValue(Type::UIntTy)); + Indices.push_back(Constant::getNullValue(Type::Int32Ty)); unsigned Offset = 0; // No offset, get first leaf. LoadedTy = getStructOffsetType(CT, Offset, Indices, TD, false); @@ -801,7 +800,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, if (ElTy != NewTy) { std::vector<Value*> Indices; - Indices.push_back(Constant::getNullValue(Type::UIntTy)); + Indices.push_back(Constant::getNullValue(Type::Int32Ty)); unsigned Offset = 0; const Type *Ty = getStructOffsetType(ElTy, Offset, Indices, TD,false); @@ -830,7 +829,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, if (isa<StructType>(ValTy)) { std::vector<Value*> Indices; - Indices.push_back(Constant::getNullValue(Type::UIntTy)); + Indices.push_back(Constant::getNullValue(Type::Int32Ty)); unsigned Offset = 0; ValTy = getStructOffsetType(ValTy, Offset, Indices, TD, false); |