LLVM API Documentation
00001 //==- llvm/CodeGen/MachineMemOperand.h - MachineMemOperand class -*- C++ -*-==// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains the declaration of the MachineMemOperand class, which is a 00011 // description of a memory reference. It is used to help track dependencies 00012 // in the backend. 00013 // 00014 //===----------------------------------------------------------------------===// 00015 00016 #ifndef LLVM_CODEGEN_MACHINEMEMOPERAND_H 00017 #define LLVM_CODEGEN_MACHINEMEMOPERAND_H 00018 00019 namespace llvm { 00020 00021 class Value; 00022 class FoldingSetNodeID; 00023 00024 //===----------------------------------------------------------------------===// 00025 /// MachineMemOperand - A description of a memory reference used in the backend. 00026 /// Instead of holding a StoreInst or LoadInst, this class holds the address 00027 /// Value of the reference along with a byte size and offset. This allows it 00028 /// to describe lowered loads and stores. Also, the special PseudoSourceValue 00029 /// objects can be used to represent loads and stores to memory locations 00030 /// that aren't explicit in the regular LLVM IR. 00031 /// 00032 class MachineMemOperand { 00033 int64_t Offset; 00034 uint64_t Size; 00035 const Value *V; 00036 unsigned int Flags; 00037 00038 public: 00039 /// Flags values. These may be or'd together. 00040 enum MemOperandFlags { 00041 /// The memory access reads data. 00042 MOLoad = 1, 00043 /// The memory access writes data. 00044 MOStore = 2, 00045 /// The memory access is volatile. 00046 MOVolatile = 4 00047 }; 00048 00049 /// MachineMemOperand - Construct an MachineMemOperand object with the 00050 /// specified address Value, flags, offset, size, and alignment. 00051 MachineMemOperand(const Value *v, unsigned int f, int64_t o, uint64_t s, 00052 unsigned int a); 00053 00054 /// getValue - Return the base address of the memory access. 00055 /// Special values are PseudoSourceValue::FPRel, PseudoSourceValue::SPRel, 00056 /// and the other PseudoSourceValue members which indicate references to 00057 /// frame/stack pointer relative references and other special references. 00058 const Value *getValue() const { return V; } 00059 00060 /// getFlags - Return the raw flags of the source value, \see MemOperandFlags. 00061 unsigned int getFlags() const { return Flags & 7; } 00062 00063 /// getOffset - For normal values, this is a byte offset added to the base 00064 /// address. For PseudoSourceValue::FPRel values, this is the FrameIndex 00065 /// number. 00066 int64_t getOffset() const { return Offset; } 00067 00068 /// getSize - Return the size in bytes of the memory reference. 00069 uint64_t getSize() const { return Size; } 00070 00071 /// getAlignment - Return the minimum known alignment in bytes of the 00072 /// memory reference. 00073 unsigned int getAlignment() const { return (1u << (Flags >> 3)) >> 1; } 00074 00075 bool isLoad() const { return Flags & MOLoad; } 00076 bool isStore() const { return Flags & MOStore; } 00077 bool isVolatile() const { return Flags & MOVolatile; } 00078 00079 /// Profile - Gather unique data for the object. 00080 /// 00081 void Profile(FoldingSetNodeID &ID) const; 00082 }; 00083 00084 } // End llvm namespace 00085 00086 #endif