llvm.org GIT mirror llvm / 028255f
Add AddresSpace to PseudoSourceValue. Differential Revision: https://reviews.llvm.org/D35089 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313297 91177308-0d34-0410-b5e6-96231b3b80d8 Jan Sjodin 2 years ago
9 changed file(s) with 86 addition(s) and 29 deletion(s). Raw diff Collapse all Expand all
2424 class MachineFrameInfo;
2525 class MachineMemOperand;
2626 class raw_ostream;
27 class TargetInstrInfo;
2728
2829 raw_ostream &operator<<(raw_ostream &OS, const MachineMemOperand &MMO);
2930 class PseudoSourceValue;
4748
4849 private:
4950 PSVKind Kind;
51 unsigned AddressSpace;
5052 friend raw_ostream &llvm::operator<<(raw_ostream &OS,
5153 const PseudoSourceValue* PSV);
5254
5759 virtual void printCustom(raw_ostream &O) const;
5860
5961 public:
60 explicit PseudoSourceValue(PSVKind Kind);
62 explicit PseudoSourceValue(PSVKind Kind, const TargetInstrInfo &TII);
6163
6264 virtual ~PseudoSourceValue();
6365
6769 bool isGOT() const { return Kind == GOT; }
6870 bool isConstantPool() const { return Kind == ConstantPool; }
6971 bool isJumpTable() const { return Kind == JumpTable; }
72
73 unsigned getAddressSpace() const { return AddressSpace; }
74
7075 unsigned getTargetCustom() const {
7176 return (Kind >= TargetCustom) ? ((Kind+1) - TargetCustom) : 0;
7277 }
9095 const int FI;
9196
9297 public:
93 explicit FixedStackPseudoSourceValue(int FI)
94 : PseudoSourceValue(FixedStack), FI(FI) {}
98 explicit FixedStackPseudoSourceValue(int FI, const TargetInstrInfo &TII)
99 : PseudoSourceValue(FixedStack, TII), FI(FI) {}
95100
96101 static bool classof(const PseudoSourceValue *V) {
97102 return V->kind() == FixedStack;
110115
111116 class CallEntryPseudoSourceValue : public PseudoSourceValue {
112117 protected:
113 CallEntryPseudoSourceValue(PSVKind Kind);
118 CallEntryPseudoSourceValue(PSVKind Kind, const TargetInstrInfo &TII);
114119
115120 public:
116121 bool isConstant(const MachineFrameInfo *) const override;
123128 const GlobalValue *GV;
124129
125130 public:
126 GlobalValuePseudoSourceValue(const GlobalValue *GV);
131 GlobalValuePseudoSourceValue(const GlobalValue *GV,
132 const TargetInstrInfo &TII);
127133
128134 static bool classof(const PseudoSourceValue *V) {
129135 return V->kind() == GlobalValueCallEntry;
137143 const char *ES;
138144
139145 public:
140 ExternalSymbolPseudoSourceValue(const char *ES);
146 ExternalSymbolPseudoSourceValue(const char *ES, const TargetInstrInfo &TII);
141147
142148 static bool classof(const PseudoSourceValue *V) {
143149 return V->kind() == ExternalSymbolCallEntry;
148154
149155 /// Manages creation of pseudo source values.
150156 class PseudoSourceValueManager {
157 const TargetInstrInfo &TII;
151158 const PseudoSourceValue StackPSV, GOTPSV, JumpTablePSV, ConstantPoolPSV;
152159 std::map> FSValues;
153160 StringMap>
157164 GlobalCallEntries;
158165
159166 public:
160 PseudoSourceValueManager();
167 PseudoSourceValueManager(const TargetInstrInfo &TII);
161168
162169 /// Return a pseudo source value referencing the area below the stack frame of
163170 /// a function, e.g., the argument space.
2424 #include "llvm/CodeGen/MachineInstr.h"
2525 #include "llvm/CodeGen/MachineLoopInfo.h"
2626 #include "llvm/CodeGen/MachineOperand.h"
27 #include "llvm/CodeGen/PseudoSourceValue.h"
2728 #include "llvm/MC/MCInstrInfo.h"
2829 #include "llvm/Support/BranchProbability.h"
2930 #include "llvm/Support/ErrorHandling.h"
10171018 }
10181019
10191020 public:
1021 /// getAddressSpaceForPseudoSourceKind - Given the kind of memory
1022 /// (e.g. stack) the target returns the corresponding address space.
1023 virtual unsigned
1024 getAddressSpaceForPseudoSourceKind(PseudoSourceValue::PSVKind Kind) const {
1025 return 0;
1026 }
1027
10201028 /// unfoldMemoryOperand - Separate a single instruction which folded a load or
10211029 /// a store or a load and a store into two or more instruction. If this is
10221030 /// possible, returns true as well as the new instructions by reference.
146146 "Can't create a MachineFunction using a Module with a "
147147 "Target-incompatible DataLayout attached\n");
148148
149 PSVManager = llvm::make_unique();
149 PSVManager =
150 llvm::make_unique(*(getSubtarget().
151 getInstrInfo()));
150152 }
151153
152154 MachineFunction::~MachineFunction() {
578578 /// getAddrSpace - Return the LLVM IR address space number that this pointer
579579 /// points into.
580580 unsigned MachinePointerInfo::getAddrSpace() const {
581 if (V.isNull() || V.is()) return 0;
581 if (V.isNull()) return 0;
582
583 if (V.is())
584 return V.get()->getAddressSpace();
585
582586 return cast(V.get()->getType())->getAddressSpace();
583587 }
584588
1313 #include "llvm/CodeGen/PseudoSourceValue.h"
1414 #include "llvm/ADT/STLExtras.h"
1515 #include "llvm/CodeGen/MachineFrameInfo.h"
16 #include "llvm/Target/TargetInstrInfo.h"
1617 #include "llvm/IR/DerivedTypes.h"
1718 #include "llvm/IR/LLVMContext.h"
1819 #include "llvm/Support/ErrorHandling.h"
2324 "Stack", "GOT", "JumpTable", "ConstantPool", "FixedStack",
2425 "GlobalValueCallEntry", "ExternalSymbolCallEntry"};
2526
26 PseudoSourceValue::PseudoSourceValue(PSVKind Kind) : Kind(Kind) {}
27 PseudoSourceValue::PseudoSourceValue(PSVKind Kind, const TargetInstrInfo &TII)
28 : Kind(Kind) {
29 AddressSpace = TII.getAddressSpaceForPseudoSourceKind(Kind);
30 }
31
2732
2833 PseudoSourceValue::~PseudoSourceValue() {}
2934
7479 OS << "FixedStack" << FI;
7580 }
7681
77 CallEntryPseudoSourceValue::CallEntryPseudoSourceValue(PSVKind Kind)
78 : PseudoSourceValue(Kind) {}
82 CallEntryPseudoSourceValue::CallEntryPseudoSourceValue(
83 PSVKind Kind, const TargetInstrInfo &TII)
84 : PseudoSourceValue(Kind, TII) {}
7985
8086 bool CallEntryPseudoSourceValue::isConstant(const MachineFrameInfo *) const {
8187 return false;
9096 }
9197
9298 GlobalValuePseudoSourceValue::GlobalValuePseudoSourceValue(
93 const GlobalValue *GV)
94 : CallEntryPseudoSourceValue(GlobalValueCallEntry), GV(GV) {}
99 const GlobalValue *GV,
100 const TargetInstrInfo &TII)
101 : CallEntryPseudoSourceValue(GlobalValueCallEntry, TII), GV(GV) {}
102 ExternalSymbolPseudoSourceValue::ExternalSymbolPseudoSourceValue(
103 const char *ES, const TargetInstrInfo &TII)
104 : CallEntryPseudoSourceValue(ExternalSymbolCallEntry, TII), ES(ES) {}
95105
96 ExternalSymbolPseudoSourceValue::ExternalSymbolPseudoSourceValue(const char *ES)
97 : CallEntryPseudoSourceValue(ExternalSymbolCallEntry), ES(ES) {}
98
99 PseudoSourceValueManager::PseudoSourceValueManager()
100 : StackPSV(PseudoSourceValue::Stack), GOTPSV(PseudoSourceValue::GOT),
101 JumpTablePSV(PseudoSourceValue::JumpTable),
102 ConstantPoolPSV(PseudoSourceValue::ConstantPool) {}
106 PseudoSourceValueManager::PseudoSourceValueManager(
107 const TargetInstrInfo &TIInfo)
108 : TII(TIInfo),
109 StackPSV(PseudoSourceValue::Stack, TII),
110 GOTPSV(PseudoSourceValue::GOT, TII),
111 JumpTablePSV(PseudoSourceValue::JumpTable, TII),
112 ConstantPoolPSV(PseudoSourceValue::ConstantPool, TII) {}
103113
104114 const PseudoSourceValue *PseudoSourceValueManager::getStack() {
105115 return &StackPSV;
115125 return &JumpTablePSV;
116126 }
117127
118 const PseudoSourceValue *PseudoSourceValueManager::getFixedStack(int FI) {
128 const PseudoSourceValue *
129 PseudoSourceValueManager::getFixedStack(int FI) {
119130 std::unique_ptr &V = FSValues[FI];
120131 if (!V)
121 V = llvm::make_unique(FI);
132 V = llvm::make_unique(FI, TII);
122133 return V.get();
123134 }
124135
127138 std::unique_ptr &E =
128139 GlobalCallEntries[GV];
129140 if (!E)
130 E = llvm::make_unique(GV);
141 E = llvm::make_unique(GV, TII);
131142 return E.get();
132143 }
133144
136147 std::unique_ptr &E =
137148 ExternalCallEntries[ES];
138149 if (!E)
139 E = llvm::make_unique(ES);
150 E = llvm::make_unique(ES, TII);
140151 return E.get();
141152 }
18711871 return false;
18721872 }
18731873 }
1874
1875 unsigned SIInstrInfo::getAddressSpaceForPseudoSourceKind(
1876 PseudoSourceValue::PSVKind Kind) const {
1877 switch(Kind) {
1878 case PseudoSourceValue::Stack:
1879 case PseudoSourceValue::FixedStack:
1880 return AMDGPUASI.PRIVATE_ADDRESS;
1881 case PseudoSourceValue::ConstantPool:
1882 case PseudoSourceValue::GOT:
1883 case PseudoSourceValue::JumpTable:
1884 case PseudoSourceValue::GlobalValueCallEntry:
1885 case PseudoSourceValue::ExternalSymbolCallEntry:
1886 case PseudoSourceValue::TargetCustom:
1887 return AMDGPUASI.CONSTANT_ADDRESS;
1888 default:
1889 return AMDGPUASI.FLAT_ADDRESS;
1890 }
1891 }
1892
18741893
18751894 static void removeModOperands(MachineInstr &MI) {
18761895 unsigned Opc = MI.getOpcode();
258258 unsigned DstReg, ArrayRef Cond,
259259 unsigned TrueReg, unsigned FalseReg) const;
260260
261 unsigned
262 getAddressSpaceForPseudoSourceKind(PseudoSourceValue::PSVKind Kind) const;
263
261264 bool
262265 areMemAccessesTriviallyDisjoint(MachineInstr &MIa, MachineInstr &MIb,
263266 AliasAnalysis *AA = nullptr) const override;
2727
2828 SIMachineFunctionInfo::SIMachineFunctionInfo(const MachineFunction &MF)
2929 : AMDGPUMachineFunction(MF),
30 BufferPSV(*(MF.getSubtarget().getInstrInfo())),
31 ImagePSV(*(MF.getSubtarget().getInstrInfo())),
3032 PrivateSegmentBuffer(false),
3133 DispatchPtr(false),
3234 QueuePtr(false),
2121 #include "llvm/ADT/Optional.h"
2222 #include "llvm/ADT/SmallVector.h"
2323 #include "llvm/CodeGen/PseudoSourceValue.h"
24 #include "llvm/Target/TargetInstrInfo.h"
2425 #include "llvm/MC/MCRegisterInfo.h"
2526 #include "llvm/Support/ErrorHandling.h"
2627 #include
3637
3738 class AMDGPUImagePseudoSourceValue : public PseudoSourceValue {
3839 public:
39 explicit AMDGPUImagePseudoSourceValue() :
40 PseudoSourceValue(PseudoSourceValue::TargetCustom) {}
40 explicit AMDGPUImagePseudoSourceValue(const TargetInstrInfo &TII) :
41 PseudoSourceValue(PseudoSourceValue::TargetCustom, TII) { }
4142
4243 bool isConstant(const MachineFrameInfo *) const override {
4344 // This should probably be true for most images, but we will start by being
6061
6162 class AMDGPUBufferPseudoSourceValue : public PseudoSourceValue {
6263 public:
63 explicit AMDGPUBufferPseudoSourceValue() :
64 PseudoSourceValue(PseudoSourceValue::TargetCustom) {}
64 explicit AMDGPUBufferPseudoSourceValue(const TargetInstrInfo &TII) :
65 PseudoSourceValue(PseudoSourceValue::TargetCustom, TII) { }
6566
6667 bool isConstant(const MachineFrameInfo *) const override {
6768 // This should probably be true for most images, but we will start by being