LLVM: lib/Target/SPIRV/SPIRVIRMapping.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_LIB_TARGET_SPIRV_SPIRVIRMAPPING_H
15#define LLVM_LIB_TARGET_SPIRV_SPIRVIRMAPPING_H
16
24
25namespace llvm {
27
30 for (unsigned I = MI->getNumDefs(); I < MI->getNumOperands(); ++I) {
36 else
38 }
39 return H;
40}
41
42using MIHandle = std::tuple<const MachineInstr *, Register, size_t>;
43
47
48using IRHandle = std::tuple<const void *, unsigned, unsigned>;
49using IRHandleMF = std::pair<IRHandle, const MachineFunction *>;
50
52 return std::make_pair(Handle, MF);
53}
54
71
81 } Flags;
83
85 unsigned Sampled, unsigned ImageFormat, unsigned AQ = 0) {
89 Flags.Arrayed = Arrayed;
91 Flags.Sampled = Sampled;
94 }
95};
96
98 unsigned Depth, unsigned Arrayed, unsigned MS,
100 unsigned AQ = 0) {
101 return std::make_tuple(
102 SampledTy,
105}
106
110 unsigned AC = AccessQualifier::AccessQualifier::None;
113 return std::make_tuple(
114 SampledTy,
121}
122
126
130
134
140
143 return std::make_tuple(Ptr, Arg, STK);
144}
145
147 StorageClass::StorageClass SC,
148 bool IsWriteable) {
149 return std::make_tuple(ElementType, (SC << 1) | IsWriteable,
151}
152
156
161
166
170
174
178
179}
180
181
182
183
187
188public:
190 if (auto DefIt = Defs.find(MI); DefIt != Defs.end()) {
191 auto [ExistHandle, ExistMF] = DefIt->second;
192 if (Handle == ExistHandle && MI->getMF() == ExistMF)
193 return false;
194
195 Vregs.erase(DefIt->second);
196 Defs.erase(DefIt);
197 }
200 auto It1 = Vregs.try_emplace(HandleMF, MIKey);
201 if (!It1.second) {
202
203 Defs.erase(std::get<0>(It1.first->second));
204
205 It1.first->second = MIKey;
206 }
207 [[maybe_unused]] auto It2 = Defs.try_emplace(MI, HandleMF);
209 return true;
210 }
212 bool Res = false;
213 if (auto It = Defs.find(MI); It != Defs.end()) {
214 Res = Vregs.erase(It->second);
215 Defs.erase(It);
216 }
217 return Res;
218 }
222 auto It = Vregs.find(HandleMF);
223 if (It == Vregs.end())
224 return nullptr;
225 auto [MI, Reg, Hash] = It->second;
228
230 return nullptr;
231 }
232 assert(Defs.contains(MI) && Defs.find(MI)->second == HandleMF);
233 return MI;
234 }
237 return MI ? MI->getOperand(0).getReg() : Register();
238 }
239
240
253
257
264
268
272
279
283
287
294
299};
300}
301#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the DenseMap class.
This file declares the MachineIRBuilder class.
Promote Memory to Register
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
unsigned getNumOperands() const
Retuns the total number of operands.
const MachineOperand & getOperand(unsigned i) const
MachineOperand class - Representation of each machine instruction operand.
const ConstantInt * getCImm() const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
const ConstantFP * getFPImm() const
@ MO_CImmediate
Immediate >64bit operand.
@ MO_FPImmediate
Floating-point immediate operand.
LLVM_ABI MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
Wrapper class representing virtual and physical registers.
Definition SPIRVIRMapping.h:184
const MachineInstr * findMI(const Type *PointeeTy, unsigned AddressSpace, const MachineFunction *MF)
Definition SPIRVIRMapping.h:249
const MachineInstr * findMI(const Type *T, bool RequiresExplicitLayout, const MachineFunction *MF)
Definition SPIRVIRMapping.h:288
const MachineInstr * findMI(const MachineInstr *Obj, const MachineFunction *MF)
Definition SPIRVIRMapping.h:295
const MachineInstr * findMI(SPIRV::IRHandle Handle, const MachineFunction *MF)
Definition SPIRVIRMapping.h:219
bool add(const Value *V, const MachineInstr *MI)
Definition SPIRVIRMapping.h:254
Register find(const Value *V, const MachineFunction *MF)
Definition SPIRVIRMapping.h:269
Register find(const Type *T, bool RequiresExplicitLayout, const MachineFunction *MF)
Definition SPIRVIRMapping.h:273
bool add(const Type *PointeeTy, unsigned AddressSpace, const MachineInstr *MI)
Definition SPIRVIRMapping.h:241
bool erase(const MachineInstr *MI)
Definition SPIRVIRMapping.h:211
bool add(SPIRV::IRHandle Handle, const MachineInstr *MI)
Definition SPIRVIRMapping.h:189
const MachineInstr * findMI(const Value *Obj, const MachineFunction *MF)
Definition SPIRVIRMapping.h:284
Register find(SPIRV::IRHandle Handle, const MachineFunction *MF)
Definition SPIRVIRMapping.h:235
Register find(const MachineInstr *MI, const MachineFunction *MF)
Definition SPIRVIRMapping.h:280
Register find(const Type *PointeeTy, unsigned AddressSpace, const MachineFunction *MF)
Definition SPIRVIRMapping.h:245
bool add(const MachineInstr *Obj, const MachineInstr *MI)
Definition SPIRVIRMapping.h:265
bool add(const Type *T, bool RequiresExplicitLayout, const MachineInstr *MI)
Definition SPIRVIRMapping.h:258
The instances of the Type class are immutable: once they are created, they are never changed.
TypeID getTypeID() const
Return the type id for the type.
LLVM Value Representation.
An opaque object representing a hash code.
IRHandle handle(const Type *Ty)
Definition SPIRVIRMapping.h:162
bool type_has_layout_decoration(const Type *T)
Definition SPIRVIRMapping.h:175
std::tuple< const MachineInstr *, Register, size_t > MIHandle
Definition SPIRVIRMapping.h:42
IRHandle irhandle_sampled_image(const Type *SampledTy, const MachineInstr *ImageTy)
Definition SPIRVIRMapping.h:107
SpecialTypeKind
Definition SPIRVIRMapping.h:55
@ STK_VkBuffer
Definition SPIRVIRMapping.h:66
@ STK_ElementPointer
Definition SPIRVIRMapping.h:62
@ STK_ExplictLayoutType
Definition SPIRVIRMapping.h:68
@ STK_MachineInstr
Definition SPIRVIRMapping.h:65
@ STK_SampledImage
Definition SPIRVIRMapping.h:58
@ STK_Last
Definition SPIRVIRMapping.h:69
@ STK_Value
Definition SPIRVIRMapping.h:64
@ STK_Sampler
Definition SPIRVIRMapping.h:59
@ STK_Empty
Definition SPIRVIRMapping.h:56
@ STK_Image
Definition SPIRVIRMapping.h:57
@ STK_Padding
Definition SPIRVIRMapping.h:67
@ STK_Type
Definition SPIRVIRMapping.h:63
@ STK_DeviceEvent
Definition SPIRVIRMapping.h:61
@ STK_Pipe
Definition SPIRVIRMapping.h:60
std::tuple< const void *, unsigned, unsigned > IRHandle
Definition SPIRVIRMapping.h:48
size_t to_hash(const MachineInstr *MI)
Definition SPIRVIRMapping.h:28
IRHandle irhandle_pointee(const Type *ElementType, unsigned AddressSpace)
Definition SPIRVIRMapping.h:135
IRHandleMF getIRHandleMF(IRHandle Handle, const MachineFunction *MF)
Definition SPIRVIRMapping.h:51
IRHandle irhandle_padding()
Definition SPIRVIRMapping.h:153
IRHandle irhandle_vkbuffer(const Type *ElementType, StorageClass::StorageClass SC, bool IsWriteable)
Definition SPIRVIRMapping.h:146
IRHandle irhandle_sampler()
Definition SPIRVIRMapping.h:123
std::pair< IRHandle, const MachineFunction * > IRHandleMF
Definition SPIRVIRMapping.h:49
IRHandle irhandle_event()
Definition SPIRVIRMapping.h:131
MIHandle getMIKey(const MachineInstr *MI)
Definition SPIRVIRMapping.h:44
IRHandle irhandle_pipe(uint8_t AQ)
Definition SPIRVIRMapping.h:127
IRHandle irhandle_explict_layout_type(const Type *Ty)
Definition SPIRVIRMapping.h:157
IRHandle irhandle_ptr(const void *Ptr, unsigned Arg, enum SpecialTypeKind STK)
Definition SPIRVIRMapping.h:141
IRHandle irhandle_image(const Type *SampledTy, unsigned Dim, unsigned Depth, unsigned Arrayed, unsigned MS, unsigned Sampled, unsigned ImageFormat, unsigned AQ=0)
Definition SPIRVIRMapping.h:97
This is an optimization pass for GlobalISel generic memory operations.
const Type * unifyPtrType(const Type *Ty)
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition SPIRVIRMapping.h:73
unsigned ImageFormat
Definition SPIRVIRMapping.h:79
unsigned MS
Definition SPIRVIRMapping.h:77
unsigned Dim
Definition SPIRVIRMapping.h:74
unsigned Depth
Definition SPIRVIRMapping.h:75
unsigned Sampled
Definition SPIRVIRMapping.h:78
unsigned AQ
Definition SPIRVIRMapping.h:80
unsigned Arrayed
Definition SPIRVIRMapping.h:76
Definition SPIRVIRMapping.h:72
struct llvm::SPIRV::ImageAttrs::BitFlags Flags
unsigned Val
Definition SPIRVIRMapping.h:82
ImageAttrs(unsigned Dim, unsigned Depth, unsigned Arrayed, unsigned MS, unsigned Sampled, unsigned ImageFormat, unsigned AQ=0)
Definition SPIRVIRMapping.h:84