mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-09 05:40:38 +00:00
add zextOrTrunc and sextOrTrunc methods, that are similar to the ones in APInt
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86549 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
43cca695a8
commit
95a3be0ba4
@ -187,6 +187,14 @@ public:
|
|||||||
/// truncated to the specified type.
|
/// truncated to the specified type.
|
||||||
ConstantRange truncate(uint32_t BitWidth) const;
|
ConstantRange truncate(uint32_t BitWidth) const;
|
||||||
|
|
||||||
|
/// zextOrTrunc - make this range have the bit width given by \p BitWidth. The
|
||||||
|
/// value is zero extended, truncated, or left alone to make it that width.
|
||||||
|
ConstantRange zextOrTrunc(uint32_t BitWidth) const;
|
||||||
|
|
||||||
|
/// sextOrTrunc - make this range have the bit width given by \p BitWidth. The
|
||||||
|
/// value is sign extended, truncated, or left alone to make it that width.
|
||||||
|
ConstantRange sextOrTrunc(uint32_t BitWidth) const;
|
||||||
|
|
||||||
/// add - Return a new range representing the possible values resulting
|
/// add - Return a new range representing the possible values resulting
|
||||||
/// from an addition of a value in this range and a value in Other.
|
/// from an addition of a value in this range and a value in Other.
|
||||||
ConstantRange add(const ConstantRange &Other) const;
|
ConstantRange add(const ConstantRange &Other) const;
|
||||||
|
@ -492,6 +492,30 @@ ConstantRange ConstantRange::truncate(uint32_t DstTySize) const {
|
|||||||
return ConstantRange(L, U);
|
return ConstantRange(L, U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// zextOrTrunc - make this range have the bit width given by \p DstTySize. The
|
||||||
|
/// value is zero extended, truncated, or left alone to make it that width.
|
||||||
|
ConstantRange ConstantRange::zextOrTrunc(uint32_t DstTySize) const {
|
||||||
|
unsigned SrcTySize = getBitWidth();
|
||||||
|
if (SrcTySize > DstTySize)
|
||||||
|
return truncate(DstTySize);
|
||||||
|
else if (SrcTySize < DstTySize)
|
||||||
|
return zeroExtend(DstTySize);
|
||||||
|
else
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// sextOrTrunc - make this range have the bit width given by \p DstTySize. The
|
||||||
|
/// value is sign extended, truncated, or left alone to make it that width.
|
||||||
|
ConstantRange ConstantRange::sextOrTrunc(uint32_t DstTySize) const {
|
||||||
|
unsigned SrcTySize = getBitWidth();
|
||||||
|
if (SrcTySize > DstTySize)
|
||||||
|
return truncate(DstTySize);
|
||||||
|
else if (SrcTySize < DstTySize)
|
||||||
|
return signExtend(DstTySize);
|
||||||
|
else
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
ConstantRange
|
ConstantRange
|
||||||
ConstantRange::add(const ConstantRange &Other) const {
|
ConstantRange::add(const ConstantRange &Other) const {
|
||||||
if (isEmptySet() || Other.isEmptySet())
|
if (isEmptySet() || Other.isEmptySet())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user