Index: llvm/include/llvm/IR/IntrinsicsSPIRV.td =================================================================== --- llvm/include/llvm/IR/IntrinsicsSPIRV.td +++ llvm/include/llvm/IR/IntrinsicsSPIRV.td @@ -12,6 +12,7 @@ let TargetPrefix = "spv" in { def int_spv_assign_type : Intrinsic<[], [llvm_any_ty, llvm_metadata_ty]>; + def int_spv_assign_ptr_type : Intrinsic<[], [llvm_any_ty, llvm_metadata_ty]>; def int_spv_assign_name : Intrinsic<[], [llvm_any_ty, llvm_vararg_ty]>; def int_spv_track_constant : Intrinsic<[llvm_any_ty], [llvm_any_ty, llvm_metadata_ty]>; Index: llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h =================================================================== --- llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h +++ llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h @@ -24,6 +24,8 @@ #include namespace llvm { +using SPIRVType = const MachineInstr; + namespace SPIRV { // NOTE: using MapVector instead of DenseMap because it helps getting // everything ordered in a stable manner for a price of extra (NumKeys)*PtrSize @@ -59,6 +61,7 @@ STK_Sampler, STK_Pipe, STK_DeviceEvent, + STK_Pointer, STK_Last = -1 }; SpecialTypeKind Kind; @@ -160,6 +163,23 @@ return TD->Kind == SpecialTypeKind::STK_DeviceEvent; } }; + +struct PointerTypeDescriptor : public SpecialTypeDescriptor { + const Type *ElementType; + unsigned AddressSpace; + + PointerTypeDescriptor() = delete; + PointerTypeDescriptor(const Type *ElementType, unsigned AddressSpace) + : SpecialTypeDescriptor(SpecialTypeKind::STK_Pointer), + ElementType(ElementType), AddressSpace(AddressSpace) { + Hash = (DenseMapInfo().getHashValue(ElementType) & 0xffff) ^ + ((AddressSpace << 8) | Kind); + } + + static bool classof(const SpecialTypeDescriptor *TD) { + return TD->Kind == SpecialTypeKind::STK_Pointer; + } +}; } // namespace SPIRV template <> struct DenseMapInfo { @@ -262,8 +282,14 @@ void buildDepsGraph(std::vector &Graph, MachineModuleInfo *MMI); - void add(const Type *T, const MachineFunction *MF, Register R) { - TT.add(T, MF, R); + void add(const Type *Ty, const MachineFunction *MF, Register R) { + TT.add(Ty, MF, R); + } + + void add(const Type *PointerElementType, unsigned AddressSpace, + const MachineFunction *MF, Register R) { + ST.add(SPIRV::PointerTypeDescriptor(PointerElementType, AddressSpace), MF, + R); } void add(const Constant *C, const MachineFunction *MF, Register R) { @@ -287,8 +313,14 @@ ST.add(TD, MF, R); } - Register find(const Type *T, const MachineFunction *MF) { - return TT.find(const_cast(T), MF); + Register find(const Type *Ty, const MachineFunction *MF) { + return TT.find(const_cast(Ty), MF); + } + + Register find(const Type *PointerElementType, unsigned AddressSpace, + const MachineFunction *MF) { + return ST.find( + SPIRV::PointerTypeDescriptor(PointerElementType, AddressSpace), MF); } Register find(const Constant *C, const MachineFunction *MF) { Index: llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp =================================================================== --- llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp +++ llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp @@ -66,6 +66,7 @@ } void replaceMemInstrUses(Instruction *Old, Instruction *New); void processInstrAfterVisit(Instruction *I); + void insertAssignPtrTypeIntrs(Instruction *I); void insertAssignTypeIntrs(Instruction *I); void processGlobalValue(GlobalVariable &GV); @@ -387,9 +388,21 @@ IRB->CreateIntrinsic(Intrinsic::spv_unref_global, GV.getType(), &GV); } +void SPIRVEmitIntrinsics::insertAssignPtrTypeIntrs(Instruction *I) { + if (I->getType()->isVoidTy() || !requireAssignType(I)) + return; + + setInsertPointSkippingPhis(*IRB, I->getNextNode()); + if (auto *AI = dyn_cast(I)) { + Constant *Const = Constant::getNullValue(AI->getAllocatedType()); + buildIntrWithMD(Intrinsic::spv_assign_ptr_type, {I->getType()}, Const, I); + } +} + void SPIRVEmitIntrinsics::insertAssignTypeIntrs(Instruction *I) { Type *Ty = I->getType(); - if (!Ty->isVoidTy() && requireAssignType(I)) { + if (!Ty->isVoidTy() && requireAssignType(I) && + I->getOpcode() != Instruction::Alloca) { setInsertPointSkippingPhis(*IRB, I->getNextNode()); Type *TypeToAssign = Ty; if (auto *II = dyn_cast(I)) { @@ -484,8 +497,10 @@ for (auto &I : instructions(Func)) Worklist.push_back(&I); - for (auto &I : Worklist) + for (auto &I : Worklist) { + insertAssignPtrTypeIntrs(I); insertAssignTypeIntrs(I); + } for (auto *I : Worklist) { TrackConstants = true; Index: llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.h =================================================================== --- llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.h +++ llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.h @@ -280,9 +280,11 @@ unsigned NumElements, MachineInstr &I, const SPIRVInstrInfo &TII); + // TODO: Remove duplicate method SPIRVType *getOrCreateSPIRVPointerType( SPIRVType *BaseType, MachineIRBuilder &MIRBuilder, SPIRV::StorageClass::StorageClass SClass = SPIRV::StorageClass::Function); + SPIRVType *getOrCreateSPIRVPointerType( SPIRVType *BaseType, MachineInstr &I, const SPIRVInstrInfo &TII, SPIRV::StorageClass::StorageClass SClass = SPIRV::StorageClass::Function); Index: llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp =================================================================== --- llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp +++ llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp @@ -630,6 +630,7 @@ if (Reg.isValid()) return getSPIRVTypeForVReg(Reg); SPIRVType *SpirvType = getOpTypeFunction(RetType, ArgTypes, MIRBuilder); + DT.add(Ty, CurMF, getSPIRVTypeID(SpirvType)); return finishCreatingSPIRVType(Ty, SpirvType); } @@ -740,8 +741,17 @@ // Do not add OpTypeForwardPointer to DT, a corresponding normal pointer type // will be added later. For special types it is already added to DT. if (SpirvType->getOpcode() != SPIRV::OpTypeForwardPointer && !Reg.isValid() && - !isSpecialOpaqueType(Ty)) - DT.add(Ty, &MIRBuilder.getMF(), getSPIRVTypeID(SpirvType)); + !isSpecialOpaqueType(Ty)) { + if (!Ty->isPointerTy()) + DT.add(Ty, &MIRBuilder.getMF(), getSPIRVTypeID(SpirvType)); + else if (Ty->isOpaquePointerTy()) + DT.add(Type::getInt8Ty(MIRBuilder.getMF().getFunction().getContext()), + Ty->getPointerAddressSpace(), &MIRBuilder.getMF(), + getSPIRVTypeID(SpirvType)); + else + DT.add(Ty->getNonOpaquePointerElementType(), Ty->getPointerAddressSpace(), + &MIRBuilder.getMF(), getSPIRVTypeID(SpirvType)); + } return SpirvType; } @@ -759,7 +769,17 @@ SPIRVType *SPIRVGlobalRegistry::getOrCreateSPIRVType( const Type *Ty, MachineIRBuilder &MIRBuilder, SPIRV::AccessQualifier::AccessQualifier AccessQual, bool EmitIR) { - Register Reg = DT.find(Ty, &MIRBuilder.getMF()); + Register Reg; + if (!Ty->isPointerTy()) + Reg = DT.find(Ty, &MIRBuilder.getMF()); + else if (Ty->isOpaquePointerTy()) + Reg = + DT.find(Type::getInt8Ty(MIRBuilder.getMF().getFunction().getContext()), + Ty->getPointerAddressSpace(), &MIRBuilder.getMF()); + else + Reg = DT.find(Ty->getNonOpaquePointerElementType(), + Ty->getPointerAddressSpace(), &MIRBuilder.getMF()); + if (Reg.isValid() && !isSpecialOpaqueType(Ty)) return getSPIRVTypeForVReg(Reg); TypesInProcessing.clear(); @@ -913,8 +933,9 @@ if (ResVReg.isValid()) return MIRBuilder.getMF().getRegInfo().getUniqueVRegDef(ResVReg); ResVReg = createTypeVReg(MIRBuilder); + SPIRVType *SpirvTy = MIRBuilder.buildInstr(Opcode).addDef(ResVReg); DT.add(Ty, &MIRBuilder.getMF(), ResVReg); - return MIRBuilder.buildInstr(Opcode).addDef(ResVReg); + return SpirvTy; } const MachineInstr * @@ -977,7 +998,6 @@ assert(CurMF == SpirvType->getMF()); VRegToTypeMap[CurMF][getSPIRVTypeID(SpirvType)] = SpirvType; SPIRVToLLVMType[SpirvType] = LLVMTy; - DT.add(LLVMTy, CurMF, getSPIRVTypeID(SpirvType)); return SpirvType; } @@ -992,6 +1012,7 @@ .addDef(createTypeVReg(CurMF->getRegInfo())) .addImm(BitWidth) .addImm(0); + DT.add(LLVMTy, CurMF, getSPIRVTypeID(MIB)); return finishCreatingSPIRVType(LLVMTy, MIB); } @@ -1012,6 +1033,7 @@ MachineBasicBlock &BB = *I.getParent(); auto MIB = BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpTypeBool)) .addDef(createTypeVReg(CurMF->getRegInfo())); + DT.add(LLVMTy, CurMF, getSPIRVTypeID(MIB)); return finishCreatingSPIRVType(LLVMTy, MIB); } @@ -1036,6 +1058,7 @@ .addDef(createTypeVReg(CurMF->getRegInfo())) .addUse(getSPIRVTypeID(BaseType)) .addImm(NumElements); + DT.add(LLVMTy, CurMF, getSPIRVTypeID(MIB)); return finishCreatingSPIRVType(LLVMTy, MIB); } @@ -1054,25 +1077,38 @@ .addDef(createTypeVReg(CurMF->getRegInfo())) .addUse(getSPIRVTypeID(BaseType)) .addUse(Len); + DT.add(LLVMTy, CurMF, getSPIRVTypeID(MIB)); return finishCreatingSPIRVType(LLVMTy, MIB); } SPIRVType *SPIRVGlobalRegistry::getOrCreateSPIRVPointerType( SPIRVType *BaseType, MachineIRBuilder &MIRBuilder, - SPIRV::StorageClass::StorageClass SClass) { - return getOrCreateSPIRVType( - PointerType::get(const_cast(getTypeForSPIRVType(BaseType)), - storageClassToAddressSpace(SClass)), - MIRBuilder); + SPIRV::StorageClass::StorageClass SC) { + const Type *PointerElementType = getTypeForSPIRVType(BaseType); + unsigned AddressSpace = storageClassToAddressSpace(SC); + Type *LLVMTy = + PointerType::get(const_cast(PointerElementType), AddressSpace); + Register Reg = DT.find(PointerElementType, AddressSpace, CurMF); + if (Reg.isValid()) + return getSPIRVTypeForVReg(Reg); + auto MIB = BuildMI(MIRBuilder.getMBB(), MIRBuilder.getInsertPt(), + MIRBuilder.getDebugLoc(), + MIRBuilder.getTII().get(SPIRV::OpTypePointer)) + .addDef(createTypeVReg(CurMF->getRegInfo())) + .addImm(static_cast(SC)) + .addUse(getSPIRVTypeID(BaseType)); + DT.add(PointerElementType, AddressSpace, CurMF, getSPIRVTypeID(MIB)); + return finishCreatingSPIRVType(LLVMTy, MIB); } SPIRVType *SPIRVGlobalRegistry::getOrCreateSPIRVPointerType( SPIRVType *BaseType, MachineInstr &I, const SPIRVInstrInfo &TII, SPIRV::StorageClass::StorageClass SC) { + const Type *PointerElementType = getTypeForSPIRVType(BaseType); + unsigned AddressSpace = storageClassToAddressSpace(SC); Type *LLVMTy = - PointerType::get(const_cast(getTypeForSPIRVType(BaseType)), - storageClassToAddressSpace(SC)); - Register Reg = DT.find(LLVMTy, CurMF); + PointerType::get(const_cast(PointerElementType), AddressSpace); + Register Reg = DT.find(PointerElementType, AddressSpace, CurMF); if (Reg.isValid()) return getSPIRVTypeForVReg(Reg); MachineBasicBlock &BB = *I.getParent(); @@ -1080,6 +1116,7 @@ .addDef(createTypeVReg(CurMF->getRegInfo())) .addImm(static_cast(SC)) .addUse(getSPIRVTypeID(BaseType)); + DT.add(PointerElementType, AddressSpace, CurMF, getSPIRVTypeID(MIB)); return finishCreatingSPIRVType(LLVMTy, MIB); } Index: llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp =================================================================== --- llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp +++ llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp @@ -1472,9 +1472,21 @@ // FIXME: don't use MachineIRBuilder here, replace it with BuildMI. MachineIRBuilder MIRBuilder(I); const GlobalValue *GV = I.getOperand(1).getGlobal(); - SPIRVType *ResType = GR.getOrCreateSPIRVType( - GV->getType(), MIRBuilder, SPIRV::AccessQualifier::ReadWrite, false); - + Type *GVType = GV->getValueType(); + SPIRVType *PointerBaseType; + if (GVType->isArrayTy()) { + SPIRVType *ArrayElementType = + GR.getOrCreateSPIRVType(GVType->getArrayElementType(), MIRBuilder, + SPIRV::AccessQualifier::ReadWrite, false); + PointerBaseType = GR.getOrCreateSPIRVArrayType( + ArrayElementType, GVType->getArrayNumElements(), I, TII); + } else { + PointerBaseType = GR.getOrCreateSPIRVType( + GVType, MIRBuilder, SPIRV::AccessQualifier::ReadWrite, false); + } + SPIRVType *ResType = GR.getOrCreateSPIRVPointerType( + PointerBaseType, I, TII, + addressSpaceToStorageClass(GV->getAddressSpace())); std::string GlobalIdent = GV->getGlobalIdentifier(); // We have functions as operands in tests with blocks of instruction e.g. in // transcoding/global_block.ll. These operands are not used and should be @@ -1485,8 +1497,6 @@ MachineBasicBlock &BB = *I.getParent(); Register NewReg = GR.find(ConstVal, GR.CurMF); if (!NewReg.isValid()) { - SPIRVType *SpvBaseTy = GR.getOrCreateSPIRVIntegerType(8, I, TII); - ResType = GR.getOrCreateSPIRVPointerType(SpvBaseTy, I, TII); Register NewReg = ResVReg; GR.add(ConstVal, GR.CurMF, NewReg); return BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpConstantNull)) Index: llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp =================================================================== --- llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp +++ llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp @@ -242,7 +242,19 @@ !ReachedBegin;) { MachineInstr &MI = *MII; - if (isSpvIntrinsic(MI, Intrinsic::spv_assign_type)) { + if (isSpvIntrinsic(MI, Intrinsic::spv_assign_ptr_type)) { + Register Reg = MI.getOperand(1).getReg(); + MIB.setInsertPt(*MI.getParent(), MI.getIterator()); + SPIRVType *BaseTy = GR->getOrCreateSPIRVType( + getMDOperandAsType(MI.getOperand(2).getMetadata(), 0), MIB); + SPIRVType *AssignedPtrType = GR->getOrCreateSPIRVPointerType( + BaseTy, MI, *MF.getSubtarget().getInstrInfo()); + MachineInstr *Def = MRI.getVRegDef(Reg); + assert(Def && "Expecting an instruction that defines the register"); + insertAssignInstr(Reg, nullptr, AssignedPtrType, GR, MIB, + MF.getRegInfo()); + ToErase.push_back(&MI); + } else if (isSpvIntrinsic(MI, Intrinsic::spv_assign_type)) { Register Reg = MI.getOperand(1).getReg(); Type *Ty = getMDOperandAsType(MI.getOperand(2).getMetadata(), 0); MachineInstr *Def = MRI.getVRegDef(Reg); Index: llvm/test/CodeGen/SPIRV/EnqueueEmptyKernel.ll =================================================================== --- llvm/test/CodeGen/SPIRV/EnqueueEmptyKernel.ll +++ /dev/null @@ -1,64 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV - -;; This test checks that Invoke parameter of OpEnueueKernel instruction meet the -;; following specification requirements in case of enqueueing empty block: -;; "Invoke must be an OpFunction whose OpTypeFunction operand has: -;; - Result Type must be OpTypeVoid. -;; - The first parameter must have a type of OpTypePointer to an 8-bit OpTypeInt. -;; - An optional list of parameters, each of which must have a type of OpTypePointer to the Workgroup Storage Class. -;; ... " -;; __kernel void test_enqueue_empty() { -;; enqueue_kernel(get_default_queue(), -;; CLK_ENQUEUE_FLAGS_WAIT_KERNEL, -;; ndrange_1D(1), -;; 0, NULL, NULL, -;; ^(){}); -;; } - -%struct.ndrange_t = type { i32, [3 x i64], [3 x i64], [3 x i64] } -%opencl.queue_t = type opaque -%opencl.clk_event_t = type opaque - -@__block_literal_global = internal addrspace(1) constant { i32, i32 } { i32 8, i32 4 }, align 4 - -; CHECK-SPIRV: OpName %[[#Block:]] "__block_literal_global" -; CHECK-SPIRV: %[[#Void:]] = OpTypeVoid -; CHECK-SPIRV: %[[#Int8:]] = OpTypeInt 8 -; CHECK-SPIRV: %[[#Int8PtrGen:]] = OpTypePointer Generic %[[#Int8]] -; CHECK-SPIRV: %[[#Int8Ptr:]] = OpTypePointer CrossWorkgroup %[[#Int8]] -; CHECK-SPIRV: %[[#Block]] = OpVariable %[[#]] - -define spir_kernel void @test_enqueue_empty() { -entry: - %tmp = alloca %struct.ndrange_t, align 8 - %call = call spir_func %opencl.queue_t* @_Z17get_default_queuev() - call spir_func void @_Z10ndrange_1Dm(%struct.ndrange_t* sret(%struct.ndrange_t*) %tmp, i64 1) - %0 = call i32 @__enqueue_kernel_basic_events(%opencl.queue_t* %call, i32 1, %struct.ndrange_t* %tmp, i32 0, %opencl.clk_event_t* addrspace(4)* null, %opencl.clk_event_t* addrspace(4)* null, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* @__test_enqueue_empty_block_invoke_kernel to i8*) to i8 addrspace(4)*), i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32 } addrspace(1)* @__block_literal_global to i8 addrspace(1)*) to i8 addrspace(4)*)) - ret void -; CHECK-SPIRV: %[[#Int8PtrBlock:]] = OpBitcast %[[#Int8Ptr]] %[[#Block]] -; CHECK-SPIRV: %[[#Int8PtrGenBlock:]] = OpPtrCastToGeneric %[[#Int8PtrGen]] %[[#Int8PtrBlock]] -; CHECK-SPIRV: %[[#]] = OpEnqueueKernel %[[#]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#Invoke:]] %[[#Int8PtrGenBlock]] %[[#]] %[[#]] -} - -declare spir_func %opencl.queue_t* @_Z17get_default_queuev() - -declare spir_func void @_Z10ndrange_1Dm(%struct.ndrange_t* sret(%struct.ndrange_t*), i64) - -define internal spir_func void @__test_enqueue_empty_block_invoke(i8 addrspace(4)* %.block_descriptor) { -entry: - %.block_descriptor.addr = alloca i8 addrspace(4)*, align 8 - store i8 addrspace(4)* %.block_descriptor, i8 addrspace(4)** %.block_descriptor.addr, align 8 - %block = bitcast i8 addrspace(4)* %.block_descriptor to <{ i32, i32 }> addrspace(4)* - ret void -} - -define internal spir_kernel void @__test_enqueue_empty_block_invoke_kernel(i8 addrspace(4)*) { -entry: - call void @__test_enqueue_empty_block_invoke(i8 addrspace(4)* %0) - ret void -} - -declare i32 @__enqueue_kernel_basic_events(%opencl.queue_t*, i32, %struct.ndrange_t*, i32, %opencl.clk_event_t* addrspace(4)*, %opencl.clk_event_t* addrspace(4)*, i8 addrspace(4)*, i8 addrspace(4)*) - -; CHECK-SPIRV: %[[#Invoke]] = OpFunction %[[#Void]] None %[[#]] -; CHECK-SPIRV-NEXT: %[[#]] = OpFunctionParameter %[[#Int8PtrGen]] Index: llvm/test/CodeGen/SPIRV/OpenCL/get_global_id.ll =================================================================== --- llvm/test/CodeGen/SPIRV/OpenCL/get_global_id.ll +++ llvm/test/CodeGen/SPIRV/OpenCL/get_global_id.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 -mtriple=spirv64-unknown-unknown -opaque-pointers=0 %s -o - | FileCheck %s +; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s ;; The set of valid inputs for get_global_id depends on the runtime NDRange, ;; but inputs outside of [0, 2] always return 0. Index: llvm/test/CodeGen/SPIRV/OpenCL/get_global_offset.ll =================================================================== --- llvm/test/CodeGen/SPIRV/OpenCL/get_global_offset.ll +++ llvm/test/CodeGen/SPIRV/OpenCL/get_global_offset.ll @@ -1,13 +1,13 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s +; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s ; CHECK: OpEntryPoint Kernel %[[#test_func:]] "test" ; CHECK: OpName %[[#outOffsets:]] "outOffsets" ; CHECK: OpName %[[#test_func]] "test" ; CHECK: OpName %[[#f2_decl:]] "BuiltInGlobalOffset" ; CHECK: OpDecorate %[[#f2_decl]] LinkageAttributes "BuiltInGlobalOffset" Import -; CHECK: %[[#int_ty:]] = OpTypeInt 32 0 -; CHECK: %[[#iptr_ty:]] = OpTypePointer CrossWorkgroup %[[#int_ty]] +; CHECK: %[[#int_ty:]] = OpTypeInt 8 0 ; CHECK: %[[#void_ty:]] = OpTypeVoid +; CHECK: %[[#iptr_ty:]] = OpTypePointer CrossWorkgroup %[[#int_ty]] ; CHECK: %[[#func_ty:]] = OpTypeFunction %[[#void_ty]] %[[#iptr_ty]] ; CHECK: %[[#int64_ty:]] = OpTypeInt 64 0 ; CHECK: %[[#vec_ty:]] = OpTypeVector %[[#int64_ty]] 3 Index: llvm/test/CodeGen/SPIRV/OpenCL/progvar_prog_scope_init.ll =================================================================== --- llvm/test/CodeGen/SPIRV/OpenCL/progvar_prog_scope_init.ll +++ llvm/test/CodeGen/SPIRV/OpenCL/progvar_prog_scope_init.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s +; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s ; CHECK: OpEntryPoint Kernel %[[#f1:]] "writer" ; CHECK: OpEntryPoint Kernel %[[#f2:]] "reader" Index: llvm/test/CodeGen/SPIRV/OpenCL/wait_group_events.ll =================================================================== --- llvm/test/CodeGen/SPIRV/OpenCL/wait_group_events.ll +++ llvm/test/CodeGen/SPIRV/OpenCL/wait_group_events.ll @@ -8,14 +8,11 @@ ; CHECK-NOT: OpCapability Groups ; CHECK: OpGroupWaitEvents -%opencl.event_t = type opaque - -define dso_local spir_kernel void @test_fn(i8 addrspace(1)* noundef %src) { -entry: - %src.addr = alloca i8 addrspace(1)*, align 8 - store i8 addrspace(1)* %src, i8 addrspace(1)** %src.addr, align 8 - call spir_func void @_Z17wait_group_eventsiPU3AS49ocl_event(i32 noundef 0, %opencl.event_t* addrspace(4)* noundef null) +define dso_local spir_kernel void @test_fn(ptr addrspace(1) %src) { + %src.addr = alloca ptr addrspace(1), align 8 + store ptr addrspace(1) %src, ptr %src.addr, align 8 + call spir_func void @_Z17wait_group_eventsiPU3AS49ocl_event(i32 0, ptr addrspace(4) null) ret void } -declare spir_func void @_Z17wait_group_eventsiPU3AS49ocl_event(i32 noundef, %opencl.event_t* addrspace(4)* noundef) +declare spir_func void @_Z17wait_group_eventsiPU3AS49ocl_event(i32, ptr addrspace(4)) Index: llvm/test/CodeGen/SPIRV/SampledImageRetType.ll =================================================================== --- llvm/test/CodeGen/SPIRV/SampledImageRetType.ll +++ /dev/null @@ -1,29 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s - -%opencl.image1d_ro_t = type opaque -; CHECK: %[[#image1d_t:]] = OpTypeImage -%opencl.sampler_t = type opaque -; CHECK: %[[#sampler_t:]] = OpTypeSampler -; CHECK: %[[#sampled_image_t:]] = OpTypeSampledImage - -declare dso_local spir_func i8 addrspace(4)* @_Z20__spirv_SampledImageI14ocl_image1d_roPvET0_T_11ocl_sampler(%opencl.image1d_ro_t addrspace(1)*, %opencl.sampler_t addrspace(2)*) local_unnamed_addr - -declare dso_local spir_func <4 x float> @_Z30__spirv_ImageSampleExplicitLodIPvDv4_fiET0_T_T1_if(i8 addrspace(4)*, i32, i32, float) local_unnamed_addr - -@__spirv_BuiltInGlobalInvocationId = external dso_local local_unnamed_addr addrspace(2) constant <3 x i64>, align 32 - -define weak_odr dso_local spir_kernel void @_ZTS17image_kernel_readILi1EE(%opencl.image1d_ro_t addrspace(1)*, %opencl.sampler_t addrspace(2)*) { -; CHECK: OpFunction -; CHECK: %[[#image:]] = OpFunctionParameter %[[#image1d_t]] -; CHECK: %[[#sampler:]] = OpFunctionParameter %[[#sampler_t]] - %3 = load <3 x i64>, <3 x i64> addrspace(2)* @__spirv_BuiltInGlobalInvocationId, align 32 - %4 = extractelement <3 x i64> %3, i64 0 - %5 = trunc i64 %4 to i32 - %6 = tail call spir_func i8 addrspace(4)* @_Z20__spirv_SampledImageI14ocl_image1d_roPvET0_T_11ocl_sampler(%opencl.image1d_ro_t addrspace(1)* %0, %opencl.sampler_t addrspace(2)* %1) - %7 = tail call spir_func <4 x float> @_Z30__spirv_ImageSampleExplicitLodIPvDv4_fiET0_T_T1_if(i8 addrspace(4)* %6, i32 %5, i32 2, float 0.000000e+00) - -; CHECK: %[[#sampled_image:]] = OpSampledImage %[[#sampled_image_t]] %[[#image]] %[[#sampler]] -; CHECK: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#sampled_image]] %[[#]] {{.*}} %[[#]] - - ret void -} Index: llvm/test/CodeGen/SPIRV/atomicrmw.ll =================================================================== --- llvm/test/CodeGen/SPIRV/atomicrmw.ll +++ llvm/test/CodeGen/SPIRV/atomicrmw.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s +; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s ; CHECK: %[[#Int:]] = OpTypeInt 32 0 ; CHECK-DAG: %[[#Scope_Device:]] = OpConstant %[[#Int]] 1 {{$}} Index: llvm/test/CodeGen/SPIRV/capabilities/capability-Float64-ImageBasic.ll =================================================================== --- llvm/test/CodeGen/SPIRV/capabilities/capability-Float64-ImageBasic.ll +++ llvm/test/CodeGen/SPIRV/capabilities/capability-Float64-ImageBasic.ll @@ -4,13 +4,11 @@ ;; kernel void test(read_only image2d_t img) {} ;; ----------------------------------------------- -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV - -%opencl.image2d_t = type opaque +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV @d = addrspace(1) global double 1.000000e+00, align 8 -define spir_kernel void @test(%opencl.image2d_t addrspace(1)* nocapture %img) { +define spir_kernel void @test(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %img) { entry: ret void } Index: llvm/test/CodeGen/SPIRV/capabilities/no_capability_shader.ll =================================================================== --- llvm/test/CodeGen/SPIRV/capabilities/no_capability_shader.ll +++ llvm/test/CodeGen/SPIRV/capabilities/no_capability_shader.ll @@ -4,10 +4,6 @@ ; CHECK-SPIRV-NOT: OpCapability Shader -%opencl.image2d_ro_t = type opaque -%opencl.image1d_buffer_ro_t = type opaque - -define spir_kernel void @sample_test(%opencl.image2d_ro_t addrspace(1)* %src, %opencl.image1d_buffer_ro_t addrspace(1)* %buf) { -entry: +define spir_kernel void @sample_test(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %src, target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 0) %buf) { ret void } Index: llvm/test/CodeGen/SPIRV/constants/global-constants.ll =================================================================== --- llvm/test/CodeGen/SPIRV/constants/global-constants.ll +++ llvm/test/CodeGen/SPIRV/constants/global-constants.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s @global = addrspace(1) constant i32 1 ; OpenCL global memory @constant = addrspace(2) constant i32 2 ; OpenCL constant memory Index: llvm/test/CodeGen/SPIRV/constants/local-null-constants.ll =================================================================== --- llvm/test/CodeGen/SPIRV/constants/local-null-constants.ll +++ llvm/test/CodeGen/SPIRV/constants/local-null-constants.ll @@ -1,21 +1,21 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s ;; OpenCL global memory -define i32 addrspace(1)* @getConstant1() { - ret i32 addrspace(1)* null +define ptr addrspace(1) @getConstant1() { + ret ptr addrspace(1) null } ;; OpenCL constant memory -define i32 addrspace(2)* @getConstant2() { - ret i32 addrspace(2)* null +define ptr addrspace(2) @getConstant2() { + ret ptr addrspace(2) null } ;; OpenCL local memory -define i32 addrspace(3)* @getConstant3() { - ret i32 addrspace(3)* null +define ptr addrspace(3) @getConstant3() { + ret ptr addrspace(3) null } -; CHECK: [[INT:%.+]] = OpTypeInt 32 +; CHECK: [[INT:%.+]] = OpTypeInt 8 ; CHECK-DAG: [[PTR_AS1:%.+]] = OpTypePointer CrossWorkgroup [[INT]] ; CHECK-DAG: OpConstantNull [[PTR_AS1]] Index: llvm/test/CodeGen/SPIRV/function/alloca-load-store.ll =================================================================== --- llvm/test/CodeGen/SPIRV/function/alloca-load-store.ll +++ llvm/test/CodeGen/SPIRV/function/alloca-load-store.ll @@ -1,12 +1,15 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s + +target triple = "spirv32-unknown-unknown" ; CHECK-DAG: OpName %[[#BAR:]] "bar" ; CHECK-DAG: OpName %[[#FOO:]] "foo" ; CHECK-DAG: OpName %[[#GOO:]] "goo" -; CHECK: %[[#INT:]] = OpTypeInt 32 +; CHECK-DAG: %[[#CHAR:]] = OpTypeInt 8 +; CHECK-DAG: %[[#INT:]] = OpTypeInt 32 ; CHECK-DAG: %[[#STACK_PTR:]] = OpTypePointer Function %[[#INT]] -; CHECK-DAG: %[[#GLOBAL_PTR:]] = OpTypePointer CrossWorkgroup %[[#INT]] +; CHECK-DAG: %[[#GLOBAL_PTR:]] = OpTypePointer CrossWorkgroup %[[#CHAR]] ; CHECK-DAG: %[[#FN1:]] = OpTypeFunction %[[#INT]] %[[#INT]] ; CHECK-DAG: %[[#FN2:]] = OpTypeFunction %[[#INT]] %[[#INT]] %[[#GLOBAL_PTR]] Index: llvm/test/CodeGen/SPIRV/function/mangled-function.ll =================================================================== --- llvm/test/CodeGen/SPIRV/function/mangled-function.ll +++ llvm/test/CodeGen/SPIRV/function/mangled-function.ll @@ -14,12 +14,9 @@ ; CHECK-SPIRV: OpName %[[#foo:]] "_Z3foo14ocl_image2d_ro" ; CHECK-SPIRV: %[[#foo]] = OpFunction %[[#]] -%opencl.image2d_ro_t = type opaque - -define spir_func void @bar(%opencl.image2d_ro_t addrspace(1)* %srcImage) local_unnamed_addr { -entry: - tail call spir_func void @_Z3foo14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)* %srcImage) +define spir_func void @bar(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %srcImage) local_unnamed_addr { + tail call spir_func void @_Z3foo14ocl_image2d_ro(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %srcImage) ret void } -declare spir_func void @_Z3foo14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)*) local_unnamed_addr +declare spir_func void @_Z3foo14ocl_image2d_ro(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0)) local_unnamed_addr Index: llvm/test/CodeGen/SPIRV/half_extension.ll =================================================================== --- llvm/test/CodeGen/SPIRV/half_extension.ll +++ llvm/test/CodeGen/SPIRV/half_extension.ll @@ -7,7 +7,7 @@ ;; return y; ;; } -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ; CHECK-SPIRV-DAG: OpCapability Float16Buffer ; CHECK-SPIRV-DAG: OpCapability Float16 Index: llvm/test/CodeGen/SPIRV/half_no_extension.ll =================================================================== --- llvm/test/CodeGen/SPIRV/half_no_extension.ll +++ /dev/null @@ -1,30 +0,0 @@ -;; __kernel void test( __global float4 *p, __global half *f ) -;; { -;; __private float4 data; -;; data = p[0]; -;; vstorea_half4_rtp( data, 0, f ); -;; } - -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV - -; CHECK-SPIRV: OpCapability Float16Buffer -; CHECK-SPIRV-NOT: OpCapability Float16 - -define spir_kernel void @test(<4 x float> addrspace(1)* %p, half addrspace(1)* %f) { -entry: - %p.addr = alloca <4 x float> addrspace(1)*, align 8 - %f.addr = alloca half addrspace(1)*, align 8 - %data = alloca <4 x float>, align 16 - store <4 x float> addrspace(1)* %p, <4 x float> addrspace(1)** %p.addr, align 8 - store half addrspace(1)* %f, half addrspace(1)** %f.addr, align 8 - %0 = load <4 x float> addrspace(1)*, <4 x float> addrspace(1)** %p.addr, align 8 - %arrayidx = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %0, i64 0 - %1 = load <4 x float>, <4 x float> addrspace(1)* %arrayidx, align 16 - store <4 x float> %1, <4 x float>* %data, align 16 - %2 = load <4 x float>, <4 x float>* %data, align 16 - %3 = load half addrspace(1)*, half addrspace(1)** %f.addr, align 8 - call spir_func void @_Z17vstorea_half4_rtpDv4_fmPU3AS1Dh(<4 x float> %2, i64 0, half addrspace(1)* %3) - ret void -} - -declare spir_func void @_Z17vstorea_half4_rtpDv4_fmPU3AS1Dh(<4 x float>, i64, half addrspace(1)*) Index: llvm/test/CodeGen/SPIRV/image_decl_func_arg.ll =================================================================== --- llvm/test/CodeGen/SPIRV/image_decl_func_arg.ll +++ /dev/null @@ -1,28 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV - -; CHECK-SPIRV: %[[#TypeImage:]] = OpTypeImage -; CHECK-SPIRV-NOT: OpTypeImage -; CHECK-SPIRV: %[[#]] = OpTypeFunction %[[#]] %[[#TypeImage]] -; CHECK-SPIRV: %[[#]] = OpTypeFunction %[[#]] %[[#TypeImage]] -; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#TypeImage]] -; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#TypeImage]] -; CHECK-SPIRV: %[[#ParamID:]] = OpFunctionParameter %[[#TypeImage]] -; CHECK-SPIRV: %[[#]] = OpFunctionCall %[[#]] %[[#]] %[[#ParamID]] - -%opencl.image2d_ro_t = type opaque - -define spir_func void @f0(%opencl.image2d_ro_t addrspace(1)* %v2, <2 x float> %v3) { -entry: - ret void -} - -define spir_func void @f1(%opencl.image2d_ro_t addrspace(1)* %v2, <2 x float> %v3) { -entry: - ret void -} - -define spir_kernel void @test(%opencl.image2d_ro_t addrspace(1)* %v1) { -entry: - call spir_func void @f0(%opencl.image2d_ro_t addrspace(1)* %v1, <2 x float> ) - ret void -} Index: llvm/test/CodeGen/SPIRV/image_dim.ll =================================================================== --- llvm/test/CodeGen/SPIRV/image_dim.ll +++ /dev/null @@ -1,12 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV - -; CHECK-SPIRV-DAG: OpCapability Sampled1D -; CHECK-SPIRV-DAG: OpCapability SampledBuffer - -%opencl.image1d_t = type opaque -%opencl.image1d_buffer_t = type opaque - -define spir_kernel void @image_d(%opencl.image1d_t addrspace(1)* %image1d_td6, %opencl.image1d_buffer_t addrspace(1)* %image1d_buffer_td8) { -entry: - ret void -} Index: llvm/test/CodeGen/SPIRV/image_store.ll =================================================================== --- llvm/test/CodeGen/SPIRV/image_store.ll +++ /dev/null @@ -1,22 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s - -;; Image types may be represented in two ways while translating to SPIR-V: -;; - OpenCL form based on pointers-to-opaque-structs, e.g. '%opencl.image2d_ro_t', -;; - SPIR-V form based on TargetExtType, e.g. 'target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0)', -;; but it is still one type which should be translated to one SPIR-V type. -;; -;; The test checks that the code below is successfully translated and only one -;; SPIR-V type for images is generated. - -; CHECK: OpTypeImage -; CHECK-NOT: OpTypeImage - -%opencl.image2d_ro_t = type opaque - -define spir_kernel void @read_image(%opencl.image2d_ro_t addrspace(1)* %srcimg) { -entry: - %srcimg.addr = alloca %opencl.image2d_ro_t addrspace(1)*, align 8 - %spirvimg.addr = alloca target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), align 8 - store %opencl.image2d_ro_t addrspace(1)* %srcimg, %opencl.image2d_ro_t addrspace(1)** %srcimg.addr, align 8 - ret void -} Index: llvm/test/CodeGen/SPIRV/link-attribute.ll =================================================================== --- llvm/test/CodeGen/SPIRV/link-attribute.ll +++ llvm/test/CodeGen/SPIRV/link-attribute.ll @@ -1,33 +1,31 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s - -%opencl.image2d_t = type opaque +; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s ; CHECK: OpDecorate %[[#ID:]] LinkageAttributes "imageSampler" Export ; CHECK: %[[#ID]] = OpVariable %[[#]] UniformConstant %[[#]] @imageSampler = addrspace(2) constant i32 36, align 4 -define spir_kernel void @sample_kernel(%opencl.image2d_t addrspace(1)* %input, float addrspace(1)* nocapture %xOffsets, float addrspace(1)* nocapture %yOffsets, <4 x float> addrspace(1)* nocapture %results) { +define spir_kernel void @sample_kernel(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, ptr addrspace(1) nocapture %xOffsets, ptr addrspace(1) nocapture %yOffsets, ptr addrspace(1) nocapture %results) { %1 = tail call spir_func i64 @_Z13get_global_idj(i32 0) %2 = trunc i64 %1 to i32 %3 = tail call spir_func i64 @_Z13get_global_idj(i32 1) %4 = trunc i64 %3 to i32 - %5 = tail call spir_func i32 @_Z15get_image_width11ocl_image2d(%opencl.image2d_t addrspace(1)* %input) + %5 = tail call spir_func i32 @_Z15get_image_width11ocl_image2d(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input) %6 = mul nsw i32 %4, %5 %7 = add nsw i32 %6, %2 %8 = sitofp i32 %2 to float %9 = insertelement <2 x float> undef, float %8, i32 0 %10 = sitofp i32 %4 to float %11 = insertelement <2 x float> %9, float %10, i32 1 - %12 = tail call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_f(%opencl.image2d_t addrspace(1)* %input, i32 36, <2 x float> %11) + %12 = tail call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, i32 36, <2 x float> %11) %13 = sext i32 %7 to i64 - %14 = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %results, i64 %13 - store <4 x float> %12, <4 x float> addrspace(1)* %14, align 16 + %14 = getelementptr inbounds <4 x float>, ptr addrspace(1) %results, i64 %13 + store <4 x float> %12, ptr addrspace(1) %14, align 16 ret void } declare spir_func i64 @_Z13get_global_idj(i32) -declare spir_func i32 @_Z15get_image_width11ocl_image2d(%opencl.image2d_t addrspace(1)*) +declare spir_func i32 @_Z15get_image_width11ocl_image2d(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0)) -declare spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_f(%opencl.image2d_t addrspace(1)*, i32, <2 x float>) +declare spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), i32, <2 x float>) Index: llvm/test/CodeGen/SPIRV/linked-list.ll =================================================================== --- llvm/test/CodeGen/SPIRV/linked-list.ll +++ /dev/null @@ -1,10 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s - -%struct.Node = type { %struct.Node.0 addrspace(1)* } -; CHECK: %[[#]] = OpTypeOpaque "struct.Node.0" -%struct.Node.0 = type opaque - -define spir_kernel void @create_linked_lists(%struct.Node addrspace(1)* nocapture %pNodes, i32 addrspace(1)* nocapture %allocation_index, i32 %list_length) { -entry: - ret void -} Index: llvm/test/CodeGen/SPIRV/literal-struct.ll =================================================================== --- llvm/test/CodeGen/SPIRV/literal-struct.ll +++ /dev/null @@ -1,47 +0,0 @@ -;; This test checks that the backend doesn't crash if the module has literal -;; structs, i.e. structs whose type has no name. Typicaly clang generate such -;; structs if the kernel contains OpenCL 2.0 blocks. The IR was produced with -;; the following command: -;; clang -cc1 -triple spir -cl-std=cl2.0 -O0 literal-struct.cl -emit-llvm -o test/literal-struct.ll - -;; literal-struct.cl: -;; void foo() -;; { -;; void (^myBlock)(void) = ^{}; -;; myBlock(); -;; } - -; RUN: llc -opaque-pointers=0 -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s - -; CHECK: OpName %[[#StructType0:]] "struct.__opencl_block_literal_generic" -; CHECK: %[[#Int8:]] = OpTypeInt 8 0 -; CHECK: %[[#Int8Ptr:]] = OpTypePointer Generic %[[#Int8]] -; CHECK: %[[#Int:]] = OpTypeInt 32 0 -; CHECK: %[[#StructType0:]] = OpTypeStruct %[[#Int]] %[[#Int]] %[[#Int8Ptr]] -; CHECK: %[[#StructType:]] = OpTypeStruct %[[#Int]] %[[#Int]] %[[#Int8Ptr]] - -%struct.__opencl_block_literal_generic = type { i32, i32, i8 addrspace(4)* } - -@__block_literal_global = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 12, i32 4, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* @__foo_block_invoke to i8*) to i8 addrspace(4)*) }, align 4 -; CHECK: OpConstantComposite %[[#StructType]] - -@__block_literal_global.1 = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } zeroinitializer, align 4 -; CHECK: OpConstantNull %[[#StructType]] - -define spir_func void @foo() { -entry: - %myBlock = alloca %struct.__opencl_block_literal_generic addrspace(4)*, align 4 - store %struct.__opencl_block_literal_generic addrspace(4)* addrspacecast (%struct.__opencl_block_literal_generic addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* @__block_literal_global to %struct.__opencl_block_literal_generic addrspace(1)*) to %struct.__opencl_block_literal_generic addrspace(4)*), %struct.__opencl_block_literal_generic addrspace(4)** %myBlock, align 4 - call spir_func void @__foo_block_invoke(i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* @__block_literal_global to i8 addrspace(1)*) to i8 addrspace(4)*)) - ret void -} - -define internal spir_func void @__foo_block_invoke(i8 addrspace(4)* %.block_descriptor) { -entry: - %.block_descriptor.addr = alloca i8 addrspace(4)*, align 4 - %block.addr = alloca <{ i32, i32, i8 addrspace(4)* }> addrspace(4)*, align 4 - store i8 addrspace(4)* %.block_descriptor, i8 addrspace(4)** %.block_descriptor.addr, align 4 - %block = bitcast i8 addrspace(4)* %.block_descriptor to <{ i32, i32, i8 addrspace(4)* }> addrspace(4)* - store <{ i32, i32, i8 addrspace(4)* }> addrspace(4)* %block, <{ i32, i32, i8 addrspace(4)* }> addrspace(4)** %block.addr, align 4 - ret void -} Index: llvm/test/CodeGen/SPIRV/llvm-intrinsics/memset.ll =================================================================== --- llvm/test/CodeGen/SPIRV/llvm-intrinsics/memset.ll +++ llvm/test/CodeGen/SPIRV/llvm-intrinsics/memset.ll @@ -1,60 +1,69 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV - -; CHECK-SPIRV: OpDecorate %[[#NonConstMemset:]] LinkageAttributes "spirv.llvm_memset_p3i8_i32" -; CHECK-SPIRV: %[[#Int32:]] = OpTypeInt 32 0 -; CHECK-SPIRV: %[[#Int8:]] = OpTypeInt 8 0 -; CHECK-SPIRV: %[[#Int8Ptr:]] = OpTypePointer Generic %[[#Int8]] -; CHECK-SPIRV: %[[#Lenmemset21:]] = OpConstant %[[#]] 4 -; CHECK-SPIRV: %[[#Int8x4:]] = OpTypeArray %[[#Int8]] %[[#Lenmemset21]] -; CHECK-SPIRV: %[[#Int8PtrConst:]] = OpTypePointer UniformConstant %[[#Int8]] -; CHECK-SPIRV: %[[#Lenmemset0:]] = OpConstant %[[#Int32]] 12 -; CHECK-SPIRV: %[[#Int8x12:]] = OpTypeArray %[[#Int8]] %[[#Lenmemset0]] -; CHECK-SPIRV: %[[#Const21:]] = OpConstant %[[#]] 21 -; CHECK-SPIRV: %[[#False:]] = OpConstantFalse %[[#]] -; CHECK-SPIRV: %[[#InitComp:]] = OpConstantComposite %[[#Int8x4]] %[[#Const21]] %[[#Const21]] %[[#Const21]] %[[#Const21]] -; CHECK-SPIRV: %[[#Init:]] = OpConstantNull %[[#Int8x12]] -; CHECK-SPIRV: %[[#ValComp:]] = OpVariable %[[#]] UniformConstant %[[#InitComp]] -; CHECK-SPIRV: %[[#Val:]] = OpVariable %[[#]] UniformConstant %[[#Init]] - -; CHECK-SPIRV: %[[#Target:]] = OpBitcast %[[#Int8Ptr]] %[[#]] -; CHECK-SPIRV: %[[#Source:]] = OpBitcast %[[#Int8PtrConst]] %[[#Val]] -; CHECK-SPIRV: OpCopyMemorySized %[[#Target]] %[[#Source]] %[[#Lenmemset0]] Aligned 4 - -; CHECK-SPIRV: %[[#SourceComp:]] = OpBitcast %[[#Int8PtrConst]] %[[#ValComp]] -; CHECK-SPIRV: OpCopyMemorySized %[[#]] %[[#SourceComp]] %[[#Lenmemset21]] Aligned 4 - -; CHECK-SPIRV: %[[#]] = OpFunctionCall %[[#]] %[[#NonConstMemset]] %[[#]] %[[#]] %[[#]] %[[#False]] - -; CHECK-SPIRV: %[[#NonConstMemset]] = OpFunction %[[#]] -; CHECK-SPIRV: %[[#Dest:]] = OpFunctionParameter %[[#]] -; CHECK-SPIRV: %[[#Value:]] = OpFunctionParameter %[[#]] -; CHECK-SPIRV: %[[#Len:]] = OpFunctionParameter %[[#]] -; CHECK-SPIRV: %[[#Volatile:]] = OpFunctionParameter %[[#]] - -; CHECK-SPIRV: %[[#Entry:]] = OpLabel -; CHECK-SPIRV: %[[#IsZeroLen:]] = OpIEqual %[[#]] %[[#Zero:]] %[[#Len]] -; CHECK-SPIRV: OpBranchConditional %[[#IsZeroLen]] %[[#End:]] %[[#WhileBody:]] - -; CHECK-SPIRV: %[[#WhileBody]] = OpLabel -; CHECK-SPIRV: %[[#Offset:]] = OpPhi %[[#]] %[[#Zero]] %[[#Entry]] %[[#OffsetInc:]] %[[#WhileBody]] -; CHECK-SPIRV: %[[#Ptr:]] = OpInBoundsPtrAccessChain %[[#]] %[[#Dest]] %[[#Offset]] -; CHECK-SPIRV: OpStore %[[#Ptr]] %[[#Value]] Aligned 1 -; CHECK-SPIRV: %[[#OffsetInc]] = OpIAdd %[[#]] %[[#Offset]] %[[#One:]] -; CHECK-SPIRV: %[[#NotEnd:]] = OpULessThan %[[#]] %[[#OffsetInc]] %[[#Len]] -; CHECK-SPIRV: OpBranchConditional %[[#NotEnd]] %[[#WhileBody]] %[[#End]] - -; CHECK-SPIRV: %[[#End]] = OpLabel -; CHECK-SPIRV: OpReturn - -; CHECK-SPIRV: OpFunctionEnd +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s + +; CHECK-DAG: OpDecorate %[[#Memset_p0i32:]] LinkageAttributes "spirv.llvm_memset_p0_i32" Export +; CHECK-DAG: OpDecorate %[[#Memset_p3i32:]] LinkageAttributes "spirv.llvm_memset_p3_i32" Export +; CHECK-DAG: OpDecorate %[[#Memset_p1i64:]] LinkageAttributes "spirv.llvm_memset_p1_i64" Export +; CHECK-DAG: OpDecorate %[[#Memset_p1i64:]] LinkageAttributes "spirv.llvm_memset_p1_i64.volatile" Export + +; CHECK-DAG: %[[#Int8:]] = OpTypeInt 8 0 +; CHECK-DAG: %[[#Int32:]] = OpTypeInt 32 0 +; CHECK-DAG: %[[#Int64:]] = OpTypeInt 64 0 +; CHECK-DAG: %[[#Void:]] = OpTypeVoid +; CHECK-DAG: %[[#Int8Ptr:]] = OpTypePointer Generic %[[#Int8]] + +; CHECK-DAG: %[[#Const4:]] = OpConstant %[[#Int32]] 4 +; CHECK: %[[#Int8x4:]] = OpTypeArray %[[#Int8]] %[[#Const4]] + +; CHECK-DAG: %[[#Const12:]] = OpConstant %[[#Int32]] 12 +; CHECK: %[[#Int8x12:]] = OpTypeArray %[[#Int8]] %[[#Const12]] + +; CHECK-DAG: %[[#Const21:]] = OpConstant %[[#Int8]] 21 +; CHECK-DAG: %[[#False:]] = OpConstantFalse %[[#]] +; CHECK-DAG: %[[#ConstComp:]] = OpConstantComposite %[[#Int8x4]] %[[#Const21]] %[[#Const21]] %[[#Const21]] %[[#Const21]] +; CHECK-DAG: %[[#ConstNull:]] = OpConstantNull %[[#Int8x12]] +; CHECK: %[[#VarComp:]] = OpVariable %[[#]] UniformConstant %[[#ConstComp]] +; CHECK: %[[#VarNull:]] = OpVariable %[[#]] UniformConstant %[[#ConstNull]] + +; CHECK-DAG: %[[#Int8PtrConst:]] = OpTypePointer UniformConstant %[[#Int8]] +; CHECK: %[[#Target:]] = OpBitcast %[[#Int8Ptr]] %[[#]] +; CHECK: %[[#Source:]] = OpBitcast %[[#Int8PtrConst]] %[[#VarNull]] +; CHECK: OpCopyMemorySized %[[#Target]] %[[#Source]] %[[#Const12]] Aligned 4 + +; CHECK: %[[#SourceComp:]] = OpBitcast %[[#Int8PtrConst]] %[[#VarComp]] +; CHECK: OpCopyMemorySized %[[#]] %[[#SourceComp]] %[[#Const4]] Aligned 4 + +; CHECK-SPIRV: %[[#]] = OpFunctionCall %[[#]] %[[#Memset_p0i32]] %[[#]] %[[#]] %[[#]] %[[#False]] + +; CHECK: %[[#Memset_p0i32]] = OpFunction %[[#]] +; CHECK: %[[#Dest:]] = OpFunctionParameter %[[#]] +; CHECK: %[[#Value:]] = OpFunctionParameter %[[#]] +; CHECK: %[[#Len:]] = OpFunctionParameter %[[#]] +; CHECK: %[[#Volatile:]] = OpFunctionParameter %[[#]] + +; CHECK: %[[#Entry:]] = OpLabel +; CHECK: %[[#IsZeroLen:]] = OpIEqual %[[#]] %[[#Zero:]] %[[#Len]] +; CHECK: OpBranchConditional %[[#IsZeroLen]] %[[#End:]] %[[#WhileBody:]] + +; CHECK: %[[#WhileBody]] = OpLabel +; CHECK: %[[#Offset:]] = OpPhi %[[#]] %[[#Zero]] %[[#Entry]] %[[#OffsetInc:]] %[[#WhileBody]] +; CHECK: %[[#Ptr:]] = OpInBoundsPtrAccessChain %[[#]] %[[#Dest]] %[[#Offset]] +; CHECK: OpStore %[[#Ptr]] %[[#Value]] Aligned 1 +; CHECK: %[[#OffsetInc]] = OpIAdd %[[#]] %[[#Offset]] %[[#One:]] +; CHECK: %[[#NotEnd:]] = OpULessThan %[[#]] %[[#OffsetInc]] %[[#Len]] +; CHECK: OpBranchConditional %[[#NotEnd]] %[[#WhileBody]] %[[#End]] + +; CHECK: %[[#End]] = OpLabel +; CHECK: OpReturn + +; CHECK: OpFunctionEnd %struct.S1 = type { i32, i32, i32 } define spir_func void @_Z5foo11v(%struct.S1 addrspace(4)* noalias nocapture sret(%struct.S1 addrspace(4)*) %agg.result, i32 %s1, i64 %s2, i8 %v) { %x = alloca [4 x i8] %x.bc = bitcast [4 x i8]* %x to i8* - %1 = bitcast %struct.S1 addrspace(4)* %agg.result to i8 addrspace(4)* - tail call void @llvm.memset.p4i8.i32(i8 addrspace(4)* align 4 %1, i8 0, i32 12, i1 false) + %a = bitcast %struct.S1 addrspace(4)* %agg.result to i8 addrspace(4)* + tail call void @llvm.memset.p4i8.i32(i8 addrspace(4)* align 4 %a, i8 0, i32 12, i1 false) tail call void @llvm.memset.p0i8.i32(i8* align 4 %x.bc, i8 21, i32 4, i1 false) ;; non-const value @@ -64,13 +73,13 @@ tail call void @llvm.memset.p0i8.i32(i8* align 4 %x.bc, i8 %v, i32 %s1, i1 false) ;; Address spaces, non-const value and size - %a = addrspacecast i8 addrspace(4)* %1 to i8 addrspace(3)* - tail call void @llvm.memset.p3i8.i32(i8 addrspace(3)* align 4 %a, i8 %v, i32 %s1, i1 false) - %b = addrspacecast i8 addrspace(4)* %1 to i8 addrspace(1)* - tail call void @llvm.memset.p1i8.i64(i8 addrspace(1)* align 4 %b, i8 %v, i64 %s2, i1 false) + %b = addrspacecast i8 addrspace(4)* %a to i8 addrspace(3)* + tail call void @llvm.memset.p3i8.i32(i8 addrspace(3)* align 4 %b, i8 %v, i32 %s1, i1 false) + %c = addrspacecast i8 addrspace(4)* %a to i8 addrspace(1)* + tail call void @llvm.memset.p1i8.i64(i8 addrspace(1)* align 4 %c, i8 %v, i64 %s2, i1 false) ;; Volatile - tail call void @llvm.memset.p1i8.i64(i8 addrspace(1)* align 4 %b, i8 %v, i64 %s2, i1 true) + tail call void @llvm.memset.p1i8.i64(i8 addrspace(1)* align 4 %c, i8 %v, i64 %s2, i1 true) ret void } Index: llvm/test/CodeGen/SPIRV/llvm-intrinsics/sqrt.ll =================================================================== --- llvm/test/CodeGen/SPIRV/llvm-intrinsics/sqrt.ll +++ llvm/test/CodeGen/SPIRV/llvm-intrinsics/sqrt.ll @@ -1,12 +1,12 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s -; CHECK: %[[#ExtInstSetId:]] = OpExtInstImport "OpenCL.std" -; CHECK: %[[#Float:]] = OpTypeFloat 32 -; CHECK: %[[#Double:]] = OpTypeFloat 64 -; CHECK: %[[#Double4:]] = OpTypeVector %[[#Double]] 4 -; CHECK: %[[#FloatArg:]] = OpConstant %[[#Float]] -; CHECK: %[[#DoubleArg:]] = OpConstant %[[#Double]] -; CHECK: %[[#Double4Arg:]] = OpConstantComposite %[[#Double4]] +; CHECK-DAG: %[[#ExtInstSetId:]] = OpExtInstImport "OpenCL.std" +; CHECK-DAG: %[[#Float:]] = OpTypeFloat 32 +; CHECK-DAG: %[[#Double:]] = OpTypeFloat 64 +; CHECK-DAG: %[[#Double4:]] = OpTypeVector %[[#Double]] 4 +; CHECK-DAG: %[[#FloatArg:]] = OpConstant %[[#Float]] +; CHECK-DAG: %[[#DoubleArg:]] = OpConstant %[[#Double]] +; CHECK-DAG: %[[#Double4Arg:]] = OpConstantComposite %[[#Double4]] ;; We need to store sqrt results, otherwise isel does not emit sqrts as dead insts. define spir_func void @test_sqrt(float* %x, double* %y, <4 x double>* %z) { Index: llvm/test/CodeGen/SPIRV/opaque_pointers.ll =================================================================== --- llvm/test/CodeGen/SPIRV/opaque_pointers.ll +++ llvm/test/CodeGen/SPIRV/opaque_pointers.ll @@ -1,11 +1,11 @@ ; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK -; CHECK: %[[#Int8Ty:]] = OpTypeInt 8 0 -; CHECK: %[[#PtrTy:]] = OpTypePointer Function %[[#Int8Ty]] -; CHECK: %[[#Int64Ty:]] = OpTypeInt 64 0 -; CHECK: %[[#FTy:]] = OpTypeFunction %[[#Int64Ty]] %[[#PtrTy]] -; CHECK: %[[#Int32Ty:]] = OpTypeInt 32 0 -; CHECK: %[[#Const:]] = OpConstant %[[#Int32Ty]] 0 +; CHECK-DAG: %[[#Int8Ty:]] = OpTypeInt 8 0 +; CHECK-DAG: %[[#PtrTy:]] = OpTypePointer Function %[[#Int8Ty]] +; CHECK-DAG: %[[#Int64Ty:]] = OpTypeInt 64 0 +; CHECK-DAG: %[[#FTy:]] = OpTypeFunction %[[#Int64Ty]] %[[#PtrTy]] +; CHECK-DAG: %[[#Int32Ty:]] = OpTypeInt 32 0 +; CHECK-DAG: %[[#Const:]] = OpConstant %[[#Int32Ty]] 0 ; CHECK: OpFunction %[[#Int64Ty]] None %[[#FTy]] ; CHECK: %[[#Parm:]] = OpFunctionParameter %[[#PtrTy]] ; CHECK: OpStore %[[#Parm]] %[[#Const]] Aligned 4 Index: llvm/test/CodeGen/SPIRV/opencl.queue_t.ll =================================================================== --- llvm/test/CodeGen/SPIRV/opencl.queue_t.ll +++ /dev/null @@ -1,11 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV - -; CHECK-SPIRV: OpCapability DeviceEnqueue -; CHECK-SPIRV: OpTypeQueue - -%opencl.queue_t = type opaque - -define spir_func void @enqueue_simple_block(%opencl.queue_t* addrspace(3)* nocapture %q) { -entry: - ret void -} Index: llvm/test/CodeGen/SPIRV/opencl/basic/vstore_private.ll =================================================================== --- llvm/test/CodeGen/SPIRV/opencl/basic/vstore_private.ll +++ /dev/null @@ -1,92 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s - -; CHECK: %[[#i16_ty:]] = OpTypeInt 16 0 -; CHECK: %[[#v4xi16_ty:]] = OpTypeVector %[[#i16_ty]] 4 -; CHECK: %[[#pv4xi16_ty:]] = OpTypePointer Function %[[#v4xi16_ty]] -; CHECK: %[[#i16_const0:]] = OpConstant %[[#i16_ty]] 0 -; CHECK: %[[#i16_undef:]] = OpUndef %[[#i16_ty]] -; CHECK: %[[#comp_const:]] = OpConstantComposite %[[#v4xi16_ty]] %[[#i16_const0]] %[[#i16_const0]] %[[#i16_const0]] %[[#i16_undef]] - -; CHECK: %[[#r:]] = OpInBoundsPtrAccessChain -; CHECK: %[[#r2:]] = OpBitcast %[[#pv4xi16_ty]] %[[#r]] -; CHECK: OpStore %[[#r2]] %[[#comp_const]] Aligned 8 - -define spir_kernel void @test_fn(i16 addrspace(1)* %srcValues, i32 addrspace(1)* %offsets, <3 x i16> addrspace(1)* %destBuffer, i32 %alignmentOffset) { -entry: - %sPrivateStorage = alloca [42 x <3 x i16>], align 8 - %0 = bitcast [42 x <3 x i16>]* %sPrivateStorage to i8* - %1 = bitcast i8* %0 to i8* - call void @llvm.lifetime.start.p0i8(i64 336, i8* %1) - %2 = call spir_func <3 x i64> @BuiltInGlobalInvocationId() - %call = extractelement <3 x i64> %2, i32 0 - %conv = trunc i64 %call to i32 - %idxprom = sext i32 %conv to i64 - %arrayidx = getelementptr inbounds [42 x <3 x i16>], [42 x <3 x i16>]* %sPrivateStorage, i64 0, i64 %idxprom - %storetmp = bitcast <3 x i16>* %arrayidx to <4 x i16>* - store <4 x i16> , <4 x i16>* %storetmp, align 8 - %conv1 = sext i32 %conv to i64 - %call2 = call spir_func <3 x i16> @OpenCL_vload3_i64_p1i16_i32(i64 %conv1, i16 addrspace(1)* %srcValues, i32 3) - %idxprom3 = sext i32 %conv to i64 - %arrayidx4 = getelementptr inbounds i32, i32 addrspace(1)* %offsets, i64 %idxprom3 - %3 = load i32, i32 addrspace(1)* %arrayidx4, align 4 - %conv5 = zext i32 %3 to i64 - %arraydecay = getelementptr inbounds [42 x <3 x i16>], [42 x <3 x i16>]* %sPrivateStorage, i64 0, i64 0 - %4 = bitcast <3 x i16>* %arraydecay to i16* - %idx.ext = zext i32 %alignmentOffset to i64 - %add.ptr = getelementptr inbounds i16, i16* %4, i64 %idx.ext - call spir_func void @OpenCL_vstore3_v3i16_i64_p0i16(<3 x i16> %call2, i64 %conv5, i16* %add.ptr) - %arraydecay6 = getelementptr inbounds [42 x <3 x i16>], [42 x <3 x i16>]* %sPrivateStorage, i64 0, i64 0 - %5 = bitcast <3 x i16>* %arraydecay6 to i16* - %idxprom7 = sext i32 %conv to i64 - %arrayidx8 = getelementptr inbounds i32, i32 addrspace(1)* %offsets, i64 %idxprom7 - %6 = load i32, i32 addrspace(1)* %arrayidx8, align 4 - %mul = mul i32 3, %6 - %idx.ext9 = zext i32 %mul to i64 - %add.ptr10 = getelementptr inbounds i16, i16* %5, i64 %idx.ext9 - %idx.ext11 = zext i32 %alignmentOffset to i64 - %add.ptr12 = getelementptr inbounds i16, i16* %add.ptr10, i64 %idx.ext11 - %7 = bitcast <3 x i16> addrspace(1)* %destBuffer to i16 addrspace(1)* - %idxprom13 = sext i32 %conv to i64 - %arrayidx14 = getelementptr inbounds i32, i32 addrspace(1)* %offsets, i64 %idxprom13 - %8 = load i32, i32 addrspace(1)* %arrayidx14, align 4 - %mul15 = mul i32 3, %8 - %idx.ext16 = zext i32 %mul15 to i64 - %add.ptr17 = getelementptr inbounds i16, i16 addrspace(1)* %7, i64 %idx.ext16 - %idx.ext18 = zext i32 %alignmentOffset to i64 - %add.ptr19 = getelementptr inbounds i16, i16 addrspace(1)* %add.ptr17, i64 %idx.ext18 - br label %for.cond - -for.cond: ; preds = %for.inc, %entry - %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ] - %cmp = icmp ult i32 %i.0, 3 - br i1 %cmp, label %for.body, label %for.end - -for.body: ; preds = %for.cond - %idxprom21 = zext i32 %i.0 to i64 - %arrayidx22 = getelementptr inbounds i16, i16* %add.ptr12, i64 %idxprom21 - %9 = load i16, i16* %arrayidx22, align 2 - %idxprom23 = zext i32 %i.0 to i64 - %arrayidx24 = getelementptr inbounds i16, i16 addrspace(1)* %add.ptr19, i64 %idxprom23 - store i16 %9, i16 addrspace(1)* %arrayidx24, align 2 - br label %for.inc - -for.inc: ; preds = %for.body - %inc = add i32 %i.0, 1 - br label %for.cond - -for.end: ; preds = %for.cond - %10 = bitcast [42 x <3 x i16>]* %sPrivateStorage to i8* - %11 = bitcast i8* %10 to i8* - call void @llvm.lifetime.end.p0i8(i64 336, i8* %11) - ret void -} - -declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) - -declare spir_func <3 x i16> @OpenCL_vload3_i64_p1i16_i32(i64, i16 addrspace(1)*, i32) - -declare spir_func void @OpenCL_vstore3_v3i16_i64_p0i16(<3 x i16>, i64, i16*) - -declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) - -declare spir_func <3 x i64> @BuiltInGlobalInvocationId() Index: llvm/test/CodeGen/SPIRV/opencl/device_execution/execute_block.ll =================================================================== --- llvm/test/CodeGen/SPIRV/opencl/device_execution/execute_block.ll +++ /dev/null @@ -1,93 +0,0 @@ -; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s - -; CHECK: %[[#bool:]] = OpTypeBool -; CHECK: %[[#true:]] = OpConstantTrue %[[#bool]] -; CHECK: OpBranchConditional %[[#true]] - -%structtype = type { i32, i32, i8 addrspace(4)* } -%structtype.0 = type <{ i32, i32, i8 addrspace(4)* }> - -@__block_literal_global = internal addrspace(1) constant %structtype { i32 16, i32 8, i8 addrspace(4)* addrspacecast (i8* null to i8 addrspace(4)*) }, align 8 -@__block_literal_global.1 = internal addrspace(1) constant %structtype { i32 16, i32 8, i8 addrspace(4)* addrspacecast (i8* null to i8 addrspace(4)*) }, align 8 -@__block_literal_global.2 = internal addrspace(1) constant %structtype { i32 16, i32 8, i8 addrspace(4)* addrspacecast (i8* null to i8 addrspace(4)*) }, align 8 - -define spir_kernel void @block_typedef_mltpl_stmnt(i32 addrspace(1)* %res) { -entry: - %0 = call spir_func <3 x i64> @BuiltInGlobalInvocationId() - %call = extractelement <3 x i64> %0, i32 0 - %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %res, i64 %call - store i32 -1, i32 addrspace(1)* %arrayidx, align 4 - %1 = bitcast %structtype addrspace(1)* @__block_literal_global to i8 addrspace(1)* - %2 = addrspacecast i8 addrspace(1)* %1 to i8 addrspace(4)* - %3 = bitcast %structtype addrspace(1)* @__block_literal_global.1 to i8 addrspace(1)* - %4 = addrspacecast i8 addrspace(1)* %3 to i8 addrspace(4)* - %5 = bitcast %structtype addrspace(1)* @__block_literal_global.2 to i8 addrspace(1)* - %6 = addrspacecast i8 addrspace(1)* %5 to i8 addrspace(4)* - br label %do.body - -do.body: ; preds = %do.cond, %entry - %a.0 = phi i32 [ undef, %entry ], [ %a.1, %do.cond ] - %call1 = call spir_func float @__block_typedef_mltpl_stmnt_block_invoke(i8 addrspace(4)* %2, float 0.000000e+00) - %call2 = call spir_func i32 @__block_typedef_mltpl_stmnt_block_invoke_2(i8 addrspace(4)* %4, i32 0) - %conv = sitofp i32 %call2 to float - %sub = fsub float %call1, %conv - %cmp = fcmp ogt float %sub, 0.000000e+00 - br i1 %cmp, label %if.then, label %if.end - -if.then: ; preds = %do.body - %call4 = call spir_func i32 @__block_typedef_mltpl_stmnt_block_invoke_3(i8 addrspace(4)* %6, i32 1) - %call5 = call spir_func i32 @__block_typedef_mltpl_stmnt_block_invoke_3(i8 addrspace(4)* %6, i32 2) - %add = add i32 %call4, %call5 - br label %cleanup - -if.end: ; preds = %do.body - br label %cleanup - -cleanup: ; preds = %if.end, %if.then - %a.1 = phi i32 [ %add, %if.then ], [ %a.0, %if.end ] - %cleanup.dest.slot.0 = phi i32 [ 2, %if.then ], [ 0, %if.end ] - switch i32 %cleanup.dest.slot.0, label %unreachable [ - i32 0, label %cleanup.cont - i32 2, label %do.end - ] - -cleanup.cont: ; preds = %cleanup - br label %do.cond - -do.cond: ; preds = %cleanup.cont - br i1 true, label %do.body, label %do.end - -do.end: ; preds = %do.cond, %cleanup - %sub7 = sub nsw i32 %a.1, 11 - %arrayidx8 = getelementptr inbounds i32, i32 addrspace(1)* %res, i64 %call - store i32 %sub7, i32 addrspace(1)* %arrayidx8, align 4 - ret void - -unreachable: ; preds = %cleanup - unreachable -} - -define internal spir_func float @__block_typedef_mltpl_stmnt_block_invoke(i8 addrspace(4)* %.block_descriptor, float %bi) { -entry: - %block = bitcast i8 addrspace(4)* %.block_descriptor to %structtype.0 addrspace(4)* - %conv = fpext float %bi to double - %add = fadd double %conv, 3.300000e+00 - %conv1 = fptrunc double %add to float - ret float %conv1 -} - -define internal spir_func i32 @__block_typedef_mltpl_stmnt_block_invoke_2(i8 addrspace(4)* %.block_descriptor, i32 %bi) { -entry: - %block = bitcast i8 addrspace(4)* %.block_descriptor to %structtype.0 addrspace(4)* - %add = add nsw i32 %bi, 2 - ret i32 %add -} - -define internal spir_func i32 @__block_typedef_mltpl_stmnt_block_invoke_3(i8 addrspace(4)* %.block_descriptor, i32 %bi) { -entry: - %block = bitcast i8 addrspace(4)* %.block_descriptor to %structtype.0 addrspace(4)* - %add = add i32 %bi, 4 - ret i32 %add -} - -declare spir_func <3 x i64> @BuiltInGlobalInvocationId() Index: llvm/test/CodeGen/SPIRV/pstruct.ll =================================================================== --- llvm/test/CodeGen/SPIRV/pstruct.ll +++ /dev/null @@ -1,121 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV - -%struct.ST = type { i32, i32, i32 } - -; CHECK-SPIRV: OpName %[[#struct:]] "struct.ST" -; CHECK-SPIRV: %[[#int:]] = OpTypeInt 32 0 -; CHECK-SPIRV: %[[#intP:]] = OpTypePointer Function %[[#int]] -; CHECK-SPIRV: %[[#struct]] = OpTypeStruct %[[#int]] %[[#int]] %[[#int]] -; CHECK-SPIRV: %[[#structP:]] = OpTypePointer Function %[[#struct]] -; CHECK-SPIRV: %[[#structPP:]] = OpTypePointer Function %[[#structP]] -; CHECK-SPIRV: %[[#zero:]] = OpConstant %[[#int]] 0 -; CHECK-SPIRV: %[[#one:]] = OpConstant %[[#int]] 1 -; CHECK-SPIRV: %[[#two:]] = OpConstant %[[#int]] 2 - -define dso_local spir_func i32 @cmp_func(i8* %p1, i8* %p2) { -entry: - %retval = alloca i32, align 4 - %p1.addr = alloca i8*, align 8 - %p2.addr = alloca i8*, align 8 -; CHECK-SPIRV: %[[#s1:]] = OpVariable %[[#structPP]] -; CHECK-SPIRV: %[[#s2:]] = OpVariable %[[#structPP]] - %s1 = alloca %struct.ST*, align 8 - %s2 = alloca %struct.ST*, align 8 - store i8* %p1, i8** %p1.addr, align 8 - store i8* %p2, i8** %p2.addr, align 8 - %0 = load i8*, i8** %p1.addr, align 8 -; CHECK-SPIRV: %[[#t1:]] = OpBitcast %[[#structP]] -; CHECK-SPIRV: OpStore %[[#s1]] %[[#t1]] - %1 = bitcast i8* %0 to %struct.ST* - store %struct.ST* %1, %struct.ST** %s1, align 8 - %2 = load i8*, i8** %p2.addr, align 8 -; CHECK-SPIRV: %[[#t2:]] = OpBitcast %[[#structP]] -; CHECK-SPIRV: OpStore %[[#s2]] %[[#t2]] - %3 = bitcast i8* %2 to %struct.ST* - store %struct.ST* %3, %struct.ST** %s2, align 8 -; CHECK-SPIRV: %[[#t3:]] = OpLoad %[[#structP]] %[[#s1]] -; CHECK-SPIRV: %[[#a1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t3]] %[[#zero]] %[[#zero]] -; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#a1]] - %4 = load %struct.ST*, %struct.ST** %s1, align 8 - %a = getelementptr inbounds %struct.ST, %struct.ST* %4, i32 0, i32 0 - %5 = load i32, i32* %a, align 4 -; CHECK-SPIRV: %[[#t4:]] = OpLoad %[[#structP]] %[[#s2]] -; CHECK-SPIRV: %[[#a2:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t4]] %[[#zero]] %[[#zero]] -; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#a2]] - %6 = load %struct.ST*, %struct.ST** %s2, align 8 - %a1 = getelementptr inbounds %struct.ST, %struct.ST* %6, i32 0, i32 0 - %7 = load i32, i32* %a1, align 4 - %cmp = icmp ne i32 %5, %7 - br i1 %cmp, label %if.then, label %if.end - -if.then: ; preds = %entry -; CHECK-SPIRV: %[[#t5:]] = OpLoad %[[#structP]] %[[#s1]] -; CHECK-SPIRV: %[[#a_1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t5]] %[[#zero]] %[[#zero]] -; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#a_1]] - %8 = load %struct.ST*, %struct.ST** %s1, align 8 - %a2 = getelementptr inbounds %struct.ST, %struct.ST* %8, i32 0, i32 0 - %9 = load i32, i32* %a2, align 4 -; CHECK-SPIRV: %[[#t6:]] = OpLoad %[[#structP]] %[[#s2]] -; CHECK-SPIRV: %[[#a_2:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t6]] %[[#zero]] %[[#zero]] -; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#a_2]] - %10 = load %struct.ST*, %struct.ST** %s2, align 8 - %a3 = getelementptr inbounds %struct.ST, %struct.ST* %10, i32 0, i32 0 - %11 = load i32, i32* %a3, align 4 - %sub = sub nsw i32 %9, %11 - store i32 %sub, i32* %retval, align 4 - br label %return - -if.end: ; preds = %entry -; CHECK-SPIRV: %[[#t7:]] = OpLoad %[[#structP]] %[[#s1]] -; CHECK-SPIRV: %[[#b1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t7]] %[[#zero]] %[[#one]] -; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#b1]] - %12 = load %struct.ST*, %struct.ST** %s1, align 8 - %b = getelementptr inbounds %struct.ST, %struct.ST* %12, i32 0, i32 1 - %13 = load i32, i32* %b, align 4 -; CHECK-SPIRV: %[[#t8:]] = OpLoad %[[#structP]] %[[#s2]] -; CHECK-SPIRV: %[[#b2:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t8]] %[[#zero]] %[[#one]] -; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#b2]] - %14 = load %struct.ST*, %struct.ST** %s2, align 8 - %b4 = getelementptr inbounds %struct.ST, %struct.ST* %14, i32 0, i32 1 - %15 = load i32, i32* %b4, align 4 - %cmp5 = icmp ne i32 %13, %15 - br i1 %cmp5, label %if.then6, label %if.end10 - -if.then6: ; preds = %if.end -; CHECK-SPIRV: %[[#t9:]] = OpLoad %[[#structP]] %[[#s1]] -; CHECK-SPIRV: %[[#b_1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t9]] %[[#zero]] %[[#one]] -; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#b_1]] - %16 = load %struct.ST*, %struct.ST** %s1, align 8 - %b7 = getelementptr inbounds %struct.ST, %struct.ST* %16, i32 0, i32 1 - %17 = load i32, i32* %b7, align 4 -; CHECK-SPIRV: %[[#t10:]] = OpLoad %[[#structP]] %[[#s2]] -; CHECK-SPIRV: %[[#b_2:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t10]] %[[#zero]] %[[#one]] -; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#b_2]] - %18 = load %struct.ST*, %struct.ST** %s2, align 8 - %b8 = getelementptr inbounds %struct.ST, %struct.ST* %18, i32 0, i32 1 - %19 = load i32, i32* %b8, align 4 - %sub9 = sub nsw i32 %17, %19 - store i32 %sub9, i32* %retval, align 4 - br label %return - -if.end10: ; preds = %if.end -; CHECK-SPIRV: %[[#t11:]] = OpLoad %[[#structP]] %[[#s1]] -; CHECK-SPIRV: %[[#c1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t11]] %[[#zero]] %[[#two]] -; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#c1]] - %20 = load %struct.ST*, %struct.ST** %s1, align 8 - %c = getelementptr inbounds %struct.ST, %struct.ST* %20, i32 0, i32 2 - %21 = load i32, i32* %c, align 4 -; CHECK-SPIRV: %[[#t12:]] = OpLoad %[[#structP]] %[[#s2]] -; CHECK-SPIRV: %[[#c2:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t12]] %[[#zero]] %[[#two]] -; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#c2]] - %22 = load %struct.ST*, %struct.ST** %s2, align 8 - %c11 = getelementptr inbounds %struct.ST, %struct.ST* %22, i32 0, i32 2 - %23 = load i32, i32* %c11, align 4 - %sub12 = sub nsw i32 %21, %23 - store i32 %sub12, i32* %retval, align 4 - br label %return - -return: ; preds = %if.end10, %if.then6, %if.then - %24 = load i32, i32* %retval, align 4 - ret i32 %24 -} Index: llvm/test/CodeGen/SPIRV/read_image.ll =================================================================== --- llvm/test/CodeGen/SPIRV/read_image.ll +++ /dev/null @@ -1,50 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV - -; CHECK-SPIRV: %[[#IntTy:]] = OpTypeInt -; CHECK-SPIRV: %[[#IVecTy:]] = OpTypeVector %[[#IntTy]] -; CHECK-SPIRV: %[[#FloatTy:]] = OpTypeFloat -; CHECK-SPIRV: %[[#FVecTy:]] = OpTypeVector %[[#FloatTy]] -; CHECK-SPIRV: OpImageRead %[[#IVecTy]] -; CHECK-SPIRV: OpImageRead %[[#FVecTy]] - -;; __kernel void kernelA(__read_only image3d_t input) { -;; uint4 c = read_imageui(input, (int4)(0, 0, 0, 0)); -;; } -;; -;; __kernel void kernelB(__read_only image3d_t input) { -;; float4 f = read_imagef(input, (int4)(0, 0, 0, 0)); -;; } - -%opencl.image3d_ro_t = type opaque - -define dso_local spir_kernel void @kernelA(%opencl.image3d_ro_t addrspace(1)* %input) { -entry: - %input.addr = alloca %opencl.image3d_ro_t addrspace(1)*, align 8 - %c = alloca <4 x i32>, align 16 - %.compoundliteral = alloca <4 x i32>, align 16 - store %opencl.image3d_ro_t addrspace(1)* %input, %opencl.image3d_ro_t addrspace(1)** %input.addr, align 8 - %0 = load %opencl.image3d_ro_t addrspace(1)*, %opencl.image3d_ro_t addrspace(1)** %input.addr, align 8 - store <4 x i32> zeroinitializer, <4 x i32>* %.compoundliteral, align 16 - %1 = load <4 x i32>, <4 x i32>* %.compoundliteral, align 16 - %call = call spir_func <4 x i32> @_Z12read_imageui14ocl_image3d_roDv4_i(%opencl.image3d_ro_t addrspace(1)* %0, <4 x i32> noundef %1) - store <4 x i32> %call, <4 x i32>* %c, align 16 - ret void -} - -declare spir_func <4 x i32> @_Z12read_imageui14ocl_image3d_roDv4_i(%opencl.image3d_ro_t addrspace(1)*, <4 x i32> noundef) - -define dso_local spir_kernel void @kernelB(%opencl.image3d_ro_t addrspace(1)* %input) { -entry: - %input.addr = alloca %opencl.image3d_ro_t addrspace(1)*, align 8 - %f = alloca <4 x float>, align 16 - %.compoundliteral = alloca <4 x i32>, align 16 - store %opencl.image3d_ro_t addrspace(1)* %input, %opencl.image3d_ro_t addrspace(1)** %input.addr, align 8 - %0 = load %opencl.image3d_ro_t addrspace(1)*, %opencl.image3d_ro_t addrspace(1)** %input.addr, align 8 - store <4 x i32> zeroinitializer, <4 x i32>* %.compoundliteral, align 16 - %1 = load <4 x i32>, <4 x i32>* %.compoundliteral, align 16 - %call = call spir_func <4 x float> @_Z11read_imagef14ocl_image3d_roDv4_i(%opencl.image3d_ro_t addrspace(1)* %0, <4 x i32> noundef %1) - store <4 x float> %call, <4 x float>* %f, align 16 - ret void -} - -declare spir_func <4 x float> @_Z11read_imagef14ocl_image3d_roDv4_i(%opencl.image3d_ro_t addrspace(1)*, <4 x i32> noundef) Index: llvm/test/CodeGen/SPIRV/struct.ll =================================================================== --- llvm/test/CodeGen/SPIRV/struct.ll +++ llvm/test/CodeGen/SPIRV/struct.ll @@ -1,16 +1,17 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s %struct.ST = type { i32, i32, i32 } -; CHECK-SPIRV: OpName %[[#struct:]] "struct.ST" -; CHECK-SPIRV: %[[#int:]] = OpTypeInt 32 0 -; CHECK-SPIRV-DAG: %[[#struct]] = OpTypeStruct %[[#int]] %[[#int]] %[[#int]] -; CHECK-SPIRV-DAG: %[[#structP:]] = OpTypePointer Function %[[#struct]] -; CHECK-SPIRV-DAG: %[[#intP:]] = OpTypePointer Function %[[#int]] -; CHECK-SPIRV: %[[#zero:]] = OpConstant %[[#int]] 0 -; CHECK-SPIRV: %[[#one:]] = OpConstant %[[#int]] 1 -; CHECK-SPIRV: %[[#two:]] = OpConstant %[[#int]] 2 -; CHECK-SPIRV: %[[#three:]] = OpConstant %[[#int]] 3 +; CHECK-DAG: OpName %[[#struct:]] "struct.ST" +; CHECK-DAG: %[[#char:]] = OpTypeInt 8 0 +; CHECK-DAG: %[[#int:]] = OpTypeInt 32 0 +; CHECK-DAG: %[[#struct]] = OpTypeStruct %[[#int]] %[[#int]] %[[#int]] +; CHECK-DAG: %[[#structP:]] = OpTypePointer Function %[[#struct]] +; CHECK-DAG: %[[#intP:]] = OpTypePointer Function %[[#char]] +; CHECK-DAG: %[[#zero:]] = OpConstant %[[#int]] 0 +; CHECK-DAG: %[[#one:]] = OpConstant %[[#int]] 1 +; CHECK-DAG: %[[#two:]] = OpConstant %[[#int]] 2 +; CHECK-DAG: %[[#three:]] = OpConstant %[[#int]] 3 define dso_local spir_func i32 @func() { entry: Index: llvm/test/CodeGen/SPIRV/transcoding/BuildNDRange_2.ll =================================================================== --- llvm/test/CodeGen/SPIRV/transcoding/BuildNDRange_2.ll +++ /dev/null @@ -1,78 +0,0 @@ -;; Test what ndrange_2D and ndrange_3D can coexist in the same module -;; -;; bash$ cat BuildNDRange_2.cl -;; void test_ndrange_2D3D() { -;; size_t lsize2[2] = {1, 1}; -;; ndrange_2D(lsize2); -;; -;; size_t lsize3[3] = {1, 1, 1}; -;; ndrange_3D(lsize3); -;; } -;; -;; void test_ndrange_const_2D3D() { -;; const size_t lsize2[2] = {1, 1}; -;; ndrange_2D(lsize2); -;; -;; const size_t lsize3[3] = {1, 1, 1}; -;; ndrange_3D(lsize3); -;; } -;; bash$ $PATH_TO_GEN/bin/clang -cc1 -x cl -cl-std=CL2.0 -triple spir64-unknown-unknown -emit-llvm -include opencl-20.h BuildNDRange_2.cl -o BuildNDRange_2.ll - -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV - -; CHECK-SPIRV-DAG: %[[#LEN2_ID:]] = OpConstant %[[#]] 2 -; CHECK-SPIRV-DAG: %[[#LEN3_ID:]] = OpConstant %[[#]] 3 -; CHECK-SPIRV-DAG: %[[#ARRAY_T2:]] = OpTypeArray %[[#]] %[[#LEN2_ID]] -; CHECK-SPIRV-DAG: %[[#ARRAY_T3:]] = OpTypeArray %[[#]] %[[#LEN3_ID]] - -; CHECK-SPIRV-LABEL: OpFunction -; CHECK-SPIRV: %[[#LOAD2_ID:]] = OpLoad %[[#ARRAY_T2]] -; CHECK-SPIRV: %[[#]] = OpBuildNDRange %[[#]] %[[#LOAD2_ID]] -; CHECK-SPIRV: %[[#LOAD3_ID:]] = OpLoad %[[#ARRAY_T3]] -; CHECK-SPIRV: %[[#]] = OpBuildNDRange %[[#]] %[[#LOAD3_ID]] -; CHECK-SPIRV-LABEL: OpFunctionEnd - -; CHECK-SPIRV-LABEL: OpFunction -; CHECK-SPIRV: %[[#CONST_LOAD2_ID:]] = OpLoad %[[#ARRAY_T2]] -; CHECK-SPIRV: %[[#]] = OpBuildNDRange %[[#]] %[[#CONST_LOAD2_ID]] -; CHECK-SPIRV: %[[#CONST_LOAD3_ID:]] = OpLoad %[[#ARRAY_T3]] -; CHECK-SPIRV: %[[#]] = OpBuildNDRange %[[#]] %[[#CONST_LOAD3_ID]] -; CHECK-SPIRV-LABEL: OpFunctionEnd - -%struct.ndrange_t = type { i32, [3 x i64], [3 x i64], [3 x i64] } - -@test_ndrange_2D3D.lsize2 = private constant [2 x i64] [i64 1, i64 1], align 8 -@test_ndrange_2D3D.lsize3 = private constant [3 x i64] [i64 1, i64 1, i64 1], align 8 - - -define spir_func void @test_ndrange_2D3D() { -entry: - %lsize2 = alloca [2 x i64], align 8 - %tmp = alloca %struct.ndrange_t, align 8 - %lsize3 = alloca [3 x i64], align 8 - %tmp3 = alloca %struct.ndrange_t, align 8 - %0 = bitcast [2 x i64]* %lsize2 to i8* - call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %0, i8* align 8 bitcast ([2 x i64]* @test_ndrange_2D3D.lsize2 to i8*), i64 16, i1 false) - %arraydecay = getelementptr inbounds [2 x i64], [2 x i64]* %lsize2, i64 0, i64 0 - call spir_func void @_Z10ndrange_2DPKm(%struct.ndrange_t* sret(%struct.ndrange_t*) %tmp, i64* %arraydecay) - %1 = bitcast [3 x i64]* %lsize3 to i8* - call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %1, i8* align 8 bitcast ([3 x i64]* @test_ndrange_2D3D.lsize3 to i8*), i64 24, i1 false) - %arraydecay2 = getelementptr inbounds [3 x i64], [3 x i64]* %lsize3, i64 0, i64 0 - call spir_func void @_Z10ndrange_3DPKm(%struct.ndrange_t* sret(%struct.ndrange_t*) %tmp3, i64* %arraydecay2) - ret void -} - -declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i1) - -declare spir_func void @_Z10ndrange_2DPKm(%struct.ndrange_t* sret(%struct.ndrange_t*), i64*) - -declare spir_func void @_Z10ndrange_3DPKm(%struct.ndrange_t* sret(%struct.ndrange_t*), i64*) - -define spir_func void @test_ndrange_const_2D3D() { -entry: - %tmp = alloca %struct.ndrange_t, align 8 - %tmp1 = alloca %struct.ndrange_t, align 8 - call spir_func void @_Z10ndrange_2DPKm(%struct.ndrange_t* sret(%struct.ndrange_t*) %tmp, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @test_ndrange_2D3D.lsize2, i64 0, i64 0)) - call spir_func void @_Z10ndrange_3DPKm(%struct.ndrange_t* sret(%struct.ndrange_t*) %tmp1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @test_ndrange_2D3D.lsize3, i64 0, i64 0)) - ret void -} Index: llvm/test/CodeGen/SPIRV/transcoding/OpConstantSampler.ll =================================================================== --- llvm/test/CodeGen/SPIRV/transcoding/OpConstantSampler.ll +++ llvm/test/CodeGen/SPIRV/transcoding/OpConstantSampler.ll @@ -10,26 +10,23 @@ ;; read_imagef(src, sampler2, 0, 0); ;; } -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ; CHECK-SPIRV: %[[#SamplerID0:]] = OpConstantSampler %[[#]] Repeat 1 Nearest ; CHECK-SPIRV: %[[#SamplerID1:]] = OpConstantSampler %[[#]] None 0 Nearest ; CHECK-SPIRV: %[[#]] = OpSampledImage %[[#]] %[[#]] %[[#SamplerID0]] ; CHECK-SPIRV: %[[#]] = OpSampledImage %[[#]] %[[#]] %[[#SamplerID1]] -%opencl.image2d_ro_t = type opaque -%opencl.sampler_t = type opaque - -define spir_func <4 x float> @foo(%opencl.image2d_ro_t addrspace(1)* %src) local_unnamed_addr { +define spir_func <4 x float> @foo(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %src) local_unnamed_addr { entry: - %0 = tail call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 23) - %1 = tail call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 0) - %call = tail call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_ff(%opencl.image2d_ro_t addrspace(1)* %src, %opencl.sampler_t addrspace(2)* %0, <2 x float> zeroinitializer, float 0.000000e+00) - %call1 = tail call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_ff(%opencl.image2d_ro_t addrspace(1)* %src, %opencl.sampler_t addrspace(2)* %1, <2 x float> zeroinitializer, float 0.000000e+00) + %0 = tail call target("spirv.Sampler") @__translate_sampler_initializer(i32 23) + %1 = tail call target("spirv.Sampler") @__translate_sampler_initializer(i32 0) + %call = tail call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_ff(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %src, target("spirv.Sampler") %0, <2 x float> zeroinitializer, float 0.000000e+00) + %call1 = tail call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_ff(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %src, target("spirv.Sampler") %1, <2 x float> zeroinitializer, float 0.000000e+00) %add = fadd <4 x float> %call, %call1 ret <4 x float> %add } -declare %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32) local_unnamed_addr +declare target("spirv.Sampler") @__translate_sampler_initializer(i32) local_unnamed_addr -declare spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_ff(%opencl.image2d_ro_t addrspace(1)*, %opencl.sampler_t addrspace(2)*, <2 x float>, float) local_unnamed_addr +declare spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_ff(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), target("spirv.Sampler"), <2 x float>, float) local_unnamed_addr Index: llvm/test/CodeGen/SPIRV/transcoding/OpenCL/atomic_cmpxchg.ll =================================================================== --- llvm/test/CodeGen/SPIRV/transcoding/OpenCL/atomic_cmpxchg.ll +++ llvm/test/CodeGen/SPIRV/transcoding/OpenCL/atomic_cmpxchg.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ;; This test checks that the backend is capable to correctly translate ;; atomic_cmpxchg OpenCL C 1.2 built-in function [1] into corresponding SPIR-V @@ -14,8 +14,9 @@ ;; } ; CHECK-SPIRV: OpName %[[#TEST:]] "test_atomic_cmpxchg" +; CHECK-SPIRV-DAG: %[[#UCHAR:]] = OpTypeInt 8 0 ; CHECK-SPIRV-DAG: %[[#UINT:]] = OpTypeInt 32 0 -; CHECK-SPIRV-DAG: %[[#UINT_PTR:]] = OpTypePointer CrossWorkgroup %[[#UINT]] +; CHECK-SPIRV-DAG: %[[#UCHAR_PTR:]] = OpTypePointer CrossWorkgroup %[[#UCHAR]] ;; In SPIR-V, atomic_cmpxchg is represented as OpAtomicCompareExchange [2], ;; which also includes memory scope and two memory semantic arguments. The @@ -30,7 +31,7 @@ ; CHECK-SPIRV-DAG: %[[#RELAXED:]] = OpConstant %[[#UINT]] 0 ; CHECK-SPIRV: %[[#TEST]] = OpFunction %[[#]] -; CHECK-SPIRV: %[[#PTR:]] = OpFunctionParameter %[[#UINT_PTR]] +; CHECK-SPIRV: %[[#PTR:]] = OpFunctionParameter %[[#UCHAR_PTR]] ; CHECK-SPIRV: %[[#CMP:]] = OpFunctionParameter %[[#UINT]] ; CHECK-SPIRV: %[[#VAL:]] = OpFunctionParameter %[[#UINT]] ; CHECK-SPIRV: %[[#]] = OpAtomicCompareExchange %[[#UINT]] %[[#PTR]] %[[#WORKGROUP_SCOPE]] %[[#RELAXED]] %[[#RELAXED]] %[[#VAL]] %[[#CMP]] Index: llvm/test/CodeGen/SPIRV/transcoding/OpenCL/atomic_legacy.ll =================================================================== --- llvm/test/CodeGen/SPIRV/transcoding/OpenCL/atomic_legacy.ll +++ llvm/test/CodeGen/SPIRV/transcoding/OpenCL/atomic_legacy.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ;; This test checks that the backend is capable to correctly translate ;; legacy atomic OpenCL C 1.2 built-in functions [1] into corresponding SPIR-V @@ -11,7 +11,8 @@ ; CHECK-SPIRV: OpName %[[#TEST:]] "test_legacy_atomics" ; CHECK-SPIRV-DAG: %[[#UINT:]] = OpTypeInt 32 0 -; CHECK-SPIRV-DAG: %[[#UINT_PTR:]] = OpTypePointer CrossWorkgroup %[[#UINT]] +; CHECK-SPIRV-DAG: %[[#UCHAR:]] = OpTypeInt 8 0 +; CHECK-SPIRV-DAG: %[[#UCHAR_PTR:]] = OpTypePointer CrossWorkgroup %[[#UCHAR]] ;; In SPIR-V, atomic_add is represented as OpAtomicIAdd [2], which also includes ;; memory scope and memory semantic arguments. The backend applies a default @@ -25,7 +26,7 @@ ; CHECK-SPIRV-DAG: %[[#RELAXED:]] = OpConstant %[[#UINT]] 0 ; CHECK-SPIRV: %[[#TEST]] = OpFunction %[[#]] -; CHECK-SPIRV: %[[#PTR:]] = OpFunctionParameter %[[#UINT_PTR]] +; CHECK-SPIRV: %[[#PTR:]] = OpFunctionParameter %[[#UCHAR_PTR]] ; CHECK-SPIRV: %[[#VAL:]] = OpFunctionParameter %[[#UINT]] ; CHECK-SPIRV: %[[#]] = OpAtomicIAdd %[[#UINT]] %[[#PTR]] %[[#WORKGROUP_SCOPE]] %[[#RELAXED]] %[[#VAL]] ; CHECK-SPIRV: %[[#]] = OpAtomicIAdd %[[#UINT]] %[[#PTR]] %[[#WORKGROUP_SCOPE]] %[[#RELAXED]] %[[#VAL]] Index: llvm/test/CodeGen/SPIRV/transcoding/block_w_struct_return.ll =================================================================== --- llvm/test/CodeGen/SPIRV/transcoding/block_w_struct_return.ll +++ /dev/null @@ -1,107 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV1_4 - -;; TODO: We cannot check SPIR_V 1.1 and 1.4 simultaneously, implement additional -;; run with CHECK-SPIRV1_1. - -;; kernel void block_ret_struct(__global int* res) -;; { -;; struct A { -;; int a; -;; }; -;; struct A (^kernelBlock)(struct A) = ^struct A(struct A a) -;; { -;; a.a = 6; -;; return a; -;; }; -;; size_t tid = get_global_id(0); -;; res[tid] = -1; -;; struct A aa; -;; aa.a = 5; -;; res[tid] = kernelBlock(aa).a - 6; -;; } - -; CHECK-SPIRV1_4: OpEntryPoint Kernel %[[#]] "block_ret_struct" %[[#InterdaceId1:]] %[[#InterdaceId2:]] -; CHECK-SPIRV1_4: OpName %[[#InterdaceId1]] "__block_literal_global" -; CHECK-SPIRV1_4: OpName %[[#InterdaceId2]] "__spirv_BuiltInGlobalInvocationId" - -; CHECK-SPIRV1_1: OpEntryPoint Kernel %[[#]] "block_ret_struct" %[[#InterdaceId1:]] -; CHECK-SPIRV1_1: OpName %[[#InterdaceId1]] "__spirv_BuiltInGlobalInvocationId" - -; CHECK-SPIRV: OpName %[[#BlockInv:]] "__block_ret_struct_block_invoke" - -; CHECK-SPIRV: %[[#IntTy:]] = OpTypeInt 32 -; CHECK-SPIRV: %[[#Int8Ty:]] = OpTypeInt 8 -; CHECK-SPIRV: %[[#Int8Ptr:]] = OpTypePointer Generic %[[#Int8Ty]] -; CHECK-SPIRV: %[[#StructTy:]] = OpTypeStruct %[[#IntTy]]{{$}} -; CHECK-SPIRV: %[[#StructPtrTy:]] = OpTypePointer Function %[[#StructTy]] - -; CHECK-SPIRV: %[[#StructArg:]] = OpVariable %[[#StructPtrTy]] Function -; CHECK-SPIRV: %[[#StructRet:]] = OpVariable %[[#StructPtrTy]] Function -; CHECK-SPIRV: %[[#BlockLit:]] = OpPtrCastToGeneric %[[#Int8Ptr]] %[[#]] -; CHECK-SPIRV: %[[#]] = OpFunctionCall %[[#]] %[[#BlockInv]] %[[#StructRet]] %[[#BlockLit]] %[[#StructArg]] - -%struct.__opencl_block_literal_generic = type { i32, i32, i8 addrspace(4)* } -%struct.A = type { i32 } - -@__block_literal_global = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 12, i32 4, i8 addrspace(4)* addrspacecast (i8* bitcast (void (%struct.A*, i8 addrspace(4)*, %struct.A*)* @__block_ret_struct_block_invoke to i8*) to i8 addrspace(4)*) }, align 4 - -define dso_local spir_kernel void @block_ret_struct(i32 addrspace(1)* noundef %res) { -entry: - %res.addr = alloca i32 addrspace(1)*, align 4 - %kernelBlock = alloca %struct.__opencl_block_literal_generic addrspace(4)*, align 4 - %tid = alloca i32, align 4 - %aa = alloca %struct.A, align 4 - %tmp = alloca %struct.A, align 4 - store i32 addrspace(1)* %res, i32 addrspace(1)** %res.addr, align 4 - %0 = bitcast %struct.__opencl_block_literal_generic addrspace(4)** %kernelBlock to i8* - call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) - store %struct.__opencl_block_literal_generic addrspace(4)* addrspacecast (%struct.__opencl_block_literal_generic addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* @__block_literal_global to %struct.__opencl_block_literal_generic addrspace(1)*) to %struct.__opencl_block_literal_generic addrspace(4)*), %struct.__opencl_block_literal_generic addrspace(4)** %kernelBlock, align 4 - %1 = bitcast i32* %tid to i8* - call void @llvm.lifetime.start.p0i8(i64 4, i8* %1) - %call = call spir_func i32 @_Z13get_global_idj(i32 noundef 0) - store i32 %call, i32* %tid, align 4 - %2 = load i32 addrspace(1)*, i32 addrspace(1)** %res.addr, align 4 - %3 = load i32, i32* %tid, align 4 - %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %2, i32 %3 - store i32 -1, i32 addrspace(1)* %arrayidx, align 4 - %4 = bitcast %struct.A* %aa to i8* - call void @llvm.lifetime.start.p0i8(i64 4, i8* %4) - %a = getelementptr inbounds %struct.A, %struct.A* %aa, i32 0, i32 0 - store i32 5, i32* %a, align 4 - call spir_func void @__block_ret_struct_block_invoke(%struct.A* sret(%struct.A) align 4 %tmp, i8 addrspace(4)* noundef addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* @__block_literal_global to i8 addrspace(1)*) to i8 addrspace(4)*), %struct.A* noundef byval(%struct.A) align 4 %aa) - %a1 = getelementptr inbounds %struct.A, %struct.A* %tmp, i32 0, i32 0 - %5 = load i32, i32* %a1, align 4 - %sub = sub nsw i32 %5, 6 - %6 = load i32 addrspace(1)*, i32 addrspace(1)** %res.addr, align 4 - %7 = load i32, i32* %tid, align 4 - %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %6, i32 %7 - store i32 %sub, i32 addrspace(1)* %arrayidx2, align 4 - %8 = bitcast %struct.A* %aa to i8* - call void @llvm.lifetime.end.p0i8(i64 4, i8* %8) - %9 = bitcast i32* %tid to i8* - call void @llvm.lifetime.end.p0i8(i64 4, i8* %9) - %10 = bitcast %struct.__opencl_block_literal_generic addrspace(4)** %kernelBlock to i8* - call void @llvm.lifetime.end.p0i8(i64 4, i8* %10) - ret void -} - -declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) - -define internal spir_func void @__block_ret_struct_block_invoke(%struct.A* noalias sret(%struct.A) align 4 %agg.result, i8 addrspace(4)* noundef %.block_descriptor, %struct.A* noundef byval(%struct.A) align 4 %a) { -entry: - %.block_descriptor.addr = alloca i8 addrspace(4)*, align 4 - store i8 addrspace(4)* %.block_descriptor, i8 addrspace(4)** %.block_descriptor.addr, align 4 - %block = bitcast i8 addrspace(4)* %.block_descriptor to <{ i32, i32, i8 addrspace(4)* }> addrspace(4)* - %a1 = getelementptr inbounds %struct.A, %struct.A* %a, i32 0, i32 0 - store i32 6, i32* %a1, align 4 - %0 = bitcast %struct.A* %agg.result to i8* - %1 = bitcast %struct.A* %a to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 %1, i32 4, i1 false) - ret void -} - -declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) - -declare spir_func i32 @_Z13get_global_idj(i32 noundef) - -declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) Index: llvm/test/CodeGen/SPIRV/transcoding/enqueue_kernel.ll =================================================================== --- llvm/test/CodeGen/SPIRV/transcoding/enqueue_kernel.ll +++ /dev/null @@ -1,385 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV - -; CHECK-SPIRV: OpEntryPoint Kernel %[[#BlockKer1:]] "__device_side_enqueue_block_invoke_kernel" -; CHECK-SPIRV: OpEntryPoint Kernel %[[#BlockKer2:]] "__device_side_enqueue_block_invoke_2_kernel" -; CHECK-SPIRV: OpEntryPoint Kernel %[[#BlockKer3:]] "__device_side_enqueue_block_invoke_3_kernel" -; CHECK-SPIRV: OpEntryPoint Kernel %[[#BlockKer4:]] "__device_side_enqueue_block_invoke_4_kernel" -; CHECK-SPIRV: OpEntryPoint Kernel %[[#BlockKer5:]] "__device_side_enqueue_block_invoke_5_kernel" -; CHECK-SPIRV: OpName %[[#BlockGlb1:]] "__block_literal_global" -; CHECK-SPIRV: OpName %[[#BlockGlb2:]] "__block_literal_global.1" - -; CHECK-SPIRV: %[[#Int32Ty:]] = OpTypeInt 32 -; CHECK-SPIRV: %[[#Int8Ty:]] = OpTypeInt 8 -; CHECK-SPIRV: %[[#VoidTy:]] = OpTypeVoid -; CHECK-SPIRV: %[[#Int8PtrGenTy:]] = OpTypePointer Generic %[[#Int8Ty]] -; CHECK-SPIRV: %[[#EventTy:]] = OpTypeDeviceEvent -; CHECK-SPIRV: %[[#EventPtrTy:]] = OpTypePointer Generic %[[#EventTy]] -; CHECK-SPIRV: %[[#Int32LocPtrTy:]] = OpTypePointer Function %[[#Int32Ty]] -; CHECK-SPIRV: %[[#BlockStructTy:]] = OpTypeStruct -; CHECK-SPIRV: %[[#BlockStructLocPtrTy:]] = OpTypePointer Function %[[#BlockStructTy]] -; CHECK-SPIRV: %[[#BlockTy1:]] = OpTypeFunction %[[#VoidTy]] %[[#Int8PtrGenTy]] -; CHECK-SPIRV: %[[#BlockTy2:]] = OpTypeFunction %[[#VoidTy]] %[[#Int8PtrGenTy]] -; CHECK-SPIRV: %[[#BlockTy3:]] = OpTypeFunction %[[#VoidTy]] %[[#Int8PtrGenTy]] - -; CHECK-SPIRV: %[[#ConstInt0:]] = OpConstant %[[#Int32Ty]] 0 -; CHECK-SPIRV: %[[#EventNull:]] = OpConstantNull %[[#EventPtrTy]] -; CHECK-SPIRV: %[[#ConstInt21:]] = OpConstant %[[#Int32Ty]] 21 -; CHECK-SPIRV: %[[#ConstInt8:]] = OpConstant %[[#Int32Ty]] 8 -; CHECK-SPIRV: %[[#ConstInt24:]] = OpConstant %[[#Int32Ty]] 24 -; CHECK-SPIRV: %[[#ConstInt12:]] = OpConstant %[[#Int32Ty]] 12 -; CHECK-SPIRV: %[[#ConstInt2:]] = OpConstant %[[#Int32Ty]] 2 - -;; typedef struct {int a;} ndrange_t; -;; #define NULL ((void*)0) - -;; kernel void device_side_enqueue(global int *a, global int *b, int i, char c0) { -;; queue_t default_queue; -;; unsigned flags = 0; -;; ndrange_t ndrange; -;; clk_event_t clk_event; -;; clk_event_t event_wait_list; -;; clk_event_t event_wait_list2[] = {clk_event}; - -;; Emits block literal on stack and block kernel. - -; CHECK-SPIRV: %[[#BlockLitPtr1:]] = OpBitcast %[[#BlockStructLocPtrTy]] -; CHECK-SPIRV-NEXT: %[[#BlockLit1:]] = OpPtrCastToGeneric %[[#Int8PtrGenTy]] %[[#BlockLitPtr1]] -; CHECK-SPIRV-NEXT: %[[#]] = OpEnqueueKernel %[[#Int32Ty]] %[[#]] %[[#]] %[[#]] %[[#ConstInt0]] %[[#EventNull]] %[[#EventNull]] %[[#BlockKer1]] %[[#BlockLit1]] %[[#ConstInt21]] %[[#ConstInt8]] - -;; enqueue_kernel(default_queue, flags, ndrange, -;; ^(void) { -;; a[i] = c0; -;; }); - -;; Emits block literal on stack and block kernel. - -; CHECK-SPIRV: %[[#Event1:]] = OpPtrCastToGeneric %[[#EventPtrTy]] -; CHECK-SPIRV: %[[#Event2:]] = OpPtrCastToGeneric %[[#EventPtrTy]] -; CHECK-SPIRV: %[[#BlockLitPtr2:]] = OpBitcast %[[#BlockStructLocPtrTy]] -; CHECK-SPIRV-NEXT: %[[#BlockLit2:]] = OpPtrCastToGeneric %[[#Int8PtrGenTy]] %[[#BlockLitPtr2]] -; CHECK-SPIRV-NEXT: %[[#]] = OpEnqueueKernel %[[#Int32Ty]] %[[#]] %[[#]] %[[#]] %[[#ConstInt2]] %[[#Event1]] %[[#Event2]] %[[#BlockKer2]] %[[#BlockLit2]] %[[#ConstInt24]] %[[#ConstInt8]] - -;; enqueue_kernel(default_queue, flags, ndrange, 2, &event_wait_list, &clk_event, -;; ^(void) { -;; a[i] = b[i]; -;; }); - -;; char c; -;; Emits global block literal and block kernel. - -; CHECK-SPIRV: %[[#Event1:]] = OpPtrCastToGeneric %[[#EventPtrTy]] -; CHECK-SPIRV: %[[#Event2:]] = OpPtrCastToGeneric %[[#EventPtrTy]] -; CHECK-SPIRV: %[[#BlockLit3Tmp:]] = OpBitcast %[[#]] %[[#BlockGlb1]] -; CHECK-SPIRV: %[[#BlockLit3:]] = OpPtrCastToGeneric %[[#Int8PtrGenTy]] %[[#BlockLit3Tmp]] -; CHECK-SPIRV: %[[#LocalBuf31:]] = OpPtrAccessChain %[[#Int32LocPtrTy]] -; CHECK-SPIRV: %[[#]] = OpEnqueueKernel %[[#Int32Ty]] %[[#]] %[[#]] %[[#]] %[[#ConstInt2]] %[[#Event1]] %[[#Event2]] %[[#BlockKer3]] %[[#BlockLit3]] %[[#ConstInt12]] %[[#ConstInt8]] %[[#LocalBuf31]] - -;; enqueue_kernel(default_queue, flags, ndrange, 2, event_wait_list2, &clk_event, -;; ^(local void *p) { -;; return; -;; }, -;; c); - -;; Emits global block literal and block kernel. - -; CHECK-SPIRV: %[[#BlockLit4Tmp:]] = OpBitcast %[[#]] %[[#BlockGlb2]] -; CHECK-SPIRV: %[[#BlockLit4:]] = OpPtrCastToGeneric %[[#Int8PtrGenTy]] %[[#BlockLit4Tmp]] -; CHECK-SPIRV: %[[#LocalBuf41:]] = OpPtrAccessChain %[[#Int32LocPtrTy]] -; CHECK-SPIRV-NEXT: %[[#LocalBuf42:]] = OpPtrAccessChain %[[#Int32LocPtrTy]] -; CHECK-SPIRV-NEXT: %[[#LocalBuf43:]] = OpPtrAccessChain %[[#Int32LocPtrTy]] -; CHECK-SPIRV-NEXT: %[[#]] = OpEnqueueKernel %[[#Int32Ty]] %[[#]] %[[#]] %[[#]] %[[#ConstInt0]] %[[#EventNull]] %[[#EventNull]] %[[#BlockKer4]] %[[#BlockLit4]] %[[#ConstInt12]] %[[#ConstInt8]] %[[#LocalBuf41]] %[[#LocalBuf42]] %[[#LocalBuf43]] - -;; enqueue_kernel(default_queue, flags, ndrange, -;; ^(local void *p1, local void *p2, local void *p3) { -;; return; -;; }, -;; 1, 2, 4); - -;; Emits block literal on stack and block kernel. - -; CHECK-SPIRV: %[[#Event1:]] = OpPtrCastToGeneric %[[#EventPtrTy]] -; CHECK-SPIRV: %[[#BlockLit5Tmp:]] = OpBitcast %[[#BlockStructLocPtrTy]] -; CHECK-SPIRV-NEXT: %[[#BlockLit5:]] = OpPtrCastToGeneric %[[#Int8PtrGenTy]] %[[#BlockLit5Tmp]] -; CHECK-SPIRV-NEXT: %[[#]] = OpEnqueueKernel %[[#Int32Ty]] %[[#]] %[[#]] %[[#]] %[[#ConstInt0]] %[[#EventNull]] %[[#Event1]] %[[#BlockKer5]] %[[#BlockLit5]] %[[#ConstInt24]] %[[#ConstInt8]] - -;; enqueue_kernel(default_queue, flags, ndrange, 0, NULL, &clk_event, -;; ^(void) { -;; a[i] = b[i]; -;; }); -;; } - -; CHECK-SPIRV-DAG: %[[#BlockKer1]] = OpFunction %[[#VoidTy]] None %[[#BlockTy1]] -; CHECK-SPIRV-DAG: %[[#BlockKer2]] = OpFunction %[[#VoidTy]] None %[[#BlockTy1]] -; CHECK-SPIRV-DAG: %[[#BlockKer3]] = OpFunction %[[#VoidTy]] None %[[#BlockTy3]] -; CHECK-SPIRV-DAG: %[[#BlockKer4]] = OpFunction %[[#VoidTy]] None %[[#BlockTy2]] -; CHECK-SPIRV-DAG: %[[#BlockKer5]] = OpFunction %[[#VoidTy]] None %[[#BlockTy1]] - -%opencl.queue_t = type opaque -%struct.ndrange_t = type { i32 } -%opencl.clk_event_t = type opaque -%struct.__opencl_block_literal_generic = type { i32, i32, i8 addrspace(4)* } - -@__block_literal_global = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 12, i32 4, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* @__device_side_enqueue_block_invoke_3 to i8*) to i8 addrspace(4)*) }, align 4 -@__block_literal_global.1 = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 12, i32 4, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*, i8 addrspace(3)*, i8 addrspace(3)*)* @__device_side_enqueue_block_invoke_4 to i8*) to i8 addrspace(4)*) }, align 4 - -define dso_local spir_kernel void @device_side_enqueue(i32 addrspace(1)* noundef %a, i32 addrspace(1)* noundef %b, i32 noundef %i, i8 noundef signext %c0) { -entry: - %a.addr = alloca i32 addrspace(1)*, align 4 - %b.addr = alloca i32 addrspace(1)*, align 4 - %i.addr = alloca i32, align 4 - %c0.addr = alloca i8, align 1 - %default_queue = alloca %opencl.queue_t*, align 4 - %flags = alloca i32, align 4 - %ndrange = alloca %struct.ndrange_t, align 4 - %clk_event = alloca %opencl.clk_event_t*, align 4 - %event_wait_list = alloca %opencl.clk_event_t*, align 4 - %event_wait_list2 = alloca [1 x %opencl.clk_event_t*], align 4 - %tmp = alloca %struct.ndrange_t, align 4 - %block = alloca <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>, align 4 - %tmp3 = alloca %struct.ndrange_t, align 4 - %block4 = alloca <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, align 4 - %c = alloca i8, align 1 - %tmp11 = alloca %struct.ndrange_t, align 4 - %block_sizes = alloca [1 x i32], align 4 - %tmp12 = alloca %struct.ndrange_t, align 4 - %block_sizes13 = alloca [3 x i32], align 4 - %tmp14 = alloca %struct.ndrange_t, align 4 - %block15 = alloca <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, align 4 - store i32 addrspace(1)* %a, i32 addrspace(1)** %a.addr, align 4 - store i32 addrspace(1)* %b, i32 addrspace(1)** %b.addr, align 4 - store i32 %i, i32* %i.addr, align 4 - store i8 %c0, i8* %c0.addr, align 1 - store i32 0, i32* %flags, align 4 - %arrayinit.begin = getelementptr inbounds [1 x %opencl.clk_event_t*], [1 x %opencl.clk_event_t*]* %event_wait_list2, i32 0, i32 0 - %0 = load %opencl.clk_event_t*, %opencl.clk_event_t** %clk_event, align 4 - store %opencl.clk_event_t* %0, %opencl.clk_event_t** %arrayinit.begin, align 4 - %1 = load %opencl.queue_t*, %opencl.queue_t** %default_queue, align 4 - %2 = load i32, i32* %flags, align 4 - %3 = bitcast %struct.ndrange_t* %tmp to i8* - %4 = bitcast %struct.ndrange_t* %ndrange to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 4, i1 false) - %block.size = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>* %block, i32 0, i32 0 - store i32 21, i32* %block.size, align 4 - %block.align = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>* %block, i32 0, i32 1 - store i32 4, i32* %block.align, align 4 - %block.invoke = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>* %block, i32 0, i32 2 - store i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* @__device_side_enqueue_block_invoke to i8*) to i8 addrspace(4)*), i8 addrspace(4)** %block.invoke, align 4 - %block.captured = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>* %block, i32 0, i32 3 - %5 = load i32 addrspace(1)*, i32 addrspace(1)** %a.addr, align 4 - store i32 addrspace(1)* %5, i32 addrspace(1)** %block.captured, align 4 - %block.captured1 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>* %block, i32 0, i32 4 - %6 = load i32, i32* %i.addr, align 4 - store i32 %6, i32* %block.captured1, align 4 - %block.captured2 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>* %block, i32 0, i32 5 - %7 = load i8, i8* %c0.addr, align 1 - store i8 %7, i8* %block.captured2, align 4 - %8 = bitcast <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>* %block to %struct.__opencl_block_literal_generic* - %9 = addrspacecast %struct.__opencl_block_literal_generic* %8 to i8 addrspace(4)* - %10 = call spir_func i32 @__enqueue_kernel_basic(%opencl.queue_t* %1, i32 %2, %struct.ndrange_t* byval(%struct.ndrange_t) %tmp, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* @__device_side_enqueue_block_invoke_kernel to i8*) to i8 addrspace(4)*), i8 addrspace(4)* %9) - %11 = load %opencl.queue_t*, %opencl.queue_t** %default_queue, align 4 - %12 = load i32, i32* %flags, align 4 - %13 = bitcast %struct.ndrange_t* %tmp3 to i8* - %14 = bitcast %struct.ndrange_t* %ndrange to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %13, i8* align 4 %14, i32 4, i1 false) - %15 = addrspacecast %opencl.clk_event_t** %event_wait_list to %opencl.clk_event_t* addrspace(4)* - %16 = addrspacecast %opencl.clk_event_t** %clk_event to %opencl.clk_event_t* addrspace(4)* - %block.size5 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block4, i32 0, i32 0 - store i32 24, i32* %block.size5, align 4 - %block.align6 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block4, i32 0, i32 1 - store i32 4, i32* %block.align6, align 4 - %block.invoke7 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block4, i32 0, i32 2 - store i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* @__device_side_enqueue_block_invoke_2 to i8*) to i8 addrspace(4)*), i8 addrspace(4)** %block.invoke7, align 4 - %block.captured8 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block4, i32 0, i32 3 - %17 = load i32 addrspace(1)*, i32 addrspace(1)** %a.addr, align 4 - store i32 addrspace(1)* %17, i32 addrspace(1)** %block.captured8, align 4 - %block.captured9 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block4, i32 0, i32 4 - %18 = load i32, i32* %i.addr, align 4 - store i32 %18, i32* %block.captured9, align 4 - %block.captured10 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block4, i32 0, i32 5 - %19 = load i32 addrspace(1)*, i32 addrspace(1)** %b.addr, align 4 - store i32 addrspace(1)* %19, i32 addrspace(1)** %block.captured10, align 4 - %20 = bitcast <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block4 to %struct.__opencl_block_literal_generic* - %21 = addrspacecast %struct.__opencl_block_literal_generic* %20 to i8 addrspace(4)* - %22 = call spir_func i32 @__enqueue_kernel_basic_events(%opencl.queue_t* %11, i32 %12, %struct.ndrange_t* %tmp3, i32 2, %opencl.clk_event_t* addrspace(4)* %15, %opencl.clk_event_t* addrspace(4)* %16, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* @__device_side_enqueue_block_invoke_2_kernel to i8*) to i8 addrspace(4)*), i8 addrspace(4)* %21) - %23 = load %opencl.queue_t*, %opencl.queue_t** %default_queue, align 4 - %24 = load i32, i32* %flags, align 4 - %25 = bitcast %struct.ndrange_t* %tmp11 to i8* - %26 = bitcast %struct.ndrange_t* %ndrange to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %25, i8* align 4 %26, i32 4, i1 false) - %arraydecay = getelementptr inbounds [1 x %opencl.clk_event_t*], [1 x %opencl.clk_event_t*]* %event_wait_list2, i32 0, i32 0 - %27 = addrspacecast %opencl.clk_event_t** %arraydecay to %opencl.clk_event_t* addrspace(4)* - %28 = addrspacecast %opencl.clk_event_t** %clk_event to %opencl.clk_event_t* addrspace(4)* - %29 = getelementptr [1 x i32], [1 x i32]* %block_sizes, i32 0, i32 0 - %30 = load i8, i8* %c, align 1 - %31 = zext i8 %30 to i32 - store i32 %31, i32* %29, align 4 - %32 = call spir_func i32 @__enqueue_kernel_events_varargs(%opencl.queue_t* %23, i32 %24, %struct.ndrange_t* %tmp11, i32 2, %opencl.clk_event_t* addrspace(4)* %27, %opencl.clk_event_t* addrspace(4)* %28, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* @__device_side_enqueue_block_invoke_3_kernel to i8*) to i8 addrspace(4)*), i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* @__block_literal_global to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, i32* %29) - %33 = load %opencl.queue_t*, %opencl.queue_t** %default_queue, align 4 - %34 = load i32, i32* %flags, align 4 - %35 = bitcast %struct.ndrange_t* %tmp12 to i8* - %36 = bitcast %struct.ndrange_t* %ndrange to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %35, i8* align 4 %36, i32 4, i1 false) - %37 = getelementptr [3 x i32], [3 x i32]* %block_sizes13, i32 0, i32 0 - store i32 1, i32* %37, align 4 - %38 = getelementptr [3 x i32], [3 x i32]* %block_sizes13, i32 0, i32 1 - store i32 2, i32* %38, align 4 - %39 = getelementptr [3 x i32], [3 x i32]* %block_sizes13, i32 0, i32 2 - store i32 4, i32* %39, align 4 - %40 = call spir_func i32 @__enqueue_kernel_varargs(%opencl.queue_t* %33, i32 %34, %struct.ndrange_t* %tmp12, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*, i8 addrspace(3)*, i8 addrspace(3)*)* @__device_side_enqueue_block_invoke_4_kernel to i8*) to i8 addrspace(4)*), i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* @__block_literal_global.1 to i8 addrspace(1)*) to i8 addrspace(4)*), i32 3, i32* %37) - %41 = load %opencl.queue_t*, %opencl.queue_t** %default_queue, align 4 - %42 = load i32, i32* %flags, align 4 - %43 = bitcast %struct.ndrange_t* %tmp14 to i8* - %44 = bitcast %struct.ndrange_t* %ndrange to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %43, i8* align 4 %44, i32 4, i1 false) - %45 = addrspacecast %opencl.clk_event_t** %clk_event to %opencl.clk_event_t* addrspace(4)* - %block.size16 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block15, i32 0, i32 0 - store i32 24, i32* %block.size16, align 4 - %block.align17 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block15, i32 0, i32 1 - store i32 4, i32* %block.align17, align 4 - %block.invoke18 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block15, i32 0, i32 2 - store i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* @__device_side_enqueue_block_invoke_5 to i8*) to i8 addrspace(4)*), i8 addrspace(4)** %block.invoke18, align 4 - %block.captured19 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block15, i32 0, i32 3 - %46 = load i32 addrspace(1)*, i32 addrspace(1)** %a.addr, align 4 - store i32 addrspace(1)* %46, i32 addrspace(1)** %block.captured19, align 4 - %block.captured20 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block15, i32 0, i32 4 - %47 = load i32, i32* %i.addr, align 4 - store i32 %47, i32* %block.captured20, align 4 - %block.captured21 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block15, i32 0, i32 5 - %48 = load i32 addrspace(1)*, i32 addrspace(1)** %b.addr, align 4 - store i32 addrspace(1)* %48, i32 addrspace(1)** %block.captured21, align 4 - %49 = bitcast <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block15 to %struct.__opencl_block_literal_generic* - %50 = addrspacecast %struct.__opencl_block_literal_generic* %49 to i8 addrspace(4)* - %51 = call spir_func i32 @__enqueue_kernel_basic_events(%opencl.queue_t* %41, i32 %42, %struct.ndrange_t* %tmp14, i32 0, %opencl.clk_event_t* addrspace(4)* null, %opencl.clk_event_t* addrspace(4)* %45, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* @__device_side_enqueue_block_invoke_5_kernel to i8*) to i8 addrspace(4)*), i8 addrspace(4)* %50) - ret void -} - -declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) - -define internal spir_func void @__device_side_enqueue_block_invoke(i8 addrspace(4)* noundef %.block_descriptor) { -entry: - %.block_descriptor.addr = alloca i8 addrspace(4)*, align 4 - %block.addr = alloca <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }> addrspace(4)*, align 4 - store i8 addrspace(4)* %.block_descriptor, i8 addrspace(4)** %.block_descriptor.addr, align 4 - %block = bitcast i8 addrspace(4)* %.block_descriptor to <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }> addrspace(4)* - store <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }> addrspace(4)* %block, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }> addrspace(4)** %block.addr, align 4 - %block.capture.addr = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }> addrspace(4)* %block, i32 0, i32 5 - %0 = load i8, i8 addrspace(4)* %block.capture.addr, align 4 - %conv = sext i8 %0 to i32 - %block.capture.addr1 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }> addrspace(4)* %block, i32 0, i32 3 - %1 = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(4)* %block.capture.addr1, align 4 - %block.capture.addr2 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }> addrspace(4)* %block, i32 0, i32 4 - %2 = load i32, i32 addrspace(4)* %block.capture.addr2, align 4 - %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %1, i32 %2 - store i32 %conv, i32 addrspace(1)* %arrayidx, align 4 - ret void -} - -define spir_kernel void @__device_side_enqueue_block_invoke_kernel(i8 addrspace(4)* %0) { -entry: - call spir_func void @__device_side_enqueue_block_invoke(i8 addrspace(4)* %0) - ret void -} - -declare spir_func i32 @__enqueue_kernel_basic(%opencl.queue_t*, i32, %struct.ndrange_t*, i8 addrspace(4)*, i8 addrspace(4)*) - -define internal spir_func void @__device_side_enqueue_block_invoke_2(i8 addrspace(4)* noundef %.block_descriptor) { -entry: - %.block_descriptor.addr = alloca i8 addrspace(4)*, align 4 - %block.addr = alloca <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)*, align 4 - store i8 addrspace(4)* %.block_descriptor, i8 addrspace(4)** %.block_descriptor.addr, align 4 - %block = bitcast i8 addrspace(4)* %.block_descriptor to <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)* - store <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)* %block, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)** %block.addr, align 4 - %block.capture.addr = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)* %block, i32 0, i32 5 - %0 = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(4)* %block.capture.addr, align 4 - %block.capture.addr1 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)* %block, i32 0, i32 4 - %1 = load i32, i32 addrspace(4)* %block.capture.addr1, align 4 - %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %0, i32 %1 - %2 = load i32, i32 addrspace(1)* %arrayidx, align 4 - %block.capture.addr2 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)* %block, i32 0, i32 3 - %3 = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(4)* %block.capture.addr2, align 4 - %block.capture.addr3 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)* %block, i32 0, i32 4 - %4 = load i32, i32 addrspace(4)* %block.capture.addr3, align 4 - %arrayidx4 = getelementptr inbounds i32, i32 addrspace(1)* %3, i32 %4 - store i32 %2, i32 addrspace(1)* %arrayidx4, align 4 - ret void -} - -define spir_kernel void @__device_side_enqueue_block_invoke_2_kernel(i8 addrspace(4)* %0) { -entry: - call spir_func void @__device_side_enqueue_block_invoke_2(i8 addrspace(4)* %0) - ret void -} - -declare spir_func i32 @__enqueue_kernel_basic_events(%opencl.queue_t*, i32, %struct.ndrange_t*, i32, %opencl.clk_event_t* addrspace(4)*, %opencl.clk_event_t* addrspace(4)*, i8 addrspace(4)*, i8 addrspace(4)*) - -define internal spir_func void @__device_side_enqueue_block_invoke_3(i8 addrspace(4)* noundef %.block_descriptor, i8 addrspace(3)* noundef %p) { -entry: - %.block_descriptor.addr = alloca i8 addrspace(4)*, align 4 - %p.addr = alloca i8 addrspace(3)*, align 4 - %block.addr = alloca <{ i32, i32, i8 addrspace(4)* }> addrspace(4)*, align 4 - store i8 addrspace(4)* %.block_descriptor, i8 addrspace(4)** %.block_descriptor.addr, align 4 - %block = bitcast i8 addrspace(4)* %.block_descriptor to <{ i32, i32, i8 addrspace(4)* }> addrspace(4)* - store i8 addrspace(3)* %p, i8 addrspace(3)** %p.addr, align 4 - store <{ i32, i32, i8 addrspace(4)* }> addrspace(4)* %block, <{ i32, i32, i8 addrspace(4)* }> addrspace(4)** %block.addr, align 4 - ret void -} - -define spir_kernel void @__device_side_enqueue_block_invoke_3_kernel(i8 addrspace(4)* %0, i8 addrspace(3)* %1) { -entry: - call spir_func void @__device_side_enqueue_block_invoke_3(i8 addrspace(4)* %0, i8 addrspace(3)* %1) - ret void -} - -declare spir_func i32 @__enqueue_kernel_events_varargs(%opencl.queue_t*, i32, %struct.ndrange_t*, i32, %opencl.clk_event_t* addrspace(4)*, %opencl.clk_event_t* addrspace(4)*, i8 addrspace(4)*, i8 addrspace(4)*, i32, i32*) - -define internal spir_func void @__device_side_enqueue_block_invoke_4(i8 addrspace(4)* noundef %.block_descriptor, i8 addrspace(3)* noundef %p1, i8 addrspace(3)* noundef %p2, i8 addrspace(3)* noundef %p3) { -entry: - %.block_descriptor.addr = alloca i8 addrspace(4)*, align 4 - %p1.addr = alloca i8 addrspace(3)*, align 4 - %p2.addr = alloca i8 addrspace(3)*, align 4 - %p3.addr = alloca i8 addrspace(3)*, align 4 - %block.addr = alloca <{ i32, i32, i8 addrspace(4)* }> addrspace(4)*, align 4 - store i8 addrspace(4)* %.block_descriptor, i8 addrspace(4)** %.block_descriptor.addr, align 4 - %block = bitcast i8 addrspace(4)* %.block_descriptor to <{ i32, i32, i8 addrspace(4)* }> addrspace(4)* - store i8 addrspace(3)* %p1, i8 addrspace(3)** %p1.addr, align 4 - store i8 addrspace(3)* %p2, i8 addrspace(3)** %p2.addr, align 4 - store i8 addrspace(3)* %p3, i8 addrspace(3)** %p3.addr, align 4 - store <{ i32, i32, i8 addrspace(4)* }> addrspace(4)* %block, <{ i32, i32, i8 addrspace(4)* }> addrspace(4)** %block.addr, align 4 - ret void -} - -define spir_kernel void @__device_side_enqueue_block_invoke_4_kernel(i8 addrspace(4)* %0, i8 addrspace(3)* %1, i8 addrspace(3)* %2, i8 addrspace(3)* %3) { -entry: - call spir_func void @__device_side_enqueue_block_invoke_4(i8 addrspace(4)* %0, i8 addrspace(3)* %1, i8 addrspace(3)* %2, i8 addrspace(3)* %3) - ret void -} - -declare spir_func i32 @__enqueue_kernel_varargs(%opencl.queue_t*, i32, %struct.ndrange_t*, i8 addrspace(4)*, i8 addrspace(4)*, i32, i32*) - -define internal spir_func void @__device_side_enqueue_block_invoke_5(i8 addrspace(4)* noundef %.block_descriptor) { -entry: - %.block_descriptor.addr = alloca i8 addrspace(4)*, align 4 - %block.addr = alloca <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)*, align 4 - store i8 addrspace(4)* %.block_descriptor, i8 addrspace(4)** %.block_descriptor.addr, align 4 - %block = bitcast i8 addrspace(4)* %.block_descriptor to <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)* - store <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)* %block, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)** %block.addr, align 4 - %block.capture.addr = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)* %block, i32 0, i32 5 - %0 = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(4)* %block.capture.addr, align 4 - %block.capture.addr1 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)* %block, i32 0, i32 4 - %1 = load i32, i32 addrspace(4)* %block.capture.addr1, align 4 - %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %0, i32 %1 - %2 = load i32, i32 addrspace(1)* %arrayidx, align 4 - %block.capture.addr2 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)* %block, i32 0, i32 3 - %3 = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(4)* %block.capture.addr2, align 4 - %block.capture.addr3 = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>, <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }> addrspace(4)* %block, i32 0, i32 4 - %4 = load i32, i32 addrspace(4)* %block.capture.addr3, align 4 - %arrayidx4 = getelementptr inbounds i32, i32 addrspace(1)* %3, i32 %4 - store i32 %2, i32 addrspace(1)* %arrayidx4, align 4 - ret void -} - -define spir_kernel void @__device_side_enqueue_block_invoke_5_kernel(i8 addrspace(4)* %0) { -entry: - call spir_func void @__device_side_enqueue_block_invoke_5(i8 addrspace(4)* %0) - ret void -} Index: llvm/test/CodeGen/SPIRV/transcoding/extract_insert_value.ll =================================================================== --- llvm/test/CodeGen/SPIRV/transcoding/extract_insert_value.ll +++ /dev/null @@ -1,66 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV - -;; Check 'LLVM ==> SPIR-V' conversion of extractvalue/insertvalue. - -%struct.arr = type { [7 x float] } -%struct.st = type { %struct.inner } -%struct.inner = type { float } - -; CHECK-SPIRV: %[[#float_ty:]] = OpTypeFloat 32 -; CHECK-SPIRV: %[[#int_ty:]] = OpTypeInt 32 -; CHECK-SPIRV: %[[#arr_size:]] = OpConstant %[[#int_ty]] 7 -; CHECK-SPIRV: %[[#array_ty:]] = OpTypeArray %[[#float_ty]] %[[#arr_size]] -; CHECK-SPIRV: %[[#struct_ty:]] = OpTypeStruct %[[#array_ty]] -; CHECK-SPIRV: %[[#struct_ptr_ty:]] = OpTypePointer CrossWorkgroup %[[#struct_ty]] -; CHECK-SPIRV: %[[#array_ptr_ty:]] = OpTypePointer CrossWorkgroup %[[#array_ty]] -; CHECK-SPIRV: %[[#struct1_in_ty:]] = OpTypeStruct %[[#float_ty]] -; CHECK-SPIRV: %[[#struct1_ty:]] = OpTypeStruct %[[#struct1_in_ty]] -; CHECK-SPIRV: %[[#struct1_ptr_ty:]] = OpTypePointer CrossWorkgroup %[[#struct1_ty]] -; CHECK-SPIRV: %[[#struct1_in_ptr_ty:]] = OpTypePointer CrossWorkgroup %[[#struct1_in_ty]] -; CHECK-SPIRV-NOT: OpConstant %{{.*}} 2 -; CHECK-SPIRV-NOT: OpConstant %{{.*}} 4 -; CHECK-SPIRV-NOT: OpConstant %{{.*}} 5 - -; CHECK-SPIRV-LABEL: OpFunction -; CHECK-SPIRV-NEXT: %[[#object:]] = OpFunctionParameter %[[#struct_ptr_ty]] -; CHECK-SPIRV: %[[#store_ptr:]] = OpInBoundsPtrAccessChain %[[#array_ptr_ty]] %[[#object]] %[[#]] %[[#]] -; CHECK-SPIRV: %[[#extracted_array:]] = OpLoad %[[#array_ty]] %[[#store_ptr]] Aligned 4 -; CHECK-SPIRV: %[[#elem_4:]] = OpCompositeExtract %[[#float_ty]] %[[#extracted_array]] 4 -; CHECK-SPIRV: %[[#elem_2:]] = OpCompositeExtract %[[#float_ty]] %[[#extracted_array]] 2 -; CHECK-SPIRV: %[[#add:]] = OpFAdd %[[#float_ty]] %[[#elem_4]] %[[#elem_2]] -; CHECK-SPIRV: %[[#inserted_array:]] = OpCompositeInsert %[[#array_ty]] %[[#add]] %[[#extracted_array]] 5 -; CHECK-SPIRV: OpStore %[[#store_ptr]] %[[#inserted_array]] -; CHECK-SPIRV-LABEL: OpFunctionEnd - -define spir_func void @array_test(%struct.arr addrspace(1)* %object) { -entry: - %0 = getelementptr inbounds %struct.arr, %struct.arr addrspace(1)* %object, i32 0, i32 0 - %1 = load [7 x float], [7 x float] addrspace(1)* %0, align 4 - %2 = extractvalue [7 x float] %1, 4 - %3 = extractvalue [7 x float] %1, 2 - %4 = fadd float %2, %3 - %5 = insertvalue [7 x float] %1, float %4, 5 - store [7 x float] %5, [7 x float] addrspace(1)* %0 - ret void -} - -; CHECK-SPIRV-LABEL: OpFunction -; CHECK-SPIRV-NEXT: %[[#object:]] = OpFunctionParameter %[[#struct1_ptr_ty]] -; CHECK-SPIRV: %[[#store1_ptr:]] = OpInBoundsPtrAccessChain %[[#struct1_in_ptr_ty]] %[[#object]] %[[#]] %[[#]] -; CHECK-SPIRV: %[[#extracted_struct:]] = OpLoad %[[#struct1_in_ty]] %[[#store1_ptr]] Aligned 4 -; CHECK-SPIRV: %[[#elem:]] = OpCompositeExtract %[[#float_ty]] %[[#extracted_struct]] 0 -; CHECK-SPIRV: %[[#add:]] = OpFAdd %[[#float_ty]] %[[#elem]] %[[#]] -; CHECK-SPIRV: %[[#inserted_struct:]] = OpCompositeInsert %[[#struct1_in_ty]] %[[#add]] %[[#extracted_struct]] 0 -; CHECK-SPIRV: OpStore %[[#store1_ptr]] %[[#inserted_struct]] -; CHECK-SPIRV-LABEL: OpFunctionEnd - -define spir_func void @struct_test(%struct.st addrspace(1)* %object) { -entry: - %0 = getelementptr inbounds %struct.st, %struct.st addrspace(1)* %object, i32 0, i32 0 - %1 = load %struct.inner, %struct.inner addrspace(1)* %0, align 4 - %2 = extractvalue %struct.inner %1, 0 - %3 = fadd float %2, 1.000000e+00 - %4 = insertvalue %struct.inner %1, float %3, 0 - store %struct.inner %4, %struct.inner addrspace(1)* %0 - ret void -} Index: llvm/test/CodeGen/SPIRV/transcoding/get_image_num_mip_levels.ll =================================================================== --- llvm/test/CodeGen/SPIRV/transcoding/get_image_num_mip_levels.ll +++ /dev/null @@ -1,82 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s - -;; Types: -; CHECK-DAG: %[[#INT:]] = OpTypeInt 32 -; CHECK-DAG: %[[#VOID:]] = OpTypeVoid -; CHECK-DAG: %[[#IMAGE1D_T:]] = OpTypeImage %[[#VOID]] 1D 0 0 0 0 Unknown ReadOnly -; CHECK-DAG: %[[#IMAGE2D_T:]] = OpTypeImage %[[#VOID]] 2D 0 0 0 0 Unknown ReadOnly -; CHECK-DAG: %[[#IMAGE3D_T:]] = OpTypeImage %[[#VOID]] 3D 0 0 0 0 Unknown ReadOnly -; CHECK-DAG: %[[#IMAGE1D_ARRAY_T:]] = OpTypeImage %[[#VOID]] 1D 0 1 0 0 Unknown ReadOnly -; CHECK-DAG: %[[#IMAGE2D_ARRAY_T:]] = OpTypeImage %[[#VOID]] 2D 0 1 0 0 Unknown ReadOnly -; CHECK-DAG: %[[#IMAGE2D_DEPTH_T:]] = OpTypeImage %[[#VOID]] 2D 1 0 0 0 Unknown ReadOnly -; CHECK-DAG: %[[#IMAGE2D_ARRAY_DEPTH_T:]] = OpTypeImage %[[#VOID]] 2D 1 1 0 0 Unknown ReadOnly -;; Instructions: -; CHECK: %[[#IMAGE1D:]] = OpLoad %[[#IMAGE1D_T]] -; CHECK-NEXT: %[[#]] = OpImageQueryLevels %[[#INT]] %[[#IMAGE1D]] -; CHECK: %[[#IMAGE2D:]] = OpLoad %[[#IMAGE2D_T]] -; CHECK-NEXT: %[[#]] = OpImageQueryLevels %[[#INT]] %[[#IMAGE2D]] -; CHECK: %[[#IMAGE3D:]] = OpLoad %[[#IMAGE3D_T]] -; CHECK-NEXT: %[[#]] = OpImageQueryLevels %[[#INT]] %[[#IMAGE3D]] -; CHECK: %[[#IMAGE1D_ARRAY:]] = OpLoad %[[#IMAGE1D_ARRAY_T]] -; CHECK-NEXT: %[[#]] = OpImageQueryLevels %[[#INT]] %[[#IMAGE1D_ARRAY]] -; CHECK: %[[#IMAGE2D_ARRAY:]] = OpLoad %[[#IMAGE2D_ARRAY_T]] -; CHECK-NEXT: %[[#]] = OpImageQueryLevels %[[#INT]] %[[#IMAGE2D_ARRAY]] -; CHECK: %[[#IMAGE2D_DEPTH:]] = OpLoad %[[#IMAGE2D_DEPTH_T]] -; CHECK-NEXT: %[[#]] = OpImageQueryLevels %[[#INT]] %[[#IMAGE2D_DEPTH]] -; CHECK: %[[#IMAGE2D_ARRAY_DEPTH:]] = OpLoad %[[#IMAGE2D_ARRAY_DEPTH_T]] -; CHECK-NEXT: %[[#]] = OpImageQueryLevels %[[#INT]] %[[#IMAGE2D_ARRAY_DEPTH]] - -%opencl.image1d_ro_t = type opaque -%opencl.image2d_ro_t = type opaque -%opencl.image3d_ro_t = type opaque -%opencl.image1d_array_ro_t = type opaque -%opencl.image2d_array_ro_t = type opaque -%opencl.image2d_depth_ro_t = type opaque -%opencl.image2d_array_depth_ro_t = type opaque - -define spir_func void @testimage1d(%opencl.image1d_ro_t addrspace(1)* %img1, %opencl.image2d_ro_t addrspace(1)* %img2, %opencl.image3d_ro_t addrspace(1)* %img3, %opencl.image1d_array_ro_t addrspace(1)* %img4, %opencl.image2d_array_ro_t addrspace(1)* %img5, %opencl.image2d_depth_ro_t addrspace(1)* %img6, %opencl.image2d_array_depth_ro_t addrspace(1)* %img7) { -entry: - %img1.addr = alloca %opencl.image1d_ro_t addrspace(1)*, align 4 - %img2.addr = alloca %opencl.image2d_ro_t addrspace(1)*, align 4 - %img3.addr = alloca %opencl.image3d_ro_t addrspace(1)*, align 4 - %img4.addr = alloca %opencl.image1d_array_ro_t addrspace(1)*, align 4 - %img5.addr = alloca %opencl.image2d_array_ro_t addrspace(1)*, align 4 - %img6.addr = alloca %opencl.image2d_depth_ro_t addrspace(1)*, align 4 - %img7.addr = alloca %opencl.image2d_array_depth_ro_t addrspace(1)*, align 4 - store %opencl.image1d_ro_t addrspace(1)* %img1, %opencl.image1d_ro_t addrspace(1)** %img1.addr, align 4 - store %opencl.image2d_ro_t addrspace(1)* %img2, %opencl.image2d_ro_t addrspace(1)** %img2.addr, align 4 - store %opencl.image3d_ro_t addrspace(1)* %img3, %opencl.image3d_ro_t addrspace(1)** %img3.addr, align 4 - store %opencl.image1d_array_ro_t addrspace(1)* %img4, %opencl.image1d_array_ro_t addrspace(1)** %img4.addr, align 4 - store %opencl.image2d_array_ro_t addrspace(1)* %img5, %opencl.image2d_array_ro_t addrspace(1)** %img5.addr, align 4 - store %opencl.image2d_depth_ro_t addrspace(1)* %img6, %opencl.image2d_depth_ro_t addrspace(1)** %img6.addr, align 4 - store %opencl.image2d_array_depth_ro_t addrspace(1)* %img7, %opencl.image2d_array_depth_ro_t addrspace(1)** %img7.addr, align 4 - %0 = load %opencl.image1d_ro_t addrspace(1)*, %opencl.image1d_ro_t addrspace(1)** %img1.addr, align 4 - %call = call spir_func i32 @_Z24get_image_num_mip_levels14ocl_image1d_ro(%opencl.image1d_ro_t addrspace(1)* %0) - %1 = load %opencl.image2d_ro_t addrspace(1)*, %opencl.image2d_ro_t addrspace(1)** %img2.addr, align 4 - %call1 = call spir_func i32 @_Z24get_image_num_mip_levels14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)* %1) - %2 = load %opencl.image3d_ro_t addrspace(1)*, %opencl.image3d_ro_t addrspace(1)** %img3.addr, align 4 - %call2 = call spir_func i32 @_Z24get_image_num_mip_levels14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)* %2) - %3 = load %opencl.image1d_array_ro_t addrspace(1)*, %opencl.image1d_array_ro_t addrspace(1)** %img4.addr, align 4 - %call3 = call spir_func i32 @_Z24get_image_num_mip_levels20ocl_image1d_array_ro(%opencl.image1d_array_ro_t addrspace(1)* %3) - %4 = load %opencl.image2d_array_ro_t addrspace(1)*, %opencl.image2d_array_ro_t addrspace(1)** %img5.addr, align 4 - %call4 = call spir_func i32 @_Z24get_image_num_mip_levels20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)* %4) - %5 = load %opencl.image2d_depth_ro_t addrspace(1)*, %opencl.image2d_depth_ro_t addrspace(1)** %img6.addr, align 4 - %call5 = call spir_func i32 @_Z24get_image_num_mip_levels20ocl_image2d_depth_ro(%opencl.image2d_depth_ro_t addrspace(1)* %5) - %6 = load %opencl.image2d_array_depth_ro_t addrspace(1)*, %opencl.image2d_array_depth_ro_t addrspace(1)** %img7.addr, align 4 - %call6 = call spir_func i32 @_Z24get_image_num_mip_levels26ocl_image2d_array_depth_ro(%opencl.image2d_array_depth_ro_t addrspace(1)* %6) - ret void -} - -declare spir_func i32 @_Z24get_image_num_mip_levels14ocl_image1d_ro(%opencl.image1d_ro_t addrspace(1)*) - -declare spir_func i32 @_Z24get_image_num_mip_levels14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)*) - -declare spir_func i32 @_Z24get_image_num_mip_levels14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)*) - -declare spir_func i32 @_Z24get_image_num_mip_levels20ocl_image1d_array_ro(%opencl.image1d_array_ro_t addrspace(1)*) - -declare spir_func i32 @_Z24get_image_num_mip_levels20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)*) - -declare spir_func i32 @_Z24get_image_num_mip_levels20ocl_image2d_depth_ro(%opencl.image2d_depth_ro_t addrspace(1)*) - -declare spir_func i32 @_Z24get_image_num_mip_levels26ocl_image2d_array_depth_ro(%opencl.image2d_array_depth_ro_t addrspace(1)*) Index: llvm/test/CodeGen/SPIRV/transcoding/global_block.ll =================================================================== --- llvm/test/CodeGen/SPIRV/transcoding/global_block.ll +++ /dev/null @@ -1,58 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV1_4 - -;; There are no blocks in SPIR-V. Therefore they are translated into regular -;; functions. An LLVM module which uses blocks, also contains some auxiliary -;; block-specific instructions, which are redundant in SPIR-V and should be -;; removed - -;; kernel void block_kernel(__global int* res) { -;; typedef int (^block_t)(int); -;; constant block_t b1 = ^(int i) { return i + 1; }; -;; *res = b1(5); -;; } - -; CHECK-SPIRV1_4: OpEntryPoint Kernel %[[#]] "block_kernel" %[[#InterfaceId:]] -; CHECK-SPIRV1_4: OpName %[[#InterfaceId]] "__block_literal_global" -; CHECK-SPIRV: OpName %[[#block_invoke:]] "_block_invoke" -; CHECK-SPIRV: %[[#int:]] = OpTypeInt 32 -; CHECK-SPIRV: %[[#int8:]] = OpTypeInt 8 -; CHECK-SPIRV: %[[#int8Ptr:]] = OpTypePointer Generic %[[#int8]] -; CHECK-SPIRV: %[[#block_invoke_type:]] = OpTypeFunction %[[#int]] %[[#int8Ptr]] %[[#int]] -; CHECK-SPIRV: %[[#five:]] = OpConstant %[[#int]] 5 - -; CHECK-SPIRV: %[[#]] = OpFunctionCall %[[#int]] %[[#block_invoke]] %[[#]] %[[#five]] - -; CHECK-SPIRV: %[[#block_invoke]] = OpFunction %[[#int]] DontInline %[[#block_invoke_type]] -; CHECK-SPIRV-NEXT: %[[#]] = OpFunctionParameter %[[#int8Ptr]] -; CHECK-SPIRV-NEXT: %[[#]] = OpFunctionParameter %[[#int]] - -%struct.__opencl_block_literal_generic = type { i32, i32, i8 addrspace(4)* } - -@block_kernel.b1 = internal addrspace(2) constant %struct.__opencl_block_literal_generic addrspace(4)* addrspacecast (%struct.__opencl_block_literal_generic addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* @__block_literal_global to %struct.__opencl_block_literal_generic addrspace(1)*) to %struct.__opencl_block_literal_generic addrspace(4)*), align 4 -@__block_literal_global = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 12, i32 4, i8 addrspace(4)* addrspacecast (i8* bitcast (i32 (i8 addrspace(4)*, i32)* @_block_invoke to i8*) to i8 addrspace(4)*) }, align 4 - -define dso_local spir_kernel void @block_kernel(i32 addrspace(1)* noundef %res) { -entry: - %res.addr = alloca i32 addrspace(1)*, align 4 - store i32 addrspace(1)* %res, i32 addrspace(1)** %res.addr, align 4 - %call = call spir_func i32 @_block_invoke(i8 addrspace(4)* noundef addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* @__block_literal_global to i8 addrspace(1)*) to i8 addrspace(4)*), i32 noundef 5) - %0 = load i32 addrspace(1)*, i32 addrspace(1)** %res.addr, align 4 - store i32 %call, i32 addrspace(1)* %0, align 4 - ret void -} - -define internal spir_func i32 @_block_invoke(i8 addrspace(4)* noundef %.block_descriptor, i32 noundef %i) #0 { -entry: - %.block_descriptor.addr = alloca i8 addrspace(4)*, align 4 - %i.addr = alloca i32, align 4 - %block.addr = alloca <{ i32, i32, i8 addrspace(4)* }> addrspace(4)*, align 4 - store i8 addrspace(4)* %.block_descriptor, i8 addrspace(4)** %.block_descriptor.addr, align 4 - %block = bitcast i8 addrspace(4)* %.block_descriptor to <{ i32, i32, i8 addrspace(4)* }> addrspace(4)* - store i32 %i, i32* %i.addr, align 4 - store <{ i32, i32, i8 addrspace(4)* }> addrspace(4)* %block, <{ i32, i32, i8 addrspace(4)* }> addrspace(4)** %block.addr, align 4 - %0 = load i32, i32* %i.addr, align 4 - %add = add nsw i32 %0, 1 - ret i32 %add -} - -attributes #0 = { noinline } Index: llvm/test/CodeGen/SPIRV/transcoding/image_with_access_qualifiers.ll =================================================================== --- llvm/test/CodeGen/SPIRV/transcoding/image_with_access_qualifiers.ll +++ /dev/null @@ -1,23 +0,0 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV - -; CHECK-SPIRV-DAG: OpCapability ImageReadWrite -; CHECK-SPIRV-DAG: OpCapability LiteralSampler -; CHECK-SPIRV-DAG: %[[#TyVoid:]] = OpTypeVoid -; CHECK-SPIRV-DAG: %[[#TyImageID:]] = OpTypeImage %[[#TyVoid]] 1D 0 0 0 0 Unknown ReadWrite -; CHECK-SPIRV-DAG: %[[#TySampledImageID:]] = OpTypeSampledImage %[[#TyImageID]] - -; CHECK-SPIRV-DAG: %[[#ResID:]] = OpSampledImage %[[#TySampledImageID]] -; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#ResID]] - -%opencl.image1d_rw_t = type opaque - -define spir_func void @sampFun(%opencl.image1d_rw_t addrspace(1)* %image) { -entry: - %image.addr = alloca %opencl.image1d_rw_t addrspace(1)*, align 4 - store %opencl.image1d_rw_t addrspace(1)* %image, %opencl.image1d_rw_t addrspace(1)** %image.addr, align 4 - %0 = load %opencl.image1d_rw_t addrspace(1)*, %opencl.image1d_rw_t addrspace(1)** %image.addr, align 4 - %call = call spir_func <4 x float> @_Z11read_imagef14ocl_image1d_rw11ocl_sampleri(%opencl.image1d_rw_t addrspace(1)* %0, i32 8, i32 2) - ret void -} - -declare spir_func <4 x float> @_Z11read_imagef14ocl_image1d_rw11ocl_sampleri(%opencl.image1d_rw_t addrspace(1)*, i32, i32) Index: llvm/test/CodeGen/SPIRV/transcoding/spec_const.ll =================================================================== --- llvm/test/CodeGen/SPIRV/transcoding/spec_const.ll +++ llvm/test/CodeGen/SPIRV/transcoding/spec_const.ll @@ -1,8 +1,8 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ; CHECK-SPIRV-NOT: OpCapability Matrix ; CHECK-SPIRV-NOT: OpCapability Shader -; CHECK-SPIRV: OpCapability Float16Buffer +; CHECK-SPIRV: OpCapability Kernel ; CHECK-SPIRV-DAG: OpDecorate %[[#SC0:]] SpecId 0 ; CHECK-SPIRV-DAG: OpDecorate %[[#SC1:]] SpecId 1 Index: llvm/test/CodeGen/SPIRV/transcoding/spirv-private-array-initialization.ll =================================================================== --- llvm/test/CodeGen/SPIRV/transcoding/spirv-private-array-initialization.ll +++ llvm/test/CodeGen/SPIRV/transcoding/spirv-private-array-initialization.ll @@ -1,30 +1,29 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ; -; CHECK-SPIRV-DAG: %[[#i32:]] = OpTypeInt 32 0 ; CHECK-SPIRV-DAG: %[[#i8:]] = OpTypeInt 8 0 +; CHECK-SPIRV-DAG: %[[#i32:]] = OpTypeInt 32 0 ; CHECK-SPIRV-DAG: %[[#one:]] = OpConstant %[[#i32]] 1 ; CHECK-SPIRV-DAG: %[[#two:]] = OpConstant %[[#i32]] 2 ; CHECK-SPIRV-DAG: %[[#three:]] = OpConstant %[[#i32]] 3 ; CHECK-SPIRV-DAG: %[[#i32x3:]] = OpTypeArray %[[#i32]] %[[#three]] -; CHECK-SPIRV-DAG: %[[#i32x3_ptr:]] = OpTypePointer Function %[[#i32x3]] +; CHECK-SPIRV-DAG: %[[#test_arr_init:]] = OpConstantComposite %[[#i32x3]] %[[#one]] %[[#two]] %[[#three]] +; CHECK-SPIRV-DAG: %[[#twelve:]] = OpConstant %[[#i32]] 12 ; CHECK-SPIRV-DAG: %[[#const_i32x3_ptr:]] = OpTypePointer UniformConstant %[[#i32x3]] -; CHECK-SPIRV-DAG: %[[#i8_ptr:]] = OpTypePointer Function %[[#i8]] -; CHECK-SPIRV-DAG: %[[#const_i8_ptr:]] = OpTypePointer UniformConstant %[[#i8]] -; CHECK-SPIRV: %[[#test_arr_init:]] = OpConstantComposite %[[#i32x3]] %[[#one]] %[[#two]] %[[#three]] -; CHECK-SPIRV: %[[#twelve:]] = OpConstant %[[#i32]] 12 + ; CHECK-SPIRV: %[[#test_arr2:]] = OpVariable %[[#const_i32x3_ptr]] UniformConstant %[[#test_arr_init]] ; CHECK-SPIRV: %[[#test_arr:]] = OpVariable %[[#const_i32x3_ptr]] UniformConstant %[[#test_arr_init]] -; + +; CHECK-SPIRV-DAG: %[[#i8_ptr:]] = OpTypePointer Function %[[#i8]] +; CHECK-SPIRV-DAG: %[[#const_i8_ptr:]] = OpTypePointer UniformConstant %[[#i8]] +; CHECK-SPIRV-DAG: %[[#i32x3_ptr:]] = OpTypePointer Function %[[#i32x3]] + ; CHECK-SPIRV: %[[#arr:]] = OpVariable %[[#i32x3_ptr]] Function ; CHECK-SPIRV: %[[#arr2:]] = OpVariable %[[#i32x3_ptr]] Function -; ; CHECK-SPIRV: %[[#arr_i8_ptr:]] = OpBitcast %[[#i8_ptr]] %[[#arr]] -; CHECK-SPIRV: %[[#test_arr_const_i8_ptr:]] = OpBitcast %[[#const_i8_ptr]] %[[#test_arr]] -; CHECK-SPIRV: OpCopyMemorySized %[[#arr_i8_ptr]] %[[#test_arr_const_i8_ptr]] %[[#twelve]] Aligned 4 -; +; CHECK-SPIRV: OpCopyMemorySized %[[#arr_i8_ptr]] %[[#test_arr]] %[[#twelve]] Aligned 4 ; CHECK-SPIRV: %[[#arr2_i8_ptr:]] = OpBitcast %[[#i8_ptr]] %[[#arr2]] -; CHECK-SPIRV: %[[#test_arr2_const_i8_ptr:]] = OpBitcast %[[#const_i8_ptr]] %[[#test_arr2]] -; CHECK-SPIRV: OpCopyMemorySized %[[#arr2_i8_ptr]] %[[#test_arr2_const_i8_ptr]] %[[#twelve]] Aligned 4 +; CHECK-SPIRV: OpCopyMemorySized %[[#arr2_i8_ptr]] %[[#test_arr2]] %[[#twelve]] Aligned 4 + @__const.test.arr = private unnamed_addr addrspace(2) constant [3 x i32] [i32 1, i32 2, i32 3], align 4 @__const.test.arr2 = private unnamed_addr addrspace(2) constant [3 x i32] [i32 1, i32 2, i32 3], align 4 Index: llvm/test/CodeGen/SPIRV/types/device_event.ll =================================================================== --- llvm/test/CodeGen/SPIRV/types/device_event.ll +++ llvm/test/CodeGen/SPIRV/types/device_event.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ; CHECK-SPIRV: OpTypeDeviceEvent ; CHECK-SPIRV: OpFunction @@ -19,29 +19,27 @@ ;; release_event(e1); ;; } -%opencl.clk_event_t = type opaque - define dso_local spir_kernel void @clk_event_t_test(i32 addrspace(1)* nocapture noundef writeonly %res, i8 addrspace(1)* noundef %prof) local_unnamed_addr { entry: - %call = call spir_func %opencl.clk_event_t* @_Z17create_user_eventv() - %call1 = call spir_func zeroext i1 @_Z14is_valid_event12ocl_clkevent(%opencl.clk_event_t* %call) + %call = call spir_func target("spirv.DeviceEvent") @_Z17create_user_eventv() + %call1 = call spir_func zeroext i1 @_Z14is_valid_event12ocl_clkevent(target("spirv.DeviceEvent") %call) %conv = zext i1 %call1 to i32 store i32 %conv, i32 addrspace(1)* %res, align 4 - call spir_func void @_Z12retain_event12ocl_clkevent(%opencl.clk_event_t* %call) - call spir_func void @_Z21set_user_event_status12ocl_clkeventi(%opencl.clk_event_t* %call, i32 noundef -42) - call spir_func void @_Z28capture_event_profiling_info12ocl_clkeventiPU3AS1v(%opencl.clk_event_t* %call, i32 noundef 1, i8 addrspace(1)* noundef %prof) - call spir_func void @_Z13release_event12ocl_clkevent(%opencl.clk_event_t* %call) + call spir_func void @_Z12retain_event12ocl_clkevent(target("spirv.DeviceEvent") %call) + call spir_func void @_Z21set_user_event_status12ocl_clkeventi(target("spirv.DeviceEvent") %call, i32 noundef -42) + call spir_func void @_Z28capture_event_profiling_info12ocl_clkeventiPU3AS1v(target("spirv.DeviceEvent") %call, i32 noundef 1, i8 addrspace(1)* noundef %prof) + call spir_func void @_Z13release_event12ocl_clkevent(target("spirv.DeviceEvent") %call) ret void } -declare spir_func %opencl.clk_event_t* @_Z17create_user_eventv() local_unnamed_addr +declare spir_func target("spirv.DeviceEvent") @_Z17create_user_eventv() local_unnamed_addr -declare spir_func zeroext i1 @_Z14is_valid_event12ocl_clkevent(%opencl.clk_event_t*) local_unnamed_addr +declare spir_func zeroext i1 @_Z14is_valid_event12ocl_clkevent(target("spirv.DeviceEvent")) local_unnamed_addr -declare spir_func void @_Z12retain_event12ocl_clkevent(%opencl.clk_event_t*) local_unnamed_addr +declare spir_func void @_Z12retain_event12ocl_clkevent(target("spirv.DeviceEvent")) local_unnamed_addr -declare spir_func void @_Z21set_user_event_status12ocl_clkeventi(%opencl.clk_event_t*, i32 noundef) local_unnamed_addr +declare spir_func void @_Z21set_user_event_status12ocl_clkeventi(target("spirv.DeviceEvent"), i32 noundef) local_unnamed_addr -declare spir_func void @_Z28capture_event_profiling_info12ocl_clkeventiPU3AS1v(%opencl.clk_event_t*, i32 noundef, i8 addrspace(1)* noundef) local_unnamed_addr +declare spir_func void @_Z28capture_event_profiling_info12ocl_clkeventiPU3AS1v(target("spirv.DeviceEvent"), i32 noundef, i8 addrspace(1)* noundef) local_unnamed_addr -declare spir_func void @_Z13release_event12ocl_clkevent(%opencl.clk_event_t*) local_unnamed_addr +declare spir_func void @_Z13release_event12ocl_clkevent(target("spirv.DeviceEvent")) local_unnamed_addr Index: llvm/test/CodeGen/SPIRV/types/image-access-qualifier.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/SPIRV/types/image-access-qualifier.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV + +; CHECK-SPIRV-DAG: OpCapability ImageReadWrite +; CHECK-SPIRV-DAG: OpCapability LiteralSampler +; CHECK-SPIRV-DAG: %[[#TyVoid:]] = OpTypeVoid +; CHECK-SPIRV-DAG: %[[#TyImageID:]] = OpTypeImage %[[#TyVoid]] 1D 0 0 0 0 Unknown ReadWrite +; CHECK-SPIRV-DAG: %[[#TySampledImageID:]] = OpTypeSampledImage %[[#TyImageID]] + +; CHECK-SPIRV-DAG: %[[#ResID:]] = OpSampledImage %[[#TySampledImageID]] +; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#ResID]] + +define spir_func void @sampFun(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 2) %image) { +entry: + %image.addr = alloca target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 2), align 4 + store target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 2) %image, ptr %image.addr, align 4 + %0 = load target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 2), ptr %image.addr, align 4 + %call = call spir_func <4 x float> @_Z11read_imagef14ocl_image1d_rw11ocl_sampleri(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 2) %0, i32 8, i32 2) + ret void +} + +declare spir_func <4 x float> @_Z11read_imagef14ocl_image1d_rw11ocl_sampleri(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 2), i32, i32) Index: llvm/test/CodeGen/SPIRV/types/image-function-argument.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/SPIRV/types/image-function-argument.ll @@ -0,0 +1,23 @@ +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV + +; CHECK-SPIRV: %[[#TypeImage:]] = OpTypeImage +; CHECK-SPIRV-NOT: OpTypeImage +; CHECK-SPIRV: %[[#]] = OpTypeFunction %[[#]] %[[#TypeImage]] +; CHECK-SPIRV: %[[#]] = OpTypeFunction %[[#]] %[[#TypeImage]] +; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#TypeImage]] +; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#TypeImage]] +; CHECK-SPIRV: %[[#ParamID:]] = OpFunctionParameter %[[#TypeImage]] +; CHECK-SPIRV: %[[#]] = OpFunctionCall %[[#]] %[[#]] %[[#ParamID]] + +define spir_func void @f0(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %v2, <2 x float> %v3) { + ret void +} + +define spir_func void @f1(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %v2, <2 x float> %v3) { + ret void +} + +define spir_kernel void @test(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %v1) { + call spir_func void @f0(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %v1, <2 x float> ) + ret void +} Index: llvm/test/CodeGen/SPIRV/types/image-query-dim-array-size.ll =================================================================== --- llvm/test/CodeGen/SPIRV/types/image-query-dim-array-size.ll +++ llvm/test/CodeGen/SPIRV/types/image-query-dim-array-size.ll @@ -1,23 +1,21 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ; CHECK-SPIRV: %[[#IMAGE_TYPE:]] = OpTypeImage ; CHECK-SPIRV: %[[#IMAGE_ARG:]] = OpFunctionParameter %[[#IMAGE_TYPE]] ; CHECK-SPIRV: %[[#]] = OpImageQuerySizeLod %[[#]] %[[#IMAGE_ARG]] ; CHECK-SPIRV: %[[#]] = OpImageQuerySizeLod %[[#]] %[[#IMAGE_ARG]] -%opencl.image2d_array_ro_t = type opaque - -define spir_kernel void @sample_kernel(%opencl.image2d_array_ro_t addrspace(1)* %input) { +define spir_kernel void @sample_kernel(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0) %input) { entry: - %call.tmp1 = call spir_func <2 x i32> @_Z13get_image_dim20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)* %input) + %call.tmp1 = call spir_func <2 x i32> @_Z13get_image_dim20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0) %input) %call.tmp2 = shufflevector <2 x i32> %call.tmp1, <2 x i32> undef, <3 x i32> - %call.tmp3 = call spir_func i64 @_Z20get_image_array_size20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)* %input) + %call.tmp3 = call spir_func i64 @_Z20get_image_array_size20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0) %input) %call.tmp4 = trunc i64 %call.tmp3 to i32 %call.tmp5 = insertelement <3 x i32> %call.tmp2, i32 %call.tmp4, i32 2 %call.old = extractelement <3 x i32> %call.tmp5, i32 0 ret void } -declare spir_func <2 x i32> @_Z13get_image_dim20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)*) +declare spir_func <2 x i32> @_Z13get_image_dim20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0)) -declare spir_func i64 @_Z20get_image_array_size20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)*) +declare spir_func i64 @_Z20get_image_array_size20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0)) Index: llvm/test/CodeGen/SPIRV/types/image-query-mip-levels.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/SPIRV/types/image-query-mip-levels.ll @@ -0,0 +1,74 @@ +; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s + +;; Types: +; CHECK-DAG: %[[#INT:]] = OpTypeInt 32 +; CHECK-DAG: %[[#VOID:]] = OpTypeVoid +; CHECK-DAG: %[[#IMAGE1D_T:]] = OpTypeImage %[[#VOID]] 1D 0 0 0 0 Unknown ReadOnly +; CHECK-DAG: %[[#IMAGE2D_T:]] = OpTypeImage %[[#VOID]] 2D 0 0 0 0 Unknown ReadOnly +; CHECK-DAG: %[[#IMAGE3D_T:]] = OpTypeImage %[[#VOID]] 3D 0 0 0 0 Unknown ReadOnly +; CHECK-DAG: %[[#IMAGE1D_ARRAY_T:]] = OpTypeImage %[[#VOID]] 1D 0 1 0 0 Unknown ReadOnly +; CHECK-DAG: %[[#IMAGE2D_ARRAY_T:]] = OpTypeImage %[[#VOID]] 2D 0 1 0 0 Unknown ReadOnly +; CHECK-DAG: %[[#IMAGE2D_DEPTH_T:]] = OpTypeImage %[[#VOID]] 2D 1 0 0 0 Unknown ReadOnly +; CHECK-DAG: %[[#IMAGE2D_ARRAY_DEPTH_T:]] = OpTypeImage %[[#VOID]] 2D 1 1 0 0 Unknown ReadOnly +;; Instructions: +; CHECK: %[[#IMAGE1D:]] = OpLoad %[[#IMAGE1D_T]] +; CHECK-NEXT: %[[#]] = OpImageQueryLevels %[[#INT]] %[[#IMAGE1D]] +; CHECK: %[[#IMAGE2D:]] = OpLoad %[[#IMAGE2D_T]] +; CHECK-NEXT: %[[#]] = OpImageQueryLevels %[[#INT]] %[[#IMAGE2D]] +; CHECK: %[[#IMAGE3D:]] = OpLoad %[[#IMAGE3D_T]] +; CHECK-NEXT: %[[#]] = OpImageQueryLevels %[[#INT]] %[[#IMAGE3D]] +; CHECK: %[[#IMAGE1D_ARRAY:]] = OpLoad %[[#IMAGE1D_ARRAY_T]] +; CHECK-NEXT: %[[#]] = OpImageQueryLevels %[[#INT]] %[[#IMAGE1D_ARRAY]] +; CHECK: %[[#IMAGE2D_ARRAY:]] = OpLoad %[[#IMAGE2D_ARRAY_T]] +; CHECK-NEXT: %[[#]] = OpImageQueryLevels %[[#INT]] %[[#IMAGE2D_ARRAY]] +; CHECK: %[[#IMAGE2D_DEPTH:]] = OpLoad %[[#IMAGE2D_DEPTH_T]] +; CHECK-NEXT: %[[#]] = OpImageQueryLevels %[[#INT]] %[[#IMAGE2D_DEPTH]] +; CHECK: %[[#IMAGE2D_ARRAY_DEPTH:]] = OpLoad %[[#IMAGE2D_ARRAY_DEPTH_T]] +; CHECK-NEXT: %[[#]] = OpImageQueryLevels %[[#INT]] %[[#IMAGE2D_ARRAY_DEPTH]] + +define spir_func void @testimage1d(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %img1, target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %img2, target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %img3, target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 0) %img4, target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0) %img5, target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 0) %img6, target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0) %img7) { +entry: + %img1.addr = alloca target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0), align 4 + %img2.addr = alloca target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), align 4 + %img3.addr = alloca target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0), align 4 + %img4.addr = alloca target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 0), align 4 + %img5.addr = alloca target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0), align 4 + %img6.addr = alloca target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 0), align 4 + %img7.addr = alloca target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0), align 4 + store target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %img1, target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0)* %img1.addr, align 4 + store target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %img2, target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0)* %img2.addr, align 4 + store target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %img3, target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0)* %img3.addr, align 4 + store target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 0) %img4, target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 0)* %img4.addr, align 4 + store target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0) %img5, target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0)* %img5.addr, align 4 + store target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 0) %img6, target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 0)* %img6.addr, align 4 + store target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0) %img7, target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0)* %img7.addr, align 4 + %0 = load target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0), target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0)* %img1.addr, align 4 + %call = call spir_func i32 @_Z24get_image_num_mip_levels14ocl_image1d_ro(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %0) + %1 = load target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0)* %img2.addr, align 4 + %call1 = call spir_func i32 @_Z24get_image_num_mip_levels14ocl_image2d_ro(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %1) + %2 = load target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0), target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0)* %img3.addr, align 4 + %call2 = call spir_func i32 @_Z24get_image_num_mip_levels14ocl_image3d_ro(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %2) + %3 = load target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 0), target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 0)* %img4.addr, align 4 + %call3 = call spir_func i32 @_Z24get_image_num_mip_levels20ocl_image1d_array_ro(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 0) %3) + %4 = load target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0), target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0)* %img5.addr, align 4 + %call4 = call spir_func i32 @_Z24get_image_num_mip_levels20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0) %4) + %5 = load target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 0), target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 0)* %img6.addr, align 4 + %call5 = call spir_func i32 @_Z24get_image_num_mip_levels20ocl_image2d_depth_ro(target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 0) %5) + %6 = load target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0), target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0)* %img7.addr, align 4 + %call6 = call spir_func i32 @_Z24get_image_num_mip_levels26ocl_image2d_array_depth_ro(target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0) %6) + ret void +} + +declare spir_func i32 @_Z24get_image_num_mip_levels14ocl_image1d_ro(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0)) + +declare spir_func i32 @_Z24get_image_num_mip_levels14ocl_image2d_ro(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0)) + +declare spir_func i32 @_Z24get_image_num_mip_levels14ocl_image3d_ro(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0)) + +declare spir_func i32 @_Z24get_image_num_mip_levels20ocl_image1d_array_ro(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 0)) + +declare spir_func i32 @_Z24get_image_num_mip_levels20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0)) + +declare spir_func i32 @_Z24get_image_num_mip_levels20ocl_image2d_depth_ro(target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 0)) + +declare spir_func i32 @_Z24get_image_num_mip_levels26ocl_image2d_array_depth_ro(target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0)) Index: llvm/test/CodeGen/SPIRV/types/image-query-size-with-access-qualifier.ll =================================================================== --- llvm/test/CodeGen/SPIRV/types/image-query-size-with-access-qualifier.ll +++ llvm/test/CodeGen/SPIRV/types/image-query-size-with-access-qualifier.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ; CHECK-SPIRV-DAG: %[[#IntTyID:]] = OpTypeInt ; CHECK-SPIRV-DAG: %[[#VoidTyID:]] = OpTypeVoid @@ -7,12 +7,10 @@ ; CHECK-SPIRV: %[[#ImageArgID:]] = OpFunctionParameter %[[#ImageTyID]] ; CHECK-SPIRV: %[[#]] = OpImageQuerySizeLod %[[#VectorTyID]] %[[#ImageArgID]] -%opencl.image2d_array_ro_t = type opaque - -define spir_kernel void @sample_kernel(%opencl.image2d_array_ro_t addrspace(1)* %input) { +define spir_kernel void @sample_kernel(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0) %input) { entry: - %call = call spir_func i32 @_Z15get_image_width20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)* %input) + %call = call spir_func i32 @_Z15get_image_width20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0) %input) ret void } -declare spir_func i32 @_Z15get_image_width20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)*) +declare spir_func i32 @_Z15get_image_width20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0)) Index: llvm/test/CodeGen/SPIRV/types/image-query-size.ll =================================================================== --- llvm/test/CodeGen/SPIRV/types/image-query-size.ll +++ llvm/test/CodeGen/SPIRV/types/image-query-size.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ;; Check conversion of get_image_width, get_image_height, get_image_depth, ;; get_image_array_size, and get_image_dim OCL built-ins. @@ -8,24 +8,15 @@ ; CHECK-SPIRV: %[[#ArrayTypeID:]] = OpTypeImage %[[#]] 1D 0 1 0 0 Unknown ReadOnly -%opencl.image1d_ro_t = type opaque -%opencl.image1d_buffer_ro_t = type opaque -%opencl.image1d_array_ro_t = type opaque -%opencl.image2d_ro_t = type opaque -%opencl.image2d_depth_ro_t = type opaque -%opencl.image2d_array_ro_t = type opaque -%opencl.image2d_array_depth_ro_t = type opaque -%opencl.image3d_ro_t = type opaque - ; CHECK-SPIRV: %[[#ArrayVarID:]] = OpFunctionParameter %[[#ArrayTypeID]] ; CHECK-SPIRV: %[[#]] = OpImageQuerySizeLod %[[#]] %[[#ArrayVarID]] ; CHECK-SPIRV-NOT: %[[#]] = OpExtInst %[[#]] %[[#]] get_image_array_size -define spir_kernel void @test_image1d(i32 addrspace(1)* nocapture %sizes, %opencl.image1d_ro_t addrspace(1)* %img, %opencl.image1d_buffer_ro_t addrspace(1)* %buffer, %opencl.image1d_array_ro_t addrspace(1)* %array) { - %1 = tail call spir_func i32 @_Z15get_image_width14ocl_image1d_ro(%opencl.image1d_ro_t addrspace(1)* %img) - %2 = tail call spir_func i32 @_Z15get_image_width21ocl_image1d_buffer_ro(%opencl.image1d_buffer_ro_t addrspace(1)* %buffer) - %3 = tail call spir_func i32 @_Z15get_image_width20ocl_image1d_array_ro(%opencl.image1d_array_ro_t addrspace(1)* %array) - %4 = tail call spir_func i64 @_Z20get_image_array_size20ocl_image1d_array_ro(%opencl.image1d_array_ro_t addrspace(1)* %array) +define spir_kernel void @test_image1d(i32 addrspace(1)* nocapture %sizes, target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %img, target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 0) %buffer, target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 0) %array) { + %1 = tail call spir_func i32 @_Z15get_image_width14ocl_image1d_ro(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %img) + %2 = tail call spir_func i32 @_Z15get_image_width21ocl_image1d_buffer_ro(target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 0) %buffer) + %3 = tail call spir_func i32 @_Z15get_image_width20ocl_image1d_array_ro(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 0) %array) + %4 = tail call spir_func i64 @_Z20get_image_array_size20ocl_image1d_array_ro(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 0) %array) %5 = trunc i64 %4 to i32 %6 = add nsw i32 %2, %1 %7 = add nsw i32 %6, %3 @@ -34,23 +25,23 @@ ret void } -declare spir_func i32 @_Z15get_image_width14ocl_image1d_ro(%opencl.image1d_ro_t addrspace(1)*) +declare spir_func i32 @_Z15get_image_width14ocl_image1d_ro(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0)) -declare spir_func i32 @_Z15get_image_width21ocl_image1d_buffer_ro(%opencl.image1d_buffer_ro_t addrspace(1)*) +declare spir_func i32 @_Z15get_image_width21ocl_image1d_buffer_ro(target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 0)) -declare spir_func i32 @_Z15get_image_width20ocl_image1d_array_ro(%opencl.image1d_array_ro_t addrspace(1)*) +declare spir_func i32 @_Z15get_image_width20ocl_image1d_array_ro(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 0)) -declare spir_func i64 @_Z20get_image_array_size20ocl_image1d_array_ro(%opencl.image1d_array_ro_t addrspace(1)*) +declare spir_func i64 @_Z20get_image_array_size20ocl_image1d_array_ro(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 0)) -define spir_kernel void @test_image2d(i32 addrspace(1)* nocapture %sizes, %opencl.image2d_ro_t addrspace(1)* %img, %opencl.image2d_depth_ro_t addrspace(1)* nocapture %img_depth, %opencl.image2d_array_ro_t addrspace(1)* %array, %opencl.image2d_array_depth_ro_t addrspace(1)* nocapture %array_depth) { - %1 = tail call spir_func i32 @_Z15get_image_width14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)* %img) - %2 = tail call spir_func i32 @_Z16get_image_height14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)* %img) - %3 = tail call spir_func <2 x i32> @_Z13get_image_dim14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)* %img) - %4 = tail call spir_func i32 @_Z15get_image_width20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)* %array) - %5 = tail call spir_func i32 @_Z16get_image_height20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)* %array) - %6 = tail call spir_func i64 @_Z20get_image_array_size20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)* %array) +define spir_kernel void @test_image2d(i32 addrspace(1)* nocapture %sizes, target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %img, target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 0) %img_depth, target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0) %array, target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0) %array_depth) { + %1 = tail call spir_func i32 @_Z15get_image_width14ocl_image2d_ro(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %img) + %2 = tail call spir_func i32 @_Z16get_image_height14ocl_image2d_ro(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %img) + %3 = tail call spir_func <2 x i32> @_Z13get_image_dim14ocl_image2d_ro(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %img) + %4 = tail call spir_func i32 @_Z15get_image_width20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0) %array) + %5 = tail call spir_func i32 @_Z16get_image_height20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0) %array) + %6 = tail call spir_func i64 @_Z20get_image_array_size20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0) %array) %7 = trunc i64 %6 to i32 - %8 = tail call spir_func <2 x i32> @_Z13get_image_dim20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)* %array) + %8 = tail call spir_func <2 x i32> @_Z13get_image_dim20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0) %array) %9 = add nsw i32 %2, %1 %10 = extractelement <2 x i32> %3, i32 0 %11 = add nsw i32 %9, %10 @@ -67,25 +58,25 @@ ret void } -declare spir_func i32 @_Z15get_image_width14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)*) +declare spir_func i32 @_Z15get_image_width14ocl_image2d_ro(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0)) -declare spir_func i32 @_Z16get_image_height14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)*) +declare spir_func i32 @_Z16get_image_height14ocl_image2d_ro(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0)) -declare spir_func <2 x i32> @_Z13get_image_dim14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)*) +declare spir_func <2 x i32> @_Z13get_image_dim14ocl_image2d_ro(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0)) -declare spir_func i32 @_Z15get_image_width20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)*) +declare spir_func i32 @_Z15get_image_width20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0)) -declare spir_func i32 @_Z16get_image_height20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)*) +declare spir_func i32 @_Z16get_image_height20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0)) -declare spir_func i64 @_Z20get_image_array_size20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)*) +declare spir_func i64 @_Z20get_image_array_size20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0)) -declare spir_func <2 x i32> @_Z13get_image_dim20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)*) +declare spir_func <2 x i32> @_Z13get_image_dim20ocl_image2d_array_ro(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0)) -define spir_kernel void @test_image3d(i32 addrspace(1)* nocapture %sizes, %opencl.image3d_ro_t addrspace(1)* %img) { - %1 = tail call spir_func i32 @_Z15get_image_width14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)* %img) - %2 = tail call spir_func i32 @_Z16get_image_height14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)* %img) - %3 = tail call spir_func i32 @_Z15get_image_depth14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)* %img) - %4 = tail call spir_func <4 x i32> @_Z13get_image_dim14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)* %img) +define spir_kernel void @test_image3d(i32 addrspace(1)* nocapture %sizes, target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %img) { + %1 = tail call spir_func i32 @_Z15get_image_width14ocl_image3d_ro(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %img) + %2 = tail call spir_func i32 @_Z16get_image_height14ocl_image3d_ro(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %img) + %3 = tail call spir_func i32 @_Z15get_image_depth14ocl_image3d_ro(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %img) + %4 = tail call spir_func <4 x i32> @_Z13get_image_dim14ocl_image3d_ro(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %img) %5 = add nsw i32 %2, %1 %6 = add nsw i32 %5, %3 %7 = extractelement <4 x i32> %4, i32 0 @@ -100,18 +91,18 @@ ret void } -declare spir_func i32 @_Z15get_image_width14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)*) +declare spir_func i32 @_Z15get_image_width14ocl_image3d_ro(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0)) -declare spir_func i32 @_Z16get_image_height14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)*) +declare spir_func i32 @_Z16get_image_height14ocl_image3d_ro(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0)) -declare spir_func i32 @_Z15get_image_depth14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)*) +declare spir_func i32 @_Z15get_image_depth14ocl_image3d_ro(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0)) -declare spir_func <4 x i32> @_Z13get_image_dim14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)*) +declare spir_func <4 x i32> @_Z13get_image_dim14ocl_image3d_ro(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0)) -define spir_kernel void @test_image2d_array_depth_t(i32 addrspace(1)* nocapture %sizes, %opencl.image2d_array_depth_ro_t addrspace(1)* %array) { - %1 = tail call spir_func i32 @_Z15get_image_width26ocl_image2d_array_depth_ro(%opencl.image2d_array_depth_ro_t addrspace(1)* %array) - %2 = tail call spir_func i32 @_Z16get_image_height26ocl_image2d_array_depth_ro(%opencl.image2d_array_depth_ro_t addrspace(1)* %array) - %3 = tail call spir_func i64 @_Z20get_image_array_size26ocl_image2d_array_depth_ro(%opencl.image2d_array_depth_ro_t addrspace(1)* %array) +define spir_kernel void @test_image2d_array_depth_t(i32 addrspace(1)* nocapture %sizes, target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0) %array) { + %1 = tail call spir_func i32 @_Z15get_image_width26ocl_image2d_array_depth_ro(target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0) %array) + %2 = tail call spir_func i32 @_Z16get_image_height26ocl_image2d_array_depth_ro(target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0) %array) + %3 = tail call spir_func i64 @_Z20get_image_array_size26ocl_image2d_array_depth_ro(target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0) %array) %4 = trunc i64 %3 to i32 %5 = add nsw i32 %2, %1 %6 = add nsw i32 %5, %4 @@ -119,8 +110,8 @@ ret void } -declare spir_func i32 @_Z15get_image_width26ocl_image2d_array_depth_ro(%opencl.image2d_array_depth_ro_t addrspace(1)*) +declare spir_func i32 @_Z15get_image_width26ocl_image2d_array_depth_ro(target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0)) -declare spir_func i32 @_Z16get_image_height26ocl_image2d_array_depth_ro(%opencl.image2d_array_depth_ro_t addrspace(1)*) +declare spir_func i32 @_Z16get_image_height26ocl_image2d_array_depth_ro(target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0)) -declare spir_func i64 @_Z20get_image_array_size26ocl_image2d_array_depth_ro(%opencl.image2d_array_depth_ro_t addrspace(1)*) +declare spir_func i64 @_Z20get_image_array_size26ocl_image2d_array_depth_ro(target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 0)) \ No newline at end of file Index: llvm/test/CodeGen/SPIRV/types/image-read-ms.ll =================================================================== --- llvm/test/CodeGen/SPIRV/types/image-read-ms.ll +++ llvm/test/CodeGen/SPIRV/types/image-read-ms.ll @@ -1,16 +1,14 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ; CHECK-SPIRV: %[[#]] = OpImageRead %[[#]] %[[#]] %[[#]] Sample %[[#]] -%opencl.image2d_msaa_ro_t = type opaque - -define spir_kernel void @sample_test(%opencl.image2d_msaa_ro_t addrspace(1)* %source, i32 %sampler, <4 x float> addrspace(1)* nocapture %results) { +define spir_kernel void @sample_test(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0) %source, i32 %sampler, <4 x float> addrspace(1)* nocapture %results) { entry: %call = tail call spir_func i32 @_Z13get_global_idj(i32 0) %call1 = tail call spir_func i32 @_Z13get_global_idj(i32 1) - %call2 = tail call spir_func i32 @_Z15get_image_width19ocl_image2d_msaa_ro(%opencl.image2d_msaa_ro_t addrspace(1)* %source) - %call3 = tail call spir_func i32 @_Z16get_image_height19ocl_image2d_msaa_ro(%opencl.image2d_msaa_ro_t addrspace(1)* %source) - %call4 = tail call spir_func i32 @_Z21get_image_num_samples19ocl_image2d_msaa_ro(%opencl.image2d_msaa_ro_t addrspace(1)* %source) + %call2 = tail call spir_func i32 @_Z15get_image_width19ocl_image2d_msaa_ro(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0) %source) + %call3 = tail call spir_func i32 @_Z16get_image_height19ocl_image2d_msaa_ro(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0) %source) + %call4 = tail call spir_func i32 @_Z21get_image_num_samples19ocl_image2d_msaa_ro(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0) %source) %cmp20 = icmp eq i32 %call4, 0 br i1 %cmp20, label %for.end, label %for.body.lr.ph @@ -25,7 +23,7 @@ %tmp = add i32 %mul5, %call1 %tmp19 = mul i32 %tmp, %call2 %add7 = add i32 %tmp19, %call - %call9 = tail call spir_func <4 x float> @_Z11read_imagef19ocl_image2d_msaa_roDv2_ii(%opencl.image2d_msaa_ro_t addrspace(1)* %source, <2 x i32> %vecinit8, i32 %sample.021) + %call9 = tail call spir_func <4 x float> @_Z11read_imagef19ocl_image2d_msaa_roDv2_ii(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0) %source, <2 x i32> %vecinit8, i32 %sample.021) %arrayidx = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %results, i32 %add7 store <4 x float> %call9, <4 x float> addrspace(1)* %arrayidx, align 16 %inc = add nuw i32 %sample.021, 1 @@ -41,10 +39,10 @@ declare spir_func i32 @_Z13get_global_idj(i32) -declare spir_func i32 @_Z15get_image_width19ocl_image2d_msaa_ro(%opencl.image2d_msaa_ro_t addrspace(1)*) +declare spir_func i32 @_Z15get_image_width19ocl_image2d_msaa_ro(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0)) -declare spir_func i32 @_Z16get_image_height19ocl_image2d_msaa_ro(%opencl.image2d_msaa_ro_t addrspace(1)*) +declare spir_func i32 @_Z16get_image_height19ocl_image2d_msaa_ro(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0)) -declare spir_func i32 @_Z21get_image_num_samples19ocl_image2d_msaa_ro(%opencl.image2d_msaa_ro_t addrspace(1)*) +declare spir_func i32 @_Z21get_image_num_samples19ocl_image2d_msaa_ro(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0)) -declare spir_func <4 x float> @_Z11read_imagef19ocl_image2d_msaa_roDv2_ii(%opencl.image2d_msaa_ro_t addrspace(1)*, <2 x i32>, i32) +declare spir_func <4 x float> @_Z11read_imagef19ocl_image2d_msaa_roDv2_ii(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0), <2 x i32>, i32) Index: llvm/test/CodeGen/SPIRV/types/image-read.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/SPIRV/types/image-read.ll @@ -0,0 +1,48 @@ +; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV + +; CHECK-SPIRV: %[[#IntTy:]] = OpTypeInt +; CHECK-SPIRV: %[[#IVecTy:]] = OpTypeVector %[[#IntTy]] +; CHECK-SPIRV: %[[#FloatTy:]] = OpTypeFloat +; CHECK-SPIRV: %[[#FVecTy:]] = OpTypeVector %[[#FloatTy]] +; CHECK-SPIRV: OpImageRead %[[#IVecTy]] +; CHECK-SPIRV: OpImageRead %[[#FVecTy]] + +;; __kernel void kernelA(__read_only image3d_t input) { +;; uint4 c = read_imageui(input, (int4)(0, 0, 0, 0)); +;; } +;; +;; __kernel void kernelB(__read_only image3d_t input) { +;; float4 f = read_imagef(input, (int4)(0, 0, 0, 0)); +;; } + +define dso_local spir_kernel void @kernelA(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %input) { +entry: + %input.addr = alloca target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0), align 8 + %c = alloca <4 x i32>, align 16 + %.compoundliteral = alloca <4 x i32>, align 16 + store target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %input, ptr %input.addr, align 8 + %0 = load target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0), ptr %input.addr, align 8 + store <4 x i32> zeroinitializer, ptr %.compoundliteral, align 16 + %1 = load <4 x i32>, ptr %.compoundliteral, align 16 + %call = call spir_func <4 x i32> @_Z12read_imageui14ocl_image3d_roDv4_i(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %0, <4 x i32> noundef %1) + store <4 x i32> %call, ptr %c, align 16 + ret void +} + +declare spir_func <4 x i32> @_Z12read_imageui14ocl_image3d_roDv4_i(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %0, <4 x i32> noundef %1) + +define dso_local spir_kernel void @kernelB(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %input) { +entry: + %input.addr = alloca target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0), align 8 + %f = alloca <4 x float>, align 16 + %.compoundliteral = alloca <4 x i32>, align 16 + store target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %input, ptr %input.addr, align 8 + %0 = load target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0), ptr %input.addr, align 8 + store <4 x i32> zeroinitializer, ptr %.compoundliteral, align 16 + %1 = load <4 x i32>, ptr %.compoundliteral, align 16 + %call = call spir_func <4 x float> @_Z11read_imagef14ocl_image3d_roDv4_i(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %0, <4 x i32> noundef %1) + store <4 x float> %call, ptr %f, align 16 + ret void +} + +declare spir_func <4 x float> @_Z11read_imagef14ocl_image3d_roDv4_i(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %0, <4 x i32> noundef %1) Index: llvm/test/CodeGen/SPIRV/types/image-sample-explicit-level-of-details.ll =================================================================== --- llvm/test/CodeGen/SPIRV/types/image-sample-explicit-level-of-details.ll +++ llvm/test/CodeGen/SPIRV/types/image-sample-explicit-level-of-details.ll @@ -1,16 +1,14 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ; CHECK-SPIRV-DAG: %[[#RetID:]] = OpImageSampleExplicitLod %[[#RetType:]] %[[#]] %[[#]] Lod %[[#]] ; CHECK-SPIRV-DAG: %[[#RetType]] = OpTypeVector %[[#]] 4 ; CHECK-SPIRV: %[[#]] = OpCompositeExtract %[[#]] %[[#RetID]] 0 -%opencl.image2d_depth_ro_t = type opaque - -define spir_kernel void @sample_kernel(%opencl.image2d_depth_ro_t addrspace(1)* %input, i32 %imageSampler, float addrspace(1)* %xOffsets, float addrspace(1)* %yOffsets, float addrspace(1)* %results) { +define spir_kernel void @sample_kernel(target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 0) %input, i32 %imageSampler, float addrspace(1)* %xOffsets, float addrspace(1)* %yOffsets, float addrspace(1)* %results) { entry: %call = call spir_func i32 @_Z13get_global_idj(i32 0) %call1 = call spir_func i32 @_Z13get_global_idj(i32 1) - %call2.tmp1 = call spir_func <2 x i32> @_Z13get_image_dim20ocl_image2d_depth_ro(%opencl.image2d_depth_ro_t addrspace(1)* %input) + %call2.tmp1 = call spir_func <2 x i32> @_Z13get_image_dim20ocl_image2d_depth_ro(target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 0) %input) %call2.old = extractelement <2 x i32> %call2.tmp1, i32 0 %mul = mul i32 %call1, %call2.old %add = add i32 %mul, %call @@ -22,14 +20,14 @@ %1 = load float, float addrspace(1)* %arrayidx3, align 4 %conv4 = fptosi float %1 to i32 %vecinit5 = insertelement <2 x i32> %vecinit, i32 %conv4, i32 1 - %call6.tmp.tmp = call spir_func float @_Z11read_imagef20ocl_image2d_depth_ro11ocl_samplerDv2_i(%opencl.image2d_depth_ro_t addrspace(1)* %input, i32 %imageSampler, <2 x i32> %vecinit5) + %call6.tmp.tmp = call spir_func float @_Z11read_imagef20ocl_image2d_depth_ro11ocl_samplerDv2_i(target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 0) %input, i32 %imageSampler, <2 x i32> %vecinit5) %arrayidx7 = getelementptr inbounds float, float addrspace(1)* %results, i32 %add store float %call6.tmp.tmp, float addrspace(1)* %arrayidx7, align 4 ret void } -declare spir_func float @_Z11read_imagef20ocl_image2d_depth_ro11ocl_samplerDv2_i(%opencl.image2d_depth_ro_t addrspace(1)*, i32, <2 x i32>) +declare spir_func float @_Z11read_imagef20ocl_image2d_depth_ro11ocl_samplerDv2_i(target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 0), i32, <2 x i32>) declare spir_func i32 @_Z13get_global_idj(i32) -declare spir_func <2 x i32> @_Z13get_image_dim20ocl_image2d_depth_ro(%opencl.image2d_depth_ro_t addrspace(1)*) +declare spir_func <2 x i32> @_Z13get_image_dim20ocl_image2d_depth_ro(target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 0)) \ No newline at end of file Index: llvm/test/CodeGen/SPIRV/types/image-sampled.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/SPIRV/types/image-sampled.ll @@ -0,0 +1,27 @@ +; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s + +; CHECK: %[[#image1d_t:]] = OpTypeImage +; CHECK: %[[#sampler_t:]] = OpTypeSampler +; CHECK: %[[#sampled_image_t:]] = OpTypeSampledImage + +declare dso_local spir_func ptr addrspace(4) @_Z20__spirv_SampledImageI14ocl_image1d_roPvET0_T_11ocl_sampler(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %0, target("spirv.Sampler") %1) local_unnamed_addr + +declare dso_local spir_func <4 x float> @_Z30__spirv_ImageSampleExplicitLodIPvDv4_fiET0_T_T1_if(ptr addrspace(4) %0, i32 %1, i32 %2, float %3) local_unnamed_addr + +@__spirv_BuiltInGlobalInvocationId = external dso_local local_unnamed_addr addrspace(2) constant <3 x i64>, align 32 + +define weak_odr dso_local spir_kernel void @_ZTS17image_kernel_readILi1EE(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0), target("spirv.Sampler")) { +; CHECK: OpFunction +; CHECK: %[[#image:]] = OpFunctionParameter %[[#image1d_t]] +; CHECK: %[[#sampler:]] = OpFunctionParameter %[[#sampler_t]] + %3 = load <3 x i64>, ptr addrspace(2) @__spirv_BuiltInGlobalInvocationId, align 32 + %4 = extractelement <3 x i64> %3, i64 0 + %5 = trunc i64 %4 to i32 + %6 = call spir_func ptr addrspace(4) @_Z20__spirv_SampledImageI14ocl_image1d_roPvET0_T_11ocl_sampler(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %0, target("spirv.Sampler") %1) + %7 = call spir_func <4 x float> @_Z30__spirv_ImageSampleExplicitLodIPvDv4_fiET0_T_T1_if(ptr addrspace(4) %6, i32 %5, i32 2, float 0.000000e+00) + +; CHECK: %[[#sampled_image:]] = OpSampledImage %[[#sampled_image_t]] %[[#image]] %[[#sampler]] +; CHECK: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#sampled_image]] %[[#]] {{.*}} %[[#]] + + ret void +} Index: llvm/test/CodeGen/SPIRV/types/image-sampled2.ll =================================================================== --- llvm/test/CodeGen/SPIRV/types/image-sampled2.ll +++ llvm/test/CodeGen/SPIRV/types/image-sampled2.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ;; constant sampler_t constSampl = CLK_FILTER_LINEAR; ;; @@ -16,9 +16,6 @@ ;; *results = read_imagei(input, CLK_FILTER_NEAREST|CLK_ADDRESS_REPEAT, coords); ;; } -%opencl.image2d_ro_t = type opaque -%opencl.sampler_t = type opaque - ; CHECK-SPIRV: OpCapability LiteralSampler ; CHECK-SPIRV: OpName %[[#sample_kernel_float:]] "sample_kernel_float" ; CHECK-SPIRV: OpName %[[#sample_kernel_int:]] "sample_kernel_int" @@ -43,22 +40,22 @@ ; CHECK-SPIRV: %[[#SampledImage3:]] = OpSampledImage %[[#SampledImageTy]] %[[#InputImage]] %[[#ConstSampler2]] ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SampledImage3]] -define dso_local spir_kernel void @sample_kernel_float(%opencl.image2d_ro_t addrspace(1)* %input, <2 x float> noundef %coords, <4 x float> addrspace(1)* nocapture noundef writeonly %results, %opencl.sampler_t addrspace(2)* %argSampl) local_unnamed_addr { +define dso_local spir_kernel void @sample_kernel_float(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, <2 x float> noundef %coords, <4 x float> addrspace(1)* nocapture noundef writeonly %results, target("spirv.Sampler") %argSampl) local_unnamed_addr { entry: - %0 = tail call spir_func %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 32) - %call = tail call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(%opencl.image2d_ro_t addrspace(1)* %input, %opencl.sampler_t addrspace(2)* %0, <2 x float> noundef %coords) + %0 = tail call spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32 32) + %call = tail call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, target("spirv.Sampler") %0, <2 x float> noundef %coords) store <4 x float> %call, <4 x float> addrspace(1)* %results, align 16 - %call1 = tail call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(%opencl.image2d_ro_t addrspace(1)* %input, %opencl.sampler_t addrspace(2)* %argSampl, <2 x float> noundef %coords) + %call1 = tail call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, target("spirv.Sampler") %argSampl, <2 x float> noundef %coords) store <4 x float> %call1, <4 x float> addrspace(1)* %results, align 16 - %1 = tail call spir_func %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 22) - %call2 = tail call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(%opencl.image2d_ro_t addrspace(1)* %input, %opencl.sampler_t addrspace(2)* %1, <2 x float> noundef %coords) + %1 = tail call spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32 22) + %call2 = tail call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, target("spirv.Sampler") %1, <2 x float> noundef %coords) store <4 x float> %call2, <4 x float> addrspace(1)* %results, align 16 ret void } -declare spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(%opencl.image2d_ro_t addrspace(1)*, %opencl.sampler_t addrspace(2)*, <2 x float> noundef) local_unnamed_addr +declare spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), target("spirv.Sampler"), <2 x float> noundef) local_unnamed_addr -declare spir_func %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32) local_unnamed_addr +declare spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32) local_unnamed_addr ; CHECK-SPIRV: %[[#sample_kernel_int]] = OpFunction %{{.*}} ; CHECK-SPIRV: %[[#InputImage:]] = OpFunctionParameter %{{.*}} @@ -73,17 +70,17 @@ ; CHECK-SPIRV: %[[#SampledImage6:]] = OpSampledImage %[[#SampledImageTy]] %[[#InputImage]] %[[#ConstSampler4]] ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SampledImage6]] -define dso_local spir_kernel void @sample_kernel_int(%opencl.image2d_ro_t addrspace(1)* %input, <2 x float> noundef %coords, <4 x i32> addrspace(1)* nocapture noundef writeonly %results, %opencl.sampler_t addrspace(2)* %argSampl) local_unnamed_addr { +define dso_local spir_kernel void @sample_kernel_int(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, <2 x float> noundef %coords, <4 x i32> addrspace(1)* nocapture noundef writeonly %results, target("spirv.Sampler") %argSampl) local_unnamed_addr { entry: - %0 = tail call spir_func %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 32) - %call = tail call spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(%opencl.image2d_ro_t addrspace(1)* %input, %opencl.sampler_t addrspace(2)* %0, <2 x float> noundef %coords) + %0 = tail call spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32 32) + %call = tail call spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, target("spirv.Sampler") %0, <2 x float> noundef %coords) store <4 x i32> %call, <4 x i32> addrspace(1)* %results, align 16 - %call1 = tail call spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(%opencl.image2d_ro_t addrspace(1)* %input, %opencl.sampler_t addrspace(2)* %argSampl, <2 x float> noundef %coords) + %call1 = tail call spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, target("spirv.Sampler") %argSampl, <2 x float> noundef %coords) store <4 x i32> %call1, <4 x i32> addrspace(1)* %results, align 16 - %1 = tail call spir_func %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 22) - %call2 = tail call spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(%opencl.image2d_ro_t addrspace(1)* %input, %opencl.sampler_t addrspace(2)* %1, <2 x float> noundef %coords) + %1 = tail call spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32 22) + %call2 = tail call spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, target("spirv.Sampler") %1, <2 x float> noundef %coords) store <4 x i32> %call2, <4 x i32> addrspace(1)* %results, align 16 ret void } -declare spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(%opencl.image2d_ro_t addrspace(1)*, %opencl.sampler_t addrspace(2)*, <2 x float> noundef) local_unnamed_addr +declare spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), target("spirv.Sampler"), <2 x float> noundef) local_unnamed_addr Index: llvm/test/CodeGen/SPIRV/types/image-unoptimized.ll =================================================================== --- llvm/test/CodeGen/SPIRV/types/image-unoptimized.ll +++ llvm/test/CodeGen/SPIRV/types/image-unoptimized.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s ; CHECK: %[[#TypeImage:]] = OpTypeImage ; CHECK: %[[#TypeSampler:]] = OpTypeSampler @@ -43,38 +43,35 @@ ;; results[tid_x + tid_y * get_image_width(srcimg)] = read_imagef(srcimg, sampler, (int2){tid_x, tid_y}); ;; } -%opencl.image2d_ro_t = type opaque -%opencl.sampler_t = type opaque - -define dso_local spir_kernel void @test_fn(%opencl.image2d_ro_t addrspace(1)* %srcimg, %opencl.sampler_t addrspace(2)* %sampler, <4 x float> addrspace(1)* noundef %results) { +define dso_local spir_kernel void @test_fn(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %srcimg, target("spirv.Sampler") %sampler, <4 x float> addrspace(1)* noundef %results) { entry: - %srcimg.addr = alloca %opencl.image2d_ro_t addrspace(1)*, align 4 - %sampler.addr = alloca %opencl.sampler_t addrspace(2)*, align 4 + %srcimg.addr = alloca target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), align 4 + %sampler.addr = alloca target("spirv.Sampler"), align 4 %results.addr = alloca <4 x float> addrspace(1)*, align 4 %tid_x = alloca i32, align 4 %tid_y = alloca i32, align 4 %.compoundliteral = alloca <2 x i32>, align 8 - store %opencl.image2d_ro_t addrspace(1)* %srcimg, %opencl.image2d_ro_t addrspace(1)** %srcimg.addr, align 4 - store %opencl.sampler_t addrspace(2)* %sampler, %opencl.sampler_t addrspace(2)** %sampler.addr, align 4 + store target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %srcimg, target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0)* %srcimg.addr, align 4 + store target("spirv.Sampler") %sampler, target("spirv.Sampler")* %sampler.addr, align 4 store <4 x float> addrspace(1)* %results, <4 x float> addrspace(1)** %results.addr, align 4 %call = call spir_func i32 @_Z13get_global_idj(i32 noundef 0) store i32 %call, i32* %tid_x, align 4 %call1 = call spir_func i32 @_Z13get_global_idj(i32 noundef 1) store i32 %call1, i32* %tid_y, align 4 - %0 = load %opencl.image2d_ro_t addrspace(1)*, %opencl.image2d_ro_t addrspace(1)** %srcimg.addr, align 4 - %1 = load %opencl.sampler_t addrspace(2)*, %opencl.sampler_t addrspace(2)** %sampler.addr, align 4 + %0 = load target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0)* %srcimg.addr, align 4 + %1 = load target("spirv.Sampler"), target("spirv.Sampler")* %sampler.addr, align 4 %2 = load i32, i32* %tid_x, align 4 %vecinit = insertelement <2 x i32> undef, i32 %2, i32 0 %3 = load i32, i32* %tid_y, align 4 %vecinit2 = insertelement <2 x i32> %vecinit, i32 %3, i32 1 store <2 x i32> %vecinit2, <2 x i32>* %.compoundliteral, align 8 %4 = load <2 x i32>, <2 x i32>* %.compoundliteral, align 8 - %call3 = call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_i(%opencl.image2d_ro_t addrspace(1)* %0, %opencl.sampler_t addrspace(2)* %1, <2 x i32> noundef %4) + %call3 = call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %0, target("spirv.Sampler") %1, <2 x i32> noundef %4) %5 = load <4 x float> addrspace(1)*, <4 x float> addrspace(1)** %results.addr, align 4 %6 = load i32, i32* %tid_x, align 4 %7 = load i32, i32* %tid_y, align 4 - %8 = load %opencl.image2d_ro_t addrspace(1)*, %opencl.image2d_ro_t addrspace(1)** %srcimg.addr, align 4 - %call4 = call spir_func i32 @_Z15get_image_width14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)* %8) + %8 = load target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0)* %srcimg.addr, align 4 + %call4 = call spir_func i32 @_Z15get_image_width14ocl_image2d_ro(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %8) %mul = mul nsw i32 %7, %call4 %add = add nsw i32 %6, %mul %arrayidx = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %5, i32 %add @@ -84,6 +81,6 @@ declare spir_func i32 @_Z13get_global_idj(i32 noundef) -declare spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_i(%opencl.image2d_ro_t addrspace(1)*, %opencl.sampler_t addrspace(2)*, <2 x i32> noundef) +declare spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), target("spirv.Sampler"), <2 x i32> noundef) -declare spir_func i32 @_Z15get_image_width14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)*) +declare spir_func i32 @_Z15get_image_width14ocl_image2d_ro(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0)) Index: llvm/test/CodeGen/SPIRV/types/image-various-dimensions-access-qualifiers.ll =================================================================== --- llvm/test/CodeGen/SPIRV/types/image-various-dimensions-access-qualifiers.ll +++ llvm/test/CodeGen/SPIRV/types/image-various-dimensions-access-qualifiers.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s ;; FIXME: Write tests to ensure invalid usage of image are rejected, such as: ;; - invalid AS (only global is allowed); @@ -6,28 +6,24 @@ ;; - used with invalid CV-qualifiers (const or volatile in C99). ;; FIXME: Write further tests to cover _array, _buffer, _depth, ... types. -%opencl.image1d_ro_t = type opaque ;; read_only image1d_t -%opencl.image2d_wo_t = type opaque ;; write_only image2d_t -%opencl.image3d_rw_t = type opaque ;; read_write image3d_t - define void @foo( - %opencl.image1d_ro_t addrspace(1)* %a, - %opencl.image2d_wo_t addrspace(1)* %b, - %opencl.image3d_rw_t addrspace(1)* %c, + target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %a, + target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1) %b, + target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 2) %c, i32 addrspace(1)* %d ) { - %pixel = call <4 x i32> @_Z11read_imagei14ocl_image1d_roi(%opencl.image1d_ro_t addrspace(1)* %a, i32 0) - call void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(%opencl.image2d_wo_t addrspace(1)* %b, <2 x i32> zeroinitializer, <4 x i32> %pixel) - %size = call i32 @_Z15get_image_width14ocl_image3d_rw(%opencl.image3d_rw_t addrspace(1)* %c) + %pixel = call <4 x i32> @_Z11read_imagei14ocl_image1d_roi(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %a, i32 0) + call void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1) %b, <2 x i32> zeroinitializer, <4 x i32> %pixel) + %size = call i32 @_Z15get_image_width14ocl_image3d_rw(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 2) %c) store i32 %size, i32 addrspace(1)* %d ret void } -declare <4 x i32> @_Z11read_imagei14ocl_image1d_roi(%opencl.image1d_ro_t addrspace(1)*, i32) +declare <4 x i32> @_Z11read_imagei14ocl_image1d_roi(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0), i32) -declare void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(%opencl.image2d_wo_t addrspace(1)*, <2 x i32>, <4 x i32>) +declare void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1), <2 x i32>, <4 x i32>) -declare i32 @_Z15get_image_width14ocl_image3d_rw(%opencl.image3d_rw_t addrspace(1)*) +declare i32 @_Z15get_image_width14ocl_image3d_rw(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 2)) ;; Capabilities: Index: llvm/test/CodeGen/SPIRV/types/image-write.ll =================================================================== --- llvm/test/CodeGen/SPIRV/types/image-write.ll +++ llvm/test/CodeGen/SPIRV/types/image-write.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ; CHECK-SPIRV: %[[#VOID_TY:]] = OpTypeVoid ; CHECK-SPIRV: %[[#IMG2D_WO_TY:]] = OpTypeImage %[[#VOID_TY]] 2D 0 0 0 0 Unknown WriteOnly @@ -16,21 +16,6 @@ ; CHECK-SPIRV: %[[#IMG3D_WO_TY:]] = OpTypeImage %[[#VOID_TY]] 3D 0 0 0 0 Unknown WriteOnly ; CHECK-SPIRV: %[[#IMG3D_RW_TY:]] = OpTypeImage %[[#VOID_TY]] 3D 0 0 0 0 Unknown ReadWrite -%opencl.image2d_wo_t = type opaque -%opencl.image2d_rw_t = type opaque -%opencl.image2d_array_wo_t = type opaque -%opencl.image2d_array_rw_t = type opaque -%opencl.image1d_wo_t = type opaque -%opencl.image1d_rw_t = type opaque -%opencl.image1d_buffer_wo_t = type opaque -%opencl.image1d_buffer_rw_t = type opaque -%opencl.image1d_array_wo_t = type opaque -%opencl.image1d_array_rw_t = type opaque -%opencl.image2d_depth_wo_t = type opaque -%opencl.image2d_array_depth_wo_t = type opaque -%opencl.image3d_wo_t = type opaque -%opencl.image3d_rw_t = type opaque - ;; kernel void test_img2d(write_only image2d_t image_wo, read_write image2d_t image_rw) ;; { ;; write_imagef(image_wo, (int2)(0,0), (float4)(0,0,0,0)); @@ -53,28 +38,28 @@ ; CHECK-SPIRV: OpImageWrite %[[#IMG2D_WO]] ; CHECK-SPIRV: OpImageWrite %[[#IMG2D_WO]] -define dso_local spir_kernel void @test_img2d(%opencl.image2d_wo_t addrspace(1)* %image_wo, %opencl.image2d_rw_t addrspace(1)* %image_rw) local_unnamed_addr { +define dso_local spir_kernel void @test_img2d(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1) %image_wo, target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 2) %image_rw) local_unnamed_addr { entry: - call spir_func void @_Z12write_imagef14ocl_image2d_woDv2_iDv4_f(%opencl.image2d_wo_t addrspace(1)* %image_wo, <2 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(%opencl.image2d_wo_t addrspace(1)* %image_wo, <2 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) - call spir_func void @_Z12write_imagef14ocl_image2d_rwDv2_iDv4_f(%opencl.image2d_rw_t addrspace(1)* %image_rw, <2 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei14ocl_image2d_rwDv2_iDv4_i(%opencl.image2d_rw_t addrspace(1)* %image_rw, <2 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) - call spir_func void @_Z12write_imagef14ocl_image2d_woDv2_iiDv4_f(%opencl.image2d_wo_t addrspace(1)* %image_wo, <2 x i32> noundef zeroinitializer, i32 noundef 0, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei14ocl_image2d_woDv2_iiDv4_i(%opencl.image2d_wo_t addrspace(1)* %image_wo, <2 x i32> noundef zeroinitializer, i32 noundef 0, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef14ocl_image2d_woDv2_iDv4_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1) %image_wo, <2 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1) %image_wo, <2 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef14ocl_image2d_rwDv2_iDv4_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 2) %image_rw, <2 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei14ocl_image2d_rwDv2_iDv4_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 2) %image_rw, <2 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef14ocl_image2d_woDv2_iiDv4_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1) %image_wo, <2 x i32> noundef zeroinitializer, i32 noundef 0, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei14ocl_image2d_woDv2_iiDv4_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1) %image_wo, <2 x i32> noundef zeroinitializer, i32 noundef 0, <4 x i32> noundef zeroinitializer) ret void } -declare spir_func void @_Z12write_imagef14ocl_image2d_woDv2_iDv4_f(%opencl.image2d_wo_t addrspace(1)*, <2 x i32> noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef14ocl_image2d_woDv2_iDv4_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1), <2 x i32> noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(%opencl.image2d_wo_t addrspace(1)*, <2 x i32> noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1), <2 x i32> noundef, <4 x i32> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagef14ocl_image2d_rwDv2_iDv4_f(%opencl.image2d_rw_t addrspace(1)*, <2 x i32> noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef14ocl_image2d_rwDv2_iDv4_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 2), <2 x i32> noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei14ocl_image2d_rwDv2_iDv4_i(%opencl.image2d_rw_t addrspace(1)*, <2 x i32> noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei14ocl_image2d_rwDv2_iDv4_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 2), <2 x i32> noundef, <4 x i32> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagef14ocl_image2d_woDv2_iiDv4_f(%opencl.image2d_wo_t addrspace(1)*, <2 x i32> noundef, i32 noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef14ocl_image2d_woDv2_iiDv4_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1), <2 x i32> noundef, i32 noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei14ocl_image2d_woDv2_iiDv4_i(%opencl.image2d_wo_t addrspace(1)*, <2 x i32> noundef, i32 noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei14ocl_image2d_woDv2_iiDv4_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1), <2 x i32> noundef, i32 noundef, <4 x i32> noundef) local_unnamed_addr ;; kernel void test_img2d_array(write_only image2d_array_t image_wo, read_write image2d_array_t image_rw) ;; { @@ -98,28 +83,28 @@ ; CHECK-SPIRV: OpImageWrite %[[#IMG2D_ARRAY_WO]] ; CHECK-SPIRV: OpImageWrite %[[#IMG2D_ARRAY_WO]] -define dso_local spir_kernel void @test_img2d_array(%opencl.image2d_array_wo_t addrspace(1)* %image_wo, %opencl.image2d_array_rw_t addrspace(1)* %image_rw) local_unnamed_addr { +define dso_local spir_kernel void @test_img2d_array(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 1) %image_wo, target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 2) %image_rw) local_unnamed_addr { entry: - call spir_func void @_Z12write_imagef20ocl_image2d_array_woDv4_iDv4_f(%opencl.image2d_array_wo_t addrspace(1)* %image_wo, <4 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei20ocl_image2d_array_woDv4_iS0_(%opencl.image2d_array_wo_t addrspace(1)* %image_wo, <4 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) - call spir_func void @_Z12write_imagef20ocl_image2d_array_rwDv4_iDv4_f(%opencl.image2d_array_rw_t addrspace(1)* %image_rw, <4 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei20ocl_image2d_array_rwDv4_iS0_(%opencl.image2d_array_rw_t addrspace(1)* %image_rw, <4 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) - call spir_func void @_Z12write_imagef20ocl_image2d_array_woDv4_iiDv4_f(%opencl.image2d_array_wo_t addrspace(1)* %image_wo, <4 x i32> noundef zeroinitializer, i32 noundef 0, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei20ocl_image2d_array_woDv4_iiS0_(%opencl.image2d_array_wo_t addrspace(1)* %image_wo, <4 x i32> noundef zeroinitializer, i32 noundef 0, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef20ocl_image2d_array_woDv4_iDv4_f(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 1) %image_wo, <4 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei20ocl_image2d_array_woDv4_iS0_(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 1) %image_wo, <4 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef20ocl_image2d_array_rwDv4_iDv4_f(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 2) %image_rw, <4 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei20ocl_image2d_array_rwDv4_iS0_(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 2) %image_rw, <4 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef20ocl_image2d_array_woDv4_iiDv4_f(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 1) %image_wo, <4 x i32> noundef zeroinitializer, i32 noundef 0, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei20ocl_image2d_array_woDv4_iiS0_(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 1) %image_wo, <4 x i32> noundef zeroinitializer, i32 noundef 0, <4 x i32> noundef zeroinitializer) ret void } -declare spir_func void @_Z12write_imagef20ocl_image2d_array_woDv4_iDv4_f(%opencl.image2d_array_wo_t addrspace(1)*, <4 x i32> noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef20ocl_image2d_array_woDv4_iDv4_f(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 1), <4 x i32> noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei20ocl_image2d_array_woDv4_iS0_(%opencl.image2d_array_wo_t addrspace(1)*, <4 x i32> noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei20ocl_image2d_array_woDv4_iS0_(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 1), <4 x i32> noundef, <4 x i32> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagef20ocl_image2d_array_rwDv4_iDv4_f(%opencl.image2d_array_rw_t addrspace(1)*, <4 x i32> noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef20ocl_image2d_array_rwDv4_iDv4_f(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 2), <4 x i32> noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei20ocl_image2d_array_rwDv4_iS0_(%opencl.image2d_array_rw_t addrspace(1)*, <4 x i32> noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei20ocl_image2d_array_rwDv4_iS0_(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 2), <4 x i32> noundef, <4 x i32> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagef20ocl_image2d_array_woDv4_iiDv4_f(%opencl.image2d_array_wo_t addrspace(1)*, <4 x i32> noundef, i32 noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef20ocl_image2d_array_woDv4_iiDv4_f(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 1), <4 x i32> noundef, i32 noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei20ocl_image2d_array_woDv4_iiS0_(%opencl.image2d_array_wo_t addrspace(1)*, <4 x i32> noundef, i32 noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei20ocl_image2d_array_woDv4_iiS0_(target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 1), <4 x i32> noundef, i32 noundef, <4 x i32> noundef) local_unnamed_addr ;; kernel void test_img1d(write_only image1d_t image_wo, read_write image1d_t image_rw) ;; { @@ -143,28 +128,28 @@ ; CHECK-SPIRV: OpImageWrite %[[#IMG1D_WO]] ; CHECK-SPIRV: OpImageWrite %[[#IMG1D_WO]] -define dso_local spir_kernel void @test_img1d(%opencl.image1d_wo_t addrspace(1)* %image_wo, %opencl.image1d_rw_t addrspace(1)* %image_rw) local_unnamed_addr { +define dso_local spir_kernel void @test_img1d(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1) %image_wo, target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 2) %image_rw) local_unnamed_addr { entry: - call spir_func void @_Z12write_imagef14ocl_image1d_woiDv4_f(%opencl.image1d_wo_t addrspace(1)* %image_wo, i32 noundef 0, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei14ocl_image1d_woiDv4_i(%opencl.image1d_wo_t addrspace(1)* %image_wo, i32 noundef 0, <4 x i32> noundef zeroinitializer) - call spir_func void @_Z12write_imagef14ocl_image1d_rwiDv4_f(%opencl.image1d_rw_t addrspace(1)* %image_rw, i32 noundef 0, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei14ocl_image1d_rwiDv4_i(%opencl.image1d_rw_t addrspace(1)* %image_rw, i32 noundef 0, <4 x i32> noundef zeroinitializer) - call spir_func void @_Z12write_imagef14ocl_image1d_woiiDv4_f(%opencl.image1d_wo_t addrspace(1)* %image_wo, i32 noundef 0, i32 noundef 0, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei14ocl_image1d_woiiDv4_i(%opencl.image1d_wo_t addrspace(1)* %image_wo, i32 noundef 0, i32 noundef 0, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef14ocl_image1d_woiDv4_f(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1) %image_wo, i32 noundef 0, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei14ocl_image1d_woiDv4_i(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1) %image_wo, i32 noundef 0, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef14ocl_image1d_rwiDv4_f(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 2) %image_rw, i32 noundef 0, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei14ocl_image1d_rwiDv4_i(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 2) %image_rw, i32 noundef 0, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef14ocl_image1d_woiiDv4_f(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1) %image_wo, i32 noundef 0, i32 noundef 0, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei14ocl_image1d_woiiDv4_i(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1) %image_wo, i32 noundef 0, i32 noundef 0, <4 x i32> noundef zeroinitializer) ret void } -declare spir_func void @_Z12write_imagef14ocl_image1d_woiDv4_f(%opencl.image1d_wo_t addrspace(1)*, i32 noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef14ocl_image1d_woiDv4_f(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1), i32 noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei14ocl_image1d_woiDv4_i(%opencl.image1d_wo_t addrspace(1)*, i32 noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei14ocl_image1d_woiDv4_i(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1), i32 noundef, <4 x i32> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagef14ocl_image1d_rwiDv4_f(%opencl.image1d_rw_t addrspace(1)*, i32 noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef14ocl_image1d_rwiDv4_f(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 2), i32 noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei14ocl_image1d_rwiDv4_i(%opencl.image1d_rw_t addrspace(1)*, i32 noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei14ocl_image1d_rwiDv4_i(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 2), i32 noundef, <4 x i32> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagef14ocl_image1d_woiiDv4_f(%opencl.image1d_wo_t addrspace(1)*, i32 noundef, i32 noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef14ocl_image1d_woiiDv4_f(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1), i32 noundef, i32 noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei14ocl_image1d_woiiDv4_i(%opencl.image1d_wo_t addrspace(1)*, i32 noundef, i32 noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei14ocl_image1d_woiiDv4_i(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1), i32 noundef, i32 noundef, <4 x i32> noundef) local_unnamed_addr ;; kernel void test_img1d_buffer(write_only image1d_buffer_t image_wo, read_write image1d_buffer_t image_rw) ;; { @@ -182,22 +167,22 @@ ; CHECK-SPIRV: OpImageWrite %[[#IMG1D_BUFFER_RW]] ; CHECK-SPIRV: OpImageWrite %[[#IMG1D_BUFFER_RW]] -define dso_local spir_kernel void @test_img1d_buffer(%opencl.image1d_buffer_wo_t addrspace(1)* %image_wo, %opencl.image1d_buffer_rw_t addrspace(1)* %image_rw) local_unnamed_addr { +define dso_local spir_kernel void @test_img1d_buffer(target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 1) %image_wo, target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 2) %image_rw) local_unnamed_addr { entry: - call spir_func void @_Z12write_imagef21ocl_image1d_buffer_woiDv4_f(%opencl.image1d_buffer_wo_t addrspace(1)* %image_wo, i32 noundef 0, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei21ocl_image1d_buffer_woiDv4_i(%opencl.image1d_buffer_wo_t addrspace(1)* %image_wo, i32 noundef 0, <4 x i32> noundef zeroinitializer) - call spir_func void @_Z12write_imagef21ocl_image1d_buffer_rwiDv4_f(%opencl.image1d_buffer_rw_t addrspace(1)* %image_rw, i32 noundef 0, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei21ocl_image1d_buffer_rwiDv4_i(%opencl.image1d_buffer_rw_t addrspace(1)* %image_rw, i32 noundef 0, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef21ocl_image1d_buffer_woiDv4_f(target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 1) %image_wo, i32 noundef 0, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei21ocl_image1d_buffer_woiDv4_i(target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 1) %image_wo, i32 noundef 0, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef21ocl_image1d_buffer_rwiDv4_f(target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 2) %image_rw, i32 noundef 0, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei21ocl_image1d_buffer_rwiDv4_i(target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 2) %image_rw, i32 noundef 0, <4 x i32> noundef zeroinitializer) ret void } -declare spir_func void @_Z12write_imagef21ocl_image1d_buffer_woiDv4_f(%opencl.image1d_buffer_wo_t addrspace(1)*, i32 noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef21ocl_image1d_buffer_woiDv4_f(target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 1), i32 noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei21ocl_image1d_buffer_woiDv4_i(%opencl.image1d_buffer_wo_t addrspace(1)*, i32 noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei21ocl_image1d_buffer_woiDv4_i(target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 1), i32 noundef, <4 x i32> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagef21ocl_image1d_buffer_rwiDv4_f(%opencl.image1d_buffer_rw_t addrspace(1)*, i32 noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef21ocl_image1d_buffer_rwiDv4_f(target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 2), i32 noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei21ocl_image1d_buffer_rwiDv4_i(%opencl.image1d_buffer_rw_t addrspace(1)*, i32 noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei21ocl_image1d_buffer_rwiDv4_i(target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 2), i32 noundef, <4 x i32> noundef) local_unnamed_addr ;; kernel void test_img1d_array(write_only image1d_array_t image_wo, read_write image1d_array_t image_rw) ;; { @@ -221,28 +206,28 @@ ; CHECK-SPIRV: OpImageWrite %[[#IMG1D_ARRAY_WO]] ; CHECK-SPIRV: OpImageWrite %[[#IMG1D_ARRAY_WO]] -define dso_local spir_kernel void @test_img1d_array(%opencl.image1d_array_wo_t addrspace(1)* %image_wo, %opencl.image1d_array_rw_t addrspace(1)* %image_rw) local_unnamed_addr { +define dso_local spir_kernel void @test_img1d_array(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 1) %image_wo, target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 2) %image_rw) local_unnamed_addr { entry: - call spir_func void @_Z12write_imagef20ocl_image1d_array_woDv2_iDv4_f(%opencl.image1d_array_wo_t addrspace(1)* %image_wo, <2 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei20ocl_image1d_array_woDv2_iDv4_i(%opencl.image1d_array_wo_t addrspace(1)* %image_wo, <2 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) - call spir_func void @_Z12write_imagef20ocl_image1d_array_rwDv2_iDv4_f(%opencl.image1d_array_rw_t addrspace(1)* %image_rw, <2 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei20ocl_image1d_array_rwDv2_iDv4_i(%opencl.image1d_array_rw_t addrspace(1)* %image_rw, <2 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) - call spir_func void @_Z12write_imagef20ocl_image1d_array_woDv2_iiDv4_f(%opencl.image1d_array_wo_t addrspace(1)* %image_wo, <2 x i32> noundef zeroinitializer, i32 noundef 0, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei20ocl_image1d_array_woDv2_iiDv4_i(%opencl.image1d_array_wo_t addrspace(1)* %image_wo, <2 x i32> noundef zeroinitializer, i32 noundef 0, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef20ocl_image1d_array_woDv2_iDv4_f(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 1) %image_wo, <2 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei20ocl_image1d_array_woDv2_iDv4_i(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 1) %image_wo, <2 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef20ocl_image1d_array_rwDv2_iDv4_f(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 2) %image_rw, <2 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei20ocl_image1d_array_rwDv2_iDv4_i(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 2) %image_rw, <2 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef20ocl_image1d_array_woDv2_iiDv4_f(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 1) %image_wo, <2 x i32> noundef zeroinitializer, i32 noundef 0, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei20ocl_image1d_array_woDv2_iiDv4_i(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 1) %image_wo, <2 x i32> noundef zeroinitializer, i32 noundef 0, <4 x i32> noundef zeroinitializer) ret void } -declare spir_func void @_Z12write_imagef20ocl_image1d_array_woDv2_iDv4_f(%opencl.image1d_array_wo_t addrspace(1)*, <2 x i32> noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef20ocl_image1d_array_woDv2_iDv4_f(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 1), <2 x i32> noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei20ocl_image1d_array_woDv2_iDv4_i(%opencl.image1d_array_wo_t addrspace(1)*, <2 x i32> noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei20ocl_image1d_array_woDv2_iDv4_i(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 1), <2 x i32> noundef, <4 x i32> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagef20ocl_image1d_array_rwDv2_iDv4_f(%opencl.image1d_array_rw_t addrspace(1)*, <2 x i32> noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef20ocl_image1d_array_rwDv2_iDv4_f(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 2), <2 x i32> noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei20ocl_image1d_array_rwDv2_iDv4_i(%opencl.image1d_array_rw_t addrspace(1)*, <2 x i32> noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei20ocl_image1d_array_rwDv2_iDv4_i(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 2), <2 x i32> noundef, <4 x i32> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagef20ocl_image1d_array_woDv2_iiDv4_f(%opencl.image1d_array_wo_t addrspace(1)*, <2 x i32> noundef, i32 noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef20ocl_image1d_array_woDv2_iiDv4_f(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 1), <2 x i32> noundef, i32 noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei20ocl_image1d_array_woDv2_iiDv4_i(%opencl.image1d_array_wo_t addrspace(1)*, <2 x i32> noundef, i32 noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei20ocl_image1d_array_woDv2_iiDv4_i(target("spirv.Image", void, 0, 0, 1, 0, 0, 0, 1), <2 x i32> noundef, i32 noundef, <4 x i32> noundef) local_unnamed_addr ;; kernel void test_img2d_depth(write_only image2d_depth_t image_wo) ;; { @@ -259,17 +244,17 @@ ; CHECK-SPIRV: OpImageWrite %[[#IMG2D_DEPTH_WO]] ; CHECK-SPIRV: OpImageWrite %[[#IMG2D_DEPTH_WO]] -define dso_local spir_kernel void @test_img2d_depth(%opencl.image2d_depth_wo_t addrspace(1)* %image_wo) local_unnamed_addr { +define dso_local spir_kernel void @test_img2d_depth(target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 1) %image_wo) local_unnamed_addr { entry: - call spir_func void @_Z12write_imagef20ocl_image2d_depth_woDv2_if(%opencl.image2d_depth_wo_t addrspace(1)* %image_wo, <2 x i32> noundef zeroinitializer, float noundef 0.000000e+00) - call spir_func void @_Z12write_imagef20ocl_image2d_depth_woDv2_if(%opencl.image2d_depth_wo_t addrspace(1)* %image_wo, <2 x i32> noundef zeroinitializer, float noundef 0.000000e+00) - call spir_func void @_Z12write_imagef20ocl_image2d_depth_woDv2_iif(%opencl.image2d_depth_wo_t addrspace(1)* %image_wo, <2 x i32> noundef zeroinitializer, i32 noundef 0, float noundef 0.000000e+00) + call spir_func void @_Z12write_imagef20ocl_image2d_depth_woDv2_if(target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 1) %image_wo, <2 x i32> noundef zeroinitializer, float noundef 0.000000e+00) + call spir_func void @_Z12write_imagef20ocl_image2d_depth_woDv2_if(target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 1) %image_wo, <2 x i32> noundef zeroinitializer, float noundef 0.000000e+00) + call spir_func void @_Z12write_imagef20ocl_image2d_depth_woDv2_iif(target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 1) %image_wo, <2 x i32> noundef zeroinitializer, i32 noundef 0, float noundef 0.000000e+00) ret void } -declare spir_func void @_Z12write_imagef20ocl_image2d_depth_woDv2_if(%opencl.image2d_depth_wo_t addrspace(1)*, <2 x i32> noundef, float noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef20ocl_image2d_depth_woDv2_if(target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 1), <2 x i32> noundef, float noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagef20ocl_image2d_depth_woDv2_iif(%opencl.image2d_depth_wo_t addrspace(1)*, <2 x i32> noundef, i32 noundef, float noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef20ocl_image2d_depth_woDv2_iif(target("spirv.Image", void, 1, 1, 0, 0, 0, 0, 1), <2 x i32> noundef, i32 noundef, float noundef) local_unnamed_addr ;; kernel void test_img2d_array_depth(write_only image2d_array_depth_t image_wo) ;; { @@ -286,17 +271,17 @@ ; CHECK-SPIRV: OpImageWrite %[[#IMG2D_ARRAY_DEPTH_WO]] ; CHECK-SPIRV: OpImageWrite %[[#IMG2D_ARRAY_DEPTH_WO]] -define dso_local spir_kernel void @test_img2d_array_depth(%opencl.image2d_array_depth_wo_t addrspace(1)* %image_wo) local_unnamed_addr { +define dso_local spir_kernel void @test_img2d_array_depth(target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 1) %image_wo) local_unnamed_addr { entry: - call spir_func void @_Z12write_imagef26ocl_image2d_array_depth_woDv4_if(%opencl.image2d_array_depth_wo_t addrspace(1)* %image_wo, <4 x i32> noundef zeroinitializer, float noundef 0.000000e+00) - call spir_func void @_Z12write_imagef26ocl_image2d_array_depth_woDv4_if(%opencl.image2d_array_depth_wo_t addrspace(1)* %image_wo, <4 x i32> noundef zeroinitializer, float noundef 0.000000e+00) - call spir_func void @_Z12write_imagef26ocl_image2d_array_depth_woDv4_iif(%opencl.image2d_array_depth_wo_t addrspace(1)* %image_wo, <4 x i32> noundef zeroinitializer, i32 noundef 0, float noundef 0.000000e+00) + call spir_func void @_Z12write_imagef26ocl_image2d_array_depth_woDv4_if(target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 1) %image_wo, <4 x i32> noundef zeroinitializer, float noundef 0.000000e+00) + call spir_func void @_Z12write_imagef26ocl_image2d_array_depth_woDv4_if(target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 1) %image_wo, <4 x i32> noundef zeroinitializer, float noundef 0.000000e+00) + call spir_func void @_Z12write_imagef26ocl_image2d_array_depth_woDv4_iif(target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 1) %image_wo, <4 x i32> noundef zeroinitializer, i32 noundef 0, float noundef 0.000000e+00) ret void } -declare spir_func void @_Z12write_imagef26ocl_image2d_array_depth_woDv4_if(%opencl.image2d_array_depth_wo_t addrspace(1)*, <4 x i32> noundef, float noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef26ocl_image2d_array_depth_woDv4_if(target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 1), <4 x i32> noundef, float noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagef26ocl_image2d_array_depth_woDv4_iif(%opencl.image2d_array_depth_wo_t addrspace(1)*, <4 x i32> noundef, i32 noundef, float noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef26ocl_image2d_array_depth_woDv4_iif(target("spirv.Image", void, 1, 1, 1, 0, 0, 0, 1), <4 x i32> noundef, i32 noundef, float noundef) local_unnamed_addr ;; kernel void test_img3d(write_only image3d_t image_wo, read_write image3d_t image_rw) ;; { @@ -320,25 +305,25 @@ ; CHECK-SPIRV: OpImageWrite %[[#IMG3D_WO]] ; CHECK-SPIRV: OpImageWrite %[[#IMG3D_WO]] -define dso_local spir_kernel void @test_img3d(%opencl.image3d_wo_t addrspace(1)* %image_wo, %opencl.image3d_rw_t addrspace(1)* %image_rw) local_unnamed_addr { +define dso_local spir_kernel void @test_img3d(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1) %image_wo, target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 2) %image_rw) local_unnamed_addr { entry: - call spir_func void @_Z12write_imagef14ocl_image3d_woDv4_iDv4_f(%opencl.image3d_wo_t addrspace(1)* %image_wo, <4 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei14ocl_image3d_woDv4_iS0_(%opencl.image3d_wo_t addrspace(1)* %image_wo, <4 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) - call spir_func void @_Z12write_imagef14ocl_image3d_rwDv4_iDv4_f(%opencl.image3d_rw_t addrspace(1)* %image_rw, <4 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei14ocl_image3d_rwDv4_iS0_(%opencl.image3d_rw_t addrspace(1)* %image_rw, <4 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) - call spir_func void @_Z12write_imagef14ocl_image3d_woDv4_iiDv4_f(%opencl.image3d_wo_t addrspace(1)* %image_wo, <4 x i32> noundef zeroinitializer, i32 noundef 0, <4 x float> noundef zeroinitializer) - call spir_func void @_Z12write_imagei14ocl_image3d_woDv4_iiS0_(%opencl.image3d_wo_t addrspace(1)* %image_wo, <4 x i32> noundef zeroinitializer, i32 noundef 0, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef14ocl_image3d_woDv4_iDv4_f(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1) %image_wo, <4 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei14ocl_image3d_woDv4_iS0_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1) %image_wo, <4 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef14ocl_image3d_rwDv4_iDv4_f(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 2) %image_rw, <4 x i32> noundef zeroinitializer, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei14ocl_image3d_rwDv4_iS0_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 2) %image_rw, <4 x i32> noundef zeroinitializer, <4 x i32> noundef zeroinitializer) + call spir_func void @_Z12write_imagef14ocl_image3d_woDv4_iiDv4_f(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1) %image_wo, <4 x i32> noundef zeroinitializer, i32 noundef 0, <4 x float> noundef zeroinitializer) + call spir_func void @_Z12write_imagei14ocl_image3d_woDv4_iiS0_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1) %image_wo, <4 x i32> noundef zeroinitializer, i32 noundef 0, <4 x i32> noundef zeroinitializer) ret void } -declare spir_func void @_Z12write_imagef14ocl_image3d_woDv4_iDv4_f(%opencl.image3d_wo_t addrspace(1)*, <4 x i32> noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef14ocl_image3d_woDv4_iDv4_f(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1), <4 x i32> noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei14ocl_image3d_woDv4_iS0_(%opencl.image3d_wo_t addrspace(1)*, <4 x i32> noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei14ocl_image3d_woDv4_iS0_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1), <4 x i32> noundef, <4 x i32> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagef14ocl_image3d_rwDv4_iDv4_f(%opencl.image3d_rw_t addrspace(1)*, <4 x i32> noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef14ocl_image3d_rwDv4_iDv4_f(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 2), <4 x i32> noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei14ocl_image3d_rwDv4_iS0_(%opencl.image3d_rw_t addrspace(1)*, <4 x i32> noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei14ocl_image3d_rwDv4_iS0_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 2), <4 x i32> noundef, <4 x i32> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagef14ocl_image3d_woDv4_iiDv4_f(%opencl.image3d_wo_t addrspace(1)*, <4 x i32> noundef, i32 noundef, <4 x float> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagef14ocl_image3d_woDv4_iiDv4_f(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1), <4 x i32> noundef, i32 noundef, <4 x float> noundef) local_unnamed_addr -declare spir_func void @_Z12write_imagei14ocl_image3d_woDv4_iiS0_(%opencl.image3d_wo_t addrspace(1)*, <4 x i32> noundef, i32 noundef, <4 x i32> noundef) local_unnamed_addr +declare spir_func void @_Z12write_imagei14ocl_image3d_woDv4_iiS0_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1), <4 x i32> noundef, i32 noundef, <4 x i32> noundef) local_unnamed_addr Index: llvm/test/CodeGen/SPIRV/types/image.ll =================================================================== --- llvm/test/CodeGen/SPIRV/types/image.ll +++ llvm/test/CodeGen/SPIRV/types/image.ll @@ -1,4 +1,4 @@ -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ; CHECK-SPIRV: %[[#VOID_TY:]] = OpTypeVoid ; CHECK-SPIRV-DAG: %[[#]] = OpTypeImage %[[#VOID_TY]] 2D 0 0 0 0 Unknown ReadOnly @@ -7,25 +7,22 @@ ; CHECK-SPIRV: OpImageSampleExplicitLod ; CHECK-SPIRV: OpImageWrite -%opencl.image2d_t = type opaque - -define spir_kernel void @image_copy(%opencl.image2d_t addrspace(1)* readnone %image1, %opencl.image2d_t addrspace(1)* %image2) !kernel_arg_access_qual !1 { -entry: +define spir_kernel void @image_copy(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %image1, target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %image2) !kernel_arg_access_qual !1 { %call = tail call spir_func i64 @_Z13get_global_idj(i32 0) %conv = trunc i64 %call to i32 %call1 = tail call spir_func i64 @_Z13get_global_idj(i32 1) %conv2 = trunc i64 %call1 to i32 %vecinit = insertelement <2 x i32> undef, i32 %conv, i32 0 %vecinit3 = insertelement <2 x i32> %vecinit, i32 %conv2, i32 1 - %call4 = tail call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(%opencl.image2d_t addrspace(1)* %image1, i32 20, <2 x i32> %vecinit3) - tail call spir_func void @_Z12write_imagef11ocl_image2dDv2_iDv4_f(%opencl.image2d_t addrspace(1)* %image2, <2 x i32> %vecinit3, <4 x float> %call4) + %call4 = tail call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %image1, i32 20, <2 x i32> %vecinit3) + tail call spir_func void @_Z12write_imagef11ocl_image2dDv2_iDv4_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %image2, <2 x i32> %vecinit3, <4 x float> %call4) ret void } declare spir_func i64 @_Z13get_global_idj(i32) -declare spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(%opencl.image2d_t addrspace(1)*, i32, <2 x i32>) +declare spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), i32, <2 x i32>) -declare spir_func void @_Z12write_imagef11ocl_image2dDv2_iDv4_f(%opencl.image2d_t addrspace(1)*, <2 x i32>, <4 x float>) +declare spir_func void @_Z12write_imagef11ocl_image2dDv2_iDv4_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), <2 x i32>, <4 x float>) !1 = !{!"read_only", !"write_only"} Index: llvm/test/CodeGen/SPIRV/types/image1d.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/SPIRV/types/image1d.ll @@ -0,0 +1,8 @@ +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV + +; CHECK-SPIRV-DAG: OpCapability Sampled1D +; CHECK-SPIRV-DAG: OpCapability SampledBuffer + +define spir_kernel void @test_image_dim(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %image1d, target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 0) %image1d_buffer) { + ret void +} Index: llvm/test/CodeGen/SPIRV/types/pipe-sampler-image.ll =================================================================== --- llvm/test/CodeGen/SPIRV/types/pipe-sampler-image.ll +++ llvm/test/CodeGen/SPIRV/types/pipe-sampler-image.ll @@ -18,7 +18,7 @@ ;; ) { ;; } -; RUN: llc -O0 -opaque-pointers=0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV ; CHECK-SPIRV-DAG: OpCapability Sampled1D ; CHECK-SPIRV-DAG: OpCapability SampledBuffer @@ -37,17 +37,6 @@ ; CHECK-SPIRV: %[[#SAMP_CONST:]] = OpConstantSampler %[[#SAMP]] None 0 Linear -%opencl.pipe_ro_t = type opaque -%opencl.pipe_wo_t = type opaque -%opencl.image3d_ro_t = type opaque -%opencl.image2d_array_ro_t = type opaque -%opencl.image1d_buffer_ro_t = type opaque -%opencl.image1d_ro_t = type opaque -%opencl.image1d_wo_t = type opaque -%opencl.image2d_rw_t = type opaque -%opencl.image2d_ro_t = type opaque -%opencl.sampler_t = type opaque - ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#PIPE_RD]] ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#PIPE_WR]] ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#IMG1D_RD]] @@ -60,28 +49,28 @@ ; CHECK-SPIRV: %[[#SAMP_ARG:]] = OpFunctionParameter %[[#SAMP]] define spir_kernel void @foo( - %opencl.pipe_ro_t addrspace(1)* nocapture %a, - %opencl.pipe_wo_t addrspace(1)* nocapture %b, - %opencl.image1d_ro_t addrspace(1)* nocapture %c1, - %opencl.image2d_ro_t addrspace(1)* nocapture %d1, - %opencl.image3d_ro_t addrspace(1)* nocapture %e1, - %opencl.image2d_array_ro_t addrspace(1)* nocapture %f1, - %opencl.image1d_buffer_ro_t addrspace(1)* nocapture %g1, - %opencl.image1d_wo_t addrspace(1)* nocapture %c2, - %opencl.image2d_rw_t addrspace(1)* nocapture %d3, - %opencl.sampler_t addrspace(2)* %s) { + target("spirv.Pipe", 0) %a, + target("spirv.Pipe", 1) %b, + target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %c1, + target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %d1, + target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %e1, + target("spirv.Image", void, 1, 0, 1, 0, 0, 0, 0) %f1, + target("spirv.Image", void, 5, 0, 0, 0, 0, 0, 0) %g1, + target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1) %c2, + target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 2) %d3, + target("spirv.Sampler") %s) { entry: ; CHECK-SPIRV: %[[#SAMPIMG_VAR1:]] = OpSampledImage %[[#SAMPIMG]] %[[#IMG_ARG]] %[[#SAMP_ARG]] ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SAMPIMG_VAR1]] - %.tmp = call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv4_if(%opencl.image2d_ro_t addrspace(1)* %d1, %opencl.sampler_t addrspace(2)* %s, <4 x i32> zeroinitializer, float 1.000000e+00) + %.tmp = call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv4_if(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %d1, target("spirv.Sampler") %s, <4 x i32> zeroinitializer, float 1.000000e+00) ; CHECK-SPIRV: %[[#SAMPIMG_VAR2:]] = OpSampledImage %[[#SAMPIMG]] %[[#IMG_ARG]] %[[#SAMP_CONST]] ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SAMPIMG_VAR2]] - %0 = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 32) - %.tmp2 = call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv4_if(%opencl.image2d_ro_t addrspace(1)* %d1, %opencl.sampler_t addrspace(2)* %0, <4 x i32> zeroinitializer, float 1.000000e+00) + %0 = call target("spirv.Sampler") @__translate_sampler_initializer(i32 32) + %.tmp2 = call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv4_if(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %d1, target("spirv.Sampler") %0, <4 x i32> zeroinitializer, float 1.000000e+00) ret void } -declare spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv4_if(%opencl.image2d_ro_t addrspace(1)*, %opencl.sampler_t addrspace(2)*, <4 x i32>, float) +declare spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv4_if(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), target("spirv.Sampler"), <4 x i32>, float) -declare %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32) +declare target("spirv.Sampler") @__translate_sampler_initializer(i32)