Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to choose program address space in emitted LLVM IR #1392

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DmitryBushev
Copy link
Contributor

SPIRV does not specify storage class for functions, although llvm does.
This patch enables choise of address space for function in data layout
of emitted LLVM module.

Comment on lines 3227 to 3241
M->setDataLayout(BM->hasProgramAddressSpace()
? std::string(SPIR_DATALAYOUT64) + "-P" +
std::to_string(BM->getProgramAddressSpace())
: SPIR_DATALAYOUT64);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to put this logic into a separate function that takes BM and SPIR_DATALAYOUT64. This way you will avoid the copy-paste below.

; CHECK: @test
; CHECK-SAME: addrspace(3)

define spir_kernel void @test() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also check the case with function pointers? Will they end up in the correct namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I've inspected, pointers' address spaces are translated directly into StorageClass and back. So, this information is already preserved by translator

@@ -488,6 +488,14 @@ class SPIRVModule {
return TranslationOpts.isAllowedToUseExtension(RequestedExtension);
}

virtual bool hasProgramAddressSpace() const final {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't get the logic behind virtual final here. Why not just use non-virtual method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get the logic either, I just copy-pasted method header and changed name. Did not even notice that first.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why adding something you don't understand. I would virtual and final here.

@DmitryBushev DmitryBushev force-pushed the master branch 2 times, most recently from 6ef9a8a to 4772d5e Compare February 1, 2022 13:53
@@ -354,6 +354,17 @@ std::string SPIRVToLLVM::transVCTypeName(SPIRVTypeBufferSurfaceINTEL *PST) {
return VectorComputeUtil::getVCBufferSurfaceName(PST->getAccessQualifier());
return VectorComputeUtil::getVCBufferSurfaceName();
}
static unsigned transPointerStorageClass(SPIRVTypePointer const *PtrType) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static unsigned transPointerStorageClass(SPIRVTypePointer const *PtrType) {
static unsigned transPointerStorageClass(SPIRVTypePointer const *PtrType) {

Comment on lines 3235 to 3264
return BM->hasProgramAddressSpace()
? GeneralLayout + "-P" +
std::to_string(BM->getProgramAddressSpace())
: GeneralLayout;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return BM->hasProgramAddressSpace()
? GeneralLayout + "-P" +
std::to_string(BM->getProgramAddressSpace())
: GeneralLayout;
if (!BM->hasProgramAddressSpace())
return GeneralLayout;
return GeneralLayout + "-P" + std::to_string(BM->getProgramAddressSpace());

@@ -3220,15 +3231,22 @@ bool SPIRVToLLVM::translate() {
return true;
}

std::string SPIRVToLLVM::transDataLayout(std::string const &GeneralLayout) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just make it a static function and pass PM. Passing this is not required but costs the same.

@@ -488,6 +488,14 @@ class SPIRVModule {
return TranslationOpts.isAllowedToUseExtension(RequestedExtension);
}

virtual bool hasProgramAddressSpace() const final {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why adding something you don't understand. I would virtual and final here.

Copy link
Contributor

@MrSidims MrSidims left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we instead of making this option modify SPV_INTEL_function_pointers , introducing storage class optional parameter to OpFunctionPointerINTEL
?


if (PtrType->getPointerElementType()->getOpCode() == OpTypeFunction) {
auto *M = PtrType->getModule();
if (M->hasProgramAddressSpace())
Copy link
Contributor

@MrSidims MrSidims Feb 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me, that any function in the module will have the set address space, which seems incorrect to me (just consider such artificial example:

%ptr = alloca i8
call addrspace(3) void @llvm.lifetime.start.p0i8(i64 1, i8* %ptr)

how backend will consider addrspace(3) ?
What if a function had address space before the translation? Now this AS is just being lost (and some BE might do some assumptions regarding what AS to pick), with this option turned on the BE won't do any assumptions, just picking the set AS, is it error-prune?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the function had addrspace before the translation the current translator will preserve AS on a pointer but will lose it on the function itself, which will result in an error during the compilation. To some extend this options saves us. Though fixing the current function pointer implementation first is a nice idea too. There's CodeSectionINTEL storage class but it is never used and it is not clear what LLVM IR addrspace should it correspond.

SPIRV does not specify storage class for functions, although llvm does.
This patch enables choise of address space for function in data layout
of emitted LLVM module.
MrSidims added a commit that referenced this pull request Sep 27, 2024
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
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 19, 2024
…up#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: KhronosGroup#1392
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 19, 2024
…up#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: KhronosGroup#1392
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 19, 2024
…up#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: KhronosGroup#1392
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 19, 2024
…up#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: KhronosGroup#1392
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 21, 2024
…up#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: KhronosGroup#1392
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 21, 2024
…up#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: KhronosGroup#1392
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 21, 2024
…up#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: KhronosGroup#1392
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 22, 2024
…up#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: KhronosGroup#1392
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 22, 2024
…up#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: KhronosGroup#1392
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 22, 2024
…up#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: KhronosGroup#1392
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 22, 2024
…up#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: KhronosGroup#1392
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 22, 2024
…up#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: KhronosGroup#1392
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 22, 2024
…up#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: KhronosGroup#1392
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 22, 2024
…up#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: KhronosGroup#1392
mshelego pushed a commit to mshelego/SPIRV-LLVM-Translator that referenced this pull request Oct 22, 2024
…up#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: KhronosGroup#1392
MrSidims added a commit that referenced this pull request Oct 23, 2024
)

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

Co-authored-by: Dmitry Sidorov <[email protected]>
MrSidims added a commit that referenced this pull request Oct 23, 2024
)

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

Co-authored-by: Dmitry Sidorov <[email protected]>
MrSidims added a commit that referenced this pull request Oct 23, 2024
)

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

Co-authored-by: Dmitry Sidorov <[email protected]>
MrSidims added a commit that referenced this pull request Oct 23, 2024
)

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

Co-authored-by: Dmitry Sidorov <[email protected]>
MrSidims added a commit that referenced this pull request Oct 23, 2024
)

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

Co-authored-by: Dmitry Sidorov <[email protected]>
MrSidims added a commit that referenced this pull request Oct 23, 2024
)

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

Co-authored-by: Dmitry Sidorov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants