CIRCT  20.0.0git
CalyxDialect.cpp
Go to the documentation of this file.
1 //===- CalyxDialect.cpp - Implement the Calyx dialect ---------------------===//
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 Calyx dialect.
10 //
11 //===----------------------------------------------------------------------===//
12 
15 #include "mlir/IR/Builders.h"
16 #include "mlir/IR/BuiltinTypes.h"
17 #include "mlir/IR/DialectImplementation.h"
18 
19 using namespace circt;
20 using namespace circt::calyx;
21 
22 //===----------------------------------------------------------------------===//
23 // Dialect specification.
24 //===----------------------------------------------------------------------===//
25 
26 namespace {
27 
28 // We implement the OpAsmDialectInterface so that Calyx dialect operations
29 // automatically interpret the name attribute on operations as their SSA name.
30 struct CalyxOpAsmDialectInterface : public OpAsmDialectInterface {
31  using OpAsmDialectInterface::OpAsmDialectInterface;
32 
33  /// Get a special name to use when printing the given operation. See
34  /// OpAsmInterface.td#getAsmResultNames for usage details and documentation.
35  void getAsmResultNames(Operation *op, OpAsmSetValueNameFn setNameFn) const {}
36 };
37 
38 } // end anonymous namespace
39 
40 void CalyxDialect::initialize() {
41  // Register operations.
42  addOperations<
43 #define GET_OP_LIST
44 #include "circt/Dialect/Calyx/Calyx.cpp.inc"
45  >();
46 
47  // Register interface implementations.
48  addInterfaces<CalyxOpAsmDialectInterface>();
49 }
50 
51 // Provide implementations for the enums and attributes we use.
52 #include "circt/Dialect/Calyx/CalyxDialect.cpp.inc"
53 #include "circt/Dialect/Calyx/CalyxEnums.cpp.inc"
void getAsmResultNames(OpAsmSetValueNameFn setNameFn, StringRef instanceName, ArrayAttr resultNames, ValueRange results)
Suggest a name for each result value based on the saved result names attribute.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
function_ref< void(Value, StringRef)> OpAsmSetValueNameFn
Definition: LLVM.h:182