https://github.com/koparasy created 
https://github.com/llvm/llvm-project/pull/232894

`CIRDialect.cpp` includes the TableGen-generated definitions of all CIR 
operations (`CIROps.cpp.inc`, ~5.1 MB). It is the slowest translation unit in a 
ClangIR-enabled build and sits on the critical path to linking `clang`. Nothing 
in the source is slow by itself: the time is spread over ~23k generated 
functions, ~80% of it in the optimizer and code generation.

This patch splits the generated definitions into eight shards. It follows the 
approach used for the 
LLVM, NVVM, ROCDL, and SPIR-V dialects (#221813, #221812, #221729, #221811):

- `CIROps.{h,cpp}.inc` are generated with `-op-shard-count=8`.
- `mlir-src-sharder` produces `CIROpDefinitions.{0..7}.cpp` from a new 
`CIROpDefinitions.cpp` template, and these are compiled as part of `MLIRCIR`.
- `CIRDialect::initialize()` uses the generated `registerCIRDialectOperations` 
hook instead of `addOperations<GET_OP_LIST>`.
- The custom-directive parsers and printers called by the generated code (the 
`custom<...>` entries in `CIROps.td`) stay in `CIRDialect.cpp`. They lose 
`static` and are declared in a new private header, `CIROpDefinitions.h`. No 
handwritten logic changes.

## Build-time impact
| | before | after |
|---|---|---|
| `CIRDialect.cpp` | 108.2 s | 28.0 s |
| largest CIR op-definition TU | 108.2 s | 43.5 s |
| ninja build (wall) | 169.8 ± 3.1 s | 146.9 ± 1.0 s (−13.4%) |
| total user CPU | 21231 s | 21447 s (+1.0%) |
| configure | 21.8 s | 21.7 s |

The extra CPU time comes from each shard parsing the same headers again. After 
this change, the CIR dialect is no longer on the critical path to linking 
`clang`.

I come clean here, I used AI to explore completely this and used the above PRs 
as a guideline. Everything here makes sense to me.


>From 5a27b41ad99057b48bb09668aa74b490ab5eeed5 Mon Sep 17 00:00:00 2001
From: Konstantinos Parasyris <[email protected]>
Date: Fri, 16 Oct 2026 11:38:51 -0700
Subject: [PATCH] [CIR] Shard generated operation definitions (NFC)

CIRDialect.cpp included the TableGen-generated definitions of all CIR
operations (a 5.1 MB CIROps.cpp.inc), which made it the slowest
translation unit in a ClangIR-enabled build and put it on the critical
path to linking clang.

Generate the CIR operation definitions in eight shards, compile them as
separate sources (CIROpDefinitions.<N>.cpp), and register the operations
through the generated registerCIRDialectOperations hook. The custom
directive parsers and printers used by the generated code stay in
CIRDialect.cpp and are declared in a private header. This follows the
same approach used for the LLVM, NVVM, ROCDL, and SPIR-V dialects.

Measured with clean, uncached Release+assertions builds on a 224-core
machine (I know this is not typical machine for the average user
but use the numbers as indicators):
  CIRDialect.cpp          108.2s         28.0s

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
---
 .../clang/CIR/Dialect/IR/CMakeLists.txt       |   4 +-
 clang/lib/CIR/Dialect/IR/CIRDialect.cpp       | 104 +++++++-----------
 clang/lib/CIR/Dialect/IR/CIROpDefinitions.cpp |  24 ++++
 clang/lib/CIR/Dialect/IR/CIROpDefinitions.h   | 103 +++++++++++++++++
 clang/lib/CIR/Dialect/IR/CMakeLists.txt       |  17 +++
 5 files changed, 187 insertions(+), 65 deletions(-)
 create mode 100644 clang/lib/CIR/Dialect/IR/CIROpDefinitions.cpp
 create mode 100644 clang/lib/CIR/Dialect/IR/CIROpDefinitions.h

diff --git a/clang/include/clang/CIR/Dialect/IR/CMakeLists.txt 
b/clang/include/clang/CIR/Dialect/IR/CMakeLists.txt
index 66fa7a40d28f7a..27ed74355d7765 100644
--- a/clang/include/clang/CIR/Dialect/IR/CMakeLists.txt
+++ b/clang/include/clang/CIR/Dialect/IR/CMakeLists.txt
@@ -5,8 +5,8 @@
 
 # Equivalent to add_mlir_dialect(CIROps cir)
 set(LLVM_TARGET_DEFINITIONS CIROps.td)
-mlir_tablegen(CIROps.h.inc -gen-op-decls)
-mlir_tablegen(CIROps.cpp.inc -gen-op-defs)
+mlir_tablegen(CIROps.h.inc -gen-op-decls -op-shard-count=8)
+mlir_tablegen(CIROps.cpp.inc -gen-op-defs -op-shard-count=8)
 mlir_tablegen(CIROpsTypes.h.inc -gen-typedef-decls)
 mlir_tablegen(CIROpsTypes.cpp.inc -gen-typedef-defs)
 mlir_tablegen(CIROpsDialect.h.inc -gen-dialect-decls)
diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp 
b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index f564eee0537057..a11519a72553b4 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Support/LogicalResult.h"
 
 #include "CIRDialectBytecode.h"
+#include "CIROpDefinitions.h"
 
 using namespace mlir;
 using namespace cir;
@@ -99,10 +100,7 @@ struct CIROpAsmDialectInterface : public 
OpAsmDialectInterface {
 void cir::CIRDialect::initialize() {
   registerTypes();
   registerAttributes();
-  addOperations<
-#define GET_OP_LIST
-#include "clang/CIR/Dialect/IR/CIROps.cpp.inc"
-      >();
+  registerCIRDialectOperations(this);
   addInterfaces<CIROpAsmDialectInterface>();
   detail::addBytecodeInterface(this);
 }
@@ -456,8 +454,8 @@ void printInlineKindAttr(OpAsmPrinter &p, 
cir::InlineKindAttr inlineKindAttr) {
 // CIR Custom Parsers/Printers
 
//===----------------------------------------------------------------------===//
 
-static mlir::ParseResult parseOmittedTerminatorRegion(mlir::OpAsmParser 
&parser,
-                                                      mlir::Region &region) {
+mlir::ParseResult parseOmittedTerminatorRegion(mlir::OpAsmParser &parser,
+                                               mlir::Region &region) {
   auto regionLoc = parser.getCurrentLocation();
   if (parser.parseRegion(region))
     return failure();
@@ -466,21 +464,13 @@ static mlir::ParseResult 
parseOmittedTerminatorRegion(mlir::OpAsmParser &parser,
   return success();
 }
 
-static void printOmittedTerminatorRegion(mlir::OpAsmPrinter &printer,
-                                         cir::ScopeOp &op,
-                                         mlir::Region &region) {
+void printOmittedTerminatorRegion(mlir::OpAsmPrinter &printer, cir::ScopeOp 
&op,
+                                  mlir::Region &region) {
   printer.printRegion(region,
                       /*printEntryBlockArgs=*/false,
                       /*printBlockTerminators=*/!omitRegionTerm(region));
 }
 
-mlir::OptionalParseResult
-parseGlobalMemorySpace(mlir::AsmParser &p,
-                       mlir::ptr::MemorySpaceAttrInterface &attr);
-
-void printGlobalMemorySpace(mlir::AsmPrinter &printer, cir::GlobalOp op,
-                            mlir::ptr::MemorySpaceAttrInterface attr);
-
 
//===----------------------------------------------------------------------===//
 // AllocaOp
 
//===----------------------------------------------------------------------===//
@@ -592,10 +582,9 @@ LogicalResult cir::DeleteArrayOp::verify() {
 // AssumeOp
 
//===----------------------------------------------------------------------===//
 
-static void printAssumeBundle(OpAsmPrinter &p, cir::AssumeOp op,
-                              cir::AssumeBundleKindAttr kindAttr,
-                              OperandRange bundleArgs,
-                              TypeRange bundleArgTypes) {
+void printAssumeBundle(OpAsmPrinter &p, cir::AssumeOp op,
+                       cir::AssumeBundleKindAttr kindAttr,
+                       OperandRange bundleArgs, TypeRange bundleArgTypes) {
   cir::AssumeBundleKind kind = kindAttr.getValue();
   if (kind == cir::AssumeBundleKind::None)
     return;
@@ -611,7 +600,7 @@ static void printAssumeBundle(OpAsmPrinter &p, 
cir::AssumeOp op,
   p << ")";
 }
 
-static ParseResult parseAssumeBundle(
+ParseResult parseAssumeBundle(
     OpAsmParser &p, cir::AssumeBundleKindAttr &bundleKindAttr,
     llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand, 4> &bundleArgs,
     llvm::SmallVector<mlir::Type, 1> &bundleArgTypes) {
@@ -2364,7 +2353,7 @@ 
cir::SwitchFlatOp::getSuccessorForOperands(ArrayRef<Attribute> operands) {
 
 /// <cases> ::= `[` (case (`,` case )* )? `]`
 /// <case>  ::= integer `:` bb-id (`(` ssa-use-and-type-list `)`)?
-static ParseResult parseSwitchFlatOpCases(
+ParseResult parseSwitchFlatOpCases(
     OpAsmParser &parser, Type flagType, mlir::ArrayAttr &caseValues,
     SmallVectorImpl<Block *> &caseDestinations,
     SmallVectorImpl<llvm::SmallVector<OpAsmParser::UnresolvedOperand>>
@@ -2407,11 +2396,11 @@ static ParseResult parseSwitchFlatOpCases(
   return parser.parseRSquare();
 }
 
-static void printSwitchFlatOpCases(OpAsmPrinter &p, cir::SwitchFlatOp op,
-                                   Type flagType, mlir::ArrayAttr caseValues,
-                                   SuccessorRange caseDestinations,
-                                   OperandRangeRange caseOperands,
-                                   const TypeRangeRange &caseOperandTypes) {
+void printSwitchFlatOpCases(OpAsmPrinter &p, cir::SwitchFlatOp op,
+                            Type flagType, mlir::ArrayAttr caseValues,
+                            SuccessorRange caseDestinations,
+                            OperandRangeRange caseOperands,
+                            const TypeRangeRange &caseOperandTypes) {
   p << '[';
   p.printNewline();
   if (!caseValues) {
@@ -2587,13 +2576,11 @@ static void printComdatName(OpAsmPrinter &p, StringAttr 
comdat) {
     p << "(\"" << comdat.getValue() << "\")";
 }
 
-static void printComdatName(OpAsmPrinter &p, cir::GlobalOp op,
-                            StringAttr comdat) {
+void printComdatName(OpAsmPrinter &p, cir::GlobalOp op, StringAttr comdat) {
   printComdatName(p, comdat);
 }
 
-static ParseResult parseComdatName(OpAsmParser &parser,
-                                   StringAttr &comdatAttr) {
+ParseResult parseComdatName(OpAsmParser &parser, StringAttr &comdatAttr) {
   if (parser.parseOptionalKeyword("comdat").failed())
     return success();
   std::string comdatKey;
@@ -2606,10 +2593,10 @@ static ParseResult parseComdatName(OpAsmParser &parser,
   return success();
 }
 
-static void printGlobalOpTypeAndInitialValue(OpAsmPrinter &p, cir::GlobalOp op,
-                                             TypeAttr type, Attribute initAttr,
-                                             mlir::Region &ctorRegion,
-                                             mlir::Region &dtorRegion) {
+void printGlobalOpTypeAndInitialValue(OpAsmPrinter &p, cir::GlobalOp op,
+                                      TypeAttr type, Attribute initAttr,
+                                      mlir::Region &ctorRegion,
+                                      mlir::Region &dtorRegion) {
   auto printType = [&]() { p << ": " << type; };
   // Aliases are definitions but they have no initial value or ctor/dtor; the
   // assembly prints them like declarations (`: type`).
@@ -2637,11 +2624,11 @@ static void 
printGlobalOpTypeAndInitialValue(OpAsmPrinter &p, cir::GlobalOp op,
   }
 }
 
-static ParseResult parseGlobalOpTypeAndInitialValue(OpAsmParser &parser,
-                                                    TypeAttr &typeAttr,
-                                                    Attribute 
&initialValueAttr,
-                                                    mlir::Region &ctorRegion,
-                                                    mlir::Region &dtorRegion) {
+ParseResult parseGlobalOpTypeAndInitialValue(OpAsmParser &parser,
+                                             TypeAttr &typeAttr,
+                                             Attribute &initialValueAttr,
+                                             mlir::Region &ctorRegion,
+                                             mlir::Region &dtorRegion) {
   mlir::Type opTy;
   if (parser.parseOptionalEqual().failed()) {
     // Absence of equal means a declaration, so we need to parse the type.
@@ -3975,8 +3962,8 @@ LogicalResult cir::CoroutineOp::verify() {
 // Prints the pointer type(s) for a `cir.copy`. `src` and `dst` share the same
 // pointee type but may differ in address space; a single type is printed when
 // they match, otherwise both are printed (`src` first).
-static void printCopyTypes(mlir::OpAsmPrinter &printer, mlir::Operation *,
-                           mlir::Type srcType, mlir::Type dstType) {
+void printCopyTypes(mlir::OpAsmPrinter &printer, mlir::Operation *,
+                    mlir::Type srcType, mlir::Type dstType) {
   printer.printType(srcType);
   if (srcType != dstType) {
     printer << ", ";
@@ -3984,9 +3971,8 @@ static void printCopyTypes(mlir::OpAsmPrinter &printer, 
mlir::Operation *,
   }
 }
 
-static mlir::ParseResult parseCopyTypes(mlir::OpAsmParser &parser,
-                                        mlir::Type &srcType,
-                                        mlir::Type &dstType) {
+mlir::ParseResult parseCopyTypes(mlir::OpAsmParser &parser, mlir::Type 
&srcType,
+                                 mlir::Type &dstType) {
   if (parser.parseType(srcType))
     return mlir::failure();
   if (parser.parseOptionalComma().succeeded()) {
@@ -5271,10 +5257,9 @@ LogicalResult cir::TryOp::verifyRegions() {
   return success();
 }
 
-static void
-printTryHandlerRegions(mlir::OpAsmPrinter &printer, cir::TryOp op,
-                       mlir::MutableArrayRef<mlir::Region> handlerRegions,
-                       mlir::ArrayAttr handlerTypes) {
+void printTryHandlerRegions(mlir::OpAsmPrinter &printer, cir::TryOp op,
+                            mlir::MutableArrayRef<mlir::Region> handlerRegions,
+                            mlir::ArrayAttr handlerTypes) {
   if (!handlerTypes)
     return;
 
@@ -5314,7 +5299,7 @@ printTryHandlerRegions(mlir::OpAsmPrinter &printer, 
cir::TryOp op,
   }
 }
 
-static mlir::ParseResult parseTryHandlerRegions(
+mlir::ParseResult parseTryHandlerRegions(
     mlir::OpAsmParser &parser,
     llvm::SmallVectorImpl<std::unique_ptr<mlir::Region>> &handlerRegions,
     mlir::ArrayAttr &handlerTypes) {
@@ -5613,7 +5598,7 @@ LogicalResult cir::EhDispatchOp::verify() {
   return success();
 }
 
-static ParseResult
+ParseResult
 parseEhDispatchDestinations(OpAsmParser &parser, mlir::ArrayAttr &catchTypes,
                             SmallVectorImpl<Block *> &catchDestinations,
                             Block *&defaultDestination,
@@ -5753,11 +5738,11 @@ parseEhDispatchDestinations(OpAsmParser &parser, 
mlir::ArrayAttr &catchTypes,
   return success();
 }
 
-static void printEhDispatchDestinations(OpAsmPrinter &p, cir::EhDispatchOp op,
-                                        mlir::ArrayAttr catchTypes,
-                                        SuccessorRange catchDestinations,
-                                        Block *defaultDestination,
-                                        mlir::UnitAttr defaultIsCatchAll) {
+void printEhDispatchDestinations(OpAsmPrinter &p, cir::EhDispatchOp op,
+                                 mlir::ArrayAttr catchTypes,
+                                 SuccessorRange catchDestinations,
+                                 Block *defaultDestination,
+                                 mlir::UnitAttr defaultIsCatchAll) {
   p << " [";
   p.printNewline();
 
@@ -5811,10 +5796,3 @@ bool cir::StdFindOp::signatureMatches(mlir::TypeRange 
operands,
   mlir::Type iterTy = operands[0];
   return iterTy == operands[1] && iterTy == operands[2] && iterTy == 
results[0];
 }
-
-//===----------------------------------------------------------------------===//
-// TableGen'd op method definitions
-//===----------------------------------------------------------------------===//
-
-#define GET_OP_CLASSES
-#include "clang/CIR/Dialect/IR/CIROps.cpp.inc"
diff --git a/clang/lib/CIR/Dialect/IR/CIROpDefinitions.cpp 
b/clang/lib/CIR/Dialect/IR/CIROpDefinitions.cpp
new file mode 100644
index 00000000000000..629fcb53bbbe4e
--- /dev/null
+++ b/clang/lib/CIR/Dialect/IR/CIROpDefinitions.cpp
@@ -0,0 +1,24 @@
+//===- CIROpDefinitions.cpp - Generated CIR op definitions 
----------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is the template for the CIROpDefinitions.<N>.cpp shards. Each 
shard
+// defines GET_OP_DEFS_<N> and includes the TableGen-generated definitions of
+// one subset of the CIR operations.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/CIR/Dialect/IR/CIRDialect.h"
+
+#include "CIROpDefinitions.h"
+
+#include "mlir/IR/DialectImplementation.h"
+
+using namespace mlir;
+using namespace cir;
+
+#include "clang/CIR/Dialect/IR/CIROps.cpp.inc"
diff --git a/clang/lib/CIR/Dialect/IR/CIROpDefinitions.h 
b/clang/lib/CIR/Dialect/IR/CIROpDefinitions.h
new file mode 100644
index 00000000000000..3f476fa9b09558
--- /dev/null
+++ b/clang/lib/CIR/Dialect/IR/CIROpDefinitions.h
@@ -0,0 +1,103 @@
+//===- CIROpDefinitions.h - CIR op implementation helpers -------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This header declares the custom directive parsers and printers implemented
+// in CIRDialect.cpp and referenced by the TableGen-generated CIR operation
+// definitions, which are compiled in separate shards.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef CLANG_LIB_CIR_DIALECT_IR_CIROPDEFINITIONS_H
+#define CLANG_LIB_CIR_DIALECT_IR_CIROPDEFINITIONS_H
+
+#include "clang/CIR/Dialect/IR/CIRDialect.h"
+
+#include "mlir/IR/OpImplementation.h"
+
+mlir::ParseResult parseOmittedTerminatorRegion(mlir::OpAsmParser &parser,
+                                               mlir::Region &region);
+void printOmittedTerminatorRegion(mlir::OpAsmPrinter &printer, cir::ScopeOp 
&op,
+                                  mlir::Region &region);
+
+mlir::OptionalParseResult
+parseGlobalMemorySpace(mlir::AsmParser &p,
+                       mlir::ptr::MemorySpaceAttrInterface &attr);
+void printGlobalMemorySpace(mlir::AsmPrinter &printer, cir::GlobalOp op,
+                            mlir::ptr::MemorySpaceAttrInterface attr);
+
+mlir::ParseResult parseAssumeBundle(
+    mlir::OpAsmParser &p, cir::AssumeBundleKindAttr &bundleKindAttr,
+    llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand, 4> &bundleArgs,
+    llvm::SmallVector<mlir::Type, 1> &bundleArgTypes);
+void printAssumeBundle(mlir::OpAsmPrinter &p, cir::AssumeOp op,
+                       cir::AssumeBundleKindAttr kindAttr,
+                       mlir::OperandRange bundleArgs,
+                       mlir::TypeRange bundleArgTypes);
+
+mlir::ParseResult parseIndirectBrOpSucessors(
+    mlir::OpAsmParser &parser, mlir::Type &flagType,
+    llvm::SmallVectorImpl<mlir::Block *> &succOperandBlocks,
+    llvm::SmallVectorImpl<
+        llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand>> &succOperands,
+    llvm::SmallVectorImpl<llvm::SmallVector<mlir::Type>> &succOperandsTypes);
+void printIndirectBrOpSucessors(mlir::OpAsmPrinter &p, cir::IndirectBrOp op,
+                                mlir::Type flagType, mlir::SuccessorRange 
succs,
+                                mlir::OperandRangeRange succOperands,
+                                const mlir::TypeRangeRange &succOperandsTypes);
+
+mlir::ParseResult parseSwitchFlatOpCases(
+    mlir::OpAsmParser &parser, mlir::Type flagType, mlir::ArrayAttr 
&caseValues,
+    llvm::SmallVectorImpl<mlir::Block *> &caseDestinations,
+    llvm::SmallVectorImpl<
+        llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand>> &caseOperands,
+    llvm::SmallVectorImpl<llvm::SmallVector<mlir::Type>> &caseOperandTypes);
+void printSwitchFlatOpCases(mlir::OpAsmPrinter &p, cir::SwitchFlatOp op,
+                            mlir::Type flagType, mlir::ArrayAttr caseValues,
+                            mlir::SuccessorRange caseDestinations,
+                            mlir::OperandRangeRange caseOperands,
+                            const mlir::TypeRangeRange &caseOperandTypes);
+
+mlir::ParseResult parseComdatName(mlir::OpAsmParser &parser,
+                                  mlir::StringAttr &comdatAttr);
+void printComdatName(mlir::OpAsmPrinter &p, cir::GlobalOp op,
+                     mlir::StringAttr comdat);
+
+mlir::ParseResult parseGlobalOpTypeAndInitialValue(
+    mlir::OpAsmParser &parser, mlir::TypeAttr &typeAttr,
+    mlir::Attribute &initialValueAttr, mlir::Region &ctorRegion,
+    mlir::Region &dtorRegion);
+void printGlobalOpTypeAndInitialValue(mlir::OpAsmPrinter &p, cir::GlobalOp op,
+                                      mlir::TypeAttr type,
+                                      mlir::Attribute initAttr,
+                                      mlir::Region &ctorRegion,
+                                      mlir::Region &dtorRegion);
+
+mlir::ParseResult parseCopyTypes(mlir::OpAsmParser &parser, mlir::Type 
&srcType,
+                                 mlir::Type &dstType);
+void printCopyTypes(mlir::OpAsmPrinter &printer, mlir::Operation *,
+                    mlir::Type srcType, mlir::Type dstType);
+
+mlir::ParseResult parseTryHandlerRegions(
+    mlir::OpAsmParser &parser,
+    llvm::SmallVectorImpl<std::unique_ptr<mlir::Region>> &handlerRegions,
+    mlir::ArrayAttr &handlerTypes);
+void printTryHandlerRegions(mlir::OpAsmPrinter &printer, cir::TryOp op,
+                            mlir::MutableArrayRef<mlir::Region> handlerRegions,
+                            mlir::ArrayAttr handlerTypes);
+
+mlir::ParseResult parseEhDispatchDestinations(
+    mlir::OpAsmParser &parser, mlir::ArrayAttr &catchTypes,
+    llvm::SmallVectorImpl<mlir::Block *> &catchDestinations,
+    mlir::Block *&defaultDestination, mlir::UnitAttr &defaultIsCatchAll);
+void printEhDispatchDestinations(mlir::OpAsmPrinter &p, cir::EhDispatchOp op,
+                                 mlir::ArrayAttr catchTypes,
+                                 mlir::SuccessorRange catchDestinations,
+                                 mlir::Block *defaultDestination,
+                                 mlir::UnitAttr defaultIsCatchAll);
+
+#endif // CLANG_LIB_CIR_DIALECT_IR_CIROPDEFINITIONS_H
diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt 
b/clang/lib/CIR/Dialect/IR/CMakeLists.txt
index ac79ad52f95ec1..f22234b8f792dd 100644
--- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt
+++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt
@@ -1,3 +1,18 @@
+set(LLVM_OPTIONAL_SOURCES
+  CIROpDefinitions.cpp
+  )
+
+# Compile the TableGen-generated op definitions in shards to reduce the
+# compile time of the largest CIR translation unit.
+set(LLVM_TARGET_DEFINITIONS CIROpDefinitions.cpp)
+foreach(index RANGE 7)
+  set(CIR_SHARDED_SRC CIROpDefinitions.${index}.cpp)
+  list(APPEND CIR_SHARDED_SRCS ${CIR_SHARDED_SRC})
+  tablegen(MLIR_SRC_SHARDER ${CIR_SHARDED_SRC}
+    -op-shard-index=${index})
+endforeach()
+add_public_tablegen_target(MLIRCIROpsShardGen)
+
 add_clang_library(MLIRCIR
   CIRAttrs.cpp
   CIRDialect.cpp
@@ -6,9 +21,11 @@ add_clang_library(MLIRCIR
   CIRTypes.cpp
   CIRDataLayout.cpp
   CIROpenCLAttrs.cpp
+  ${CIR_SHARDED_SRCS}
 
   DEPENDS
   MLIRCIROpsIncGen
+  MLIRCIROpsShardGen
   MLIRCIRDialectBytecodeIncGen
   MLIRCIRTypeConstraintsIncGen
   MLIRCIREnumsGen

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to