LLVM 20.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
16namespace llvm {
17
18class GlobalValue;
19class MachineFrameInfo;
20class MachineMemOperand;
21class MIRFormatter;
22class PseudoSourceValue;
23class raw_ostream;
24class TargetMachine;
25
26raw_ostream &operator<<(raw_ostream &OS, const PseudoSourceValue* PSV);
27
28/// Special value supplied for machine level alias analysis. It indicates that
29/// a memory access references the functions stack frame (e.g., a spill slot),
30/// below the stack frame (e.g., argument space), or constant pool.
32public:
33 enum PSVKind : unsigned {
42 };
43
44private:
45 unsigned Kind;
46 unsigned AddressSpace;
48 const PseudoSourceValue* PSV);
49
50 friend class MachineMemOperand; // For printCustom().
51 friend class MIRFormatter; // For printCustom().
52
53 /// Implement printing for PseudoSourceValue. This is called from
54 /// Value::print or Value's operator<<.
55 virtual void printCustom(raw_ostream &O) const;
56
57public:
58 explicit PseudoSourceValue(unsigned Kind, const TargetMachine &TM);
59
61
62 unsigned kind() const { return Kind; }
63
64 bool isStack() const { return Kind == Stack; }
65 bool isGOT() const { return Kind == GOT; }
66 bool isConstantPool() const { return Kind == ConstantPool; }
67 bool isJumpTable() const { return Kind == JumpTable; }
68
69 unsigned getAddressSpace() const { return AddressSpace; }
70
71 unsigned getTargetCustom() const {
72 return (Kind >= TargetCustom) ? ((Kind+1) - TargetCustom) : 0;
73 }
74
75 /// Test whether the memory pointed to by this PseudoSourceValue has a
76 /// constant value.
77 virtual bool isConstant(const MachineFrameInfo *) const;
78
79 /// Test whether the memory pointed to by this PseudoSourceValue may also be
80 /// pointed to by an LLVM IR Value.
81 virtual bool isAliased(const MachineFrameInfo *) const;
82
83 /// Return true if the memory pointed to by this PseudoSourceValue can ever
84 /// alias an LLVM IR Value.
85 virtual bool mayAlias(const MachineFrameInfo *) const;
86};
87
88/// A specialized PseudoSourceValue for holding FixedStack values, which must
89/// include a frame index.
91 const int FI;
92
93public:
94 explicit FixedStackPseudoSourceValue(int FI, const TargetMachine &TM)
95 : PseudoSourceValue(FixedStack, TM), FI(FI) {}
96
97 static bool classof(const PseudoSourceValue *V) {
98 return V->kind() == FixedStack;
99 }
100
101 bool isConstant(const MachineFrameInfo *MFI) const override;
102
103 bool isAliased(const MachineFrameInfo *MFI) const override;
104
105 bool mayAlias(const MachineFrameInfo *) const override;
106
107 void printCustom(raw_ostream &OS) const override;
108
109 int getFrameIndex() const { return FI; }
110};
111
113protected:
114 CallEntryPseudoSourceValue(unsigned Kind, const TargetMachine &TM);
115
116public:
117 bool isConstant(const MachineFrameInfo *) const override;
118 bool isAliased(const MachineFrameInfo *) const override;
119 bool mayAlias(const MachineFrameInfo *) const override;
120};
121
122/// A specialized pseudo source value for holding GlobalValue values.
124 const GlobalValue *GV;
125
126public:
128
129 static bool classof(const PseudoSourceValue *V) {
130 return V->kind() == GlobalValueCallEntry;
131 }
132
133 const GlobalValue *getValue() const { return GV; }
134};
135
136/// A specialized pseudo source value for holding external symbol values.
138 const char *ES;
139
140public:
141 ExternalSymbolPseudoSourceValue(const char *ES, const TargetMachine &TM);
142
143 static bool classof(const PseudoSourceValue *V) {
144 return V->kind() == ExternalSymbolCallEntry;
145 }
146
147 const char *getSymbol() const { return ES; }
148};
149
150} // end namespace llvm
151
152#endif
raw_pwrite_stream & OS
bool isAliased(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue may also be pointed to by an LLVM IR Val...
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
bool isConstant(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
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.
void printCustom(raw_ostream &OS) const override
Implement printing for PseudoSourceValue.
bool isAliased(const MachineFrameInfo *MFI) const override
Test whether the memory pointed to by this PseudoSourceValue may also be pointed to by an LLVM IR Val...
FixedStackPseudoSourceValue(int FI, const TargetMachine &TM)
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
static bool classof(const PseudoSourceValue *V)
bool isConstant(const MachineFrameInfo *MFI) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
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:32
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.
virtual bool mayAlias(const MachineFrameInfo *) const
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
virtual bool isAliased(const MachineFrameInfo *) const
Test whether the memory pointed to by this PseudoSourceValue may also be pointed to by an LLVM IR Val...
unsigned getAddressSpace() const
unsigned getTargetCustom() const
virtual bool isConstant(const MachineFrameInfo *) const
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
AddressSpace
Definition: NVPTXBaseInfo.h:21
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:292