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