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

handle OpBitcast between pointers and non-pointers #2948

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

bashbaug
Copy link
Contributor

Adds support for SPIR-V OpBitcast instructions where the source is a pointer and the destination is not a pointer, and where the source is not a pointer and the destination is a pointer. This needs to be handled as a special case because the LLVM bitcast instruction does not support this.

Handles bitcasts between pointers and scalar integers, which is supported by all SPIR-V versions, and pointers and vectors of integers, which is supported by SPIR-V 1.5 (though only for vectors of 32-bit integers).

Even though we only expect to OpBitcast a pointer to a vector of
two 32-bit integers, it's easy enough to just handle all vector
types.
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %kernel "test"
%uint = OpTypeInt 32 0
%ulong = OpTypeInt 64 0
Copy link
Member

Choose a reason for hiding this comment

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

Seems unused.

@@ -1085,6 +1085,37 @@ Value *SPIRVToLLVM::transConvertInst(SPIRVValue *BV, Function *F,
case OpFConvert:
CO = IsExt ? Instruction::FPExt : Instruction::FPTrunc;
break;
case OpBitcast:
CO = Instruction::BitCast;
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps it would be nice to add a comment here to highlight the difference between OpBitcast and llvm's bitcast (repeating the PR description would work for me).

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.

2 participants