14#ifndef LLVM_LIB_TARGET_SPIRV_SPIRVIRMAPPING_H
15#define LLVM_LIB_TARGET_SPIRV_SPIRVIRMAPPING_H
32 for (
unsigned I =
MI->getNumDefs(); I < MI->getNumOperands(); ++
I) {
44using MIHandle = std::tuple<const MachineInstr *, Register, size_t>;
50using IRHandle = std::tuple<const void *, unsigned, unsigned>;
51using IRHandleMF = std::pair<IRHandle, const MachineFunction *>;
54 return std::make_pair(Handle, MF);
86 unsigned Sampled,
unsigned ImageFormat,
unsigned AQ = 0) {
99 unsigned Depth,
unsigned Arrayed,
unsigned MS,
100 unsigned Sampled,
unsigned ImageFormat,
102 return std::make_tuple(
111 unsigned AC = AccessQualifier::AccessQualifier::None;
114 return std::make_tuple(
144 return std::make_tuple(
Ptr, Arg, STK);
148 StorageClass::StorageClass SC,
150 return std::make_tuple(ElementType, (SC << 1) | IsWriteable,
173 return (isa<StructType>(
T) || isa<ArrayType>(
T));
187 if (
auto DefIt = Defs.
find(
MI); DefIt != Defs.
end()) {
188 auto [ExistHandle, ExistMF] = DefIt->second;
189 if (Handle == ExistHandle &&
MI->getMF() == ExistMF)
192 Vregs.
erase(DefIt->second);
200 Defs.
erase(std::get<0>(It1.first->second));
202 It1.first->second = MIKey;
210 if (
auto It = Defs.
find(
MI); It != Defs.
end()) {
211 Res = Vregs.
erase(It->second);
219 auto It = Vregs.
find(HandleMF);
220 if (It == Vregs.
end())
222 auto [
MI,
Reg, Hash] = It->second;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the DenseMap class.
This file declares the MachineIRBuilder class.
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
bool erase(const KeyT &Val)
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
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.
const MachineInstr * findMI(const Type *PointeeTy, unsigned AddressSpace, const MachineFunction *MF)
const MachineInstr * findMI(const Type *T, bool RequiresExplicitLayout, const MachineFunction *MF)
const MachineInstr * findMI(const MachineInstr *Obj, const MachineFunction *MF)
const MachineInstr * findMI(SPIRV::IRHandle Handle, const MachineFunction *MF)
bool add(const Value *V, const MachineInstr *MI)
Register find(const Value *V, const MachineFunction *MF)
Register find(const Type *T, bool RequiresExplicitLayout, const MachineFunction *MF)
bool add(const Type *PointeeTy, unsigned AddressSpace, const MachineInstr *MI)
bool erase(const MachineInstr *MI)
bool add(SPIRV::IRHandle Handle, const MachineInstr *MI)
const MachineInstr * findMI(const Value *Obj, const MachineFunction *MF)
Register find(SPIRV::IRHandle Handle, const MachineFunction *MF)
Register find(const MachineInstr *MI, const MachineFunction *MF)
Register find(const Type *PointeeTy, unsigned AddressSpace, const MachineFunction *MF)
bool add(const MachineInstr *Obj, const MachineInstr *MI)
bool add(const Type *T, bool RequiresExplicitLayout, const MachineInstr *MI)
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)
bool type_has_layout_decoration(const Type *T)
IRHandle irhandle_sampled_image(const Type *SampledTy, const MachineInstr *ImageTy)
size_t to_hash(const MachineInstr *MI)
std::pair< IRHandle, const MachineFunction * > IRHandleMF
IRHandle irhandle_pointee(const Type *ElementType, unsigned AddressSpace)
std::tuple< const void *, unsigned, unsigned > IRHandle
std::tuple< const MachineInstr *, Register, size_t > MIHandle
IRHandleMF getIRHandleMF(IRHandle Handle, const MachineFunction *MF)
IRHandle irhandle_vkbuffer(const Type *ElementType, StorageClass::StorageClass SC, bool IsWriteable)
IRHandle irhandle_sampler()
IRHandle irhandle_event()
MIHandle getMIKey(const MachineInstr *MI)
IRHandle irhandle_pipe(uint8_t AQ)
IRHandle irhandle_explict_layout_type(const Type *Ty)
IRHandle irhandle_ptr(const void *Ptr, unsigned Arg, enum SpecialTypeKind STK)
IRHandle irhandle_image(const Type *SampledTy, unsigned Dim, unsigned Depth, unsigned Arrayed, unsigned MS, unsigned Sampled, unsigned ImageFormat, unsigned AQ=0)
This is an optimization pass for GlobalISel generic memory operations.
const Type * unifyPtrType(const Type *Ty)
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
struct llvm::SPIRV::ImageAttrs::BitFlags Flags
ImageAttrs(unsigned Dim, unsigned Depth, unsigned Arrayed, unsigned MS, unsigned Sampled, unsigned ImageFormat, unsigned AQ=0)