CIRCT  19.0.0git
FIRRTL.h
Go to the documentation of this file.
1 //===- FIRRTL.h - C interface for the FIRRTL dialect --------------*- C -*-===//
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 #ifndef CIRCT_C_DIALECT_FIRRTL_H
10 #define CIRCT_C_DIALECT_FIRRTL_H
11 
12 #include "mlir-c/IR.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 // NOLINTNEXTLINE(modernize-use-using)
19 typedef enum FIRRTLConvention {
23 
24 // NOLINTNEXTLINE(modernize-use-using)
25 typedef enum FIRRTLDirection {
29 
30 // NOLINTNEXTLINE(modernize-use-using)
31 typedef enum FIRRTLNameKind {
35 
36 // NOLINTNEXTLINE(modernize-use-using)
37 typedef enum FIRRTLRUW {
42 
43 // NOLINTNEXTLINE(modernize-use-using)
44 typedef enum FIRRTLMemDir {
50 
51 // NOLINTNEXTLINE(modernize-use-using)
52 typedef enum FIRRTLEventControl {
57 
58 // NOLINTNEXTLINE(modernize-use-using)
59 typedef enum FIRRTLValueFlow {
65 
66 // NOLINTNEXTLINE(modernize-use-using)
67 typedef struct FIRRTLBundleField {
68  MlirIdentifier name;
69  bool isFlip;
70  MlirType type;
72 
73 // NOLINTNEXTLINE(modernize-use-using)
74 typedef struct FIRRTLClassElement {
75  MlirIdentifier name;
76  MlirType type;
79 
80 //===----------------------------------------------------------------------===//
81 // Dialect API.
82 //===----------------------------------------------------------------------===//
83 
85 
86 //===----------------------------------------------------------------------===//
87 // Type API.
88 //===----------------------------------------------------------------------===//
89 
90 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetUInt(MlirContext ctx, int32_t width);
91 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetSInt(MlirContext ctx, int32_t width);
92 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetClock(MlirContext ctx);
93 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetReset(MlirContext ctx);
94 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetAsyncReset(MlirContext ctx);
95 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetAnalog(MlirContext ctx, int32_t width);
96 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetVector(MlirContext ctx,
97  MlirType element, size_t count);
98 MLIR_CAPI_EXPORTED bool firrtlTypeIsAOpenBundle(MlirType type);
99 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetBundle(
100  MlirContext ctx, size_t count, const FIRRTLBundleField *fields);
101 MLIR_CAPI_EXPORTED unsigned
102 firrtlTypeGetBundleFieldIndex(MlirType type, MlirStringRef fieldName);
103 
104 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetRef(MlirType target, bool forceable);
105 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetAnyRef(MlirContext ctx);
106 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetInteger(MlirContext ctx);
107 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetDouble(MlirContext ctx);
108 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetString(MlirContext ctx);
109 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetBoolean(MlirContext ctx);
110 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetPath(MlirContext ctx);
111 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetList(MlirContext ctx,
112  MlirType elementType);
113 MLIR_CAPI_EXPORTED MlirType
114 firrtlTypeGetClass(MlirContext ctx, MlirAttribute name, size_t numberOfElements,
115  const FIRRTLClassElement *elements);
116 
117 MLIR_CAPI_EXPORTED MlirType firrtlTypeGetMaskType(MlirType type);
118 
119 //===----------------------------------------------------------------------===//
120 // Attribute API.
121 //===----------------------------------------------------------------------===//
122 
123 MLIR_CAPI_EXPORTED MlirAttribute
124 firrtlAttrGetConvention(MlirContext ctx, FIRRTLConvention convention);
125 
126 MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetPortDirs(
127  MlirContext ctx, size_t count, const FIRRTLDirection *dirs);
128 
129 MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetParamDecl(MlirContext ctx,
130  MlirIdentifier name,
131  MlirType type,
132  MlirAttribute value);
133 
134 MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetNameKind(MlirContext ctx,
135  FIRRTLNameKind nameKind);
136 
137 MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetRUW(MlirContext ctx,
138  FIRRTLRUW ruw);
139 
140 MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetMemInit(MlirContext ctx,
141  MlirIdentifier filename,
142  bool isBinary,
143  bool isInline);
144 
145 MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetMemDir(MlirContext ctx,
146  FIRRTLMemDir dir);
147 
148 MLIR_CAPI_EXPORTED MlirAttribute
149 firrtlAttrGetEventControl(MlirContext ctx, FIRRTLEventControl eventControl);
150 
151 // Workaround:
152 // https://github.com/llvm/llvm-project/issues/84190#issuecomment-2035552035
153 MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetIntegerFromString(
154  MlirType type, unsigned numBits, MlirStringRef str, uint8_t radix);
155 
156 //===----------------------------------------------------------------------===//
157 // Utility API.
158 //===----------------------------------------------------------------------===//
159 
160 MLIR_CAPI_EXPORTED FIRRTLValueFlow firrtlValueFoldFlow(MlirValue value,
161  FIRRTLValueFlow flow);
162 
163 MLIR_CAPI_EXPORTED bool
164 firrtlImportAnnotationsFromJSONRaw(MlirContext ctx,
165  MlirStringRef annotationsStr,
166  MlirAttribute *importedAnnotationsArray);
167 
168 #ifdef __cplusplus
169 }
170 #endif
171 
172 #endif // CIRCT_C_DIALECT_FIRRTL_H
MlirType elementType
Definition: CHIRRTL.cpp:29
int32_t width
Definition: FIRRTL.cpp:36
struct FIRRTLBundleField FIRRTLBundleField
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetSInt(MlirContext ctx, int32_t width)
Definition: FIRRTL.cpp:40
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetInteger(MlirContext ctx)
Definition: FIRRTL.cpp:121
MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetPortDirs(MlirContext ctx, size_t count, const FIRRTLDirection *dirs)
Definition: FIRRTL.cpp:192
MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetEventControl(MlirContext ctx, FIRRTLEventControl eventControl)
Definition: FIRRTL.cpp:271
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetAnalog(MlirContext ctx, int32_t width)
Definition: FIRRTL.cpp:56
struct FIRRTLClassElement FIRRTLClassElement
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetReset(MlirContext ctx)
Definition: FIRRTL.cpp:48
FIRRTLValueFlow
Definition: FIRRTL.h:59
@ FIRRTL_VALUE_FLOW_SOURCE
Definition: FIRRTL.h:61
@ FIRRTL_VALUE_FLOW_NONE
Definition: FIRRTL.h:60
@ FIRRTL_VALUE_FLOW_SINK
Definition: FIRRTL.h:62
@ FIRRTL_VALUE_FLOW_DUPLEX
Definition: FIRRTL.h:63
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(FIRRTL, firrtl)
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetPath(MlirContext ctx)
Definition: FIRRTL.cpp:137
FIRRTLNameKind
Definition: FIRRTL.h:31
@ FIRRTL_NAME_KIND_DROPPABLE_NAME
Definition: FIRRTL.h:32
@ FIRRTL_NAME_KIND_INTERESTING_NAME
Definition: FIRRTL.h:33
FIRRTLMemDir
Definition: FIRRTL.h:44
@ FIRRTL_MEM_DIR_INFER
Definition: FIRRTL.h:45
@ FIRRTL_MEM_DIR_READ
Definition: FIRRTL.h:46
@ FIRRTL_MEM_DIR_READ_WRITE
Definition: FIRRTL.h:48
@ FIRRTL_MEM_DIR_WRITE
Definition: FIRRTL.h:47
MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetConvention(MlirContext ctx, FIRRTLConvention convention)
Definition: FIRRTL.cpp:176
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetRef(MlirType target, bool forceable)
Definition: FIRRTL.cpp:110
MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetNameKind(MlirContext ctx, FIRRTLNameKind nameKind)
Definition: FIRRTL.cpp:211
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetUInt(MlirContext ctx, int32_t width)
MLIR_CAPI_EXPORTED bool firrtlTypeIsAOpenBundle(MlirType type)
Definition: FIRRTL.cpp:67
MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetRUW(MlirContext ctx, FIRRTLRUW ruw)
Definition: FIRRTL.cpp:226
MLIR_CAPI_EXPORTED unsigned firrtlTypeGetBundleFieldIndex(MlirType type, MlirStringRef fieldName)
Definition: FIRRTL.cpp:97
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetString(MlirContext ctx)
Definition: FIRRTL.cpp:129
MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetMemInit(MlirContext ctx, MlirIdentifier filename, bool isBinary, bool isInline)
Definition: FIRRTL.cpp:244
FIRRTLEventControl
Definition: FIRRTL.h:52
@ FIRRTL_EVENT_CONTROL_AT_POS_EDGE
Definition: FIRRTL.h:53
@ FIRRTL_EVENT_CONTROL_AT_NEG_EDGE
Definition: FIRRTL.h:54
@ FIRRTL_EVENT_CONTROL_AT_EDGE
Definition: FIRRTL.h:55
MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetMemDir(MlirContext ctx, FIRRTLMemDir dir)
Definition: FIRRTL.cpp:250
MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetParamDecl(MlirContext ctx, MlirIdentifier name, MlirType type, MlirAttribute value)
Definition: FIRRTL.cpp:205
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetList(MlirContext ctx, MlirType elementType)
Definition: FIRRTL.cpp:141
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetVector(MlirContext ctx, MlirType element, size_t count)
Definition: FIRRTL.cpp:60
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetBundle(MlirContext ctx, size_t count, const FIRRTLBundleField *fields)
Definition: FIRRTL.cpp:71
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetAsyncReset(MlirContext ctx)
Definition: FIRRTL.cpp:52
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetDouble(MlirContext ctx)
Definition: FIRRTL.cpp:125
FIRRTLDirection
Definition: FIRRTL.h:25
@ FIRRTL_DIRECTION_OUT
Definition: FIRRTL.h:27
@ FIRRTL_DIRECTION_IN
Definition: FIRRTL.h:26
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetMaskType(MlirType type)
Definition: FIRRTL.cpp:166
MLIR_CAPI_EXPORTED bool firrtlImportAnnotationsFromJSONRaw(MlirContext ctx, MlirStringRef annotationsStr, MlirAttribute *importedAnnotationsArray)
Definition: FIRRTL.cpp:329
MLIR_CAPI_EXPORTED FIRRTLValueFlow firrtlValueFoldFlow(MlirValue value, FIRRTLValueFlow flow)
Definition: FIRRTL.cpp:296
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetClock(MlirContext ctx)
Definition: FIRRTL.cpp:44
MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetIntegerFromString(MlirType type, unsigned numBits, MlirStringRef str, uint8_t radix)
Definition: FIRRTL.cpp:290
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetAnyRef(MlirContext ctx)
Definition: FIRRTL.cpp:117
FIRRTLRUW
Definition: FIRRTL.h:37
@ FIRRTL_RUW_OLD
Definition: FIRRTL.h:39
@ FIRRTL_RUW_UNDEFINED
Definition: FIRRTL.h:38
@ FIRRTL_RUW_NEW
Definition: FIRRTL.h:40
FIRRTLConvention
Definition: FIRRTL.h:19
@ FIRRTL_CONVENTION_SCALARIZED
Definition: FIRRTL.h:21
@ FIRRTL_CONVENTION_INTERNAL
Definition: FIRRTL.h:20
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetBoolean(MlirContext ctx)
Definition: FIRRTL.cpp:133
MLIR_CAPI_EXPORTED MlirType firrtlTypeGetClass(MlirContext ctx, MlirAttribute name, size_t numberOfElements, const FIRRTLClassElement *elements)
Definition: FIRRTL.cpp:148
MlirType type
Definition: FIRRTL.h:70
MlirIdentifier name
Definition: FIRRTL.h:68
MlirIdentifier name
Definition: FIRRTL.h:75
MlirType type
Definition: FIRRTL.h:76
FIRRTLDirection direction
Definition: FIRRTL.h:77