Move MachineMemOperand's constructor out of line, to avoid a
[oota-llvm.git] / include / llvm / CodeGen / MachineMemOperand.h
1 //==- llvm/CodeGen/MachineMemOperand.h - MachineMemOperand class -*- C++ -*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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
12 // in the backend.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_CODEGEN_MEMOPERAND_H
17 #define LLVM_CODEGEN_MEMOPERAND_H
18
19 namespace llvm {
20
21 class Value;
22
23 //===----------------------------------------------------------------------===//
24 /// MachineMemOperand - A description of a memory reference used in the backend.
25 /// Instead of holding a StoreInst or LoadInst, this class holds the address
26 /// Value of the reference along with a byte size and offset. This allows it
27 /// to describe lowered loads and stores. Also, the special PseudoSourceValue
28 /// objects can be used to represent loads and stores to memory locations
29 /// that aren't explicit in the regular LLVM IR.
30 ///
31 class MachineMemOperand {
32   int64_t Offset;
33   uint64_t Size;
34   const Value *V;
35   unsigned int Flags;
36
37 public:
38   /// Flags values. These may be or'd together.
39   enum MemOperandFlags {
40     /// The memory access reads data.
41     MOLoad = 1,
42     /// The memory access writes data.
43     MOStore = 2,
44     /// The memory access is volatile.
45     MOVolatile = 4
46   };
47
48   /// MachineMemOperand - Construct an MachineMemOperand object with the
49   /// specified address Value, flags, offset, size, and alignment.
50   MachineMemOperand(const Value *v, unsigned int f, int64_t o, uint64_t s,
51                     unsigned int a);
52
53   /// getValue - Return the base address of the memory access.
54   /// Special values are PseudoSourceValue::FPRel, PseudoSourceValue::SPRel,
55   /// and the other PseudoSourceValue members which indicate references to
56   /// frame/stack pointer relative references and other special references.
57   const Value *getValue() const { return V; }
58
59   /// getFlags - Return the raw flags of the source value, \see MemOperandFlags.
60   unsigned int getFlags() const { return Flags & 7; }
61
62   /// getOffset - For normal values, this is a byte offset added to the base
63   /// address. For PseudoSourceValue::FPRel values, this is the FrameIndex
64   /// number.
65   int64_t getOffset() const { return Offset; }
66
67   /// getSize - Return the size in bytes of the memory reference.
68   uint64_t getSize() const { return Size; }
69
70   /// getAlignment - Return the minimum known alignment in bytes of the
71   /// memory reference.
72   unsigned int getAlignment() const { return (1u << (Flags >> 3)) >> 1; }
73
74   bool isLoad() const { return Flags & MOLoad; }
75   bool isStore() const { return Flags & MOStore; }
76   bool isVolatile() const { return Flags & MOVolatile; }
77 };
78
79 } // End llvm namespace
80
81 #endif