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
17249423Sdim#include "llvm/IR/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 Value *V) {
54199481Srdivacky      return V->getValueID() == PseudoSourceValueVal ||
55199481Srdivacky             V->getValueID() == FixedStackPseudoSourceValueVal;
56193323Sed    }
57193323Sed
58193323Sed    /// A pseudo source value referencing a fixed stack frame entry,
59193323Sed    /// e.g., a spill slot.
60193323Sed    static const PseudoSourceValue *getFixedStack(int FI);
61193323Sed
62198090Srdivacky    /// A pseudo source value referencing the area below the stack frame of
63198090Srdivacky    /// a function, e.g., the argument space.
64193323Sed    static const PseudoSourceValue *getStack();
65193323Sed
66198090Srdivacky    /// A pseudo source value referencing the global offset table
67198090Srdivacky    /// (or something the like).
68193323Sed    static const PseudoSourceValue *getGOT();
69193323Sed
70198090Srdivacky    /// A pseudo source value referencing the constant pool. Since constant
71198090Srdivacky    /// pools are constant, this doesn't need to identify a specific constant
72198090Srdivacky    /// pool entry.
73193323Sed    static const PseudoSourceValue *getConstantPool();
74193323Sed
75198090Srdivacky    /// A pseudo source value referencing a jump table. Since jump tables are
76198090Srdivacky    /// constant, this doesn't need to identify a specific jump table.
77193323Sed    static const PseudoSourceValue *getJumpTable();
78193323Sed  };
79199481Srdivacky
80199481Srdivacky  /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue
81199481Srdivacky  /// for holding FixedStack values, which must include a frame
82199481Srdivacky  /// index.
83199481Srdivacky  class FixedStackPseudoSourceValue : public PseudoSourceValue {
84199481Srdivacky    const int FI;
85199481Srdivacky  public:
86199481Srdivacky    explicit FixedStackPseudoSourceValue(int fi) :
87199481Srdivacky        PseudoSourceValue(FixedStackPseudoSourceValueVal), FI(fi) {}
88199481Srdivacky
89199481Srdivacky    /// classof - Methods for support type inquiry through isa, cast, and
90199481Srdivacky    /// dyn_cast:
91199481Srdivacky    ///
92199481Srdivacky    static inline bool classof(const Value *V) {
93199481Srdivacky      return V->getValueID() == FixedStackPseudoSourceValueVal;
94199481Srdivacky    }
95199481Srdivacky
96199481Srdivacky    virtual bool isConstant(const MachineFrameInfo *MFI) const;
97199481Srdivacky
98199481Srdivacky    virtual bool isAliased(const MachineFrameInfo *MFI) const;
99199481Srdivacky
100199481Srdivacky    virtual bool mayAlias(const MachineFrameInfo *) const;
101199481Srdivacky
102199481Srdivacky    virtual void printCustom(raw_ostream &OS) const;
103199481Srdivacky
104199481Srdivacky    int getFrameIndex() const { return FI; }
105199481Srdivacky  };
106193323Sed} // End llvm namespace
107193323Sed
108193323Sed#endif
109