Redirect DataLayout from TargetMachine to Module in MachineFunction
[oota-llvm.git] / include / llvm / CodeGen / PseudoSourceValue.h
1 //===-- llvm/CodeGen/PseudoSourceValue.h ------------------------*- 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 PseudoSourceValue class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
15 #define LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
16
17 #include "llvm/IR/Value.h"
18
19 namespace llvm {
20   class MachineFrameInfo;
21   class MachineMemOperand;
22   class raw_ostream;
23
24   raw_ostream &operator<<(raw_ostream &OS, const MachineMemOperand &MMO);
25
26   /// PseudoSourceValue - Special value supplied for machine level alias
27   /// analysis. It indicates that a memory access references the functions
28   /// stack frame (e.g., a spill slot), below the stack frame (e.g., argument
29   /// space), or constant pool.
30   class PseudoSourceValue {
31   private:
32     friend class MachineMemOperand; // For printCustom().
33
34     /// printCustom - Implement printing for PseudoSourceValue. This is called
35     /// from Value::print or Value's operator<<.
36     ///
37     virtual void printCustom(raw_ostream &O) const;
38
39   public:
40     /// isFixed - Whether this is a FixedStackPseudoSourceValue.
41     bool isFixed;
42
43     explicit PseudoSourceValue(bool isFixed = false);
44
45     virtual ~PseudoSourceValue();
46
47     /// isConstant - Test whether the memory pointed to by this
48     /// PseudoSourceValue has a constant value.
49     ///
50     virtual bool isConstant(const MachineFrameInfo *) const;
51
52     /// isAliased - Test whether the memory pointed to by this
53     /// PseudoSourceValue may also be pointed to by an LLVM IR Value.
54     virtual bool isAliased(const MachineFrameInfo *) const;
55
56     /// mayAlias - Return true if the memory pointed to by this
57     /// PseudoSourceValue can ever alias an LLVM IR Value.
58     virtual bool mayAlias(const MachineFrameInfo *) const;
59
60     /// A pseudo source value referencing a fixed stack frame entry,
61     /// e.g., a spill slot.
62     static const PseudoSourceValue *getFixedStack(int FI);
63
64     /// A pseudo source value referencing the area below the stack frame of
65     /// a function, e.g., the argument space.
66     static const PseudoSourceValue *getStack();
67
68     /// A pseudo source value referencing the global offset table
69     /// (or something the like).
70     static const PseudoSourceValue *getGOT();
71
72     /// A pseudo source value referencing the constant pool. Since constant
73     /// pools are constant, this doesn't need to identify a specific constant
74     /// pool entry.
75     static const PseudoSourceValue *getConstantPool();
76
77     /// A pseudo source value referencing a jump table. Since jump tables are
78     /// constant, this doesn't need to identify a specific jump table.
79     static const PseudoSourceValue *getJumpTable();
80   };
81
82   /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue
83   /// for holding FixedStack values, which must include a frame
84   /// index.
85   class FixedStackPseudoSourceValue : public PseudoSourceValue {
86     const int FI;
87   public:
88     explicit FixedStackPseudoSourceValue(int fi) :
89         PseudoSourceValue(true), FI(fi) {}
90
91     /// classof - Methods for support type inquiry through isa, cast, and
92     /// dyn_cast:
93     ///
94     static inline bool classof(const PseudoSourceValue *V) {
95       return V->isFixed == true;
96     }
97
98     bool isConstant(const MachineFrameInfo *MFI) const override;
99
100     bool isAliased(const MachineFrameInfo *MFI) const override;
101
102     bool mayAlias(const MachineFrameInfo *) const override;
103
104     void printCustom(raw_ostream &OS) const override;
105
106     int getFrameIndex() const { return FI; }
107   };
108 } // End llvm namespace
109
110 #endif