• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/Value.h"
18 
19 namespace llvm {
20   class MachineFrameInfo;
21   class raw_ostream;
22 
23   /// PseudoSourceValue - Special value supplied for machine level alias
24   /// analysis. It indicates that a memory access references the functions
25   /// stack frame (e.g., a spill slot), below the stack frame (e.g., argument
26   /// space), or constant pool.
27   class PseudoSourceValue : public Value {
28   private:
29     /// printCustom - Implement printing for PseudoSourceValue. This is called
30     /// from Value::print or Value's operator<<.
31     ///
32     virtual void printCustom(raw_ostream &O) const;
33 
34   public:
35     explicit PseudoSourceValue(enum ValueTy Subclass = PseudoSourceValueVal);
36 
37     /// isConstant - Test whether the memory pointed to by this
38     /// PseudoSourceValue has a constant value.
39     ///
40     virtual bool isConstant(const MachineFrameInfo *) const;
41 
42     /// isAliased - Test whether the memory pointed to by this
43     /// PseudoSourceValue may also be pointed to by an LLVM IR Value.
44     virtual bool isAliased(const MachineFrameInfo *) const;
45 
46     /// mayAlias - Return true if the memory pointed to by this
47     /// PseudoSourceValue can ever alias a LLVM IR Value.
48     virtual bool mayAlias(const MachineFrameInfo *) const;
49 
50     /// classof - Methods for support type inquiry through isa, cast, and
51     /// dyn_cast:
52     ///
classof(const PseudoSourceValue *)53     static inline bool classof(const PseudoSourceValue *) { return true; }
classof(const Value * V)54     static inline bool classof(const Value *V) {
55       return V->getValueID() == PseudoSourceValueVal ||
56              V->getValueID() == FixedStackPseudoSourceValueVal;
57     }
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:
FixedStackPseudoSourceValue(int fi)87     explicit FixedStackPseudoSourceValue(int fi) :
88         PseudoSourceValue(FixedStackPseudoSourceValueVal), FI(fi) {}
89 
90     /// classof - Methods for support type inquiry through isa, cast, and
91     /// dyn_cast:
92     ///
classof(const FixedStackPseudoSourceValue *)93     static inline bool classof(const FixedStackPseudoSourceValue *) {
94       return true;
95     }
classof(const Value * V)96     static inline bool classof(const Value *V) {
97       return V->getValueID() == FixedStackPseudoSourceValueVal;
98     }
99 
100     virtual bool isConstant(const MachineFrameInfo *MFI) const;
101 
102     virtual bool isAliased(const MachineFrameInfo *MFI) const;
103 
104     virtual bool mayAlias(const MachineFrameInfo *) const;
105 
106     virtual void printCustom(raw_ostream &OS) const;
107 
getFrameIndex()108     int getFrameIndex() const { return FI; }
109   };
110 } // End llvm namespace
111 
112 #endif
113