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