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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CIR][CIRGen][LowerToLLVM] Add address space attribute for pointer type #606

Merged
merged 6 commits into from
May 20, 2024

Conversation

seven-mile
Copy link
Collaborator

@seven-mile seven-mile commented May 15, 2024

This is the prelude of address space support. Linked issue: #418 .

I want to solve it by these steps:

  1. This PR, add the attribute and implement asm format & type conversion.
  2. Enable the feature flag of address space, but break it into several other flags. And re-categorize / fix occurrences in the codebase. There is already a draft commit for this part. PR coming soon.
    • The proposed new feature flags are: addressSpaceCasting and (existing) addressSpaceInGlobalVar
  3. Implement clang::CK_AddressSpaceConversion as a new kind of cir.cast. Also fix the corresponding occurrences.
  4. Make ops like cir.global and cir.get_global aware of address space, and solve the latter flag.
  5. Relax the restriction of default alloca address space. Then we can use correct address spaces for languages like OpenCL in future.

Revert to this PR itself, which includes:

  • custom assembly format cir.ptr<T[, $addrspace]> cir.ptr<T[, addrspace($addrspace)]>
  • two build functions with optional argument addrspace = 0 extended
    • I set skipDefaultBuilders = 1, tell me if it's not a good practice馃槈
  • CIRGen / Lowering support for the two type converter from AST -> CIR -> LLVM pipeline
  • two corresponding test cases

clang/lib/CIR/Dialect/IR/CIRTypes.cpp Outdated Show resolved Hide resolved
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.

Neat!

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.

Thanks for working on this. Seems almost good, some nits, just fix them and I'll merge

clang/test/CIR/CodeGen/address-space.c Outdated Show resolved Hide resolved
clang/test/CIR/CodeGen/address-space.c Outdated Show resolved Hide resolved
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.

Looks great. In the future please make sure you update the PR description to only reflect what's currently done in the PR + no need to state what changed between commits because I squash them before merging.

@bcardosolopes bcardosolopes merged commit 1166bdb into llvm:main May 20, 2024
6 checks passed
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.

None yet

5 participants