LLVM 22.0.0git
PseudoSourceValue.h
Go to the documentation of this file.
1//===-- llvm/CodeGen/PseudoSourceValue.h ------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the declaration of the PseudoSourceValue class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
14#define LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
15
17
18namespace llvm {
19
20class GlobalValue;
21class MachineFrameInfo;
22class MachineMemOperand;
23class MIRFormatter;
24class PseudoSourceValue;
25class raw_ostream;
26class TargetMachine;
27
28LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const PseudoSourceValue *PSV);
29
30/// Special value supplied for machine level alias analysis. It indicates that
31/// a memory access references the functions stack frame (e.g., a spill slot),
32/// below the stack frame (e.g., argument space), or constant pool.
34public:
35 enum PSVKind : unsigned {
43 TargetCustom
44 };
45
46private:
47 unsigned Kind;
48 unsigned AddressSpace;
50 const PseudoSourceValue *PSV);
51
52 friend class MachineMemOperand; // For printCustom().
53 friend class MIRFormatter; // For printCustom().
54
55 /// Implement printing for PseudoSourceValue. This is called from
56 /// Value::print or Value's operator<<.
57 virtual void printCustom(raw_ostream &O) const;
58
59public:
60 explicit PseudoSourceValue(unsigned Kind, const TargetMachine &TM);
61
63
64 unsigned kind() const { return Kind; }
65
66 bool isStack() const { return Kind == Stack; }
67 bool isGOT() const { return Kind == GOT; }
68 bool isConstantPool() const { return Kind == ConstantPool; }
69 bool isJumpTable() const { return Kind == JumpTable; }
70
71 unsigned getAddressSpace() const { return AddressSpace; }
72
73 unsigned getTargetCustom() const {
74 return (Kind >= TargetCustom) ? ((Kind+1) - TargetCustom) : 0;
75 }
76
77 /// Test whether the memory pointed to by this PseudoSourceValue has a
78 /// constant value.
79 virtual bool isConstant(const MachineFrameInfo *) const;
80
81 /// Test whether the memory pointed to by this PseudoSourceValue may also be
82 /// pointed to by an LLVM IR Value.
83 virtual bool isAliased(const MachineFrameInfo *) const;
84
85 /// Return true if the memory pointed to by this PseudoSourceValue can ever
86 /// alias an LLVM IR Value.
87 virtual bool mayAlias(const MachineFrameInfo *) const;
88};
89
90/// A specialized PseudoSourceValue for holding FixedStack values, which must
91/// include a frame index.
93 const int FI;
94
95public:
96 explicit FixedStackPseudoSourceValue(int FI, const TargetMachine &TM)
97 : PseudoSourceValue(FixedStack, TM), FI(FI) {}
98
99 static bool classof(const PseudoSourceValue *V) {
100 return V->kind() == FixedStack;
101 }
102
103 bool isConstant(const MachineFrameInfo *MFI) const override;
104
105 bool isAliased(const MachineFrameInfo *MFI) const override;
106
107 bool mayAlias(const MachineFrameInfo *) const override;
108
109 void printCustom(raw_ostream &OS) const override;
110
111 int getFrameIndex() const { return FI; }
112};
113
115protected:
116 CallEntryPseudoSourceValue(unsigned Kind, const TargetMachine &TM);
117
118public:
119 bool isConstant(const MachineFrameInfo *) const override;
120 bool isAliased(const MachineFrameInfo *) const override;
121 bool mayAlias(const MachineFrameInfo *) const override;
122};
123
124/// A specialized pseudo source value for holding GlobalValue values.
126 const GlobalValue *GV;
127
128public:
130 const TargetMachine &TM);
131
132 static bool classof(const PseudoSourceValue *V) {
133 return V->kind() == GlobalValueCallEntry;
134 }
135
136 const GlobalValue *getValue() const { return GV; }
137};
138
139/// A specialized pseudo source value for holding external symbol values.
141 const char *ES;
142
143public:
145 const TargetMachine &TM);
146
147 static bool classof(const PseudoSourceValue *V) {
148 return V->kind() == ExternalSymbolCallEntry;
149 }
150
151 const char *getSymbol() const { return ES; }
152};
153
154} // end namespace llvm
155
156#endif
static bool mayAlias(MachineInstr &MIa, SmallVectorImpl< MachineInstr * > &MemInsns, AliasAnalysis *AA)
static bool isConstant(const MachineInstr &MI)
#define LLVM_ABI
Definition: Compiler.h:213
raw_pwrite_stream & OS
A specialized pseudo source value for holding external symbol values.
static bool classof(const PseudoSourceValue *V)
A specialized PseudoSourceValue for holding FixedStack values, which must include a frame index.
FixedStackPseudoSourceValue(int FI, const TargetMachine &TM)
static bool classof(const PseudoSourceValue *V)
A specialized pseudo source value for holding GlobalValue values.
const GlobalValue * getValue() const
static bool classof(const PseudoSourceValue *V)
MIRFormater - Interface to format MIR operand based on target.
Definition: MIRFormatter.h:33
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
A description of a memory reference used in the backend.
Special value supplied for machine level alias analysis.
unsigned getAddressSpace() const
unsigned getTargetCustom() const
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:83
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:312