================ @@ -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. ---------------- dkolsen-pgi wrote:
I thought about it briefly, but decided that the code complexity was not worth the benefit. The `typeCache` being added in this commit means each `cir::IntType` will be duplicated only once or twice, not lots of times. So the benefits of using `cgm.SInt*` are minimal. 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