Skip to content

_BitInt(N) with large N #1212

Open
Open
@dkolsen-pgi

Description

@dkolsen-pgi

ClangIR implements the C23 _BitInt(N) types as cir.int. That works fine for N <= 128, which is currently the upper limit for the width of cir.int. But Clang supports _BitInt(N) for much larger N, up to 8,388,608. ClangIR should also support large _BitInt types. I don't know whether the right way to do this is to extend the upper limit of cir.int or to use a different CIR type for large _BitInt types.

$ cat bitint.cpp
int main() {
  _BitInt(130) a = 42;
  _BitInt(130) b = 100;
  _BitInt(130) c = a + b;
  return c;
}
$ clang++ bitint.cpp
$ clang++ -fclangir bitint.cpp
error: IntType only supports widths from 1 up to 128
clang-19: /local/home/dolsen/clangir/llvm/../mlir/include/mlir/IR/StorageUniquerSupport.h:179: static ConcreteT mlir::detail::StorageUserBase<ConcreteT, BaseT, StorageT, UniquerT, Traits>::get(mlir::MLIRContext*, Args&& ...) [with Args = {unsigned int, bool}; ConcreteT = cir::IntType; BaseT = mlir::Type; StorageT = cir::detail::IntTypeStorage; UniquerT = mlir::detail::TypeUniquer; Traits = {mlir::DataLayoutTypeInterface::Trait}]: Assertion `succeeded( ConcreteT::verifyInvariants(getDefaultDiagnosticEmitFn(ctx), args...))' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions