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] Add initial support for bit-precise integer types #538

Merged
merged 4 commits into from
Apr 15, 2024

Conversation

Lancern
Copy link
Member

@Lancern Lancern commented Apr 9, 2024

This PR adds initial support for the bit-precise integer type _BitInt(N). This type goes into the C23 standard, and has already been supported by clang since 2020, previously known as _ExtInt(N).

This PR is quite simple and straight-forward. Basically it leverages the existing cir.int type to represent such types. Previously cir.int verifies that its width must be a multiple of 8, and this verification has been removed in this PR.

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.

Hi, this is cool, thanks! You say initial support, what's remaining here?

Few extra things this PR needs:

  • Add LLVM lowering support, and add tests similar from clang/test/CodeGen/ext-int.c and clang/test/CodeGen/ext-int-cc.c. I'm open to this being follow up work, but it probably goes well with the size of this PR.
  • A bunch of constraints in tablegen assume int types of the primitive ones, so we need to refine those or split them into more variants. Example CIR_IntType, CIR_AnyIntOrFloat, IntOrFPPtr, IntegerVector (We either need a better name for them, or change how they are defined). You need to go through each user in CIROps.td and check whether it makes sense for the operations to use anything other than canonical primite types when ints are involved.

@bcardosolopes
Copy link
Member

@sitio-couto you might be interested in this.

@Lancern
Copy link
Member Author

Lancern commented Apr 11, 2024

You say initial support, what's remaining here?

Well, I'm just not sure whether the changes in this PR is sufficient for a full support, or there are still some unnoticed cases that needs to be resolved. Tests do not follow up that quickly.

Add LLVM lowering support, and add tests similar from clang/test/CodeGen/ext-int.c and clang/test/CodeGen/ext-int-cc.c.

Added. Tests that require unimplemented features are not added for now.

A bunch of constraints in tablegen assume int types of the primitive ones, so we need to refine those or split them into more variants.

Updated.

@bcardosolopes
Copy link
Member

Well, I'm just not sure whether the changes in this PR is sufficient for a full support, or there are still some unnoticed cases that needs to be resolved. Tests do not follow up that quickly.

Sounds good, just out of curiosity.

Added. Tests that require unimplemented features are not added for now.

Thanks

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.

Mostly another round of cosmetic reviews. Please also add aliases to these new ints.

clang/include/clang/CIR/Dialect/IR/CIRTypes.td Outdated Show resolved Hide resolved
clang/include/clang/CIR/Dialect/IR/CIROps.td Outdated Show resolved Hide resolved
clang/include/clang/CIR/Dialect/IR/CIRTypes.td Outdated Show resolved Hide resolved
clang/include/clang/CIR/Dialect/IR/CIRTypes.td Outdated Show resolved Hide resolved
clang/include/clang/CIR/Dialect/IR/CIRTypes.td Outdated Show resolved Hide resolved
This patch adds support for the bit-precise integer type `_BitInt(N)`. This type
goes into the C23 standard, and has already been supported by clang since 2020,
previously known as `_ExtInt(N)`.

Basically this patch leverages the existing `cir.int` type to represent such
types. Previously `cir.int` verifies that its width must be a multiple of 8, and
this verification has been removed in this patch.
@Lancern
Copy link
Member Author

Lancern commented Apr 14, 2024

Rebased onto the latest main.

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 one minor comment that can be address in another PR.

// We only provide alias for standard integer types (i.e. integer types
// whose width is divisible by 8).
if (intType.getWidth() % 8 != 0)
return AliasResult::NoAlias;
Copy link
Member

Choose a reason for hiding this comment

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

Not a blocker for this PR, but why not?

@bcardosolopes bcardosolopes merged commit 64ce3c1 into llvm:main Apr 15, 2024
6 checks passed
@Lancern Lancern deleted the bitint branch April 20, 2024 11:58
lanza pushed a commit that referenced this pull request Apr 29, 2024
This PR adds initial support for the bit-precise integer type
`_BitInt(N)`. This type goes into the C23 standard, and has already been
supported by clang since 2020, previously known as `_ExtInt(N)`.

This PR is quite simple and straight-forward. Basically it leverages the
existing `cir.int` type to represent such types. Previously `cir.int`
verifies that its width must be a multiple of 8, and this verification
has been removed in this PR.
lanza pushed a commit that referenced this pull request Apr 29, 2024
This PR adds initial support for the bit-precise integer type
`_BitInt(N)`. This type goes into the C23 standard, and has already been
supported by clang since 2020, previously known as `_ExtInt(N)`.

This PR is quite simple and straight-forward. Basically it leverages the
existing `cir.int` type to represent such types. Previously `cir.int`
verifies that its width must be a multiple of 8, and this verification
has been removed in this PR.
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Apr 29, 2024
This PR adds initial support for the bit-precise integer type
`_BitInt(N)`. This type goes into the C23 standard, and has already been
supported by clang since 2020, previously known as `_ExtInt(N)`.

This PR is quite simple and straight-forward. Basically it leverages the
existing `cir.int` type to represent such types. Previously `cir.int`
verifies that its width must be a multiple of 8, and this verification
has been removed in this PR.
lanza pushed a commit that referenced this pull request Apr 29, 2024
This PR adds initial support for the bit-precise integer type
`_BitInt(N)`. This type goes into the C23 standard, and has already been
supported by clang since 2020, previously known as `_ExtInt(N)`.

This PR is quite simple and straight-forward. Basically it leverages the
existing `cir.int` type to represent such types. Previously `cir.int`
verifies that its width must be a multiple of 8, and this verification
has been removed in this PR.
bruteforceboy pushed a commit to bruteforceboy/clangir that referenced this pull request Oct 2, 2024
This PR adds initial support for the bit-precise integer type
`_BitInt(N)`. This type goes into the C23 standard, and has already been
supported by clang since 2020, previously known as `_ExtInt(N)`.

This PR is quite simple and straight-forward. Basically it leverages the
existing `cir.int` type to represent such types. Previously `cir.int`
verifies that its width must be a multiple of 8, and this verification
has been removed in this PR.
Hugobros3 pushed a commit to shady-gang/clangir that referenced this pull request Oct 2, 2024
This PR adds initial support for the bit-precise integer type
`_BitInt(N)`. This type goes into the C23 standard, and has already been
supported by clang since 2020, previously known as `_ExtInt(N)`.

This PR is quite simple and straight-forward. Basically it leverages the
existing `cir.int` type to represent such types. Previously `cir.int`
verifies that its width must be a multiple of 8, and this verification
has been removed in this PR.
keryell pushed a commit to keryell/clangir that referenced this pull request Oct 19, 2024
This PR adds initial support for the bit-precise integer type
`_BitInt(N)`. This type goes into the C23 standard, and has already been
supported by clang since 2020, previously known as `_ExtInt(N)`.

This PR is quite simple and straight-forward. Basically it leverages the
existing `cir.int` type to represent such types. Previously `cir.int`
verifies that its width must be a multiple of 8, and this verification
has been removed in this PR.
lanza pushed a commit that referenced this pull request Nov 5, 2024
This PR adds initial support for the bit-precise integer type
`_BitInt(N)`. This type goes into the C23 standard, and has already been
supported by clang since 2020, previously known as `_ExtInt(N)`.

This PR is quite simple and straight-forward. Basically it leverages the
existing `cir.int` type to represent such types. Previously `cir.int`
verifies that its width must be a multiple of 8, and this verification
has been removed in this PR.
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