CIRCT  20.0.0git
SeqDialect.cpp
Go to the documentation of this file.
1 //===- SeqDialect.cpp - Implement the Seq 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 Seq dialect.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "circt/Dialect/HW/HWOps.h"
16 #include "mlir/IR/Builders.h"
17 #include "mlir/IR/BuiltinTypes.h"
18 #include "mlir/IR/DialectImplementation.h"
19 
20 using namespace circt;
21 using namespace seq;
22 
23 //===----------------------------------------------------------------------===//
24 // Dialect specification.
25 //===----------------------------------------------------------------------===//
26 
27 void SeqDialect::initialize() {
28  registerTypes();
29  registerAttributes();
30 
31  // Register operations.
32  addOperations<
33 #define GET_OP_LIST
34 #include "circt/Dialect/Seq/Seq.cpp.inc"
35  >();
36 }
37 
38 /// Registered hook to materialize a single constant operation from a given
39 /// attribute value with the desired resultant type. This method should use
40 /// the provided builder to create the operation without changing the
41 /// insertion position. The generated operation is expected to be constant
42 /// like, i.e. single result, zero operands, non side-effecting, etc. On
43 /// success, this hook should return the value generated to represent the
44 /// constant value. Otherwise, it should return null on failure.
45 Operation *SeqDialect::materializeConstant(OpBuilder &builder, Attribute value,
46  Type type, Location loc) {
47  // Integer constants.
48  if (auto intType = dyn_cast<IntegerType>(type))
49  if (auto attrValue = dyn_cast<IntegerAttr>(value))
50  return builder.create<hw::ConstantOp>(loc, type, attrValue);
51 
52  if (isa<ClockType>(type))
53  if (auto attrValue = dyn_cast<ClockConstAttr>(value))
54  return builder.create<seq::ConstClockOp>(loc, attrValue);
55 
56  return nullptr;
57 }
58 
59 #include "circt/Dialect/Seq/SeqDialect.cpp.inc"
def create(data_type, value)
Definition: hw.py:393
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
Definition: seq.py:1