================ @@ -9,22 +9,32 @@ using namespace clang; using namespace clang::CIRGen; CIRGenTypes::CIRGenTypes(CIRGenModule &genModule) - : cgm(genModule), context(genModule.getASTContext()) {} + : cgm(genModule), context(genModule.getASTContext()), + builder(cgm.getBuilder()) {} CIRGenTypes::~CIRGenTypes() {} +mlir::MLIRContext &CIRGenTypes::getMLIRContext() const { + return *builder.getContext(); +} + mlir::Type CIRGenTypes::convertType(QualType type) { type = context.getCanonicalType(type); const Type *ty = type.getTypePtr(); + // Has the type already been processed? + TypeCacheTy::iterator tci = typeCache.find(ty); + if (tci != typeCache.end()) + return tci->second; + // For types that haven't been implemented yet or are otherwise unsupported, // report an error and return 'int'. mlir::Type resultType = nullptr; switch (ty->getTypeClass()) { case Type::Builtin: { switch (cast<BuiltinType>(ty)->getKind()) { - // Signed types. + // Signed integral types. ---------------- erichkeane wrote:
Perhaps some additional complexity, but was it considered to use the cached kinds for all of these instead of creating it again? https://github.com/llvm/llvm-project/pull/119037 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits