mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Add a new helper method to Value to strip in-bounds constant offsets of
pointers, but accumulate the offset into an APInt in the process of stripping it. This is a pretty handy thing to have, such as when trying to determine if two pointers are at some constant relative offset. I'll be committing a patch shortly to use it for exactly that purpose. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189000 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -22,26 +22,29 @@
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class Constant;
|
||||
class APInt;
|
||||
class Argument;
|
||||
class Instruction;
|
||||
class AssemblyAnnotationWriter;
|
||||
class BasicBlock;
|
||||
class GlobalValue;
|
||||
class Constant;
|
||||
class DataLayout;
|
||||
class Function;
|
||||
class GlobalVariable;
|
||||
class GlobalAlias;
|
||||
class GlobalValue;
|
||||
class GlobalVariable;
|
||||
class InlineAsm;
|
||||
class Instruction;
|
||||
class LLVMContext;
|
||||
class MDNode;
|
||||
class StringRef;
|
||||
class Twine;
|
||||
class Type;
|
||||
class ValueHandleBase;
|
||||
class ValueSymbolTable;
|
||||
class raw_ostream;
|
||||
|
||||
template<typename ValueTy> class StringMapEntry;
|
||||
typedef StringMapEntry<Value*> ValueName;
|
||||
class raw_ostream;
|
||||
class AssemblyAnnotationWriter;
|
||||
class ValueHandleBase;
|
||||
class LLVMContext;
|
||||
class Twine;
|
||||
class MDNode;
|
||||
class Type;
|
||||
class StringRef;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Value Class
|
||||
@@ -287,6 +290,22 @@ public:
|
||||
return const_cast<Value*>(this)->stripInBoundsConstantOffsets();
|
||||
}
|
||||
|
||||
/// \brief Strips like \c stripInBoundsConstantOffsets but also accumulates
|
||||
/// the constant offset stripped.
|
||||
///
|
||||
/// Stores the resulting constant offset stripped into the APInt provided.
|
||||
/// The provided APInt will be extended or truncated as needed to be the
|
||||
/// correct bitwidth for an offset of this pointer type.
|
||||
///
|
||||
/// If this is called on a non-pointer value, it returns 'this'.
|
||||
Value *stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL,
|
||||
APInt &Offset);
|
||||
const Value *stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL,
|
||||
APInt &Offset) const {
|
||||
return const_cast<Value *>(this)
|
||||
->stripAndAccumulateInBoundsConstantOffsets(DL, Offset);
|
||||
}
|
||||
|
||||
/// \brief Strips off unneeded pointer casts and any in-bounds offsets from
|
||||
/// the specified value, returning the original pointer value.
|
||||
///
|
||||
|
Reference in New Issue
Block a user