1 //==- llvm/CodeGen/MachineMemOperand.h - MachineMemOperand class -*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the declaration of the MachineMemOperand class, which is a
11 // description of a memory reference. It is used to help track dependencies
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_CODEGEN_MACHINEMEMOPERAND_H
17 #define LLVM_CODEGEN_MACHINEMEMOPERAND_H
22 class FoldingSetNodeID;
24 //===----------------------------------------------------------------------===//
25 /// MachineMemOperand - A description of a memory reference used in the backend.
26 /// Instead of holding a StoreInst or LoadInst, this class holds the address
27 /// Value of the reference along with a byte size and offset. This allows it
28 /// to describe lowered loads and stores. Also, the special PseudoSourceValue
29 /// objects can be used to represent loads and stores to memory locations
30 /// that aren't explicit in the regular LLVM IR.
32 class MachineMemOperand {
39 /// Flags values. These may be or'd together.
40 enum MemOperandFlags {
41 /// The memory access reads data.
43 /// The memory access writes data.
45 /// The memory access is volatile.
49 /// MachineMemOperand - Construct an MachineMemOperand object with the
50 /// specified address Value, flags, offset, size, and alignment.
51 MachineMemOperand(const Value *v, unsigned int f, int64_t o, uint64_t s,
54 /// getValue - Return the base address of the memory access.
55 /// Special values are PseudoSourceValue::FPRel, PseudoSourceValue::SPRel,
56 /// and the other PseudoSourceValue members which indicate references to
57 /// frame/stack pointer relative references and other special references.
58 const Value *getValue() const { return V; }
60 /// getFlags - Return the raw flags of the source value, \see MemOperandFlags.
61 unsigned int getFlags() const { return Flags & 7; }
63 /// getOffset - For normal values, this is a byte offset added to the base
64 /// address. For PseudoSourceValue::FPRel values, this is the FrameIndex
66 int64_t getOffset() const { return Offset; }
68 /// getSize - Return the size in bytes of the memory reference.
69 uint64_t getSize() const { return Size; }
71 /// getAlignment - Return the minimum known alignment in bytes of the
73 unsigned int getAlignment() const { return (1u << (Flags >> 3)) >> 1; }
75 bool isLoad() const { return Flags & MOLoad; }
76 bool isStore() const { return Flags & MOStore; }
77 bool isVolatile() const { return Flags & MOVolatile; }
79 /// Profile - Gather unique data for the object.
81 void Profile(FoldingSetNodeID &ID) const;
84 } // End llvm namespace