Small infrastructure and background changes to ClangIR. Create class `CIRGenBuilderTy` and its base class `CIRBaseBuilderTy`. These are mostly empty for now, except for what is inherited from `mlir::OpBuilder`. But they will fill up quickly as more ClangIR code gen is upstreamed. `CIRGenModule` and `CIRGenTypes` are changed to use `CIRGenBuilderTy`. Add cached types to struct `CIRGenTypeCache` for the integral types that are currently supported. Initialize those cached types in the `CIRGenModule` constructor. The first uses of those types (well, one of them) is in `CIRGenTypes::convertType`. Have `CIRGenTypes::convertType` cache its results in a map from `clang::Type` to `mlir::Type`, saving it from having to convert the same type again and again. There are no new tests or changed tests in this commit. There are no changes to behavior, just improvements to how the existing behavior is implemented.
29 lines
859 B
C++
29 lines
859 B
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENBUILDER_H
|
|
#define LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENBUILDER_H
|
|
|
|
#include "CIRGenTypeCache.h"
|
|
|
|
#include "clang/CIR/Dialect/Builder/CIRBaseBuilder.h"
|
|
|
|
namespace clang::CIRGen {
|
|
|
|
class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
|
|
const CIRGenTypeCache &typeCache;
|
|
|
|
public:
|
|
CIRGenBuilderTy(mlir::MLIRContext &mlirContext, const CIRGenTypeCache &tc)
|
|
: CIRBaseBuilderTy(mlirContext), typeCache(tc) {}
|
|
};
|
|
|
|
} // namespace clang::CIRGen
|
|
|
|
#endif
|