forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CIR] Infrastructure: class CIRGenBuilderTy; cache CIR types (llvm#11…
…9037) 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.
- Loading branch information
1 parent
e0f3410
commit ffb19f4
Showing
7 changed files
with
121 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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_CIR_DIALECT_BUILDER_CIRBASEBUILDER_H | ||
#define LLVM_CLANG_CIR_DIALECT_BUILDER_CIRBASEBUILDER_H | ||
|
||
#include "mlir/IR/Builders.h" | ||
|
||
namespace cir { | ||
|
||
class CIRBaseBuilderTy : public mlir::OpBuilder { | ||
|
||
public: | ||
CIRBaseBuilderTy(mlir::MLIRContext &mlirContext) | ||
: mlir::OpBuilder(&mlirContext) {} | ||
}; | ||
|
||
} // namespace cir | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters