diff options
author | David Olsen <dolsen@nvidia.com> | 2025-02-25 11:40:15 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-25 11:40:15 -0800 |
commit | eacbcbe47744a496ad1651ebd65914f9e6a66f85 (patch) | |
tree | 57000c54c9562bcf04263b8f85e859e625131cbf /clang/lib/CIR/CodeGen/CIRGenModule.cpp | |
parent | 4357a6603f2c21f343d500778f71494e865262ac (diff) | |
download | llvm-eacbcbe47744a496ad1651ebd65914f9e6a66f85.zip llvm-eacbcbe47744a496ad1651ebd65914f9e6a66f85.tar.gz llvm-eacbcbe47744a496ad1651ebd65914f9e6a66f85.tar.bz2 |
[CIR] Upstream type `bool` (#128601)
Support the type `bool` and the literals `true` and `false`. Add the
type `cir::BoolType` and the attribute `cir::BoolAttr` to ClangIR. Add
code in all the necessary places in ClangIR CodeGen to handle and to
recognize the type and the attribute.
Add test cases to existing tests func-simple.cpp and
global-var-simple.cpp.
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenModule.cpp')
-rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenModule.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index c1d3265..d8acc99 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -141,7 +141,11 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *vd, if (APValue *value = initDecl->evaluateValue()) { switch (value->getKind()) { case APValue::Int: { - initializer = builder.getAttr<cir::IntAttr>(type, value->getInt()); + if (mlir::isa<cir::BoolType>(type)) + initializer = + builder.getCIRBoolAttr(value->getInt().getZExtValue()); + else + initializer = builder.getAttr<cir::IntAttr>(type, value->getInt()); break; } case APValue::Float: { |