-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
67 lines (60 loc) · 2.68 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "mlir-interactive/InitDefaultTransforms.h"
#include "mlir-interactive/mainwindow.h"
#include <QApplication>
#include "circt/Conversion/Passes.h"
#include "circt/InitAllDialects.h"
#include "mlir/Conversion/Passes.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlow.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Pass/PassManager.h"
#include "llvm/Support/InitLLVM.h"
/// TODO: This could probably be done more elegantly by a modified TableGen
/// executable. That TableGen executable should also add additional reflection
/// about the options of passes. Currently, this is nested deeply within type
/// erased, private, and .cpp containing logic, which is impossible to even hack
/// our way through to inspect.
void initTransforms(TransformsRegistry ®istry) {
registry.registerTransformation(
"mlir-clang", NodeType({TypeKind::C, TypeKind::CPP}),
NodeType(TypeKind::AnyMLIR),
[](mlir::OpPassManager &pm) { assert(false && "how do we do this?"); });
registry.registerTransformation("Affine lowering", NodeType(TypeKind::Affine),
NodeType(TypeKind::Standard),
[](mlir::OpPassManager &pm) {
pm.addPass(mlir::createLowerAffinePass());
});
registry.registerTransformation(
"Standard to Handshake", NodeType(TypeKind::AnyMLIR),
NodeType(TypeKind::Handshake), [](mlir::OpPassManager &pm) {
pm.addPass(circt::createStandardToHandshakePass());
});
registry.registerTransformation(
"Handshake to FIRRTL", NodeType(TypeKind::Handshake),
NodeType(TypeKind::FIRRTL), [](mlir::OpPassManager &pm) {
pm.addPass(circt::createHandshakeToFIRRTLPass());
});
}
int main(int argc, char *argv[]) {
llvm::InitLLVM y(argc, argv);
QApplication a(argc, argv);
mlir::DialectRegistry dialectRegistry;
dialectRegistry.insert<mlir::AffineDialect>();
dialectRegistry.insert<mlir::LLVM::LLVMDialect>();
dialectRegistry.insert<mlir::memref::MemRefDialect>();
dialectRegistry.insert<mlir::func::FuncDialect>();
dialectRegistry.insert<mlir::arith::ArithmeticDialect>();
dialectRegistry.insert<mlir::cf::ControlFlowDialect>();
dialectRegistry.insert<mlir::scf::SCFDialect>();
circt::registerAllDialects(dialectRegistry);
mlir::MLIRContext context(dialectRegistry);
context.allowUnregisteredDialects();
TransformsRegistry registry;
initTransforms(registry);
initDefaultTransforms(registry);
MainWindow w(context, registry);
w.showMaximized();
return a.exec();
}