PseudoSourceValue.h revision 223017
1193323Sed//===-- llvm/CodeGen/PseudoSourceValue.h ------------------------*- C++ -*-===//
2193323Sed//
3193323Sed//                     The LLVM Compiler Infrastructure
4193323Sed//
5193323Sed// This file is distributed under the University of Illinois Open Source
6193323Sed// License. See LICENSE.TXT for details.
7193323Sed//
8193323Sed//===----------------------------------------------------------------------===//
9193323Sed//
10193323Sed// This file contains the declaration of the PseudoSourceValue class.
11193323Sed//
12193323Sed//===----------------------------------------------------------------------===//
13193323Sed
14193323Sed#ifndef LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
15193323Sed#define LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
16193323Sed
17193323Sed#include "llvm/Value.h"
18193323Sed
19193323Sednamespace llvm {
20193323Sed  class MachineFrameInfo;
21193323Sed  class raw_ostream;
22193323Sed
23193323Sed  /// PseudoSourceValue - Special value supplied for machine level alias
24223017Sdim  /// analysis. It indicates that a memory access references the functions
25193323Sed  /// stack frame (e.g., a spill slot), below the stack frame (e.g., argument
26193323Sed  /// space), or constant pool.
27193323Sed  class PseudoSourceValue : public Value {
28198090Srdivacky  private:
29198090Srdivacky    /// printCustom - Implement printing for PseudoSourceValue. This is called
30198090Srdivacky    /// from Value::print or Value's operator<<.
31198090Srdivacky    ///
32198090Srdivacky    virtual void printCustom(raw_ostream &O) const;
33198090Srdivacky
34193323Sed  public:
35199481Srdivacky    explicit PseudoSourceValue(enum ValueTy Subclass = PseudoSourceValueVal);
36193323Sed
37198090Srdivacky    /// isConstant - Test whether the memory pointed to by this
38198090Srdivacky    /// PseudoSourceValue has a constant value.
39193323Sed    ///
40193323Sed    virtual bool isConstant(const MachineFrameInfo *) const;
41193323Sed
42198396Srdivacky    /// isAliased - Test whether the memory pointed to by this
43198396Srdivacky    /// PseudoSourceValue may also be pointed to by an LLVM IR Value.
44198396Srdivacky    virtual bool isAliased(const MachineFrameInfo *) const;
45198396Srdivacky
46198892Srdivacky    /// mayAlias - Return true if the memory pointed to by this
47198892Srdivacky    /// PseudoSourceValue can ever alias a LLVM IR Value.
48198892Srdivacky    virtual bool mayAlias(const MachineFrameInfo *) const;
49198892Srdivacky
50193323Sed    /// classof - Methods for support type inquiry through isa, cast, and
51193323Sed    /// dyn_cast:
52193323Sed    ///
53193323Sed    static inline bool classof(const PseudoSourceValue *) { return true; }
54193323Sed    static inline bool classof(const Value *V) {
55199481Srdivacky      return V->getValueID() == PseudoSourceValueVal ||
56199481Srdivacky             V->getValueID() == FixedStackPseudoSourceValueVal;
57193323Sed    }
58193323Sed
59193323Sed    /// A pseudo source value referencing a fixed stack frame entry,
60193323Sed    /// e.g., a spill slot.
61193323Sed    static const PseudoSourceValue *getFixedStack(int FI);
62193323Sed
63198090Srdivacky    /// A pseudo source value referencing the area below the stack frame of
64198090Srdivacky    /// a function, e.g., the argument space.
65193323Sed    static const PseudoSourceValue *getStack();
66193323Sed
67198090Srdivacky    /// A pseudo source value referencing the global offset table
68198090Srdivacky    /// (or something the like).
69193323Sed    static const PseudoSourceValue *getGOT();
70193323Sed
71198090Srdivacky    /// A pseudo source value referencing the constant pool. Since constant
72198090Srdivacky    /// pools are constant, this doesn't need to identify a specific constant
73198090Srdivacky    /// pool entry.
74193323Sed    static const PseudoSourceValue *getConstantPool();
75193323Sed
76198090Srdivacky    /// A pseudo source value referencing a jump table. Since jump tables are
77198090Srdivacky    /// constant, this doesn't need to identify a specific jump table.
78193323Sed    static const PseudoSourceValue *getJumpTable();
79193323Sed  };
80199481Srdivacky
81199481Srdivacky  /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue
82199481Srdivacky  /// for holding FixedStack values, which must include a frame
83199481Srdivacky  /// index.
84199481Srdivacky  class FixedStackPseudoSourceValue : public PseudoSourceValue {
85199481Srdivacky    const int FI;
86199481Srdivacky  public:
87199481Srdivacky    explicit FixedStackPseudoSourceValue(int fi) :
88199481Srdivacky        PseudoSourceValue(FixedStackPseudoSourceValueVal), FI(fi) {}
89199481Srdivacky
90199481Srdivacky    /// classof - Methods for support type inquiry through isa, cast, and
91199481Srdivacky    /// dyn_cast:
92199481Srdivacky    ///
93199481Srdivacky    static inline bool classof(const FixedStackPseudoSourceValue *) {
94199481Srdivacky      return true;
95199481Srdivacky    }
96199481Srdivacky    static inline bool classof(const Value *V) {
97199481Srdivacky      return V->getValueID() == FixedStackPseudoSourceValueVal;
98199481Srdivacky    }
99199481Srdivacky
100199481Srdivacky    virtual bool isConstant(const MachineFrameInfo *MFI) const;
101199481Srdivacky
102199481Srdivacky    virtual bool isAliased(const MachineFrameInfo *MFI) const;
103199481Srdivacky
104199481Srdivacky    virtual bool mayAlias(const MachineFrameInfo *) const;
105199481Srdivacky
106199481Srdivacky    virtual void printCustom(raw_ostream &OS) const;
107199481Srdivacky
108199481Srdivacky    int getFrameIndex() const { return FI; }
109199481Srdivacky  };
110193323Sed} // End llvm namespace
111193323Sed
112193323Sed#endif
113