Skip to content

Conversation

badumbatish
Copy link
Contributor

From the comment on PR review #1844, it seems like we're missing the flags for GEP.

I'm opening the PR to add the flags.

The first commit is just a prototype to gather opinions and reviews to see if I'm heading to the right direction with this.

Copy link

github-actions bot commented Aug 26, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

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.

Nice! This also needs CIRGen changes and lowering to LLVM support, but looks like a good start

@tommymcm
Copy link
Collaborator

It might make sense for cir.get_element to get the same treatment. Maybe we should have it inherit from ptr_stride to avoid duplicating everything? get_element is essentially just a ptr_stride with 'better' type information.

@badumbatish
Copy link
Contributor Author

is there any historical reason why we didn't consolidate the two?

@tommymcm
Copy link
Collaborator

is there any historical reason why we didn't consolidate the two?

Nope, I introduced get_element recently-ish. It just didn't have any meaningful overlap until this. Other option is having them share a parent (some kind of "ptr_arith" base class).
This can all be handled in a later PR though.

@andykaylor
Copy link
Collaborator

I like get_element as a separate operation, because it does something logically different than ptr_stride, but if we can share code between them, we should.

@badumbatish
Copy link
Contributor Author

I added lowering and codegen, I added OGCG test initially but was reluctant if i should push it.

I also didn't remove the missing feature check, i'm not sure how feature ready this is compared to OG.

Copy link
Collaborator

@xlauko xlauko left a comment

Choose a reason for hiding this comment

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

Can this be first ported to incubator then mirrored here.

@badumbatish
Copy link
Contributor Author

Can this be first ported to incubator then mirrored here.

I dont quite follow, this repo is the incubator yes?

- Add CIR_I32BitEnum similar to CIR_I32Enum.
- Add usage example where we use enums
- Use look up table instead of static cast when converting from CIR to
  LLVM
Copy link
Collaborator

@tommymcm tommymcm left a comment

Choose a reason for hiding this comment

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

Need to update the CIR-to-LLVM GEP flag function. Also some formatting nits.

bcardosolopes pushed a commit that referenced this pull request Sep 5, 2025
tommymcm pushed a commit to tommymcm/clangir that referenced this pull request Sep 5, 2025
@xlauko
Copy link
Collaborator

xlauko commented Sep 6, 2025

Can this be first ported to incubator then mirrored here.

I dont quite follow, this repo is the incubator yes?

Yeah sorry, I was jumping in between PRs and missed that this was already in clangir.

@badumbatish
Copy link
Contributor Author

i got an unrelated code formatting error, should I wait for the formatting PR to come in separately or do you guys want me to include the correct formatting as well?

@bcardosolopes
Copy link
Member

i got an unrelated code formatting error, should I wait for the formatting PR to come in separately or do you guys want me to include the correct formatting as well?

How sure it's unrelated? Is it showing up in other PRs? I see at least clang/test/CIR/CodeGen/pointers.cpp in the list, haven't checked the others. If you can reproduce locally and there's a small workaround you could include that'd be welcome

@badumbatish
Copy link
Contributor Author

clang-format CI shows this file not passing the CI but this PR doesn't include the lines in those files
Screenshot 2025-09-08 at 2 36 45 PM

@bcardosolopes
Copy link
Member

Gotcha, maybe we made a mistake and landed non-formatted things, just landed a fix for it. Can you rebase the PR just to make sure it goes smooth?

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, I'll merge as soon as it passes all tests

@bcardosolopes bcardosolopes merged commit 9e61bea into llvm:main Sep 9, 2025
8 of 9 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.

5 participants