aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/MachineMemOperand.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/CodeGen/MachineMemOperand.h')
-rw-r--r--include/llvm/CodeGen/MachineMemOperand.h136
1 files changed, 69 insertions, 67 deletions
diff --git a/include/llvm/CodeGen/MachineMemOperand.h b/include/llvm/CodeGen/MachineMemOperand.h
index 1ca0d90465a4..5fa7058733b3 100644
--- a/include/llvm/CodeGen/MachineMemOperand.h
+++ b/include/llvm/CodeGen/MachineMemOperand.h
@@ -16,6 +16,7 @@
#ifndef LLVM_CODEGEN_MACHINEMEMOPERAND_H
#define LLVM_CODEGEN_MACHINEMEMOPERAND_H
+#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/CodeGen/PseudoSourceValue.h"
#include "llvm/IR/Metadata.h"
@@ -30,12 +31,11 @@ class raw_ostream;
class MachineFunction;
class ModuleSlotTracker;
-/// MachinePointerInfo - This class contains a discriminated union of
-/// information about pointers in memory operands, relating them back to LLVM IR
-/// or to virtual locations (such as frame indices) that are exposed during
-/// codegen.
+/// This class contains a discriminated union of information about pointers in
+/// memory operands, relating them back to LLVM IR or to virtual locations (such
+/// as frame indices) that are exposed during codegen.
struct MachinePointerInfo {
- /// V - This is the IR pointer value for the access, or it is null if unknown.
+ /// This is the IR pointer value for the access, or it is null if unknown.
/// If this is null, then the access is to a pointer in the default address
/// space.
PointerUnion<const Value *, const PseudoSourceValue *> V;
@@ -57,34 +57,30 @@ struct MachinePointerInfo {
return MachinePointerInfo(V.get<const PseudoSourceValue*>(), Offset+O);
}
- /// getAddrSpace - Return the LLVM IR address space number that this pointer
- /// points into.
+ /// Return the LLVM IR address space number that this pointer points into.
unsigned getAddrSpace() const;
- /// getConstantPool - Return a MachinePointerInfo record that refers to the
- /// constant pool.
+ /// Return a MachinePointerInfo record that refers to the constant pool.
static MachinePointerInfo getConstantPool(MachineFunction &MF);
- /// getFixedStack - Return a MachinePointerInfo record that refers to the
- /// the specified FrameIndex.
+ /// Return a MachinePointerInfo record that refers to the specified
+ /// FrameIndex.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI,
int64_t Offset = 0);
- /// getJumpTable - Return a MachinePointerInfo record that refers to a
- /// jump table entry.
+ /// Return a MachinePointerInfo record that refers to a jump table entry.
static MachinePointerInfo getJumpTable(MachineFunction &MF);
- /// getGOT - Return a MachinePointerInfo record that refers to a
- /// GOT entry.
+ /// Return a MachinePointerInfo record that refers to a GOT entry.
static MachinePointerInfo getGOT(MachineFunction &MF);
- /// getStack - stack pointer relative access.
+ /// Stack pointer relative access.
static MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset);
};
//===----------------------------------------------------------------------===//
-/// MachineMemOperand - A description of a memory reference used in the backend.
+/// A description of a memory reference used in the backend.
/// Instead of holding a StoreInst or LoadInst, this class holds the address
/// Value of the reference along with a byte size and offset. This allows it
/// to describe lowered loads and stores. Also, the special PseudoSourceValue
@@ -92,43 +88,50 @@ struct MachinePointerInfo {
/// that aren't explicit in the regular LLVM IR.
///
class MachineMemOperand {
- MachinePointerInfo PtrInfo;
- uint64_t Size;
- unsigned Flags;
- AAMDNodes AAInfo;
- const MDNode *Ranges;
-
public:
/// Flags values. These may be or'd together.
- enum MemOperandFlags {
+ enum Flags : uint16_t {
+ // No flags set.
+ MONone = 0,
/// The memory access reads data.
- MOLoad = 1,
+ MOLoad = 1u << 0,
/// The memory access writes data.
- MOStore = 2,
+ MOStore = 1u << 1,
/// The memory access is volatile.
- MOVolatile = 4,
+ MOVolatile = 1u << 2,
/// The memory access is non-temporal.
- MONonTemporal = 8,
+ MONonTemporal = 1u << 3,
/// The memory access is invariant.
- MOInvariant = 16,
- // Target hints allow target passes to annotate memory operations.
- MOTargetStartBit = 5,
- MOTargetNumBits = 3,
- // This is the number of bits we need to represent flags.
- MOMaxBits = 8
+ MOInvariant = 1u << 4,
+
+ // Reserved for use by target-specific passes.
+ MOTargetFlag1 = 1u << 5,
+ MOTargetFlag2 = 1u << 6,
+ MOTargetFlag3 = 1u << 7,
+
+ LLVM_MARK_AS_BITMASK_ENUM(/* LargestFlag = */ MOTargetFlag3)
};
- /// MachineMemOperand - Construct an MachineMemOperand object with the
- /// specified PtrInfo, flags, size, and base alignment.
- MachineMemOperand(MachinePointerInfo PtrInfo, unsigned flags, uint64_t s,
+private:
+ MachinePointerInfo PtrInfo;
+ uint64_t Size;
+ Flags FlagVals;
+ uint16_t BaseAlignLog2; // log_2(base_alignment) + 1
+ AAMDNodes AAInfo;
+ const MDNode *Ranges;
+
+public:
+ /// Construct a MachineMemOperand object with the specified PtrInfo, flags,
+ /// size, and base alignment.
+ MachineMemOperand(MachinePointerInfo PtrInfo, Flags flags, uint64_t s,
unsigned base_alignment,
const AAMDNodes &AAInfo = AAMDNodes(),
const MDNode *Ranges = nullptr);
const MachinePointerInfo &getPointerInfo() const { return PtrInfo; }
- /// getValue - Return the base address of the memory access. This may either
- /// be a normal LLVM IR Value, or one of the special values used in CodeGen.
+ /// Return the base address of the memory access. This may either be a normal
+ /// LLVM IR Value, or one of the special values used in CodeGen.
/// Special values are those obtained via
/// PseudoSourceValue::getFixedStack(int), PseudoSourceValue::getStack, and
/// other PseudoSourceValue member functions which return objects which stand
@@ -142,59 +145,58 @@ public:
const void *getOpaqueValue() const { return PtrInfo.V.getOpaqueValue(); }
- /// getFlags - Return the raw flags of the source value, \see MemOperandFlags.
- unsigned int getFlags() const { return Flags & ((1 << MOMaxBits) - 1); }
+ /// Return the raw flags of the source value, \see Flags.
+ Flags getFlags() const { return FlagVals; }
/// Bitwise OR the current flags with the given flags.
- void setFlags(unsigned f) { Flags |= (f & ((1 << MOMaxBits) - 1)); }
+ void setFlags(Flags f) { FlagVals |= f; }
- /// getOffset - For normal values, this is a byte offset added to the base
- /// address. For PseudoSourceValue::FPRel values, this is the FrameIndex
- /// number.
+ /// For normal values, this is a byte offset added to the base address.
+ /// For PseudoSourceValue::FPRel values, this is the FrameIndex number.
int64_t getOffset() const { return PtrInfo.Offset; }
unsigned getAddrSpace() const { return PtrInfo.getAddrSpace(); }
- /// getSize - Return the size in bytes of the memory reference.
+ /// Return the size in bytes of the memory reference.
uint64_t getSize() const { return Size; }
- /// getAlignment - Return the minimum known alignment in bytes of the
- /// actual memory reference.
+ /// Return the minimum known alignment in bytes of the actual memory
+ /// reference.
uint64_t getAlignment() const;
- /// getBaseAlignment - Return the minimum known alignment in bytes of the
- /// base address, without the offset.
- uint64_t getBaseAlignment() const { return (1u << (Flags >> MOMaxBits)) >> 1; }
+ /// Return the minimum known alignment in bytes of the base address, without
+ /// the offset.
+ uint64_t getBaseAlignment() const { return (1u << BaseAlignLog2) >> 1; }
- /// getAAInfo - Return the AA tags for the memory reference.
+ /// Return the AA tags for the memory reference.
AAMDNodes getAAInfo() const { return AAInfo; }
- /// getRanges - Return the range tag for the memory reference.
+ /// Return the range tag for the memory reference.
const MDNode *getRanges() const { return Ranges; }
- bool isLoad() const { return Flags & MOLoad; }
- bool isStore() const { return Flags & MOStore; }
- bool isVolatile() const { return Flags & MOVolatile; }
- bool isNonTemporal() const { return Flags & MONonTemporal; }
- bool isInvariant() const { return Flags & MOInvariant; }
+ bool isLoad() const { return FlagVals & MOLoad; }
+ bool isStore() const { return FlagVals & MOStore; }
+ bool isVolatile() const { return FlagVals & MOVolatile; }
+ bool isNonTemporal() const { return FlagVals & MONonTemporal; }
+ bool isInvariant() const { return FlagVals & MOInvariant; }
- /// isUnordered - Returns true if this memory operation doesn't have any
- /// ordering constraints other than normal aliasing. Volatile and atomic
- /// memory operations can't be reordered.
+ /// Returns true if this memory operation doesn't have any ordering
+ /// constraints other than normal aliasing. Volatile and atomic memory
+ /// operations can't be reordered.
///
/// Currently, we don't model the difference between volatile and atomic
/// operations. They should retain their ordering relative to all memory
/// operations.
bool isUnordered() const { return !isVolatile(); }
- /// refineAlignment - Update this MachineMemOperand to reflect the alignment
- /// of MMO, if it has a greater alignment. This must only be used when the
- /// new alignment applies to all users of this MachineMemOperand.
+ /// Update this MachineMemOperand to reflect the alignment of MMO, if it has a
+ /// greater alignment. This must only be used when the new alignment applies
+ /// to all users of this MachineMemOperand.
void refineAlignment(const MachineMemOperand *MMO);
- /// setValue - Change the SourceValue for this MachineMemOperand. This
- /// should only be used when an object is being relocated and all references
- /// to it are being updated.
+ /// Change the SourceValue for this MachineMemOperand. This should only be
+ /// used when an object is being relocated and all references to it are being
+ /// updated.
void setValue(const Value *NewSV) { PtrInfo.V = NewSV; }
void setValue(const PseudoSourceValue *NewSV) { PtrInfo.V = NewSV; }
void setOffset(int64_t NewOffset) { PtrInfo.Offset = NewOffset; }