Skip to content

Commit 89c9fde

Browse files
committed
[CIR][cir-link] Setup CIRLinkerInterface
1 parent cfa0c16 commit 89c9fde

File tree

4 files changed

+99
-0
lines changed

4 files changed

+99
-0
lines changed

clang/include/clang/CIR/Dialect/IR/CIRDialect.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ class SameFirstSecondOperandAndResultType
8989
} // namespace mlir
9090

9191
namespace cir {
92+
93+
/// Register the `CIRLinkerInterface` implementation of `LinkerInterface` within
94+
/// the CIR dialect.
95+
void registerLinkerInterface(mlir::DialectRegistry &registry);
96+
9297
void buildTerminatedBody(mlir::OpBuilder &builder, mlir::Location loc);
9398
} // namespace cir
9499

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
// Defines the interface to link CIR dialect.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef CLANG_INTERFACES_CIR_CIRLINKINTERFACE_H_
14+
#define CLANG_INTERFACES_CIR_CIRLINKINTERFACE_H_
15+
16+
namespace mlir {
17+
class DialectRegistry;
18+
} // namespace mlir
19+
20+
namespace cir {
21+
void registerLinkerInterface(mlir::DialectRegistry &registry);
22+
} // namespace cir
23+
24+
#endif // CLANG_INTERFACES_CIR_CIRLINKINTERFACE_H_
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
// Defines the interface to link CIR dialect.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "clang/CIR/Interfaces/CIRLinkerInterface.h"
14+
#include "mlir/Linker/LinkerInterface.h"
15+
#include "clang/CIR/Dialect/IR/CIRDialect.h"
16+
17+
using namespace mlir;
18+
using namespace mlir::link;
19+
20+
//===----------------------------------------------------------------------===//
21+
// CIRSymbolLinkerInterface
22+
//===----------------------------------------------------------------------===//
23+
24+
class CIRSymbolLinkerInterface : public SymbolLinkerInterface {
25+
public:
26+
using SymbolLinkerInterface::SymbolLinkerInterface;
27+
28+
bool canBeLinked(Operation *op) const override { llvm_unreachable("NYI"); }
29+
30+
StringRef getSymbol(Operation *op) const override { llvm_unreachable("NYI"); }
31+
32+
Conflict findConflict(Operation *src) const override {
33+
llvm_unreachable("NYI");
34+
}
35+
36+
bool isLinkNeeded(Conflict pair, bool forDependency) const override {
37+
llvm_unreachable("NYI");
38+
}
39+
40+
LogicalResult resolveConflict(Conflict pair) override {
41+
llvm_unreachable("NYI");
42+
}
43+
44+
void registerForLink(Operation *op) override { llvm_unreachable("NYI"); }
45+
46+
LogicalResult initialize(ModuleOp src) override { return success(); }
47+
48+
LogicalResult link(LinkState &state) const override {
49+
llvm_unreachable("NYI");
50+
}
51+
52+
Operation *materialize(Operation *src, LinkState &state) const override {
53+
llvm_unreachable("NYI");
54+
}
55+
56+
SmallVector<Operation *> dependencies(Operation *op) const override {
57+
llvm_unreachable("NYI");
58+
}
59+
};
60+
61+
//===----------------------------------------------------------------------===//
62+
// registerLinkerInterface
63+
//===----------------------------------------------------------------------===//
64+
65+
void cir::registerLinkerInterface(mlir::DialectRegistry &registry) {
66+
registry.addExtension(+[](mlir::MLIRContext *ctx, cir::CIRDialect *dialect) {
67+
dialect->addInterfaces<CIRSymbolLinkerInterface>();
68+
});
69+
}

clang/lib/CIR/Interfaces/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
add_clang_library(MLIRCIRInterfaces
22
ASTAttrInterfaces.cpp
33
CIROpInterfaces.cpp
4+
CIRLinkerInterface.cpp
45
CIRLoopOpInterface.cpp
56
CIRFPTypeInterface.cpp
67

0 commit comments

Comments
 (0)