13#ifndef LLVM_LIB_TARGET_SPIRV_SPIRVUTILS_H
14#define LLVM_LIB_TARGET_SPIRV_SPIRVUTILS_H
25class MachineInstrBuilder;
26class MachineIRBuilder;
27class MachineRegisterInfo;
37void addStringImm(
const StringRef &Str, MachineInstrBuilder &MIB);
39 std::vector<Value *> &Args);
43std::string
getStringImm(
const MachineInstr &
MI,
unsigned StartIndex);
46void addNumImm(
const APInt &Imm, MachineInstrBuilder &MIB);
50 MachineIRBuilder &MIRBuilder);
54 SPIRV::Decoration::Decoration Dec,
55 const std::vector<uint32_t> &DecArgs,
56 StringRef StrImm =
"");
58 SPIRV::Decoration::Decoration Dec,
59 const std::vector<uint32_t> &DecArgs,
60 StringRef StrImm =
"");
64 const MDNode *GVarMD);
70SPIRV::StorageClass::StorageClass
73SPIRV::MemorySemantics::MemorySemantics
82 const MachineRegisterInfo *
MRI);
127 Type *SubT =
T->getScalarType();
129 ? cast<PointerType>(SubT)->getAddressSpace()
130 : cast<TypedPointerType>(SubT)->getAddressSpace();
151 for (
unsigned i = 0; i <
F->arg_size(); ++i)
156#define TYPED_PTR_TARGET_EXT_NAME "spirv.$TypedPointerType"
169 if (
auto *ExtTy = dyn_cast<TargetExtType>(Ty)) {
172 ExtTy->getIntParameter(0));
173 }
else if (
auto *VecTy = dyn_cast<VectorType>(Ty)) {
174 Type *ElemTy = VecTy->getElementType();
176 if (NewElemTy != ElemTy)
183 if (
auto PType = dyn_cast<TypedPointerType>(Ty))
184 return PType->getElementType();
185 else if (
auto *ExtTy = dyn_cast<TargetExtType>(Ty))
194 if (
auto *ExtTy = dyn_cast<TargetExtType>(Ty2))
196 ExtTy->getTypeParameter(0) ==
198 ExtTy->getIntParameter(0) == cast<PointerType>(Ty1)->getAddressSpace())
220 bool IsUntypedPtr =
false;
227 if (!IsUntypedPtr &&
RetTy == OrigRetTy)
236 if (
auto FTy = dyn_cast<FunctionType>(Ty))
unsigned const MachineRegisterInfo * MRI
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
const HexagonInstrInfo * TII
Promote Memory to Register
#define TYPED_PTR_TARGET_EXT_NAME
This class represents an incoming formal argument to a Function.
Type * getParamByRefType() const
If this is a byref argument, return its type.
bool hasByRefAttr() const
Return true if this argument has the byref attribute.
Type * getParamStructRetType() const
If this is an sret argument, return its type.
bool hasByValAttr() const
Return true if this argument has the byval attribute.
Type * getParamByValType() const
If this is a byval argument, return its type.
bool hasStructRetAttr() const
Return true if this argument has the sret attribute.
Class to represent function types.
ArrayRef< Type * > params() const
Type * getReturnType() const
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Class to represent target extensions types, which are generally unintrospectable from target-independ...
unsigned getNumIntParameters() const
static TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types=std::nullopt, ArrayRef< unsigned > Ints=std::nullopt)
Return a target extension type having the specified name and optional type and integer parameters.
unsigned getNumTypeParameters() const
StringRef getName() const
Return the name for this target extension type.
The instances of the Type class are immutable: once they are created, they are never changed.
@ TypedPointerTyID
Typed pointer used by some GPU targets.
bool isTargetExtTy() const
Return true if this is a target extension type.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static IntegerType * getInt8Ty(LLVMContext &C)
TypeID getTypeID() const
Return the type id for the type.
static TypedPointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
This is an optimization pass for GlobalISel generic memory operations.
void buildOpName(Register Target, const StringRef &Name, MachineIRBuilder &MIRBuilder)
unsigned storageClassToAddressSpace(SPIRV::StorageClass::StorageClass SC)
std::string getStringImm(const MachineInstr &MI, unsigned StartIndex)
unsigned getPointerAddressSpace(const Type *T)
void addNumImm(const APInt &Imm, MachineInstrBuilder &MIB)
Type * toTypedFunPointer(FunctionType *FTy)
uint64_t getIConstVal(Register ConstReg, const MachineRegisterInfo *MRI)
SPIRV::MemorySemantics::MemorySemantics getMemSemanticsForStorageClass(SPIRV::StorageClass::StorageClass SC)
std::string getOclOrSpirvBuiltinDemangledName(StringRef Name)
bool isTypedPointerTy(const Type *T)
bool isUntypedEquivalentToTyExt(Type *Ty1, Type *Ty2)
void buildOpDecorate(Register Reg, MachineIRBuilder &MIRBuilder, SPIRV::Decoration::Decoration Dec, const std::vector< uint32_t > &DecArgs, StringRef StrImm)
Type * getTypedPointerWrapper(Type *ElemTy, unsigned AS)
Type * reconstructFunctionType(Function *F)
Type * toTypedPointer(Type *Ty)
bool isSpecialOpaqueType(const Type *Ty)
bool isPointerTy(const Type *T)
const Type * unifyPtrType(const Type *Ty)
bool isTypedPointerWrapper(TargetExtType *ExtTy)
bool isEntryPoint(const Function &F)
SPIRV::StorageClass::StorageClass addressSpaceToStorageClass(unsigned AddrSpace, const SPIRVSubtarget &STI)
AtomicOrdering
Atomic ordering for LLVM's memory model.
Type * parseBasicTypeName(StringRef &TypeName, LLVMContext &Ctx)
Type * getPointeeTypeByAttr(Argument *Arg)
bool hasPointeeTypeAttr(Argument *Arg)
MachineInstr * getDefInstrMaybeConstant(Register &ConstReg, const MachineRegisterInfo *MRI)
bool isEquivalentTypes(Type *Ty1, Type *Ty2)
bool hasBuiltinTypePrefix(StringRef Name)
Type * getMDOperandAsType(const MDNode *N, unsigned I)
Type * getPointeeType(Type *Ty)
Type * applyWrappers(Type *Ty)
bool isSpvIntrinsic(const MachineInstr &MI, Intrinsic::ID IntrinsicID)
void addStringImm(const StringRef &Str, MCInst &Inst)
void buildOpSpirvDecorations(Register Reg, MachineIRBuilder &MIRBuilder, const MDNode *GVarMD)
bool isUntypedPointerTy(const Type *T)
SPIRV::MemorySemantics::MemorySemantics getMemSemantics(AtomicOrdering Ord)