CIRCT 20.0.0git
Loading...
Searching...
No Matches
OM.h
Go to the documentation of this file.
1//===- OM.h - C interface for the OM 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_OM_H
10#define CIRCT_C_DIALECT_OM_H
11
12#include "mlir-c/IR.h"
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18//===----------------------------------------------------------------------===//
19// Dialect API.
20//===----------------------------------------------------------------------===//
21
23
24//===----------------------------------------------------------------------===//
25// Type API.
26//===----------------------------------------------------------------------===//
27
28/// Is the Type an AnyType.
29MLIR_CAPI_EXPORTED bool omTypeIsAAnyType(MlirType type);
30
31/// Get the TypeID for an AnyType.
32MLIR_CAPI_EXPORTED MlirTypeID omAnyTypeGetTypeID(void);
33
34/// Is the Type a ClassType.
35MLIR_CAPI_EXPORTED bool omTypeIsAClassType(MlirType type);
36
37/// Get the TypeID for a ClassType.
38MLIR_CAPI_EXPORTED MlirTypeID omClassTypeGetTypeID(void);
39
40/// Get the name for a ClassType.
41MLIR_CAPI_EXPORTED MlirIdentifier omClassTypeGetName(MlirType type);
42
43/// Is the Type a FrozenBasePathType.
44MLIR_CAPI_EXPORTED bool omTypeIsAFrozenBasePathType(MlirType type);
45
46/// Get the TypeID for a FrozenBasePathType.
47MLIR_CAPI_EXPORTED MlirTypeID omFrozenBasePathTypeGetTypeID(void);
48
49/// Is the Type a FrozenPathType.
50MLIR_CAPI_EXPORTED bool omTypeIsAFrozenPathType(MlirType type);
51
52/// Get the TypeID for a FrozenPathType.
53MLIR_CAPI_EXPORTED MlirTypeID omFrozenPathTypeGetTypeID(void);
54
55/// Is the Type a ListType.
56MLIR_CAPI_EXPORTED bool omTypeIsAListType(MlirType type);
57
58/// Get the TypeID for a ListType.
59MLIR_CAPI_EXPORTED MlirTypeID omListTypeGetTypeID(void);
60
61// Return a element type of a ListType.
62MLIR_CAPI_EXPORTED MlirType omListTypeGetElementType(MlirType type);
63
64/// Is the Type a MapType.
65MLIR_CAPI_EXPORTED bool omTypeIsAMapType(MlirType type);
66
67// Return a key type of a MapType.
68MLIR_CAPI_EXPORTED MlirType omMapTypeGetKeyType(MlirType type);
69
70/// Is the Type a StringType.
71MLIR_CAPI_EXPORTED bool omTypeIsAStringType(MlirType type);
72
73//===----------------------------------------------------------------------===//
74// Evaluator data structures.
75//===----------------------------------------------------------------------===//
76
77/// A value type for use in C APIs that just wraps a pointer to an Evaluator.
78/// This is in line with the usual MLIR DEFINE_C_API_STRUCT.
80 void *ptr;
81};
82
83// clang-tidy doesn't respect extern "C".
84// see https://github.com/llvm/llvm-project/issues/35272.
85// NOLINTNEXTLINE(modernize-use-using)
86typedef struct OMEvaluator OMEvaluator;
87
88/// A value type for use in C APIs that just wraps a pointer to an Object.
89/// This is in line with the usual MLIR DEFINE_C_API_STRUCT.
91 void *ptr;
92};
93
94// clang-tidy doesn't respect extern "C".
95// see https://github.com/llvm/llvm-project/issues/35272.
96// NOLINTNEXTLINE(modernize-use-using)
98
99//===----------------------------------------------------------------------===//
100// Evaluator API.
101//===----------------------------------------------------------------------===//
102
103/// Construct an Evaluator with an IR module.
104MLIR_CAPI_EXPORTED OMEvaluator omEvaluatorNew(MlirModule mod);
105
106/// Use the Evaluator to Instantiate an Object from its class name and actual
107/// parameters.
108MLIR_CAPI_EXPORTED OMEvaluatorValue
109omEvaluatorInstantiate(OMEvaluator evaluator, MlirAttribute className,
110 intptr_t nActualParams, OMEvaluatorValue *actualParams);
111
112/// Get the Module the Evaluator is built from.
113MLIR_CAPI_EXPORTED MlirModule omEvaluatorGetModule(OMEvaluator evaluator);
114
115//===----------------------------------------------------------------------===//
116// Object API.
117//===----------------------------------------------------------------------===//
118
119/// Query if the Object is null.
120MLIR_CAPI_EXPORTED bool omEvaluatorObjectIsNull(OMEvaluatorValue object);
121
122/// Get the Type from an Object, which will be a ClassType.
123MLIR_CAPI_EXPORTED MlirType omEvaluatorObjectGetType(OMEvaluatorValue object);
124
125/// Get a field from an Object, which must contain a field of that name.
126MLIR_CAPI_EXPORTED OMEvaluatorValue
127omEvaluatorObjectGetField(OMEvaluatorValue object, MlirAttribute name);
128
129/// Get the object hash.
130MLIR_CAPI_EXPORTED unsigned omEvaluatorObjectGetHash(OMEvaluatorValue object);
131
132/// Check equality of two objects.
133MLIR_CAPI_EXPORTED bool omEvaluatorObjectIsEq(OMEvaluatorValue object,
134 OMEvaluatorValue other);
135
136/// Get all the field names from an Object, can be empty if object has no
137/// fields.
138MLIR_CAPI_EXPORTED MlirAttribute
140
141//===----------------------------------------------------------------------===//
142// EvaluatorValue API.
143//===----------------------------------------------------------------------===//
144
145// Get a context from an EvaluatorValue.
146MLIR_CAPI_EXPORTED MlirContext
148
149// Get Location from an EvaluatorValue.
150MLIR_CAPI_EXPORTED MlirLocation
152
153// Query if the EvaluatorValue is null.
154MLIR_CAPI_EXPORTED bool omEvaluatorValueIsNull(OMEvaluatorValue evaluatorValue);
155
156/// Query if the EvaluatorValue is an Object.
157MLIR_CAPI_EXPORTED bool
159
160/// Query if the EvaluatorValue is a Primitive.
161MLIR_CAPI_EXPORTED bool
163
164/// Get the Primitive from an EvaluatorValue, which must contain a Primitive.
165MLIR_CAPI_EXPORTED MlirAttribute
167
168/// Get the EvaluatorValue from a Primitive value.
169MLIR_CAPI_EXPORTED OMEvaluatorValue
170omEvaluatorValueFromPrimitive(MlirAttribute primitive);
171
172/// Query if the EvaluatorValue is an Object.
173MLIR_CAPI_EXPORTED bool
175
176/// Get the length of the list.
177MLIR_CAPI_EXPORTED intptr_t
179
180/// Get an element of the list.
181MLIR_CAPI_EXPORTED OMEvaluatorValue
182omEvaluatorListGetElement(OMEvaluatorValue evaluatorValue, intptr_t pos);
183
184/// Query if the EvaluatorValue is a Tuple.
185MLIR_CAPI_EXPORTED bool
187
188/// Get the size of the tuple.
189MLIR_CAPI_EXPORTED intptr_t
191
192/// Get an element of the tuple.
193MLIR_CAPI_EXPORTED OMEvaluatorValue
194omEvaluatorTupleGetElement(OMEvaluatorValue evaluatorValue, intptr_t pos);
195
196/// Get an element of the map.
197MLIR_CAPI_EXPORTED OMEvaluatorValue
198omEvaluatorMapGetElement(OMEvaluatorValue evaluatorValue, MlirAttribute attr);
199
200MLIR_CAPI_EXPORTED MlirAttribute omEvaluatorMapGetKeys(OMEvaluatorValue object);
201
202/// Query if the EvaluatorValue is a Map.
203MLIR_CAPI_EXPORTED bool omEvaluatorValueIsAMap(OMEvaluatorValue evaluatorValue);
204
205/// Get the Type from a Map, which will be a MapType.
206MLIR_CAPI_EXPORTED MlirType
208
209/// Query if the EvaluatorValue is a BasePath.
210MLIR_CAPI_EXPORTED bool
212
213/// Create an empty BasePath.
214MLIR_CAPI_EXPORTED OMEvaluatorValue
215omEvaluatorBasePathGetEmpty(MlirContext context);
216
217/// Query if the EvaluatorValue is a Path.
218MLIR_CAPI_EXPORTED bool
220
221/// Get a string representation of a Path.
222MLIR_CAPI_EXPORTED MlirAttribute
224
225/// Query if the EvaluatorValue is a Reference.
226MLIR_CAPI_EXPORTED bool
228
229/// Dereference a Reference EvaluatorValue. Emits an error and returns null if
230/// the Reference cannot be dereferenced.
231MLIR_CAPI_EXPORTED OMEvaluatorValue
233
234//===----------------------------------------------------------------------===//
235// ReferenceAttr API
236//===----------------------------------------------------------------------===//
237
238MLIR_CAPI_EXPORTED bool omAttrIsAReferenceAttr(MlirAttribute attr);
239
240MLIR_CAPI_EXPORTED MlirAttribute omReferenceAttrGetInnerRef(MlirAttribute attr);
241
242//===----------------------------------------------------------------------===//
243// IntegerAttr API
244//===----------------------------------------------------------------------===//
245
246MLIR_CAPI_EXPORTED bool omAttrIsAIntegerAttr(MlirAttribute attr);
247
248/// Given an om::IntegerAttr, return the mlir::IntegerAttr.
249MLIR_CAPI_EXPORTED MlirAttribute omIntegerAttrGetInt(MlirAttribute attr);
250
251/// Get an om::IntegerAttr from mlir::IntegerAttr.
252MLIR_CAPI_EXPORTED MlirAttribute omIntegerAttrGet(MlirAttribute attr);
253
254/// Get a string representation of an om::IntegerAttr.
255MLIR_CAPI_EXPORTED MlirStringRef omIntegerAttrToString(MlirAttribute attr);
256
257//===----------------------------------------------------------------------===//
258// ListAttr API
259//===----------------------------------------------------------------------===//
260
261MLIR_CAPI_EXPORTED bool omAttrIsAListAttr(MlirAttribute attr);
262
263MLIR_CAPI_EXPORTED intptr_t omListAttrGetNumElements(MlirAttribute attr);
264
265MLIR_CAPI_EXPORTED MlirAttribute omListAttrGetElement(MlirAttribute attr,
266 intptr_t pos);
267
268//===----------------------------------------------------------------------===//
269// MapAttr API
270//===----------------------------------------------------------------------===//
271
272MLIR_CAPI_EXPORTED bool omAttrIsAMapAttr(MlirAttribute attr);
273
274MLIR_CAPI_EXPORTED intptr_t omMapAttrGetNumElements(MlirAttribute attr);
275
276MLIR_CAPI_EXPORTED MlirIdentifier omMapAttrGetElementKey(MlirAttribute attr,
277 intptr_t pos);
278
279MLIR_CAPI_EXPORTED MlirAttribute omMapAttrGetElementValue(MlirAttribute attr,
280 intptr_t pos);
281
282#ifdef __cplusplus
283}
284#endif
285
286#endif // CIRCT_C_DIALECT_OM_H
MLIR_CAPI_EXPORTED bool omEvaluatorObjectIsEq(OMEvaluatorValue object, OMEvaluatorValue other)
Check equality of two objects.
Definition OM.cpp:183
MLIR_CAPI_EXPORTED intptr_t omListAttrGetNumElements(MlirAttribute attr)
Definition OM.cpp:419
MLIR_CAPI_EXPORTED unsigned omEvaluatorObjectGetHash(OMEvaluatorValue object)
Get the object hash.
Definition OM.cpp:178
MLIR_CAPI_EXPORTED bool omTypeIsAFrozenBasePathType(MlirType type)
Is the Type a FrozenBasePathType.
Definition OM.cpp:50
MLIR_CAPI_EXPORTED MlirTypeID omListTypeGetTypeID(void)
Get the TypeID for a ListType.
Definition OM.cpp:73
MLIR_CAPI_EXPORTED bool omAttrIsAListAttr(MlirAttribute attr)
Definition OM.cpp:415
MLIR_CAPI_EXPORTED bool omTypeIsAListType(MlirType type)
Is the Type a ListType.
Definition OM.cpp:70
MLIR_CAPI_EXPORTED MlirTypeID omFrozenPathTypeGetTypeID(void)
Get the TypeID for a FrozenPathType.
Definition OM.cpp:65
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsABasePath(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a BasePath.
Definition OM.cpp:328
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsNull(OMEvaluatorValue evaluatorValue)
Definition OM.cpp:234
MLIR_CAPI_EXPORTED MlirAttribute omMapAttrGetElementValue(MlirAttribute attr, intptr_t pos)
Definition OM.cpp:445
MLIR_CAPI_EXPORTED intptr_t omEvaluatorTupleGetNumElements(OMEvaluatorValue evaluatorValue)
Get the size of the tuple.
Definition OM.cpp:299
MLIR_CAPI_EXPORTED OMEvaluator omEvaluatorNew(MlirModule mod)
Construct an Evaluator with an IR module.
Definition OM.cpp:122
MLIR_CAPI_EXPORTED OMEvaluatorValue omEvaluatorValueGetReferenceValue(OMEvaluatorValue evaluatorValue)
Dereference a Reference EvaluatorValue.
Definition OM.cpp:353
MLIR_CAPI_EXPORTED MlirLocation omEvaluatorValueGetLoc(OMEvaluatorValue evaluatorValue)
Definition OM.cpp:229
MLIR_CAPI_EXPORTED MlirAttribute omEvaluatorValueGetPrimitive(OMEvaluatorValue evaluatorValue)
Get the Primitive from an EvaluatorValue, which must contain a Primitive.
Definition OM.cpp:252
MLIR_CAPI_EXPORTED OMEvaluatorValue omEvaluatorBasePathGetEmpty(MlirContext context)
Create an empty BasePath.
Definition OM.cpp:332
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsAPath(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a Path.
Definition OM.cpp:336
MLIR_CAPI_EXPORTED bool omTypeIsAAnyType(MlirType type)
Is the Type an AnyType.
Definition OM.cpp:33
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsAMap(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a Map.
Definition OM.cpp:324
MLIR_CAPI_EXPORTED MlirTypeID omFrozenBasePathTypeGetTypeID(void)
Get the TypeID for a FrozenBasePathType.
Definition OM.cpp:55
MLIR_CAPI_EXPORTED MlirModule omEvaluatorGetModule(OMEvaluator evaluator)
Get the Module the Evaluator is built from.
Definition OM.cpp:157
MLIR_CAPI_EXPORTED MlirType omMapTypeGetKeyType(MlirType type)
Return a key type of a map.
Definition OM.cpp:91
MLIR_CAPI_EXPORTED OMEvaluatorValue omEvaluatorInstantiate(OMEvaluator evaluator, MlirAttribute className, intptr_t nActualParams, OMEvaluatorValue *actualParams)
Use the Evaluator to Instantiate an Object from its class name and actual parameters.
Definition OM.cpp:129
MLIR_CAPI_EXPORTED MlirTypeID omClassTypeGetTypeID(void)
Get the TypeID for a ClassType.
Definition OM.cpp:42
MLIR_CAPI_EXPORTED OMEvaluatorValue omEvaluatorMapGetElement(OMEvaluatorValue evaluatorValue, MlirAttribute attr)
Get an element of the map.
Definition OM.cpp:313
MLIR_CAPI_EXPORTED bool omTypeIsAMapType(MlirType type)
Is the Type a MapType.
MLIR_CAPI_EXPORTED intptr_t omEvaluatorListGetNumElements(OMEvaluatorValue evaluatorValue)
Get the length of the list.
Definition OM.cpp:280
MLIR_CAPI_EXPORTED MlirIdentifier omClassTypeGetName(MlirType type)
Get the name for a ClassType.
Definition OM.cpp:45
MLIR_CAPI_EXPORTED bool omAttrIsAReferenceAttr(MlirAttribute attr)
Definition OM.cpp:374
MLIR_CAPI_EXPORTED OMEvaluatorValue omEvaluatorTupleGetElement(OMEvaluatorValue evaluatorValue, intptr_t pos)
Get an element of the tuple.
Definition OM.cpp:306
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsAList(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is an Object.
Definition OM.cpp:267
MLIR_CAPI_EXPORTED MlirType omListTypeGetElementType(MlirType type)
Definition OM.cpp:76
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsATuple(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a Tuple.
Definition OM.cpp:294
MLIR_CAPI_EXPORTED MlirType omEvaluatorMapGetType(OMEvaluatorValue evaluatorValue)
Get the Type from a Map, which will be a MapType.
Definition OM.cpp:193
MLIR_CAPI_EXPORTED bool omTypeIsAFrozenPathType(MlirType type)
Is the Type a FrozenPathType.
Definition OM.cpp:60
MLIR_CAPI_EXPORTED MlirType omEvaluatorObjectGetType(OMEvaluatorValue object)
Get the Type from an Object, which will be a ClassType.
Definition OM.cpp:173
MLIR_CAPI_EXPORTED bool omAttrIsAIntegerAttr(MlirAttribute attr)
Definition OM.cpp:387
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(OM, om)
MLIR_CAPI_EXPORTED bool omTypeIsAStringType(MlirType type)
Is the Type a StringType.
Definition OM.cpp:81
MLIR_CAPI_EXPORTED OMEvaluatorValue omEvaluatorListGetElement(OMEvaluatorValue evaluatorValue, intptr_t pos)
Get an element of the list.
Definition OM.cpp:287
MLIR_CAPI_EXPORTED bool omTypeIsAClassType(MlirType type)
Is the Type a ClassType.
Definition OM.cpp:39
MLIR_CAPI_EXPORTED bool omEvaluatorObjectIsNull(OMEvaluatorValue object)
Query if the Object is null.
Definition OM.cpp:167
MLIR_CAPI_EXPORTED intptr_t omMapAttrGetNumElements(MlirAttribute attr)
Definition OM.cpp:435
MLIR_CAPI_EXPORTED MlirStringRef omIntegerAttrToString(MlirAttribute attr)
Get a string representation of an om::IntegerAttr.
Definition OM.cpp:402
MLIR_CAPI_EXPORTED MlirIdentifier omMapAttrGetElementKey(MlirAttribute attr, intptr_t pos)
Definition OM.cpp:440
MLIR_CAPI_EXPORTED OMEvaluatorValue omEvaluatorValueFromPrimitive(MlirAttribute primitive)
Get the EvaluatorValue from a Primitive value.
Definition OM.cpp:261
MLIR_CAPI_EXPORTED MlirAttribute omIntegerAttrGet(MlirAttribute attr)
Get an om::IntegerAttr from mlir::IntegerAttr.
Definition OM.cpp:395
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsAObject(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is an Object.
Definition OM.cpp:240
MLIR_CAPI_EXPORTED MlirAttribute omListAttrGetElement(MlirAttribute attr, intptr_t pos)
Definition OM.cpp:424
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsAPrimitive(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a Primitive.
Definition OM.cpp:246
MLIR_CAPI_EXPORTED OMEvaluatorValue omEvaluatorObjectGetField(OMEvaluatorValue object, MlirAttribute name)
Get a field from an Object, which must contain a field of that name.
Definition OM.cpp:203
MLIR_CAPI_EXPORTED MlirAttribute omEvaluatorMapGetKeys(OMEvaluatorValue object)
Get an ArrayAttr with the keys in a Map.
Definition OM.cpp:198
MLIR_CAPI_EXPORTED MlirContext omEvaluatorValueGetContext(OMEvaluatorValue evaluatorValue)
Definition OM.cpp:224
MLIR_CAPI_EXPORTED MlirAttribute omEvaluatorObjectGetFieldNames(OMEvaluatorValue object)
Get all the field names from an Object, can be empty if object has no fields.
Definition OM.cpp:189
MLIR_CAPI_EXPORTED bool omAttrIsAMapAttr(MlirAttribute attr)
Definition OM.cpp:433
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsAReference(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a Reference.
Definition OM.cpp:346
MLIR_CAPI_EXPORTED MlirTypeID omAnyTypeGetTypeID(void)
Get the TypeID for an AnyType.
Definition OM.cpp:36
MLIR_CAPI_EXPORTED MlirAttribute omEvaluatorPathGetAsString(OMEvaluatorValue evaluatorValue)
Get a string representation of a Path.
Definition OM.cpp:340
MLIR_CAPI_EXPORTED MlirAttribute omReferenceAttrGetInnerRef(MlirAttribute attr)
Definition OM.cpp:378
MLIR_CAPI_EXPORTED MlirAttribute omIntegerAttrGetInt(MlirAttribute attr)
Given an om::IntegerAttr, return the mlir::IntegerAttr.
Definition OM.cpp:391
Definition om.py:1
A value type for use in C APIs that just wraps a pointer to an Object.
Definition OM.h:90
void * ptr
Definition OM.h:91
A value type for use in C APIs that just wraps a pointer to an Evaluator.
Definition OM.h:79
void * ptr
Definition OM.h:80