Loading [MathJax]/extensions/tex2jax.js
CIRCT 22.0.0git
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 StringType.
65MLIR_CAPI_EXPORTED bool omTypeIsAStringType(MlirType type);
66
67/// Get the TypeID for a StringType.
68MLIR_CAPI_EXPORTED MlirTypeID omStringTypeGetTypeID(void);
69
70/// Get a StringType.
71MLIR_CAPI_EXPORTED MlirType omStringTypeGet(MlirContext ctx);
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 BasePath.
185MLIR_CAPI_EXPORTED bool
187
188/// Create an empty BasePath.
189MLIR_CAPI_EXPORTED OMEvaluatorValue
190omEvaluatorBasePathGetEmpty(MlirContext context);
191
192/// Query if the EvaluatorValue is a Path.
193MLIR_CAPI_EXPORTED bool
195
196/// Get a string representation of a Path.
197MLIR_CAPI_EXPORTED MlirAttribute
199
200/// Query if the EvaluatorValue is a Reference.
201MLIR_CAPI_EXPORTED bool
203
204/// Dereference a Reference EvaluatorValue. Emits an error and returns null if
205/// the Reference cannot be dereferenced.
206MLIR_CAPI_EXPORTED OMEvaluatorValue
208
209//===----------------------------------------------------------------------===//
210// ReferenceAttr API
211//===----------------------------------------------------------------------===//
212
213MLIR_CAPI_EXPORTED bool omAttrIsAReferenceAttr(MlirAttribute attr);
214
215MLIR_CAPI_EXPORTED MlirAttribute omReferenceAttrGetInnerRef(MlirAttribute attr);
216
217//===----------------------------------------------------------------------===//
218// IntegerAttr API
219//===----------------------------------------------------------------------===//
220
221MLIR_CAPI_EXPORTED bool omAttrIsAIntegerAttr(MlirAttribute attr);
222
223/// Given an om::IntegerAttr, return the mlir::IntegerAttr.
224MLIR_CAPI_EXPORTED MlirAttribute omIntegerAttrGetInt(MlirAttribute attr);
225
226/// Get an om::IntegerAttr from mlir::IntegerAttr.
227MLIR_CAPI_EXPORTED MlirAttribute omIntegerAttrGet(MlirAttribute attr);
228
229/// Get a string representation of an om::IntegerAttr.
230MLIR_CAPI_EXPORTED MlirStringRef omIntegerAttrToString(MlirAttribute attr);
231
232//===----------------------------------------------------------------------===//
233// ListAttr API
234//===----------------------------------------------------------------------===//
235
236MLIR_CAPI_EXPORTED bool omAttrIsAListAttr(MlirAttribute attr);
237
238MLIR_CAPI_EXPORTED intptr_t omListAttrGetNumElements(MlirAttribute attr);
239
240MLIR_CAPI_EXPORTED MlirAttribute omListAttrGetElement(MlirAttribute attr,
241 intptr_t pos);
242
243MLIR_CAPI_EXPORTED MlirAttribute omListAttrGet(MlirType elementType,
244 intptr_t numElements,
245 const MlirAttribute *elements);
246
247#ifdef __cplusplus
248}
249#endif
250
251#endif // CIRCT_C_DIALECT_OM_H
MlirType uint64_t numElements
Definition CHIRRTL.cpp:30
MlirType elementType
Definition CHIRRTL.cpp:29
MLIR_CAPI_EXPORTED bool omEvaluatorObjectIsEq(OMEvaluatorValue object, OMEvaluatorValue other)
Check equality of two objects.
Definition OM.cpp:181
MLIR_CAPI_EXPORTED intptr_t omListAttrGetNumElements(MlirAttribute attr)
Definition OM.cpp:373
MLIR_CAPI_EXPORTED unsigned omEvaluatorObjectGetHash(OMEvaluatorValue object)
Get the object hash.
Definition OM.cpp:176
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 MlirAttribute omListAttrGet(MlirType elementType, intptr_t numElements, const MlirAttribute *elements)
Definition OM.cpp:383
MLIR_CAPI_EXPORTED bool omAttrIsAListAttr(MlirAttribute attr)
Definition OM.cpp:369
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:282
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsNull(OMEvaluatorValue evaluatorValue)
Definition OM.cpp:223
MLIR_CAPI_EXPORTED OMEvaluator omEvaluatorNew(MlirModule mod)
Construct an Evaluator with an IR module.
Definition OM.cpp:120
MLIR_CAPI_EXPORTED OMEvaluatorValue omEvaluatorValueGetReferenceValue(OMEvaluatorValue evaluatorValue)
Dereference a Reference EvaluatorValue.
Definition OM.cpp:307
MLIR_CAPI_EXPORTED MlirLocation omEvaluatorValueGetLoc(OMEvaluatorValue evaluatorValue)
Definition OM.cpp:218
MLIR_CAPI_EXPORTED MlirAttribute omEvaluatorValueGetPrimitive(OMEvaluatorValue evaluatorValue)
Get the Primitive from an EvaluatorValue, which must contain a Primitive.
Definition OM.cpp:241
MLIR_CAPI_EXPORTED OMEvaluatorValue omEvaluatorBasePathGetEmpty(MlirContext context)
Create an empty BasePath.
Definition OM.cpp:286
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsAPath(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a Path.
Definition OM.cpp:290
MLIR_CAPI_EXPORTED bool omTypeIsAAnyType(MlirType type)
Is the Type an AnyType.
Definition OM.cpp:33
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:155
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:127
MLIR_CAPI_EXPORTED MlirTypeID omClassTypeGetTypeID(void)
Get the TypeID for a ClassType.
Definition OM.cpp:42
MLIR_CAPI_EXPORTED intptr_t omEvaluatorListGetNumElements(OMEvaluatorValue evaluatorValue)
Get the length of the list.
Definition OM.cpp:269
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:328
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsAList(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is an Object.
Definition OM.cpp:256
MLIR_CAPI_EXPORTED MlirType omListTypeGetElementType(MlirType type)
Definition OM.cpp:76
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:171
MLIR_CAPI_EXPORTED bool omAttrIsAIntegerAttr(MlirAttribute attr)
Definition OM.cpp:341
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:276
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:165
MLIR_CAPI_EXPORTED MlirStringRef omIntegerAttrToString(MlirAttribute attr)
Get a string representation of an om::IntegerAttr.
Definition OM.cpp:356
MLIR_CAPI_EXPORTED OMEvaluatorValue omEvaluatorValueFromPrimitive(MlirAttribute primitive)
Get the EvaluatorValue from a Primitive value.
Definition OM.cpp:250
MLIR_CAPI_EXPORTED MlirAttribute omIntegerAttrGet(MlirAttribute attr)
Get an om::IntegerAttr from mlir::IntegerAttr.
Definition OM.cpp:349
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsAObject(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is an Object.
Definition OM.cpp:229
MLIR_CAPI_EXPORTED MlirAttribute omListAttrGetElement(MlirAttribute attr, intptr_t pos)
Definition OM.cpp:378
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsAPrimitive(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a Primitive.
Definition OM.cpp:235
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:192
MLIR_CAPI_EXPORTED MlirTypeID omStringTypeGetTypeID(void)
Get the TypeID for a StringType.
Definition OM.cpp:91
MLIR_CAPI_EXPORTED MlirContext omEvaluatorValueGetContext(OMEvaluatorValue evaluatorValue)
Definition OM.cpp:213
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:187
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsAReference(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a Reference.
Definition OM.cpp:300
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:294
MLIR_CAPI_EXPORTED MlirType omStringTypeGet(MlirContext ctx)
Get a StringType.
Definition OM.cpp:86
MLIR_CAPI_EXPORTED MlirAttribute omReferenceAttrGetInnerRef(MlirAttribute attr)
Definition OM.cpp:332
MLIR_CAPI_EXPORTED MlirAttribute omIntegerAttrGetInt(MlirAttribute attr)
Given an om::IntegerAttr, return the mlir::IntegerAttr.
Definition OM.cpp:345
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