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

[CIR][CodeGen][LowerToLLVM] Emit OpenCL version metadata for SPIR-V target #773

Merged
merged 5 commits into from
Aug 8, 2024

Conversation

seven-mile
Copy link
Collaborator

Similar to #767, this PR emit the module level OpenCL version metadata following the OG CodeGen skeleton.

We use a full qualified cir.cl.version attribute on the module op to store the info in CIR.

@seven-mile
Copy link
Collaborator Author

Other idea includes adding a new cir.lang_std attribute similar to cir.lang to model the clang's equivalent clang::LangStandard.

But I think our IR should be composed of language-version-agnostic constructs. Also, that would not conflict with this one. I prefer not early abstracting it. If we have more use cases for something like cir.lang_std, it will be nice to have it at that time.

Btw, refactor of CodeGen logic specific to OpenCL will come right after this patch.

Copy link
Contributor

@jopperm jopperm left a comment

Choose a reason for hiding this comment

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

+1 on keeping this OpenCL-specific for now, and plan to abstract later on demand.

if (auto openclVersionAttr = mlir::dyn_cast<mlir::cir::OpenCLVersionAttr>(
attribute.getValue())) {
auto *int32Ty = llvm::IntegerType::get(llvmContext, 32);
llvm::Metadata *olcVerElts[] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be oclVerElts.

Example:
```
// Module compiled from OpenCL 1.2.
module attributes {cir.cl.version = cir.cl.version<1,2>} {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Super-Nit: The attribute is printed cir.cl.version<1, 2> (with a space after the comma) according to the added lit test.

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Look overall good, minor improvement request!

Example:
```
// Module compiled from OpenCL 1.2.
module attributes {cir.cl.version = cir.cl.version<1, 2>} {}
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add an alias so that the attribute could be a little less verbose?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The description updated.

Copy link
Member

Choose a reason for hiding this comment

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

It actually looks even more verbose with the alias! Hopefully we can have a better output once we implement our owne cir module. Anyways, please go back to the previous version (without the alias), I'll approve now and merge later when you update again, sorry the back-n-forth

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

LGTM with another nit

@bcardosolopes bcardosolopes merged commit ccac403 into llvm:main Aug 8, 2024
6 checks passed
Hugobros3 pushed a commit to shady-gang/clangir that referenced this pull request Oct 2, 2024
…arget (llvm#773)

Similar to llvm#767, this PR emit the module level OpenCL version metadata
following the OG CodeGen skeleton.

We use a full qualified `cir.cl.version` attribute on the module op to
store the info in CIR.
smeenai pushed a commit to smeenai/clangir that referenced this pull request Oct 9, 2024
…arget (llvm#773)

Similar to llvm#767, this PR emit the module level OpenCL version metadata
following the OG CodeGen skeleton.

We use a full qualified `cir.cl.version` attribute on the module op to
store the info in CIR.
smeenai pushed a commit to smeenai/clangir that referenced this pull request Oct 9, 2024
…arget (llvm#773)

Similar to llvm#767, this PR emit the module level OpenCL version metadata
following the OG CodeGen skeleton.

We use a full qualified `cir.cl.version` attribute on the module op to
store the info in CIR.
keryell pushed a commit to keryell/clangir that referenced this pull request Oct 19, 2024
…arget (llvm#773)

Similar to llvm#767, this PR emit the module level OpenCL version metadata
following the OG CodeGen skeleton.

We use a full qualified `cir.cl.version` attribute on the module op to
store the info in CIR.
lanza pushed a commit that referenced this pull request Nov 5, 2024
…arget (#773)

Similar to #767, this PR emit the module level OpenCL version metadata
following the OG CodeGen skeleton.

We use a full qualified `cir.cl.version` attribute on the module op to
store the info in CIR.
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