-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[NFC][HLSL] Allow target intrinsic switching to optionally be set. #117648
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
Closed
Closed
Changes from all commits
Commits
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
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.
I feel like this is a bit of extra preprocessor complexity. Instead of having
GENERATE_HLSL_INTRINSIC_FUNCTIONchange to take arguments, we could just define target-specific macros (i.e.GENERATE_HLSL_DX_INTRINSIC_FUNCTIONandGENERATE_HLSL_SPV_INTRINSIC_FUNCTION).I also generally think putting
DEFAULTin the name of something is a bit of a red flag since you're making the name longer, but not adding relevant context.Uh oh!
There was an error while loading. Please reload this page.
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.
I don't see how creating target specific macros is better than just using
llvm::Intrinsic::spv_*orllvm::Intrinsic::dx_*. The idea behind making it arguments is that if we have more targets after spv and dx we aren't adding anNnumber of new macros its just one more argument and one moreIF_INCLUDEcase block.instead ofDEFAULTI could rename toALL?I could also makeGENERATE_HLSL_DX_INTRINSIC_FUNCTION-->GENERATE_HLSL_INTRINSIC_FUNCTION(FunctionName, IntrinsicPostfix, 1, 0)andGENERATE_HLSL_SPV_INTRINSIC_FUNCTION-->GENERATE_HLSL_INTRINSIC_FUNCTION(FunctionName, IntrinsicPostfix, 0, 1)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.
I believe the C preprocessor is the wrong tool to do what you're trying to do here. I think this makes the code significantly harder to read, understand and debug.
There are other approaches we could take like constexpr template abstractions which would be easier to read, write and maintain than nested C preprocessor macros with dependent expansions.
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.
Fair enough closing this PR.