[clang] [CIR] Integral types; simple global variables (PR #118743)

David Olsen via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 5 13:41:32 PST 2024


================
@@ -0,0 +1,90 @@
+#include "CIRGenTypes.h"
+
+#include "CIRGenModule.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Type.h"
+
+using namespace clang;
+using namespace clang::CIRGen;
+
+CIRGenTypes::CIRGenTypes(CIRGenModule &genModule)
+    : cgm(genModule), context(genModule.getASTContext()) {}
+
+CIRGenTypes::~CIRGenTypes() {}
+
+mlir::Type CIRGenTypes::convertType(QualType type) {
+  type = context.getCanonicalType(type);
+  const Type *ty = type.getTypePtr();
+
+  mlir::Type resultType = nullptr;
+  switch (ty->getTypeClass()) {
+  case Type::Builtin: {
+    switch (cast<BuiltinType>(ty)->getKind()) {
+    // Signed types.
+    case BuiltinType::Accum:
+    case BuiltinType::Char_S:
+    case BuiltinType::Fract:
+    case BuiltinType::Int:
+    case BuiltinType::Int128:
+    case BuiltinType::Long:
+    case BuiltinType::LongAccum:
----------------
dkolsen-pgi wrote:

I have now removed all of the fixed-point related types (not just the saturation arithmetic types) from `CIRGenTypes::convertType`.  Those types will now result in a "Not Yet Implemented" error message.

All of the `BuiltinType`s listed in `CIRGenTypes::convertType` are now tested in the test case for this change.  (Except that I can't test both `Char_S` and `Char_U` in the same compilation, since the type `char` can be only one of those at a time.)

The ClangIR issue to support fixed-point arithmetic is https://github.com/llvm/clangir/issues/1211


https://github.com/llvm/llvm-project/pull/118743


More information about the cfe-commits mailing list