Skip to content

Commit c971184

Browse files
MrSidimsjsji
authored andcommitted
Introduce CodeSectionINTEL storage class (#2728)
This storage class is used for function pointers. It's added as based on cl_intel_function_pointers specification, it is not guaranteed that sizeof(void(*)(void) == sizeof(void *) - to allow consumers use this fact, we cannot say that function pointer belongs to the same storage class as data pointers. It wasn't added during initial implementation, now it's time to fill this gap. As it would be a breaking change its generation is added only under -spirv-emit-function-ptr-addr-space option. Also SPIR-V consumer may pass this option during reverse translation to get new address space even in a case, when OpConstantFunctionPointerINTEL doesn't reside in CodeSectionINTEL storage class. Expected behavior: No option is passed to the forward translation stage and function pointers are in addrspace(9): no CodeSectionINTEL storage class in SPIR-V The option is passed to the forward translation stage and function pointers are in addrepace(9): CodeSectionINTEL storage class is generated No option is passed to the reverse translation stage: function pointers are in private address space The option is passed to the reverse translation stage: function pointers are in addrspace(9) Spec: https://github.com/intel/llvm/blob/sycl/sycl/doc/design/spirv-extensions/SPV_INTEL_function_pointers.asciidoc The previous approach: #1392 Original commit: KhronosGroup/SPIRV-LLVM-Translator@46c9eb9ea9b4c6f
1 parent bb1bc6a commit c971184

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3073,7 +3073,7 @@ void SPIRVToLLVM::transFunctionAttrs(SPIRVFunction *BF, Function *F) {
30733073
});
30743074
}
30753075

3076-
Function *SPIRVToLLVM::transFunction(SPIRVFunction *BF) {
3076+
Function *SPIRVToLLVM::transFunction(SPIRVFunction *BF, unsigned AS) {
30773077
auto Loc = FuncMap.find(BF);
30783078
if (Loc != FuncMap.end())
30793079
return Loc->second;

llvm-spirv/lib/SPIRV/SPIRVReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class SPIRVToLLVM : private BuiltinCallHelper {
103103
void transAuxDataInst(SPIRVExtInst *BC);
104104
std::vector<Value *> transValue(const std::vector<SPIRVValue *> &,
105105
Function *F, BasicBlock *);
106-
Function *transFunction(SPIRVFunction *F);
106+
Function *transFunction(SPIRVFunction *F, unsigned AS = SPIRAS_Private);
107107
void transFunctionAttrs(SPIRVFunction *BF, Function *F);
108108
Value *transBlockInvoke(SPIRVValue *Invoke, BasicBlock *BB);
109109
Instruction *transWGSizeQueryBI(SPIRVInstruction *BI, BasicBlock *BB);

0 commit comments

Comments
 (0)