-
Notifications
You must be signed in to change notification settings - Fork 212
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
Fix OCL builtins translation in case SPV_KHR_untyped_pointers is enabled #2723
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2003,6 +2003,12 @@ class SPIRVExtInst : public SPIRVFunctionCallGeneric<OpExtInst, 5> { | |
} | ||
return VArgs; | ||
} | ||
SPIRVValue *getArg(SPIRVWord I) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be renamed getArgValue to be consistent with the pre-existing getArgValues which returns a vector pointers. Also, consider implementing getArgValues with getArgValue. |
||
if (isOperandLiteral(I)) | ||
return Module->getLiteralAsConstant(Args[I]); | ||
return getValue(Args[I]); | ||
} | ||
|
||
std::vector<SPIRVType *> getArgTypes() { | ||
std::vector<SPIRVType *> ArgTypes; | ||
auto VArgs = getArgValues(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,32 @@ | ||
; RUN: llvm-as %s -o %t.bc | ||
; RUN: llvm-spirv %t.bc -o %t.spv | ||
; RUN: spirv-val %t.spv | ||
; RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV | ||
; RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-NOEXT | ||
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc | ||
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM | ||
|
||
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_KHR_untyped_pointers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How did you pick this file to do additional testing with SPV_KHR_untyped_pointers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I'm just running all the tests with the extension enabled and trying to understand where the real fixes should be made, or where we just need to update Checks. |
||
; TODO: enable back once spirv-tools are updated | ||
; R/UN: spirv-val %t.spv | ||
; RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-EXT | ||
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc | ||
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM | ||
|
||
source_filename = "math_builtin_float_half.cpp" | ||
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 = "spirv64-unknown-unknown" | ||
|
||
; CHECK-SPIRV: 3 TypeFloat [[HALF:[0-9]+]] 16 | ||
; CHECK-SPIRV: 4 TypePointer [[HALFPTR:[0-9]+]] 7 [[HALF]] | ||
; CHECK-SPIRV: 4 TypeVector [[HALFV2:[0-9]+]] [[HALF]] 2 | ||
; CHECK-SPIRV: 4 TypePointer [[HALFV2PTR:[0-9]+]] 7 [[HALFV2]] | ||
; CHECK-SPIRV: 4 Constant [[HALF]] [[CONST:[0-9]+]] 14788 | ||
; CHECK-SPIRV: 4 Variable [[HALFPTR]] [[ADDR:[0-9]+]] 7 | ||
; CHECK-SPIRV: 4 Variable [[HALFV2PTR]] [[ADDR2:[0-9]+]] 7 | ||
; CHECK-SPIRV: 7 ExtInst [[HALF]] [[#]] 1 fract [[CONST]] [[ADDR]] | ||
; CHECK-SPIRV: 7 ExtInst [[HALFV2]] [[#]] 1 fract [[#]] [[ADDR2]] | ||
; CHECK-SPIRV: TypeFloat [[HALF:[0-9]+]] 16 | ||
; CHECK-SPIRV-NOEXT: TypePointer [[HALFPTR:[0-9]+]] 7 [[HALF]] | ||
; CHECK-SPIRV-EXT: TypeUntypedPointerKHR [[HALFPTR:[0-9]+]] 7 | ||
; CHECK-SPIRV: TypeVector [[HALFV2:[0-9]+]] [[HALF]] 2 | ||
; CHECK-SPIRV: TypePointer [[HALFV2PTR:[0-9]+]] 7 [[HALFV2]] | ||
; CHECK-SPIRV: Constant [[HALF]] [[CONST:[0-9]+]] 14788 | ||
; CHECK-SPIRV-NOEXT: Variable [[HALFPTR]] [[ADDR:[0-9]+]] 7 | ||
; CHECK-SPIRV-EXT: UntypedVariableKHR [[HALFPTR]] [[ADDR:[0-9]+]] 7 [[HALF]] | ||
; CHECK-SPIRV: Variable [[HALFV2PTR]] [[ADDR2:[0-9]+]] 7 | ||
; CHECK-SPIRV: ExtInst [[HALF]] [[#]] 1 fract [[CONST]] [[ADDR]] | ||
; CHECK-SPIRV: ExtInst [[HALFV2]] [[#]] 1 fract [[#]] [[ADDR2]] | ||
|
||
; CHECK-LLVM: %addr = alloca half | ||
; CHECK-LLVM: %addr2 = alloca <2 x half> | ||
|
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.
Does function transBuiltinFromInst() also need this special handling? It also calls transTypeVector() and gets a mangled name. Consider putting this special processing within transTypeVector().
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.
My experiments show that e.g. for
OpEnqueKernel
we don't meet untyped variables in arguments, but the mangling is still wrong - should be fixed elsewhere.It's still possible to unify this fix inside
transTypeVector()
, but not sure if it'd be used bytransBuiltinFromInst()
.