1 //===-- llvm/CodeGen/PseudoSourceValue.h ------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the declaration of the PseudoSourceValue class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
15 #define LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
17 #include "llvm/IR/Value.h"
21 class MachineFrameInfo;
22 class MachineMemOperand;
25 raw_ostream &operator<<(raw_ostream &OS, const MachineMemOperand &MMO);
27 /// Special value supplied for machine level alias analysis. It indicates that
28 /// a memory access references the functions stack frame (e.g., a spill slot),
29 /// below the stack frame (e.g., argument space), or constant pool.
30 class PseudoSourceValue {
32 enum PSVKind { Stack, GOT, JumpTable, ConstantPool, FixedStack, MipsPSV };
37 friend class MachineMemOperand; // For printCustom().
39 /// Implement printing for PseudoSourceValue. This is called from
40 /// Value::print or Value's operator<<.
41 virtual void printCustom(raw_ostream &O) const;
44 explicit PseudoSourceValue(PSVKind Kind);
46 virtual ~PseudoSourceValue();
48 PSVKind kind() const { return Kind; }
50 bool isStack() const { return Kind == Stack; }
51 bool isGOT() const { return Kind == GOT; }
52 bool isConstantPool() const { return Kind == ConstantPool; }
53 bool isJumpTable() const { return Kind == JumpTable; }
55 /// Test whether the memory pointed to by this PseudoSourceValue has a
57 virtual bool isConstant(const MachineFrameInfo *) const;
59 /// Test whether the memory pointed to by this PseudoSourceValue may also be
60 /// pointed to by an LLVM IR Value.
61 virtual bool isAliased(const MachineFrameInfo *) const;
63 /// Return true if the memory pointed to by this PseudoSourceValue can ever
64 /// alias an LLVM IR Value.
65 virtual bool mayAlias(const MachineFrameInfo *) const;
67 /// A pseudo source value referencing a fixed stack frame entry,
68 /// e.g., a spill slot.
69 static const PseudoSourceValue *getFixedStack(int FI);
71 /// A pseudo source value referencing the area below the stack frame of
72 /// a function, e.g., the argument space.
73 static const PseudoSourceValue *getStack();
75 /// A pseudo source value referencing the global offset table
76 /// (or something the like).
77 static const PseudoSourceValue *getGOT();
79 /// A pseudo source value referencing the constant pool. Since constant
80 /// pools are constant, this doesn't need to identify a specific constant
82 static const PseudoSourceValue *getConstantPool();
84 /// A pseudo source value referencing a jump table. Since jump tables are
85 /// constant, this doesn't need to identify a specific jump table.
86 static const PseudoSourceValue *getJumpTable();
89 /// A specialized PseudoSourceValue for holding FixedStack values, which must
90 /// include a frame index.
91 class FixedStackPseudoSourceValue : public PseudoSourceValue {
95 explicit FixedStackPseudoSourceValue(int FI)
96 : PseudoSourceValue(FixedStack), FI(FI) {}
98 static inline bool classof(const PseudoSourceValue *V) {
99 return V->kind() == FixedStack;
102 bool isConstant(const MachineFrameInfo *MFI) const override;
104 bool isAliased(const MachineFrameInfo *MFI) const override;
106 bool mayAlias(const MachineFrameInfo *) const override;
108 void printCustom(raw_ostream &OS) const override;
110 int getFrameIndex() const { return FI; }
113 } // end namespace llvm