mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-01 03:33:42 +00:00
add a new ConstantIntegral::get method. Simplify the implementation of
ConstantInt::get git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32080 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f0d6dd6006
commit
68329b2187
@ -44,6 +44,10 @@ protected:
|
||||
uint64_t Val;
|
||||
ConstantIntegral(const Type *Ty, ValueTy VT, uint64_t V);
|
||||
public:
|
||||
|
||||
/// ConstantIntegral::get - Return a bool or integer constant.
|
||||
static ConstantIntegral *get(const Type *Ty, int64_t V);
|
||||
|
||||
/// Return the constant as a 64-bit unsigned integer value after it
|
||||
/// has been zero extended as appropriate for the type of this constant.
|
||||
/// @brief Return the zero extended value.
|
||||
|
@ -929,9 +929,12 @@ static ManagedStatic<ValueMap<uint64_t, Type, ConstantInt> > IntConstants;
|
||||
// just return the stored value while getSExtValue has to convert back to sign
|
||||
// extended. getZExtValue is more common in LLVM than getSExtValue().
|
||||
ConstantInt *ConstantInt::get(const Type *Ty, int64_t V) {
|
||||
unsigned Size = Ty->getPrimitiveSizeInBits();
|
||||
uint64_t ZeroExtendedCanonicalization = V & (~uint64_t(0UL) >> (64-Size));
|
||||
return IntConstants->getOrCreate(Ty, ZeroExtendedCanonicalization );
|
||||
return IntConstants->getOrCreate(Ty, V & Ty->getIntegralTypeMask());
|
||||
}
|
||||
|
||||
ConstantIntegral *ConstantIntegral::get(const Type *Ty, int64_t V) {
|
||||
if (Ty == Type::BoolTy) return ConstantBool::get(V&1);
|
||||
return IntConstants->getOrCreate(Ty, V & Ty->getIntegralTypeMask());
|
||||
}
|
||||
|
||||
//---- ConstantFP::get() implementation...
|
||||
|
Loading…
x
Reference in New Issue
Block a user