CIRCT 23.0.0git
Loading...
Searching...
No Matches
RTG.h
Go to the documentation of this file.
1//===- RTG.h - C interface for the for RTG 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_RTG_H
10#define CIRCT_C_DIALECT_RTG_H
11
12#include "mlir-c/IR.h"
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18//===----------------------------------------------------------------------===//
19// Dialect API.
20//===----------------------------------------------------------------------===//
21
23MLIR_CAPI_EXPORTED void registerRTGPipelines(void);
24
25//===----------------------------------------------------------------------===//
26// Type API.
27//===----------------------------------------------------------------------===//
28
29/// If the type is an RTG sequence.
30MLIR_CAPI_EXPORTED bool rtgTypeIsASequence(MlirType type);
31
32/// Creates an RTG sequence type in the context.
33MLIR_CAPI_EXPORTED MlirType rtgSequenceTypeGet(MlirContext ctxt,
34 intptr_t numElements,
35 MlirType const *elementTypes);
36
37/// The number of substitution elements of the RTG sequence.
38MLIR_CAPI_EXPORTED unsigned rtgSequenceTypeGetNumElements(MlirType type);
39
40/// The type of of the substitution element at the given index.
41MLIR_CAPI_EXPORTED MlirType rtgSequenceTypeGetElement(MlirType type,
42 unsigned i);
43
44/// If the type is an RTG randomized sequence.
45MLIR_CAPI_EXPORTED bool rtgTypeIsARandomizedSequence(MlirType type);
46
47/// Creates an RTG randomized sequence type in the context.
48MLIR_CAPI_EXPORTED MlirType rtgRandomizedSequenceTypeGet(MlirContext ctxt);
49
50/// If the type is an RTG label.
51MLIR_CAPI_EXPORTED bool rtgTypeIsALabel(MlirType type);
52
53/// Creates an RTG mode type in the context.
54MLIR_CAPI_EXPORTED MlirType rtgLabelTypeGet(MlirContext ctxt);
55
56/// If the type is an RTG set.
57MLIR_CAPI_EXPORTED bool rtgTypeIsASet(MlirType type);
58
59/// Creates an RTG set type in the context.
60MLIR_CAPI_EXPORTED MlirType rtgSetTypeGet(MlirType elementType);
61
62/// Return the element type of the RTG set.
63MLIR_CAPI_EXPORTED MlirType rtgSetTypeGetElementType(MlirType type);
64
65/// If the type is an RTG bag.
66MLIR_CAPI_EXPORTED bool rtgTypeIsABag(MlirType type);
67
68/// Creates an RTG bag type in the context.
69MLIR_CAPI_EXPORTED MlirType rtgBagTypeGet(MlirType elementType);
70
71/// Return the element type of the RTG bag.
72MLIR_CAPI_EXPORTED MlirType rtgBagTypeGetElementType(MlirType type);
73
74/// If the type is an RTG dict.
75MLIR_CAPI_EXPORTED bool rtgTypeIsADict(MlirType type);
76
77/// Creates an RTG dict type in the context.
78MLIR_CAPI_EXPORTED MlirType rtgDictTypeGet(MlirContext ctxt,
79 intptr_t numEntries,
80 MlirAttribute const *entryNames,
81 MlirType const *entryTypes);
82
83/// If the type is an RTG immediate.
84MLIR_CAPI_EXPORTED bool rtgTypeIsAImmediate(MlirType type);
85
86/// Creates an RTG immediate type in the context.
87MLIR_CAPI_EXPORTED MlirType rtgImmediateTypeGet(MlirContext ctx,
88 uint32_t width);
89
90/// Returns the width of the RTG immediate type.
91MLIR_CAPI_EXPORTED uint32_t rtgImmediateTypeGetWidth(MlirType type);
92
93/// Creates an RTG array type in the context.
94MLIR_CAPI_EXPORTED MlirType rtgArrayTypeGet(MlirType elementType);
95
96/// If the type is an RTG array.
97MLIR_CAPI_EXPORTED bool rtgTypeIsAArray(MlirType type);
98
99/// Returns the element type of the RTG array.
100MLIR_CAPI_EXPORTED MlirType rtgArrayTypeGetElementType(MlirType type);
101
102/// If the type is an RTG map.
103MLIR_CAPI_EXPORTED bool rtgTypeIsAMap(MlirType type);
104
105/// Creates an RTG map type in the context.
106MLIR_CAPI_EXPORTED MlirType rtgMapTypeGet(MlirType keyType, MlirType valueType);
107
108/// Return the key type of the RTG map.
109MLIR_CAPI_EXPORTED MlirType rtgMapTypeGetKeyType(MlirType type);
110
111/// Return the value type of the RTG map.
112MLIR_CAPI_EXPORTED MlirType rtgMapTypeGetValueType(MlirType type);
113
114/// Creates an RTG tuple type in the context.
115MLIR_CAPI_EXPORTED MlirType rtgTupleTypeGet(MlirContext ctxt,
116 intptr_t numFields,
117 MlirType const *fieldTypes);
118
119/// If the type is an RTG tuple.
120MLIR_CAPI_EXPORTED bool rtgTypeIsATuple(MlirType type);
121
122/// Returns the number of fields in the RTG tuple.
123MLIR_CAPI_EXPORTED intptr_t rtgTypeGetNumFields(MlirType type);
124
125/// Returns a field type of the RTG tuple.
126MLIR_CAPI_EXPORTED MlirType rtgTupleTypeGetFieldType(MlirType type,
127 intptr_t idx);
128
129/// If the type is an RTG memory.
130MLIR_CAPI_EXPORTED bool rtgTypeIsAMemory(MlirType type);
131
132/// Creates an RTG memory type in the context.
133MLIR_CAPI_EXPORTED MlirType rtgMemoryTypeGet(MlirContext ctx,
134 uint32_t addressWidth);
135
136/// Returns the address with of an RTG memory type.
137MLIR_CAPI_EXPORTED uint32_t rtgMemoryTypeGetAddressWidth(MlirType type);
138
139/// If the type is an RTG memory block.
140MLIR_CAPI_EXPORTED bool rtgTypeIsAMemoryBlock(MlirType type);
141
142/// Creates an RTG memory block type in the context.
143MLIR_CAPI_EXPORTED MlirType rtgMemoryBlockTypeGet(MlirContext ctx,
144 uint32_t addressWidth);
145
146/// Returns the address with of an RTG memory block type.
147MLIR_CAPI_EXPORTED uint32_t rtgMemoryBlockTypeGetAddressWidth(MlirType type);
148
149/// If the type is an RTG string.
150MLIR_CAPI_EXPORTED bool rtgTypeIsAString(MlirType type);
151
152/// Creates an RTG string type in the context.
153MLIR_CAPI_EXPORTED MlirType rtgStringTypeGet(MlirContext ctxt);
154
155//===----------------------------------------------------------------------===//
156// Attribute API.
157//===----------------------------------------------------------------------===//
158
165
166/// If the attribute is an RTG label visibility.
167MLIR_CAPI_EXPORTED bool rtgAttrIsALabelVisibilityAttr(MlirAttribute attr);
168
169/// Get the RTG label visibility from the attribute.
170MLIR_CAPI_EXPORTED RTGLabelVisibility
171rtgLabelVisibilityAttrGetValue(MlirAttribute attr);
172
173/// Creates an RTG label visibility attribute in the context.
174MLIR_CAPI_EXPORTED MlirAttribute
175rtgLabelVisibilityAttrGet(MlirContext ctxt, RTGLabelVisibility visibility);
176
177/// If the attribute is an RTG default context.
178MLIR_CAPI_EXPORTED bool rtgAttrIsADefaultContextAttr(MlirAttribute attr);
179
180/// Creates an RTG default context attribute in the context.
181MLIR_CAPI_EXPORTED MlirAttribute rtgDefaultContextAttrGet(MlirContext ctxt,
182 MlirType type);
183
184/// Checks if the attribute is an RTG immediate attribute.
185MLIR_CAPI_EXPORTED bool rtgAttrIsAImmediate(MlirAttribute attr);
186
187/// Creates an RTG immediate attribute in the context with the given width and
188/// value.
189MLIR_CAPI_EXPORTED MlirAttribute rtgImmediateAttrGet(MlirContext ctx,
190 uint32_t width,
191 uint64_t value);
192
193/// Returns the width of the RTG immediate attribute.
194MLIR_CAPI_EXPORTED uint32_t rtgImmediateAttrGetWidth(MlirAttribute attr);
195
196/// Returns the value of the RTG immediate attribute.
197MLIR_CAPI_EXPORTED uint64_t rtgImmediateAttrGetValue(MlirAttribute attr);
198
199/// If the attribute is an RTG any context attribute.
200MLIR_CAPI_EXPORTED bool rtgAttrIsAAnyContextAttr(MlirAttribute attr);
201
202/// Creates an RTG any context attribute in the context.
203MLIR_CAPI_EXPORTED MlirAttribute rtgAnyContextAttrGet(MlirContext ctxt,
204 MlirType type);
205
206/// Checks if the attribute is an RTG virtual register config attribute.
207MLIR_CAPI_EXPORTED bool rtgAttrIsAVirtualRegisterConfig(MlirAttribute attr);
208
209/// Creates an RTG virtual register config attribute in the context.
210MLIR_CAPI_EXPORTED MlirAttribute rtgVirtualRegisterConfigAttrGet(
211 MlirContext ctxt, intptr_t numRegs, MlirAttribute const *allowedRegs);
212
213/// Returns the number of allowed registers in the RTG virtual register config
214/// attribute.
215MLIR_CAPI_EXPORTED intptr_t
217
218/// Returns the allowed register at the given index in the RTG virtual register
219/// config attribute.
220MLIR_CAPI_EXPORTED MlirAttribute
221rtgVirtualRegisterConfigAttrGetRegister(MlirAttribute attr, intptr_t index);
222
223/// Checks if the attribute is an RTG label attribute.
224MLIR_CAPI_EXPORTED bool rtgAttrIsALabel(MlirAttribute attr);
225
226/// Creates an RTG label attribute in the context with the given name.
227MLIR_CAPI_EXPORTED MlirAttribute rtgLabelAttrGet(MlirContext ctx,
228 MlirStringRef name);
229
230/// Returns the name of the RTG label attribute.
231MLIR_CAPI_EXPORTED MlirStringRef rtgLabelAttrGetName(MlirAttribute attr);
232
233/// Checks if the attribute is an RTG map attribute.
234MLIR_CAPI_EXPORTED bool rtgAttrIsAMap(MlirAttribute attr);
235
236/// Creates an RTG map attribute in the context with the given entries.
237MLIR_CAPI_EXPORTED MlirAttribute rtgMapAttrGet(MlirContext ctx,
238 MlirType mapType,
239 intptr_t numEntries,
240 MlirAttribute const *keys,
241 MlirAttribute const *values);
242
243/// Looks up the value associated with the given key in the RTG map attribute.
244/// Returns a null attribute if the key is not found.
245MLIR_CAPI_EXPORTED MlirAttribute rtgMapAttrLookup(MlirAttribute attr,
246 MlirAttribute key);
247
248#ifdef __cplusplus
249}
250#endif
251
252#include "circt/Dialect/RTG/Transforms/RTGPasses.capi.h.inc"
253
254#endif // CIRCT_C_DIALECT_RTG_H
MlirType uint64_t numElements
Definition CHIRRTL.cpp:30
MlirType elementType
Definition CHIRRTL.cpp:29
MLIR_CAPI_EXPORTED MlirAttribute rtgAnyContextAttrGet(MlirContext ctxt, MlirType type)
Creates an RTG any context attribute in the context.
Definition RTG.cpp:307
MLIR_CAPI_EXPORTED bool rtgTypeIsAMemory(MlirType type)
If the type is an RTG memory.
Definition RTG.cpp:195
MLIR_CAPI_EXPORTED bool rtgAttrIsAAnyContextAttr(MlirAttribute attr)
If the attribute is an RTG any context attribute.
Definition RTG.cpp:303
MLIR_CAPI_EXPORTED MlirType rtgLabelTypeGet(MlirContext ctxt)
Creates an RTG mode type in the context.
Definition RTG.cpp:73
MLIR_CAPI_EXPORTED RTGLabelVisibility rtgLabelVisibilityAttrGetValue(MlirAttribute attr)
Get the RTG label visibility from the attribute.
Definition RTG.cpp:251
MLIR_CAPI_EXPORTED MlirAttribute rtgVirtualRegisterConfigAttrGet(MlirContext ctxt, intptr_t numRegs, MlirAttribute const *allowedRegs)
Creates an RTG virtual register config attribute in the context.
Definition RTG.cpp:319
MLIR_CAPI_EXPORTED uint32_t rtgImmediateAttrGetWidth(MlirAttribute attr)
Returns the width of the RTG immediate attribute.
Definition RTG.cpp:292
RTGLabelVisibility
Definition RTG.h:159
@ RTG_LABEL_VISIBILITY_EXTERNAL
Definition RTG.h:162
@ RTG_LABEL_VISIBILITY_GLOBAL
Definition RTG.h:161
@ RTG_LABEL_VISIBILITY_LOCAL
Definition RTG.h:160
MLIR_CAPI_EXPORTED MlirAttribute rtgVirtualRegisterConfigAttrGetRegister(MlirAttribute attr, intptr_t index)
Returns the allowed register at the given index in the RTG virtual register config attribute.
Definition RTG.cpp:331
MLIR_CAPI_EXPORTED MlirType rtgSequenceTypeGetElement(MlirType type, unsigned i)
The type of of the substitution element at the given index.
Definition RTG.cpp:53
MLIR_CAPI_EXPORTED MlirAttribute rtgDefaultContextAttrGet(MlirContext ctxt, MlirType type)
Creates an RTG default context attribute in the context.
Definition RTG.cpp:240
MLIR_CAPI_EXPORTED MlirAttribute rtgMapAttrGet(MlirContext ctx, MlirType mapType, intptr_t numEntries, MlirAttribute const *keys, MlirAttribute const *values)
Creates an RTG map attribute in the context with the given entries.
Definition RTG.cpp:360
MLIR_CAPI_EXPORTED MlirType rtgImmediateTypeGet(MlirContext ctx, uint32_t width)
Creates an RTG immediate type in the context.
Definition RTG.cpp:184
MLIR_CAPI_EXPORTED uint32_t rtgMemoryTypeGetAddressWidth(MlirType type)
Returns the address with of an RTG memory type.
Definition RTG.cpp:201
MLIR_CAPI_EXPORTED bool rtgTypeIsAArray(MlirType type)
If the type is an RTG array.
Definition RTG.cpp:131
MLIR_CAPI_EXPORTED bool rtgAttrIsALabelVisibilityAttr(MlirAttribute attr)
If the attribute is an RTG label visibility.
Definition RTG.cpp:247
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(RTG, rtg)
MLIR_CAPI_EXPORTED bool rtgAttrIsALabel(MlirAttribute attr)
Checks if the attribute is an RTG label attribute.
Definition RTG.cpp:341
MLIR_CAPI_EXPORTED intptr_t rtgTypeGetNumFields(MlirType type)
Returns the number of fields in the RTG tuple.
Definition RTG.cpp:169
MLIR_CAPI_EXPORTED MlirAttribute rtgLabelVisibilityAttrGet(MlirContext ctxt, RTGLabelVisibility visibility)
Creates an RTG label visibility attribute in the context.
Definition RTG.cpp:265
MLIR_CAPI_EXPORTED MlirAttribute rtgMapAttrLookup(MlirAttribute attr, MlirAttribute key)
Looks up the value associated with the given key in the RTG map attribute.
Definition RTG.cpp:371
MLIR_CAPI_EXPORTED MlirType rtgMapTypeGet(MlirType keyType, MlirType valueType)
Creates an RTG map type in the context.
Definition RTG.cpp:142
MLIR_CAPI_EXPORTED void registerRTGPipelines(void)
Definition RTG.cpp:28
MLIR_CAPI_EXPORTED MlirType rtgArrayTypeGetElementType(MlirType type)
Returns the element type of the RTG array.
Definition RTG.cpp:133
MLIR_CAPI_EXPORTED bool rtgTypeIsATuple(MlirType type)
If the type is an RTG tuple.
Definition RTG.cpp:165
MLIR_CAPI_EXPORTED bool rtgTypeIsABag(MlirType type)
If the type is an RTG bag.
Definition RTG.cpp:94
MLIR_CAPI_EXPORTED MlirType rtgSequenceTypeGet(MlirContext ctxt, intptr_t numElements, MlirType const *elementTypes)
Creates an RTG sequence type in the context.
Definition RTG.cpp:41
MLIR_CAPI_EXPORTED MlirType rtgStringTypeGet(MlirContext ctxt)
Creates an RTG string type in the context.
Definition RTG.cpp:225
MLIR_CAPI_EXPORTED MlirAttribute rtgImmediateAttrGet(MlirContext ctx, uint32_t width, uint64_t value)
Creates an RTG immediate attribute in the context with the given width and value.
Definition RTG.cpp:287
MLIR_CAPI_EXPORTED unsigned rtgSequenceTypeGetNumElements(MlirType type)
The number of substitution elements of the RTG sequence.
Definition RTG.cpp:49
MLIR_CAPI_EXPORTED MlirType rtgSetTypeGet(MlirType elementType)
Creates an RTG set type in the context.
Definition RTG.cpp:82
MLIR_CAPI_EXPORTED bool rtgTypeIsASet(MlirType type)
If the type is an RTG set.
Definition RTG.cpp:80
MLIR_CAPI_EXPORTED MlirType rtgTupleTypeGet(MlirContext ctxt, intptr_t numFields, MlirType const *fieldTypes)
Creates an RTG tuple type in the context.
Definition RTG.cpp:157
MLIR_CAPI_EXPORTED MlirType rtgMemoryTypeGet(MlirContext ctx, uint32_t addressWidth)
Creates an RTG memory type in the context.
Definition RTG.cpp:197
MLIR_CAPI_EXPORTED MlirType rtgRandomizedSequenceTypeGet(MlirContext ctxt)
Creates an RTG randomized sequence type in the context.
Definition RTG.cpp:64
MLIR_CAPI_EXPORTED uint64_t rtgImmediateAttrGetValue(MlirAttribute attr)
Returns the value of the RTG immediate attribute.
Definition RTG.cpp:296
MLIR_CAPI_EXPORTED bool rtgTypeIsAMemoryBlock(MlirType type)
If the type is an RTG memory block.
Definition RTG.cpp:208
MLIR_CAPI_EXPORTED bool rtgAttrIsAImmediate(MlirAttribute attr)
Checks if the attribute is an RTG immediate attribute.
Definition RTG.cpp:283
MLIR_CAPI_EXPORTED bool rtgTypeIsARandomizedSequence(MlirType type)
If the type is an RTG randomized sequence.
Definition RTG.cpp:60
MLIR_CAPI_EXPORTED bool rtgTypeIsAMap(MlirType type)
If the type is an RTG map.
Definition RTG.cpp:140
MLIR_CAPI_EXPORTED bool rtgTypeIsADict(MlirType type)
If the type is an RTG dict.
Definition RTG.cpp:108
MLIR_CAPI_EXPORTED MlirType rtgTupleTypeGetFieldType(MlirType type, intptr_t idx)
Returns a field type of the RTG tuple.
Definition RTG.cpp:173
MLIR_CAPI_EXPORTED MlirStringRef rtgLabelAttrGetName(MlirAttribute attr)
Returns the name of the RTG label attribute.
Definition RTG.cpp:349
MLIR_CAPI_EXPORTED bool rtgAttrIsAVirtualRegisterConfig(MlirAttribute attr)
Checks if the attribute is an RTG virtual register config attribute.
Definition RTG.cpp:314
MLIR_CAPI_EXPORTED bool rtgTypeIsAImmediate(MlirType type)
If the type is an RTG immediate.
Definition RTG.cpp:180
MLIR_CAPI_EXPORTED MlirType rtgDictTypeGet(MlirContext ctxt, intptr_t numEntries, MlirAttribute const *entryNames, MlirType const *entryTypes)
Creates an RTG dict type in the context.
Definition RTG.cpp:110
MLIR_CAPI_EXPORTED bool rtgAttrIsAMap(MlirAttribute attr)
Checks if the attribute is an RTG map attribute.
Definition RTG.cpp:356
MLIR_CAPI_EXPORTED intptr_t rtgVirtualRegisterConfigAttrGetNumRegisters(MlirAttribute attr)
Returns the number of allowed registers in the RTG virtual register config attribute.
Definition RTG.cpp:327
MLIR_CAPI_EXPORTED MlirType rtgBagTypeGet(MlirType elementType)
Creates an RTG bag type in the context.
Definition RTG.cpp:96
MLIR_CAPI_EXPORTED uint32_t rtgMemoryBlockTypeGetAddressWidth(MlirType type)
Returns the address with of an RTG memory block type.
Definition RTG.cpp:216
MLIR_CAPI_EXPORTED MlirType rtgArrayTypeGet(MlirType elementType)
Creates an RTG array type in the context.
Definition RTG.cpp:126
MLIR_CAPI_EXPORTED MlirType rtgBagTypeGetElementType(MlirType type)
Return the element type of the RTG bag.
Definition RTG.cpp:101
MLIR_CAPI_EXPORTED bool rtgTypeIsAString(MlirType type)
If the type is an RTG string.
Definition RTG.cpp:223
MLIR_CAPI_EXPORTED bool rtgTypeIsASequence(MlirType type)
If the type is an RTG sequence.
Definition RTG.cpp:37
MLIR_CAPI_EXPORTED MlirAttribute rtgLabelAttrGet(MlirContext ctx, MlirStringRef name)
Creates an RTG label attribute in the context with the given name.
Definition RTG.cpp:345
MLIR_CAPI_EXPORTED bool rtgTypeIsALabel(MlirType type)
If the type is an RTG label.
Definition RTG.cpp:71
MLIR_CAPI_EXPORTED uint32_t rtgImmediateTypeGetWidth(MlirType type)
Returns the width of the RTG immediate type.
Definition RTG.cpp:188
MLIR_CAPI_EXPORTED MlirType rtgMemoryBlockTypeGet(MlirContext ctx, uint32_t addressWidth)
Creates an RTG memory block type in the context.
Definition RTG.cpp:212
MLIR_CAPI_EXPORTED MlirType rtgMapTypeGetKeyType(MlirType type)
Return the key type of the RTG map.
Definition RTG.cpp:146
MLIR_CAPI_EXPORTED MlirType rtgSetTypeGetElementType(MlirType type)
Return the element type of the RTG set.
Definition RTG.cpp:87
MLIR_CAPI_EXPORTED bool rtgAttrIsADefaultContextAttr(MlirAttribute attr)
If the attribute is an RTG default context.
Definition RTG.cpp:236
MLIR_CAPI_EXPORTED MlirType rtgMapTypeGetValueType(MlirType type)
Return the value type of the RTG map.
Definition RTG.cpp:150
Definition rtg.py:1