-
Notifications
You must be signed in to change notification settings - Fork 246
Introduce CodeSectionINTEL storage class #2728
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/alias.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| ; RUN: llvm-as %s -o %t.bc | ||
| ; RUN: llvm-spirv -spirv-ext=+SPV_INTEL_function_pointers -spirv-text %t.bc -o - | FileCheck %s --check-prefix=CHECK-SPIRV | ||
| ; RUN: llvm-spirv -spirv-ext=+SPV_INTEL_function_pointers %t.bc -o %t.spv | ||
| ; RUN: llvm-spirv -r -spirv-emit-function-ptr-addr-space %t.spv -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-LLVM | ||
|
|
||
| target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
| target triple = "spir64-unknown-unknown" | ||
|
|
||
| ; Check that aliases are dereferenced and translated to their aliasee values | ||
| ; when used since they can't be translated directly. | ||
|
|
||
| ; CHECK-SPIRV-DAG: Name [[#FOO:]] "foo" | ||
| ; CHECK-SPIRV-DAG: Name [[#BAR:]] "bar" | ||
| ; CHECK-SPIRV-DAG: Name [[#Y:]] "y" | ||
| ; CHECK-SPIRV-DAG: Name [[#FOOPTR:]] "foo.alias" | ||
| ; CHECK-SPIRV-DAG: Decorate [[#FOO]] LinkageAttributes "foo" Export | ||
| ; CHECK-SPIRV-DAG: Decorate [[#BAR]] LinkageAttributes "bar" Export | ||
| ; CHECK-SPIRV-DAG: TypeInt [[#I32:]] 32 0 | ||
| ; CHECK-SPIRV-DAG: TypeInt [[#I64:]] 64 0 | ||
| ; CHECK-SPIRV-DAG: TypeFunction [[#FOO_TYPE:]] [[#I32]] [[#I32]] | ||
| ; CHECK-SPIRV-DAG: TypeVoid [[#VOID:]] | ||
| ; CHECK-SPIRV-DAG: TypePointer [[#I64PTR:]] 7 [[#I64]] | ||
| ; CHECK-SPIRV-DAG: TypeFunction [[#BAR_TYPE:]] [[#VOID]] [[#I64PTR]] | ||
| ; CHECK-SPIRV-DAG: TypePointer [[#FOOPTR_TYPE:]] 7 [[#FOO_TYPE]] | ||
| ; CHECK-SPIRV-DAG: ConstantFunctionPointerINTEL [[#FOOPTR_TYPE]] [[#FOOPTR]] [[#FOO]] | ||
|
|
||
| ; CHECK-SPIRV: Function [[#I32]] [[#FOO]] 0 [[#FOO_TYPE]] | ||
|
|
||
| ; CHECK-SPIRV: Function [[#VOID]] [[#BAR]] 0 [[#BAR_TYPE]] | ||
| ; CHECK-SPIRV: FunctionParameter [[#I64PTR]] [[#Y]] | ||
| ; CHECK-SPIRV: ConvertPtrToU [[#I64]] [[#PTRTOINT:]] [[#FOOPTR]] | ||
| ; CHECK-SPIRV: Store [[#Y]] [[#PTRTOINT]] 2 8 | ||
|
|
||
| ; CHECK-LLVM: define spir_func i32 @foo(i32 %x) addrspace(9) | ||
|
|
||
| ; CHECK-LLVM: define spir_kernel void @bar(ptr %y) | ||
| ; CHECK-LLVM: [[PTRTOINT:%.*]] = ptrtoint ptr addrspace(9) @foo to i64 | ||
| ; CHECK-LLVM: store i64 [[PTRTOINT]], ptr %y, align 8 | ||
|
|
||
| define spir_func i32 @foo(i32 %x) { | ||
| ret i32 %x | ||
| } | ||
|
|
||
| @foo.alias = internal alias i32 (i32), ptr @foo | ||
|
|
||
| define spir_kernel void @bar(ptr %y) { | ||
| store i64 ptrtoint (ptr @foo.alias to i64), ptr %y | ||
| ret void | ||
| } | ||
53 changes: 53 additions & 0 deletions
53
test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/bitcast.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| ; OpenCL C source: | ||
| ; char foo(char a) { | ||
| ; return a; | ||
| ; } | ||
| ; void bar() { | ||
| ; int (*fun_ptr)(int) = &foo; | ||
| ; fun_ptr(0); | ||
| ; } | ||
|
|
||
| ; RUN: llvm-as %s -o %t.bc | ||
| ; RUN: llvm-spirv %t.bc -spirv-ext=+SPV_INTEL_function_pointers -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 -spirv-emit-function-ptr-addr-space %t.spv -o %t.r.bc | ||
| ; RUN: llvm-dis %t.r.bc -o %t.r.ll | ||
| ; RUN: FileCheck < %t.r.ll %s --check-prefix=CHECK-LLVM | ||
|
|
||
| ; CHECK-SPIRV-DAG: TypeInt [[#I8:]] 8 | ||
| ; CHECK-SPIRV-DAG: TypeInt [[#I32:]] 32 | ||
| ; CHECK-SPIRV-DAG: TypeFunction [[#FOO_TY:]] [[#I8]] [[#I8]] | ||
| ; CHECK-SPIRV-DAG: TypeFunction [[#DEST_TY:]] [[#I32]] [[#I32]] | ||
| ; CHECK-SPIRV-DAG: TypePointer [[#DEST_TY_PTR:]] [[#]] [[#DEST_TY]] | ||
| ; CHECK-SPIRV-DAG: TypePointer [[#FOO_TY_PTR:]] [[#]] [[#FOO_TY]] | ||
| ; CHECK-SPIRV: ConstantFunctionPointerINTEL [[#FOO_TY_PTR]] [[#FOO_PTR:]] [[#FOO:]] | ||
| ; CHECK-SPIRV: Function [[#]] [[#FOO]] [[#]] [[#FOO_TY]] | ||
|
|
||
| ; CHECK-SPIRV: Bitcast [[#DEST_TY_PTR]] [[#]] [[#FOO_PTR]] | ||
|
|
||
| ; CHECK-LLVM: bitcast ptr addrspace(9) @foo to ptr addrspace(9) | ||
|
|
||
| ; ModuleID = './example.c' | ||
| source_filename = "./example.c" | ||
| 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: noinline nounwind optnone | ||
| define dso_local spir_func signext i8 @foo(i8 signext %0) #0 { | ||
| ret i8 %0 | ||
| } | ||
|
|
||
| ; Function Attrs: noinline nounwind optnone | ||
| define dso_local spir_func void @bar() #0 { | ||
| %1 = call i32 @foo(i32 0) | ||
| ret void | ||
| } | ||
|
|
||
| attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } | ||
|
|
||
| !llvm.module.flags = !{!0} | ||
| !llvm.ident = !{!1} | ||
|
|
||
| !0 = !{i32 1, !"wchar_size", i32 4} | ||
| !1 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 0e1accd0f726eef2c47be9f37dd0a06cb50d207e)"} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: most of these tests are copies from SPV_INTEL_function_pointers/* tests with -spirv-emit-function-ptr-addr-space option added in reverse translation to check if addrspace(9) is generated. The only exception to this is function-pointer-dedicated-as.ll test