Skip to content

Commit d5f5275

Browse files
committed
[CIR][cir-link] Setup cir-link tool
1 parent 89c9fde commit d5f5275

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

clang/tools/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ add_clang_subdirectory(driver)
55
add_clang_subdirectory(apinotes-test)
66
if(CLANG_ENABLE_CIR)
77
add_clang_subdirectory(cir-opt)
8+
add_clang_subdirectory(cir-link)
89
add_clang_subdirectory(cir-translate)
910
add_clang_subdirectory(cir-lsp-server)
1011
endif()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
2+
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
3+
4+
add_clang_tool(cir-link
5+
cir-link.cpp
6+
)
7+
8+
clang_target_link_libraries(cir-link
9+
PRIVATE
10+
clangCIR
11+
MLIRCIR
12+
MLIRLinkLib
13+
MLIRSupport
14+
)
15+
16+
target_include_directories(cir-link
17+
PRIVATE
18+
${LLVM_MAIN_SRC_DIR}/../mlir/include
19+
${CMAKE_BINARY_DIR}/tools/mlir/include
20+
)

clang/tools/cir-link/cir-link.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements the main function for cir-link, a tool to link CIR
10+
// modules: cir-link a.mlir b.mlir c.mlir -o x.mlir
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#include "mlir/Dialect/DLTI/DLTI.h"
15+
#include "mlir/IR/BuiltinDialect.h"
16+
#include "mlir/IR/Dialect.h"
17+
#include "mlir/IR/MLIRContext.h"
18+
#include "mlir/Tools/mlir-link/MlirLinkMain.h"
19+
#include "mlir/IR/BuiltinLinkerInterface.h"
20+
#include "clang/CIR/Dialect/IR/CIRDialect.h"
21+
#include "clang/CIR/Interfaces/CIRLinkerInterface.h"
22+
23+
using namespace mlir;
24+
25+
int main(int argc, char **argv) {
26+
DialectRegistry registry;
27+
registry.insert<mlir::BuiltinDialect, cir::CIRDialect, mlir::DLTIDialect>();
28+
builtin::registerLinkerInterface(registry);
29+
cir::registerLinkerInterface(registry);
30+
31+
return failed(MlirLinkMain(argc, argv, registry));
32+
}

0 commit comments

Comments
 (0)