diff options
Diffstat (limited to 'llvm/lib/Target/SPIRV/SPIRVUtils.cpp')
| -rw-r--r-- | llvm/lib/Target/SPIRV/SPIRVUtils.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/llvm/lib/Target/SPIRV/SPIRVUtils.cpp b/llvm/lib/Target/SPIRV/SPIRVUtils.cpp index f4f3cdce1ac3..0bd51436082d 100644 --- a/llvm/lib/Target/SPIRV/SPIRVUtils.cpp +++ b/llvm/lib/Target/SPIRV/SPIRVUtils.cpp @@ -15,6 +15,7 @@ #include "SPIRV.h" #include "SPIRVInstrInfo.h" #include "llvm/ADT/StringRef.h" +#include "llvm/CodeGen/GlobalISel/GenericMachineInstrs.h" #include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" @@ -209,15 +210,16 @@ SPIRV::MemorySemantics::MemorySemantics getMemSemantics(AtomicOrdering Ord) { MachineInstr *getDefInstrMaybeConstant(Register &ConstReg, const MachineRegisterInfo *MRI) { MachineInstr *ConstInstr = MRI->getVRegDef(ConstReg); - if (ConstInstr->getOpcode() == TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS && - ConstInstr->getIntrinsicID() == Intrinsic::spv_track_constant) { - ConstReg = ConstInstr->getOperand(2).getReg(); - ConstInstr = MRI->getVRegDef(ConstReg); + if (auto *GI = dyn_cast<GIntrinsic>(ConstInstr)) { + if (GI->is(Intrinsic::spv_track_constant)) { + ConstReg = ConstInstr->getOperand(2).getReg(); + return MRI->getVRegDef(ConstReg); + } } else if (ConstInstr->getOpcode() == SPIRV::ASSIGN_TYPE) { ConstReg = ConstInstr->getOperand(1).getReg(); - ConstInstr = MRI->getVRegDef(ConstReg); + return MRI->getVRegDef(ConstReg); } - return ConstInstr; + return MRI->getVRegDef(ConstReg); } uint64_t getIConstVal(Register ConstReg, const MachineRegisterInfo *MRI) { @@ -227,8 +229,9 @@ uint64_t getIConstVal(Register ConstReg, const MachineRegisterInfo *MRI) { } bool isSpvIntrinsic(MachineInstr &MI, Intrinsic::ID IntrinsicID) { - return MI.getOpcode() == TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS && - MI.getIntrinsicID() == IntrinsicID; + if (auto *GI = dyn_cast<GIntrinsic>(&MI)) + return GI->is(IntrinsicID); + return false; } Type *getMDOperandAsType(const MDNode *N, unsigned I) { @@ -323,13 +326,12 @@ std::string getOclOrSpirvBuiltinDemangledName(StringRef Name) { } const Type *getTypedPtrEltType(const Type *Ty) { - auto PType = dyn_cast<PointerType>(Ty); - if (!PType || PType->isOpaque()) - return Ty; - return PType->getNonOpaquePointerElementType(); + // TODO: This function requires updating following the opaque pointer + // migration. + return Ty; } -static bool hasBuiltinTypePrefix(StringRef Name) { +bool hasBuiltinTypePrefix(StringRef Name) { if (Name.starts_with("opencl.") || Name.starts_with("spirv.")) return true; return false; |
