CIRCT 20.0.0git
Loading...
Searching...
No Matches
Moore.cpp
Go to the documentation of this file.
1//===- Moore.h - C interface for the Moore 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
12#include "mlir/CAPI/IR.h"
13#include "mlir/CAPI/Registration.h"
14#include "mlir/CAPI/Support.h"
15
16using namespace circt;
17using namespace circt::moore;
18
19//===----------------------------------------------------------------------===//
20// Dialect
21//===----------------------------------------------------------------------===//
22
23MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Moore, moore, MooreDialect)
24
25//===----------------------------------------------------------------------===//
26// Types
27//===----------------------------------------------------------------------===//
28
29/// Create a void type.
30MlirType mooreVoidTypeGet(MlirContext ctx) {
31 return wrap(VoidType::get(unwrap(ctx)));
32}
33
34/// Create a string type.
35MlirType mooreStringTypeGet(MlirContext ctx) {
36 return wrap(StringType::get(unwrap(ctx)));
37}
38
39/// Create a chandle type.
40MlirType mooreChandleTypeGet(MlirContext ctx) {
41 return wrap(ChandleType::get(unwrap(ctx)));
42}
43
44/// Create a event type.
45MlirType mooreEventTypeGet(MlirContext ctx) {
46 return wrap(EventType::get(unwrap(ctx)));
47}
48
49/// Create a two-valued simple bit vector type.
50MlirType mooreIntTypeGetInt(MlirContext ctx, unsigned width) {
51 return wrap(IntType::getInt(unwrap(ctx), width));
52}
53
54/// Create a four-valued simple bit vector type.
55MlirType mooreIntTypeGetLogic(MlirContext ctx, unsigned width) {
56 return wrap(IntType::getLogic(unwrap(ctx), width));
57}
58
59/// Create a real type.
60MlirType mooreRealTypeGet(MlirContext ctx) {
61 return wrap(RealType::get(unwrap(ctx)));
62}
63
65 return wrap(OpenArrayType::get(cast<PackedType>(unwrap(elementType))));
66}
67
68MlirType mooreArrayTypeGet(unsigned size, MlirType elementType) {
69 return wrap(ArrayType::get(size, cast<PackedType>(unwrap(elementType))));
70}
71
73 return wrap(
74 OpenUnpackedArrayType::get(cast<UnpackedType>(unwrap(elementType))));
75}
76
77MlirType mooreUnpackedArrayTypeGet(unsigned size, MlirType elementType) {
78 return wrap(
79 UnpackedArrayType::get(size, cast<UnpackedType>(unwrap(elementType))));
80}
81
82MlirType mooreAssocArrayTypeGet(MlirType elementType, MlirType indexType) {
83 return wrap(AssocArrayType::get(cast<UnpackedType>(unwrap(elementType)),
84 cast<UnpackedType>(unwrap(indexType))));
85}
86
87MlirType mooreQueueTypeGet(MlirType elementType, unsigned bound) {
88 return wrap(QueueType::get(cast<UnpackedType>(unwrap(elementType)), bound));
89}
90
91bool mooreIsTwoValuedType(MlirType type) {
92 return cast<UnpackedType>(unwrap(type)).getDomain() == Domain::TwoValued;
93}
94
95bool mooreIsFourValuedType(MlirType type) {
96 return cast<UnpackedType>(unwrap(type)).getDomain() == Domain::FourValued;
97}
return wrap(CMemoryType::get(unwrap(ctx), baseType, numElements))
MlirType elementType
Definition CHIRRTL.cpp:29
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(CHIRRTL, chirrtl, circt::chirrtl::CHIRRTLDialect) MlirType chirrtlTypeGetCMemory(MlirContext ctx
MlirType mooreVoidTypeGet(MlirContext ctx)
Create a void type.
Definition Moore.cpp:30
MlirType mooreChandleTypeGet(MlirContext ctx)
Create a chandle type.
Definition Moore.cpp:40
bool mooreIsTwoValuedType(MlirType type)
Checks whether the passed UnpackedType is a two-valued type.
Definition Moore.cpp:91
MlirType mooreIntTypeGetLogic(MlirContext ctx, unsigned width)
Create a four-valued simple bit vector type.
Definition Moore.cpp:55
MlirType mooreOpenUnpackedArrayTypeGet(MlirType elementType)
Create an unpacked open array type.
Definition Moore.cpp:72
bool mooreIsFourValuedType(MlirType type)
Checks whether the passed UnpackedType is a four-valued type.
Definition Moore.cpp:95
MlirType mooreArrayTypeGet(unsigned size, MlirType elementType)
Create a packed array type.
Definition Moore.cpp:68
MlirType mooreIntTypeGetInt(MlirContext ctx, unsigned width)
Create a two-valued simple bit vector type.
Definition Moore.cpp:50
MlirType mooreQueueTypeGet(MlirType elementType, unsigned bound)
Create an unpacked queue type.
Definition Moore.cpp:87
MlirType mooreEventTypeGet(MlirContext ctx)
Create a event type.
Definition Moore.cpp:45
MlirType mooreOpenArrayTypeGet(MlirType elementType)
Create a packed open array type.
Definition Moore.cpp:64
MlirType mooreStringTypeGet(MlirContext ctx)
Create a string type.
Definition Moore.cpp:35
MlirType mooreRealTypeGet(MlirContext ctx)
Create a real type.
Definition Moore.cpp:60
MlirType mooreAssocArrayTypeGet(MlirType elementType, MlirType indexType)
Create an unpacked associative array type.
Definition Moore.cpp:82
MlirType mooreUnpackedArrayTypeGet(unsigned size, MlirType elementType)
Create an unpacked array type.
Definition Moore.cpp:77
static EvaluatorValuePtr unwrap(OMEvaluatorValue c)
Definition OM.cpp:113
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.