Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package intel-graphics-compiler for openSUSE:Factory checked in at 2023-06-16 16:54:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/intel-graphics-compiler (Old) and /work/SRC/openSUSE:Factory/.intel-graphics-compiler.new.15902 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "intel-graphics-compiler" Fri Jun 16 16:54:19 2023 rev:5 rq:1093302 version:1.0.13822.6 Changes: -------- --- /work/SRC/openSUSE:Factory/intel-graphics-compiler/intel-graphics-compiler.changes 2023-05-30 22:02:53.123166939 +0200 +++ /work/SRC/openSUSE:Factory/.intel-graphics-compiler.new.15902/intel-graphics-compiler.changes 2023-06-16 16:55:32.469954137 +0200 @@ -1,0 +2,7 @@ +Thu Jun 15 06:25:27 UTC 2023 - Patrik Jakobsson <patrik.jakobs...@suse.com> + +- Update to version 1.0.13822.6 + * Fixes a segfault happening for certain GPUs (bsc#1212193) +- Update spirv-llvm-translator to a4e58ffda317221a15149f9d0d4f73424c9584fb + +------------------------------------------------------------------- Old: ---- igc-1.0.13700.14.tar.gz New: ---- igc-1.0.13822.6.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ intel-graphics-compiler.spec ++++++ --- /var/tmp/diff_new_pack.R5URJT/_old 2023-06-16 16:55:33.725961545 +0200 +++ /var/tmp/diff_new_pack.R5URJT/_new 2023-06-16 16:55:33.729961569 +0200 @@ -18,10 +18,10 @@ %global llvm_commit llvmorg-11.1.0 %global opencl_clang_commit 10237c7109d613ef1161065d140b76d92133062f -%global spirv_llvm_translator_commit b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1 +%global spirv_llvm_translator_commit a4e58ffda317221a15149f9d0d4f73424c9584fb %global vc_intrinsics_commit v0.12.3 Name: intel-graphics-compiler -Version: 1.0.13700.14 +Version: 1.0.13822.6 Release: 1%{?dist} Summary: Intel Graphics Compiler for OpenCL License: MIT ++++++ igc-1.0.13700.14.tar.gz -> igc-1.0.13822.6.tar.gz ++++++ /work/SRC/openSUSE:Factory/intel-graphics-compiler/igc-1.0.13700.14.tar.gz /work/SRC/openSUSE:Factory/.intel-graphics-compiler.new.15902/igc-1.0.13822.6.tar.gz differ: char 13, line 1 ++++++ spirv-llvm-translator.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/include/LLVMSPIRVExtensions.inc new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/include/LLVMSPIRVExtensions.inc --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/include/LLVMSPIRVExtensions.inc 2023-02-20 14:48:11.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/include/LLVMSPIRVExtensions.inc 2023-03-18 21:49:42.000000000 +0100 @@ -45,3 +45,4 @@ EXT(SPV_INTEL_tensor_float32_conversion) EXT(SPV_INTEL_hw_thread_queries) EXT(SPV_EXT_relaxed_printf_string_address_space) +EXT(SPV_INTEL_global_variable_decorations) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/SPIRVInternal.h new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/SPIRVInternal.h --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/SPIRVInternal.h 2023-02-20 14:48:11.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/SPIRVInternal.h 2023-03-18 21:49:42.000000000 +0100 @@ -274,6 +274,9 @@ #define SPIR_MD_KERNEL_ARG_TYPE_QUAL "kernel_arg_type_qual" #define SPIR_MD_KERNEL_ARG_NAME "kernel_arg_name" +#define SPIRV_MD_PARAMETER_DECORATIONS "spirv.ParameterDecorations" +#define SPIRV_MD_DECORATIONS "spirv.Decorations" + #define OCL_TYPE_NAME_SAMPLER_T "sampler_t" #define SPIR_TYPE_NAME_EVENT_T "opencl.event_t" #define SPIR_TYPE_NAME_CLK_EVENT_T "opencl.clk_event_t" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/SPIRVReader.cpp new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/SPIRVReader.cpp --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/SPIRVReader.cpp 2023-02-20 14:48:11.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/SPIRVReader.cpp 2023-03-18 21:49:42.000000000 +0100 @@ -160,7 +160,7 @@ NamedMD->addOperand(MDNode::get(*Context, ValueVec)); } -static void addOCLKernelArgumentMetadata( +static void addKernelArgumentMetadata( LLVMContext *Context, const std::string &MDName, SPIRVFunction *BF, llvm::Function *Fn, std::function<Metadata *(SPIRVFunctionParameter *)> Func) { @@ -3443,6 +3443,82 @@ } } +static llvm::MDNode * +transDecorationsToMetadataList(llvm::LLVMContext *Context, + std::vector<SPIRVDecorate const *> Decorates) { + SmallVector<Metadata *, 4> MDs; + MDs.reserve(Decorates.size()); + for (const auto *Deco : Decorates) { + std::vector<Metadata *> OPs; + auto *KindMD = ConstantAsMetadata::get( + ConstantInt::get(Type::getInt32Ty(*Context), Deco->getDecorateKind())); + OPs.push_back(KindMD); + switch (static_cast<size_t>(Deco->getDecorateKind())) { + case DecorationLinkageAttributes: { + const auto *const LinkAttrDeco = + static_cast<const SPIRVDecorateLinkageAttr *>(Deco); + auto *const LinkNameMD = + MDString::get(*Context, LinkAttrDeco->getLinkageName()); + auto *const LinkTypeMD = ConstantAsMetadata::get(ConstantInt::get( + Type::getInt32Ty(*Context), LinkAttrDeco->getLinkageType())); + OPs.push_back(LinkNameMD); + OPs.push_back(LinkTypeMD); + break; + } + case spv::internal::DecorationHostAccessINTEL: { + const auto *const HostAccDeco = + static_cast<const SPIRVDecorateHostAccessINTEL *>(Deco); + auto *const AccModeMD = ConstantAsMetadata::get(ConstantInt::get( + Type::getInt32Ty(*Context), HostAccDeco->getAccessMode())); + auto *const NameMD = MDString::get(*Context, HostAccDeco->getVarName()); + OPs.push_back(AccModeMD); + OPs.push_back(NameMD); + break; + } + case DecorationMergeINTEL: { + const auto MergeAttrLits = Deco->getVecLiteral(); + std::string FirstString = getString(MergeAttrLits); + std::string SecondString = + getString(MergeAttrLits.cbegin() + getVec(FirstString).size(), + MergeAttrLits.cend()); + OPs.push_back(MDString::get(*Context, FirstString)); + OPs.push_back(MDString::get(*Context, SecondString)); + break; + } + case DecorationMemoryINTEL: + case DecorationUserSemantic: { + auto *const StrMD = + MDString::get(*Context, getString(Deco->getVecLiteral())); + OPs.push_back(StrMD); + break; + } + default: { + for (const SPIRVWord Lit : Deco->getVecLiteral()) { + auto *const LitMD = ConstantAsMetadata::get( + ConstantInt::get(Type::getInt32Ty(*Context), Lit)); + OPs.push_back(LitMD); + } + break; + } + } + MDs.push_back(MDNode::get(*Context, OPs)); + } + return MDNode::get(*Context, MDs); +} + +void SPIRVToLLVM::transVarDecorationsToMetadata(SPIRVValue *BV, Value *V) { + if (!BV->isVariable()) + return; + + if (auto *GV = dyn_cast<GlobalVariable>(V)) { + std::vector<SPIRVDecorate const *> Decorates = BV->getDecorations(); + if (!Decorates.empty()) { + MDNode *MDList = transDecorationsToMetadataList(Context, Decorates); + GV->setMetadata(SPIRV_MD_DECORATIONS, MDList); + } + } +} + bool SPIRVToLLVM::transDecoration(SPIRVValue *BV, Value *V) { if (!transAlign(BV, V)) return false; @@ -3450,6 +3526,10 @@ transIntelFPGADecorations(BV, V); transMemAliasingINTELDecorations(BV, V); + // Decoration metadata is only enabled in SPIR-V friendly mode + if (BM->getDesiredBIsRepresentation() == BIsRepresentation::SPIRVFriendlyIR) + transVarDecorationsToMetadata(BV, V); + DbgTran->transDbgInfo(BV, V); return true; } @@ -3581,6 +3661,23 @@ return true; } +void SPIRVToLLVM::transFunctionDecorationsToMetadata(SPIRVFunction *BF, + Function *F) { + size_t TotalParameterDecorations = 0; + BF->foreachArgument([&](SPIRVFunctionParameter *Arg) { + TotalParameterDecorations += Arg->getNumDecorations(); + }); + if (TotalParameterDecorations == 0) + return; + + // Generate metadata for spirv.ParameterDecorations + addKernelArgumentMetadata(Context, SPIRV_MD_PARAMETER_DECORATIONS, BF, F, + [=](SPIRVFunctionParameter *Arg) { + return transDecorationsToMetadataList( + Context, Arg->getDecorations()); + }); +} + bool SPIRVToLLVM::transMetadata() { SmallVector<Function *, 2> CtorKernels; for (unsigned I = 0, E = BM->getNumFunctions(); I != E; ++I) { @@ -3591,6 +3688,10 @@ transOCLMetadata(BF); transVectorComputeMetadata(BF); + // Decoration metadata is only enabled in SPIR-V friendly mode + if (BM->getDesiredBIsRepresentation() == BIsRepresentation::SPIRVFriendlyIR) + transFunctionDecorationsToMetadata(BF, F); + if (BF->hasDecorate(DecorationCallableFunctionINTEL)) F->addFnAttr(kVCMetadata::VCCallable); if (isKernel(BF) && @@ -3668,7 +3769,7 @@ return true; // Generate metadata for kernel_arg_addr_space - addOCLKernelArgumentMetadata( + addKernelArgumentMetadata( Context, SPIR_MD_KERNEL_ARG_ADDR_SPACE, BF, F, [=](SPIRVFunctionParameter *Arg) { SPIRVType *ArgTy = Arg->getType(); @@ -3681,31 +3782,31 @@ ConstantInt::get(Type::getInt32Ty(*Context), AS)); }); // Generate metadata for kernel_arg_access_qual - addOCLKernelArgumentMetadata(Context, SPIR_MD_KERNEL_ARG_ACCESS_QUAL, BF, F, - [=](SPIRVFunctionParameter *Arg) { - std::string Qual; - auto T = Arg->getType(); - if (T->isTypeOCLImage()) { - auto ST = static_cast<SPIRVTypeImage *>(T); - Qual = transOCLImageTypeAccessQualifier(ST); - } else if (T->isTypePipe()) { - auto PT = static_cast<SPIRVTypePipe *>(T); - Qual = transOCLPipeTypeAccessQualifier(PT); - } else - Qual = "none"; - return MDString::get(*Context, Qual); - }); + addKernelArgumentMetadata(Context, SPIR_MD_KERNEL_ARG_ACCESS_QUAL, BF, F, + [=](SPIRVFunctionParameter *Arg) { + std::string Qual; + auto *T = Arg->getType(); + if (T->isTypeOCLImage()) { + auto *ST = static_cast<SPIRVTypeImage *>(T); + Qual = transOCLImageTypeAccessQualifier(ST); + } else if (T->isTypePipe()) { + auto *PT = static_cast<SPIRVTypePipe *>(T); + Qual = transOCLPipeTypeAccessQualifier(PT); + } else + Qual = "none"; + return MDString::get(*Context, Qual); + }); // Generate metadata for kernel_arg_type if (!transKernelArgTypeMedataFromString(Context, BM, F, SPIR_MD_KERNEL_ARG_TYPE)) - addOCLKernelArgumentMetadata(Context, SPIR_MD_KERNEL_ARG_TYPE, BF, F, - [=](SPIRVFunctionParameter *Arg) { - return transOCLKernelArgTypeName(Arg); - }); + addKernelArgumentMetadata(Context, SPIR_MD_KERNEL_ARG_TYPE, BF, F, + [=](SPIRVFunctionParameter *Arg) { + return transOCLKernelArgTypeName(Arg); + }); // Generate metadata for kernel_arg_type_qual if (!transKernelArgTypeMedataFromString(Context, BM, F, SPIR_MD_KERNEL_ARG_TYPE_QUAL)) - addOCLKernelArgumentMetadata( + addKernelArgumentMetadata( Context, SPIR_MD_KERNEL_ARG_TYPE_QUAL, BF, F, [=](SPIRVFunctionParameter *Arg) { std::string Qual; @@ -3723,17 +3824,16 @@ return MDString::get(*Context, Qual); }); // Generate metadata for kernel_arg_base_type - addOCLKernelArgumentMetadata(Context, SPIR_MD_KERNEL_ARG_BASE_TYPE, BF, F, - [=](SPIRVFunctionParameter *Arg) { - return transOCLKernelArgTypeName(Arg); - }); + addKernelArgumentMetadata(Context, SPIR_MD_KERNEL_ARG_BASE_TYPE, BF, F, + [=](SPIRVFunctionParameter *Arg) { + return transOCLKernelArgTypeName(Arg); + }); // Generate metadata for kernel_arg_name if (BM->isGenArgNameMDEnabled()) { - addOCLKernelArgumentMetadata(Context, SPIR_MD_KERNEL_ARG_NAME, BF, F, - [=](SPIRVFunctionParameter *Arg) { - return MDString::get(*Context, - Arg->getName()); - }); + addKernelArgumentMetadata(Context, SPIR_MD_KERNEL_ARG_NAME, BF, F, + [=](SPIRVFunctionParameter *Arg) { + return MDString::get(*Context, Arg->getName()); + }); } // Generate metadata for kernel_arg_buffer_location addBufferLocationMetadata(Context, BF, F, [=](SPIRVFunctionParameter *Arg) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/SPIRVReader.h new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/SPIRVReader.h --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/SPIRVReader.h 2023-02-20 14:48:11.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/SPIRVReader.h 2023-03-18 21:49:42.000000000 +0100 @@ -233,6 +233,8 @@ SmallVectorImpl<Function *> &Funcs); void transIntelFPGADecorations(SPIRVValue *BV, Value *V); void transMemAliasingINTELDecorations(SPIRVValue *BV, Value *V); + void transVarDecorationsToMetadata(SPIRVValue *BV, Value *V); + void transFunctionDecorationsToMetadata(SPIRVFunction *BF, Function *F); }; // class SPIRVToLLVM } // namespace SPIRV diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/SPIRVToLLVMDbgTran.cpp new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/SPIRVToLLVMDbgTran.cpp --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/SPIRVToLLVMDbgTran.cpp 2023-02-20 14:48:11.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/SPIRVToLLVMDbgTran.cpp 2023-03-18 21:49:42.000000000 +0100 @@ -522,7 +522,7 @@ SPIRVFunction *BF = static_cast<SPIRVFunction *>(E); llvm::Function *F = SPIRVReader->transFunction(BF); assert(F && "Translation of function failed!"); - if (!F->hasMetadata()) + if (!F->hasMetadata("dbg")) F->setMetadata("dbg", DIS); } return DIS; @@ -631,7 +631,7 @@ SPIRVValue *V = BM->get<SPIRVValue>(Ops[VariableIdx]); Value *Var = SPIRVReader->transValue(V, nullptr, nullptr); llvm::GlobalVariable *GV = dyn_cast_or_null<llvm::GlobalVariable>(Var); - if (GV && !GV->hasMetadata()) + if (GV && !GV->hasMetadata("dbg")) GV->addMetadata("dbg", *VarDecl); } return VarDecl; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/SPIRVWriter.cpp new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/SPIRVWriter.cpp --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/SPIRVWriter.cpp 2023-02-20 14:48:11.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/SPIRVWriter.cpp 2023-03-18 21:49:42.000000000 +0100 @@ -106,6 +106,15 @@ } } +static void foreachKernelArgMD( + MDNode *MD, SPIRVFunction *BF, + std::function<void(Metadata *MDOp, SPIRVFunctionParameter *BA)> Func) { + for (unsigned I = 0, E = MD->getNumOperands(); I != E; ++I) { + SPIRVFunctionParameter *BA = BF->getArgument(I); + Func(MD->getOperand(I), BA); + } +} + static SPIRVMemoryModelKind getMemoryModel(Module &M) { auto *MemoryModelMD = M.getNamedMetadata(kSPIRVMD::MemoryModel); if (MemoryModelMD && (MemoryModelMD->getNumOperands() > 0)) { @@ -1901,6 +1910,186 @@ return BV; } +#define ONE_STRING_DECORATION_CASE(NAME, NAMESPACE) \ + case NAMESPACE::Decoration##NAME: { \ + assert(NumOperands == 2 && #NAME " requires exactly 1 extra operand"); \ + auto *StrDecoEO = dyn_cast<MDString>(DecoMD->getOperand(1)); \ + assert(StrDecoEO &&#NAME " requires extra operand to be a string"); \ + Target->addDecorate( \ + new SPIRVDecorate##NAME##Attr(Target, StrDecoEO->getString().str())); \ + break; \ + } + +#define ONE_INT_DECORATION_CASE(NAME, NAMESPACE, TYPE) \ + case NAMESPACE::Decoration##NAME: { \ + assert(NumOperands == 2 && #NAME " requires exactly 1 extra operand"); \ + auto *IntDecoEO = \ + mdconst::dyn_extract<ConstantInt>(DecoMD->getOperand(1)); \ + assert(IntDecoEO &&#NAME " requires extra operand to be an integer"); \ + Target->addDecorate(new SPIRVDecorate##NAME( \ + Target, static_cast<TYPE>(IntDecoEO->getZExtValue()))); \ + break; \ + } + +#define TWO_INT_DECORATION_CASE(NAME, NAMESPACE, TYPE1, TYPE2) \ + case NAMESPACE::Decoration##NAME: { \ + assert(NumOperands == 3 && #NAME " requires exactly 2 extra operand"); \ + auto *IntDecoEO1 = \ + mdconst::dyn_extract<ConstantInt>(DecoMD->getOperand(1)); \ + assert(IntDecoEO1 &&#NAME \ + " requires first extra operand to be an integer"); \ + auto *IntDecoEO2 = \ + mdconst::dyn_extract<ConstantInt>(DecoMD->getOperand(2)); \ + assert(IntDecoEO2 &&#NAME \ + " requires second extra operand to be an integer"); \ + Target->addDecorate(new SPIRVDecorate##NAME( \ + Target, static_cast<TYPE1>(IntDecoEO1->getZExtValue()), \ + static_cast<TYPE2>(IntDecoEO2->getZExtValue()))); \ + break; \ + } + +void checkIsGlobalVar(SPIRVEntry *E, Decoration Dec) { + std::string ErrStr = + SPIRVDecorationNameMap::map(Dec) + " can only be applied to a variable"; + + E->getErrorLog().checkError(E->isVariable(), SPIRVEC_InvalidModule, ErrStr); + + auto AddrSpace = SPIRSPIRVAddrSpaceMap::rmap( + static_cast<SPIRVVariable *>(E)->getStorageClass()); + ErrStr += " in a global (module) scope"; + E->getErrorLog().checkError(AddrSpace == SPIRAS_Global, SPIRVEC_InvalidModule, + ErrStr); +} + +static void transMetadataDecorations(Metadata *MD, SPIRVEntry *Target) { + auto *ArgDecoMD = dyn_cast<MDNode>(MD); + assert(ArgDecoMD && "Decoration list must be a metadata node"); + for (unsigned I = 0, E = ArgDecoMD->getNumOperands(); I != E; ++I) { + auto *DecoMD = dyn_cast<MDNode>(ArgDecoMD->getOperand(I)); + assert(DecoMD && "Decoration does not name metadata"); + assert(DecoMD->getNumOperands() > 0 && + "Decoration metadata must have at least one operand"); + auto *DecoKindConst = + mdconst::dyn_extract<ConstantInt>(DecoMD->getOperand(0)); + assert(DecoKindConst && "First operand of decoration must be the kind"); + auto DecoKind = static_cast<Decoration>(DecoKindConst->getZExtValue()); + + const size_t NumOperands = DecoMD->getNumOperands(); + switch (static_cast<size_t>(DecoKind)) { + ONE_STRING_DECORATION_CASE(MemoryINTEL, spv) + ONE_STRING_DECORATION_CASE(UserSemantic, spv) + ONE_INT_DECORATION_CASE(AliasScopeINTEL, spv::internal, SPIRVId) + ONE_INT_DECORATION_CASE(NoAliasINTEL, spv::internal, SPIRVId) + TWO_INT_DECORATION_CASE(FunctionRoundingModeINTEL, spv, SPIRVWord, + FPRoundingMode); + TWO_INT_DECORATION_CASE(FunctionDenormModeINTEL, spv, SPIRVWord, + FPDenormMode); + TWO_INT_DECORATION_CASE(FunctionFloatingPointModeINTEL, spv, SPIRVWord, + FPOperationMode); + case DecorationMergeINTEL: { + assert(NumOperands == 3 && "MergeINTEL requires exactly 3 extra operand"); + auto *Name = dyn_cast<MDString>(DecoMD->getOperand(1)); + assert(Name && "MergeINTEL requires first extra operand to be a string"); + auto *Direction = dyn_cast<MDString>(DecoMD->getOperand(2)); + assert(Direction && + "MergeINTEL requires second extra operand to be a string"); + Target->addDecorate(new SPIRVDecorateMergeINTELAttr( + Target, Name->getString().str(), Direction->getString().str())); + break; + } + case DecorationLinkageAttributes: { + assert(NumOperands == 3 && + "LinkageAttributes requires exactly 3 extra operand"); + auto *Name = dyn_cast<MDString>(DecoMD->getOperand(1)); + assert(Name && + "LinkageAttributes requires first extra operand to be a string"); + auto *Type = mdconst::dyn_extract<ConstantInt>(DecoMD->getOperand(2)); + assert(Type && + "LinkageAttributes requires second extra operand to be an int"); + auto TypeKind = static_cast<SPIRVLinkageTypeKind>(Type->getZExtValue()); + Target->addDecorate(new SPIRVDecorateLinkageAttr( + Target, Name->getString().str(), TypeKind)); + break; + } + case spv::internal::DecorationHostAccessINTEL: { + checkIsGlobalVar(Target, DecoKind); + + assert(NumOperands == 3 && "HostAccessINTEL requires 2 extra operands " + "after the decoration kind number"); + auto *AccessMode = + mdconst::dyn_extract<ConstantInt>(DecoMD->getOperand(1)); + assert(AccessMode && + "HostAccessINTEL requires first extra operand to be an int"); + auto *Name = dyn_cast<MDString>(DecoMD->getOperand(2)); + assert(Name && + "HostAccessINTEL requires second extra operand to be a string"); + + Target->addDecorate(new SPIRVDecorateHostAccessINTEL( + Target, AccessMode->getZExtValue(), Name->getString().str())); + break; + } + case spv::internal::DecorationInitModeINTEL: { + checkIsGlobalVar(Target, DecoKind); + assert(static_cast<SPIRVVariable *>(Target)->getInitializer() && + "InitModeINTEL only be applied to a global (module scope) " + "variable which has an Initializer operand"); + + assert(NumOperands == 2 && + "InitModeINTEL requires exactly 1 extra operand"); + auto *Trigger = mdconst::dyn_extract<ConstantInt>(DecoMD->getOperand(1)); + assert(Trigger && + "InitModeINTEL requires extra operand to be an integer"); + + Target->addDecorate( + new SPIRVDecorateInitModeINTEL(Target, Trigger->getZExtValue())); + break; + } + case spv::internal::DecorationImplementInCSRINTEL: { + checkIsGlobalVar(Target, DecoKind); + + assert(NumOperands == 2 && + "ImplementInCSRINTEL requires exactly 1 extra operand"); + auto *Value = mdconst::dyn_extract<ConstantInt>(DecoMD->getOperand(1)); + assert(Value && + "ImplementInCSRINTEL requires extra operand to be an integer"); + + Target->addDecorate( + new SPIRVDecorateImplementInCSRINTEL(Target, Value->getZExtValue())); + break; + } + default: { + if (NumOperands == 1) { + Target->addDecorate(new SPIRVDecorate(DecoKind, Target)); + break; + } + + auto *DecoValEO1 = + mdconst::dyn_extract<ConstantInt>(DecoMD->getOperand(1)); + assert(DecoValEO1 && + "First extra operand in default decoration case must be integer."); + if (NumOperands == 2) { + Target->addDecorate( + new SPIRVDecorate(DecoKind, Target, DecoValEO1->getZExtValue())); + break; + } + + auto *DecoValEO2 = + mdconst::dyn_extract<ConstantInt>(DecoMD->getOperand(2)); + assert(DecoValEO2 && + "First extra operand in default decoration case must be integer."); + assert(NumOperands == 3 && "At most 2 extra operands expected."); + Target->addDecorate(new SPIRVDecorate(DecoKind, Target, + DecoValEO1->getZExtValue(), + DecoValEO2->getZExtValue())); + } + } + } +} + +#undef ONE_STRING_DECORATION_CASE +#undef ONE_INT_DECORATION_CASE +#undef TWO_INT_DECORATION_CASE + bool LLVMToSPIRVBase::transDecoration(Value *V, SPIRVValue *BV) { if (!transAlign(V, BV)) return false; @@ -1964,6 +2153,10 @@ } } + if (auto *GV = dyn_cast<GlobalVariable>(V)) + if (auto *GVDecoMD = GV->getMetadata(SPIRV_MD_DECORATIONS)) + transMetadataDecorations(GVDecoMD, BV); + return true; } @@ -3879,6 +4072,8 @@ BM->setName(BA, Str); }); } + if (auto *KernArgDecoMD = F.getMetadata(SPIRV_MD_PARAMETER_DECORATIONS)) + foreachKernelArgMD(KernArgDecoMD, BF, transMetadataDecorations); } return true; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp 2023-02-20 14:48:11.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp 2023-03-18 21:49:42.000000000 +0100 @@ -101,7 +101,7 @@ void SPIRVDecorate::encode(spv_ostream &O) const { SPIRVEncoder Encoder = getEncoder(O); Encoder << Target << Dec; - switch (Dec) { + switch (static_cast<size_t>(Dec)) { case DecorationLinkageAttributes: SPIRVDecorateLinkageAttr::encodeLiterals(Encoder, Literals); break; @@ -114,6 +114,9 @@ case DecorationUserSemantic: SPIRVDecorateUserSemanticAttr::encodeLiterals(Encoder, Literals); break; + case spv::internal::DecorationHostAccessINTEL: + SPIRVDecorateHostAccessINTEL::encodeLiterals(Encoder, Literals); + break; default: Encoder << Literals; } @@ -127,7 +130,7 @@ void SPIRVDecorate::decode(std::istream &I) { SPIRVDecoder Decoder = getDecoder(I); Decoder >> Target >> Dec; - switch (Dec) { + switch (static_cast<size_t>(Dec)) { case DecorationLinkageAttributes: SPIRVDecorateLinkageAttr::decodeLiterals(Decoder, Literals); break; @@ -140,6 +143,9 @@ case DecorationUserSemantic: SPIRVDecorateUserSemanticAttr::decodeLiterals(Decoder, Literals); break; + case spv::internal::DecorationHostAccessINTEL: + SPIRVDecorateHostAccessINTEL::decodeLiterals(Decoder, Literals); + break; default: Decoder >> Literals; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/libSPIRV/SPIRVDecorate.h new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/libSPIRV/SPIRVDecorate.h --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/libSPIRV/SPIRVDecorate.h 2023-02-20 14:48:11.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/libSPIRV/SPIRVDecorate.h 2023-03-18 21:49:42.000000000 +0100 @@ -188,6 +188,10 @@ return ExtensionID::SPV_INTEL_float_controls2; case DecorationCallableFunctionINTEL: return ExtensionID::SPV_INTEL_fast_composite; + case internal::DecorationHostAccessINTEL: + case internal::DecorationInitModeINTEL: + case internal::DecorationImplementInCSRINTEL: + return ExtensionID::SPV_INTEL_global_variable_decorations; default: return {}; } @@ -662,6 +666,69 @@ AliasList){}; }; +class SPIRVDecorateHostAccessINTEL : public SPIRVDecorate { +public: + // Complete constructor for SPIRVHostAccessINTEL + SPIRVDecorateHostAccessINTEL(SPIRVEntry *TheTarget, SPIRVWord AccessMode, + const std::string &VarName) + : SPIRVDecorate(spv::internal::DecorationHostAccessINTEL, TheTarget) { + Literals.push_back(AccessMode); + for (auto &I : getVec(VarName)) + Literals.push_back(I); + WordCount += Literals.size(); + }; + + SPIRVWord getAccessMode() const { return Literals.front(); } + std::string getVarName() const { + return getString(Literals.cbegin() + 1, Literals.cend()); + } + + static void encodeLiterals(SPIRVEncoder &Encoder, + const std::vector<SPIRVWord> &Literals) { +#ifdef _SPIRV_SUPPORT_TEXT_FMT + if (SPIRVUseTextFormat) { + Encoder << Literals.front(); + std::string Name = getString(Literals.cbegin() + 1, Literals.cend()); + Encoder << Name; + } else +#endif + Encoder << Literals; + } + + static void decodeLiterals(SPIRVDecoder &Decoder, + std::vector<SPIRVWord> &Literals) { +#ifdef _SPIRV_SUPPORT_TEXT_FMT + if (SPIRVUseTextFormat) { + SPIRVWord Mode; + Decoder >> Mode; + std::string Name; + Decoder >> Name; + Literals.front() = Mode; + std::copy_n(getVec(Name).begin(), Literals.size() - 1, + Literals.begin() + 1); + + } else +#endif + Decoder >> Literals; + } +}; + +class SPIRVDecorateInitModeINTEL : public SPIRVDecorate { +public: + // Complete constructor for SPIRVInitModeINTEL + SPIRVDecorateInitModeINTEL(SPIRVEntry *TheTarget, SPIRVWord Trigger) + : SPIRVDecorate(spv::internal::DecorationInitModeINTEL, TheTarget, + Trigger){}; +}; + +class SPIRVDecorateImplementInCSRINTEL : public SPIRVDecorate { +public: + // Complete constructor for SPIRVImplementInCSRINTEL + SPIRVDecorateImplementInCSRINTEL(SPIRVEntry *TheTarget, SPIRVWord Value) + : SPIRVDecorate(spv::internal::DecorationImplementInCSRINTEL, TheTarget, + Value){}; +}; + } // namespace SPIRV #endif // SPIRV_LIBSPIRV_SPIRVDECORATE_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/libSPIRV/SPIRVEntry.cpp new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/libSPIRV/SPIRVEntry.cpp --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/libSPIRV/SPIRVEntry.cpp 2023-02-20 14:48:11.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/libSPIRV/SPIRVEntry.cpp 2023-03-18 21:49:42.000000000 +0100 @@ -441,6 +441,14 @@ return Decors; } +std::vector<SPIRVDecorate const *> SPIRVEntry::getDecorations() const { + std::vector<SPIRVDecorate const *> Decors; + Decors.reserve(Decorates.size()); + for (const auto &DecoPair : Decorates) + Decors.push_back(DecoPair.second); + return Decors; +} + std::set<SPIRVId> SPIRVEntry::getDecorateId(Decoration Kind, size_t Index) const { auto Range = DecorateIds.equal_range(Kind); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/libSPIRV/SPIRVEntry.h new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/libSPIRV/SPIRVEntry.h --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/libSPIRV/SPIRVEntry.h 2023-02-20 14:48:11.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/libSPIRV/SPIRVEntry.h 2023-03-18 21:49:42.000000000 +0100 @@ -297,6 +297,7 @@ return {}; } const std::string &getName() const { return Name; } + size_t getNumDecorations() const { return Decorates.size(); } bool hasDecorate(Decoration Kind, size_t Index = 0, SPIRVWord *Result = 0) const; bool hasDecorateId(Decoration Kind, size_t Index = 0, @@ -314,6 +315,7 @@ SPIRVWord MemberNumber) const; std::set<SPIRVWord> getDecorate(Decoration Kind, size_t Index = 0) const; std::vector<SPIRVDecorate const *> getDecorations(Decoration Kind) const; + std::vector<SPIRVDecorate const *> getDecorations() const; std::set<SPIRVId> getDecorateId(Decoration Kind, size_t Index = 0) const; std::vector<SPIRVDecorateId const *> getDecorationIds(Decoration Kind) const; bool hasId() const { return !(Attrib & SPIRVEA_NOID); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/libSPIRV/SPIRVEnum.h new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/libSPIRV/SPIRVEnum.h --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/libSPIRV/SPIRVEnum.h 2023-02-20 14:48:11.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/libSPIRV/SPIRVEnum.h 2023-03-18 21:49:42.000000000 +0100 @@ -429,6 +429,13 @@ {internal::CapabilityMemoryAccessAliasingINTEL}); ADD_VEC_INIT(internal::DecorationNoAliasINTEL, {internal::CapabilityMemoryAccessAliasingINTEL}); + + ADD_VEC_INIT(internal::DecorationHostAccessINTEL, + {internal::CapabilityGlobalVariableDecorationsINTEL}); + ADD_VEC_INIT(internal::DecorationInitModeINTEL, + {internal::CapabilityGlobalVariableDecorationsINTEL}); + ADD_VEC_INIT(internal::DecorationImplementInCSRINTEL, + {internal::CapabilityGlobalVariableDecorationsINTEL}); } template <> inline void SPIRVMap<BuiltIn, SPIRVCapVec>::init() { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h 2023-02-20 14:48:11.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h 2023-03-18 21:49:42.000000000 +0100 @@ -174,6 +174,9 @@ add(internal::DecorationAliasScopeINTEL, "AliasScopeINTEL"); add(internal::DecorationNoAliasINTEL, "NoAliasINTEL"); + add(internal::DecorationHostAccessINTEL, "HostAccessINTEL"); + add(internal::DecorationInitModeINTEL, "InitModeINTEL"); + add(internal::DecorationImplementInCSRINTEL, "ImplementInCSRINTEL"); add(DecorationMax, "Max"); } @@ -578,6 +581,8 @@ add(internal::CapabilityTensorFloat32ConversionINTEL, "TensorFloat32ConversionINTEL"); add(internal::CapabilityHWThreadQueryINTEL, "HWThreadQueryINTEL"); + add(internal::CapabilityGlobalVariableDecorationsINTEL, + "GlobalVariableDecorationsINTEL"); } SPIRV_DEF_NAMEMAP(Capability, SPIRVCapabilityNameMap) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/libSPIRV/spirv_internal.hpp new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/libSPIRV/spirv_internal.hpp --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/lib/SPIRV/libSPIRV/spirv_internal.hpp 2023-02-20 14:48:11.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/lib/SPIRV/libSPIRV/spirv_internal.hpp 2023-03-18 21:49:42.000000000 +0100 @@ -49,7 +49,10 @@ enum InternalDecoration { IDecAliasScopeINTEL = 5914, - IDecNoAliasINTEL = 5915 + IDecNoAliasINTEL = 5915, + IDecHostAccessINTEL = 6147, + IDecInitModeINTEL = 6148, + IDecImplementInCSRINTEL = 6149 }; enum InternalCapability { @@ -60,6 +63,7 @@ ICapabilityTensorFloat32ConversionINTEL = 6425, ICapabilityMaskedGatherScatterINTEL = 6427, ICapabilityHWThreadQueryINTEL = 6134, + ICapGlobalVariableDecorationsINTEL = 6146 }; enum InternalFunctionControlMask { IFunctionControlOptNoneINTELMask = 0x10000 }; @@ -106,6 +110,13 @@ constexpr Decoration DecorationNoAliasINTEL = static_cast<Decoration>(IDecNoAliasINTEL); +constexpr Decoration DecorationHostAccessINTEL = + static_cast<Decoration>(IDecHostAccessINTEL); +constexpr Decoration DecorationInitModeINTEL = + static_cast<Decoration>(IDecInitModeINTEL); +constexpr Decoration DecorationImplementInCSRINTEL = + static_cast<Decoration>(IDecImplementInCSRINTEL); + constexpr Capability CapabilityOptNoneINTEL = static_cast<Capability>(ICapOptNoneINTEL); constexpr Capability CapabilityMemoryAccessAliasingINTEL = @@ -114,6 +125,8 @@ static_cast<Capability>(ICapBfloat16ConversionINTEL); constexpr Capability CapabilityDebugInfoModuleINTEL = static_cast<Capability>(ICapDebugInfoModuleINTEL); +constexpr Capability CapabilityGlobalVariableDecorationsINTEL = + static_cast<Capability>(ICapGlobalVariableDecorationsINTEL); constexpr FunctionControlMask FunctionControlOptNoneINTELMask = static_cast<FunctionControlMask>(IFunctionControlOptNoneINTELMask); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/test/spirv_global_variable_decoration.ll new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/test/spirv_global_variable_decoration.ll --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/test/spirv_global_variable_decoration.ll 1970-01-01 01:00:00.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/test/spirv_global_variable_decoration.ll 2023-03-18 21:49:42.000000000 +0100 @@ -0,0 +1,38 @@ +; RUN: llvm-as %s -o %t.bc +; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llvm-spirv %t.bc -o %t.spv +; RUN: llvm-spirv -r %t.spv --spirv-target-env=SPV-IR -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-SPV-IR +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM + +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir" + +@v1 = addrspace(1) global i32 42, !spirv.Decorations !2 +@v2 = addrspace(1) global float 1.0, !spirv.Decorations !4 + +; CHECK-SPIRV: Decorate [[PId1:[0-9]+]] Constant +; CHECK-SPIRV: Decorate [[PId2:[0-9]+]] Constant +; CHECK-SPIRV: Decorate [[PId2]] Binding 1 +; CHECK-SPIRV: Variable {{[0-9]+}} [[PId1]] +; CHECK-SPIRV: Variable {{[0-9]+}} [[PId2]] + +!1 = !{i32 22} +!2 = !{!1} +!3 = !{i32 33, i32 1} +!4 = !{!1, !3} + +; CHECK-SPV-IR: @v1 = addrspace(1) constant i32 42, !spirv.Decorations ![[Var1DecosId:[0-9]+]] +; CHECK-SPV-IR: @v2 = addrspace(1) constant float 1.000000e+00, !spirv.Decorations ![[Var2DecosId:[0-9]+]] +; CHECK-SPV-IR-DAG: ![[Var1DecosId]] = !{![[Deco1Id:[0-9]+]], ![[LinkageDeco1Id:[0-9]+]]} +; CHECK-SPV-IR-DAG: ![[Var2DecosId]] = !{![[Deco1Id]], ![[Deco2Id:[0-9]+]], ![[LinkageDeco2Id:[0-9]+]]} +; CHECK-SPV-IR-DAG: ![[Deco1Id]] = !{i32 22} +; CHECK-SPV-IR-DAG: ![[Deco2Id]] = !{i32 33, i32 1} +; CHECK-SPV-IR-DAG: ![[LinkageDeco1Id]] = !{i32 41, !"v1", i32 0} +; CHECK-SPV-IR-DAG: ![[LinkageDeco2Id]] = !{i32 41, !"v2", i32 0} + +; CHECK-LLVM-NOT: @v1 = {{.*}}, !spirv.Decorations !{{[0-9]+}} +; CHECK-LLVM-NOT: @v2 = {{.*}}, !spirv.Decorations !{{[0-9]+}} +; CHECK-LLVM: @v1 = addrspace(1) constant i32 42 +; CHECK-LLVM: @v2 = addrspace(1) constant float 1.000000e+00 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/test/spirv_param_decorations.ll new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/test/spirv_param_decorations.ll --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/test/spirv_param_decorations.ll 1970-01-01 01:00:00.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/test/spirv_param_decorations.ll 2023-03-18 21:49:42.000000000 +0100 @@ -0,0 +1,55 @@ +; RUN: llvm-as %s -o %t.bc +; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llvm-spirv %t.bc -o %t.spv +; RUN: llvm-spirv -r %t.spv --spirv-target-env=SPV-IR -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-SPV-IR +; RUN: llvm-spirv -r %t.spv --spirv-target-env=SPV-IR -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM + +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir" + +; Function Attrs: convergent nounwind +define spir_kernel void @k(float %a, float %b, float %c) #0 !kernel_arg_addr_space !4 !kernel_arg_access_qual !5 !kernel_arg_type !6 !kernel_arg_type_qual !7 !kernel_arg_base_type !6 !spirv.ParameterDecorations !14 { +entry: + ret void +} + +; CHECK-SPIRV: Decorate [[PId1:[0-9]+]] Restrict +; CHECK-SPIRV: Decorate [[PId2:[0-9]+]] Volatile +; CHECK-SPIRV: Decorate [[PId1]] FPRoundingMode 2 +; CHECK-SPIRV: FunctionParameter {{[0-9]+}} [[PId1]] +; CHECK-SPIRV: FunctionParameter {{[0-9]+}} [[PId2]] + +!llvm.module.flags = !{!0} +!opencl.ocl.version = !{!1} +!opencl.spir.version = !{!2} +!llvm.ident = !{!3} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, i32 0} +!2 = !{i32 1, i32 2} +!3 = !{!"clang version 14.0.0"} +!4 = !{i32 0, i32 0, i32 0} +!5 = !{!"none", !"none", !"none"} +!6 = !{!"float", !"float", !"float"} +!7 = !{!"", !"", !""} +!8 = !{i32 19} +!9 = !{i32 39, i32 2} +!10 = !{i32 21} +!11 = !{!8, !9} +!12 = !{} +!13 = !{!10} +!14 = !{!11, !12, !13} + +; CHECK-SPV-IR: define spir_kernel void @k(float %a, float %b, float %c) {{.*}} !spirv.ParameterDecorations ![[ParamDecoListId:[0-9]+]] { +; CHECK-SPV-IR-DAG: ![[ParamDecoListId]] = !{![[Param1DecoId:[0-9]+]], ![[Param2DecoId:[0-9]+]], ![[Param3DecoId:[0-9]+]]} +; CHECK-SPV-IR-DAG: ![[Param1DecoId]] = !{![[Deco1Id:[0-9]+]], ![[Deco2Id:[0-9]+]]} +; CHECK-SPV-IR-DAG: ![[Param2DecoId]] = !{} +; CHECK-SPV-IR-DAG: ![[Param3DecoId]] = !{![[Deco3Id:[0-9]+]]} +; CHECK-SPV-IR-DAG: ![[Deco1Id]] = !{i32 19} +; CHECK-SPV-IR-DAG: ![[Deco2Id]] = !{i32 39, i32 2} +; CHECK-SPV-IR-DAG: ![[Deco3Id]] = !{i32 21} + +; CHECK-LLVM-NOT: define spir_kernel void @k(float %a, float %b, float %c) {{.*}} !spirv.ParameterDecorations ![[ParamDecoListId:[0-9]+]] { +; CHECK-LLVM: define spir_kernel void @k(float %a, float %b, float %c) {{.*}} { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/test/spirv_param_decorations_quals.ll new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/test/spirv_param_decorations_quals.ll --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/test/spirv_param_decorations_quals.ll 1970-01-01 01:00:00.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/test/spirv_param_decorations_quals.ll 2023-03-18 21:49:42.000000000 +0100 @@ -0,0 +1,50 @@ +; RUN: llvm-as %s -o %t.bc +; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llvm-spirv %t.bc -o %t.spv +; RUN: llvm-spirv -r %t.spv --spirv-target-env=SPV-IR -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-SPV-IR +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM + +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir" + +; Function Attrs: convergent nounwind +define spir_kernel void @k(i32 addrspace(1)* %a) #0 !kernel_arg_addr_space !4 !kernel_arg_access_qual !5 !kernel_arg_type !6 !kernel_arg_type_qual !7 !kernel_arg_base_type !6 !spirv.ParameterDecorations !10 { +entry: + ret void +} + +; CHECK-SPIRV: Decorate [[PId:[0-9]+]] Volatile +; CHECK-SPIRV: Decorate [[PId]] FuncParamAttr 4 +; CHECK-SPIRV: FunctionParameter {{[0-9]+}} [[PId]] + +!llvm.module.flags = !{!0} +!opencl.ocl.version = !{!1} +!opencl.spir.version = !{!2} +!llvm.ident = !{!3} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, i32 0} +!2 = !{i32 1, i32 2} +!3 = !{!"clang version 14.0.0"} +!4 = !{i32 0, i32 0, i32 0} +!5 = !{!"none"} +!6 = !{!"int*"} +!7 = !{!"volatile"} +!8 = !{i32 38, i32 4} ; FuncParamAttr NoAlias +!9 = !{!8} +!10 = !{!9} + +; CHECK-SPV-IR: define spir_kernel void @k(i32 addrspace(1)* %a) +; CHECK-SPV-IR-SAME: !kernel_arg_type_qual ![[KernelArgTypeQual:[0-9]+]] +; CHECK-SPV-IR-SAME: !spirv.ParameterDecorations ![[ParamDecoListId:[0-9]+]] +; CHECK-SPV-IR-DAG: ![[ParamDecoListId]] = !{![[ParamDecoId:[0-9]+]]} +; CHECK-SPV-IR-DAG: ![[ParamDecoId]] = !{![[VolatileDecoId:[0-9]+]], ![[NoAliasDecoId:[0-9]+]]} +; CHECK-SPV-IR-DAG: ![[NoAliasDecoId]] = !{i32 38, i32 4} +; CHECK-SPV-IR-DAG: ![[VolatileDecoId]] = !{i32 21} +; CHECK-SPV-IR-DAG: ![[KernelArgTypeQual]] = !{!"volatile restrict"} + +; CHECK-LLVM-NOT: !spirv.ParameterDecorations +; CHECK-LLVM: define spir_kernel void @k(i32 addrspace(1)* %a) {{.*}} !kernel_arg_type_qual ![[KernelArgTypeQual:[0-9]+]] {{.*}} { +; CHECK-LLVM-DAG: ![[KernelArgTypeQual]] = !{!"volatile restrict"} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/test/transcoding/SPV_INTEL_global_variable_decorations/global_var_decorations.ll new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/test/transcoding/SPV_INTEL_global_variable_decorations/global_var_decorations.ll --- old/SPIRV-LLVM-Translator-b23efa4f0400f8ee10f1db0cc9ff2e081b581ca1/test/transcoding/SPV_INTEL_global_variable_decorations/global_var_decorations.ll 1970-01-01 01:00:00.000000000 +0100 +++ new/SPIRV-LLVM-Translator-a4e58ffda317221a15149f9d0d4f73424c9584fb/test/transcoding/SPV_INTEL_global_variable_decorations/global_var_decorations.ll 2023-03-18 21:49:42.000000000 +0100 @@ -0,0 +1,74 @@ +; RUN: llvm-as %s -o %t.bc +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_global_variable_decorations -o %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r %t.spv --spirv-target-env=SPV-IR -o %t.rev.bc +; RUN: llvm-dis %t.rev.bc +; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-SPV-IR + +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis %t.rev.bc +; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM + +; Expected to fail - the decorations require enabled extension to be translated. +; RUN: not llvm-spirv %t.bc -o %t.spv + +target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" +target triple = "spir64-unknown-unknown" + +@int_var = addrspace(1) global i32 42, !spirv.Decorations !1 +@float_var = addrspace(1) global float 1.0, !spirv.Decorations !6 +@bool_var = addrspace(1) global i1 0, !spirv.Decorations !9 + +; CHECK-SPIRV: Capability GlobalVariableDecorationsINTEL +; CHECK-SPIRV: Extension "SPV_INTEL_global_variable_decorations" +; CHECK-SPIRV: Decorate [[#INT_VAR_ID:]] HostAccessINTEL 1 "IntVarName" +; CHECK-SPIRV: Decorate [[#BOOL_VAR_ID:]] HostAccessINTEL 3 "BoolVarName" + +; CHECK-SPIRV: Decorate [[#INT_VAR_ID]] InitModeINTEL 0 +; CHECK-SPIRV: Decorate [[#BOOL_VAR_ID]] InitModeINTEL 0 +; CHECK-SPIRV: Decorate [[#FLOAT_VAR_ID:]] InitModeINTEL 1 + +; CHECK-SPIRV: Decorate [[#BOOL_VAR_ID]] ImplementInCSRINTEL 0 +; CHECK-SPIRV: Decorate [[#INT_VAR_ID]] ImplementInCSRINTEL 1 +; CHECK-SPIRV: Decorate [[#FLOAT_VAR_ID]] ImplementInCSRINTEL 1 + + +; 5 is a global storage +; CHECK-SPIRV: Variable [[#]] [[#INT_VAR_ID]] 5 +; CHECK-SPIRV: Variable [[#]] [[#FLOAT_VAR_ID]] 5 +; CHECK-SPIRV: Variable [[#]] [[#BOOL_VAR_ID]] 5 + +!1 = !{!2, !3, !4} +!2 = !{i32 6147, i32 1, !"IntVarName"} ; HostAccessINTEL 1 "IntVarName" +!3 = !{i32 6149, i1 true} ; ImplementInCSRINTEL = true +!4 = !{i32 6148, i32 0} ; InitModeINTEL = 0 +!5 = !{i32 6148, i32 1} ; InitModeINTEL = 1 +!6 = !{!3, !5} +!7 = !{i32 6147, i32 3, !"BoolVarName"} ; HostAccessINTEL 3 "BoolVarName" +!8 = !{i32 6149, i1 false} ; ImplementInCSRINTEL = false +!9 = !{!7, !8, !4} + +; CHECK-SPV-IR: @int_var = addrspace(1) global i32 42, !spirv.Decorations ![[#INT_VAR_DEC:]] +; CHECK-SPV-IR: @float_var = addrspace(1) global float 1.000000e+00, !spirv.Decorations ![[#FLOAT_VAR_DEC:]] +; CHECK-SPV-IR: @bool_var = addrspace(1) global i1 false, !spirv.Decorations ![[#BOOL_VAR_DEC:]] + +; CHECK-SPV-IR: ![[#INT_VAR_DEC]] = !{![[#]], ![[#MD_HOST_ACCESS_INTVAR:]], ![[#MD_INIT_0:]], ![[#MD_CSR_1:]]} +; CHECK-SPV-IR: ![[#MD_HOST_ACCESS_INTVAR]] = !{i32 6147, i32 1, !"IntVarName"} +; CHECK-SPV-IR: ![[#MD_INIT_0]] = !{i32 6148, i32 0} +; CHECK-SPV-IR: ![[#MD_CSR_1]] = !{i32 6149, i32 1} +; CHECK-SPV-IR: ![[#FLOAT_VAR_DEC]] = !{![[#]], ![[#MD_INIT_1:]], ![[#MD_CSR_1]]} +; CHECK-SPV-IR: ![[#MD_INIT_1]] = !{i32 6148, i32 1} +; CHECK-SPV-IR: ![[#BOOL_VAR_DEC]] = !{![[#]], ![[#MD_HOST_ACCESS_BOOLVAR:]], ![[#MD_INIT_0]], ![[#MD_CSR_0:]]} +; CHECK-SPV-IR: ![[#MD_HOST_ACCESS_BOOLVAR]] = !{i32 6147, i32 3, !"BoolVarName"} +; CHECK-SPV-IR: ![[#MD_CSR_0]] = !{i32 6149, i32 0} + + +; CHECK-LLVM-NOT: @int_var = {{.*}}, !spirv.Decorations ![[#]] +; CHECK-LLVM-NOT: @float_var = {{.*}}, !spirv.Decorations ![[#]] +; CHECK-LLVM-NOT: @bool_var = {{.*}}, !spirv.Decorations ![[#]] + +; CHECK-LLVM: @int_var = addrspace(1) global i32 42 +; CHECK-LLVM: @float_var = addrspace(1) global float 1.000000e+00 +; CHECK-LLVM: @bool_var = addrspace(1) global i1 false