CIRCT 21.0.0git
Loading...
Searching...
No Matches
OM.cpp
Go to the documentation of this file.
1//===- OM.cpp - C interface for the OM 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
13#include "mlir/CAPI/Registration.h"
14#include "mlir/CAPI/Wrap.h"
15#include "mlir/IR/Location.h"
16#include "llvm/ADT/Hashing.h"
17#include "llvm/Support/Casting.h"
18
19using namespace mlir;
20using namespace circt::om;
21
22//===----------------------------------------------------------------------===//
23// Dialect API.
24//===----------------------------------------------------------------------===//
25
27
28//===----------------------------------------------------------------------===//
29// Type API.
30//===----------------------------------------------------------------------===//
31
32/// Is the Type an AnyType.
33bool omTypeIsAAnyType(MlirType type) { return isa<AnyType>(unwrap(type)); }
34
35/// Get the TypeID for an AnyType.
36MlirTypeID omAnyTypeGetTypeID(void) { return wrap(AnyType::getTypeID()); }
37
38/// Is the Type a ClassType.
39bool omTypeIsAClassType(MlirType type) { return isa<ClassType>(unwrap(type)); }
40
41/// Get the TypeID for a ClassType.
42MlirTypeID omClassTypeGetTypeID() { return wrap(ClassType::getTypeID()); }
43
44/// Get the name for a ClassType.
45MlirIdentifier omClassTypeGetName(MlirType type) {
46 return wrap(cast<ClassType>(unwrap(type)).getClassName().getAttr());
47}
48
49/// Is the Type a FrozenBasePathType.
50bool omTypeIsAFrozenBasePathType(MlirType type) {
51 return isa<FrozenBasePathType>(unwrap(type));
52}
53
54/// Get the TypeID for a FrozenBasePathType.
56 return wrap(FrozenBasePathType::getTypeID());
57}
58
59/// Is the Type a FrozenPathType.
60bool omTypeIsAFrozenPathType(MlirType type) {
61 return isa<FrozenPathType>(unwrap(type));
62}
63
64/// Get the TypeID for a FrozenPathType.
65MlirTypeID omFrozenPathTypeGetTypeID(void) {
66 return wrap(FrozenPathType::getTypeID());
67}
68
69/// Is the Type a ListType.
70bool omTypeIsAListType(MlirType type) { return isa<ListType>(unwrap(type)); }
71
72/// Get the TypeID for a ListType.
73MlirTypeID omListTypeGetTypeID(void) { return wrap(ListType::getTypeID()); }
74
75// Return a element type of a ListType.
76MlirType omListTypeGetElementType(MlirType type) {
77 return wrap(cast<ListType>(unwrap(type)).getElementType());
78}
79
80/// Is the Type a StringType.
81bool omTypeIsAStringType(MlirType type) {
82 return isa<StringType>(unwrap(type));
83}
84
85/// Get a StringType.
86MlirType omStringTypeGet(MlirContext ctx) {
87 return wrap(StringType::get(unwrap(ctx)));
88}
89
90/// Get the TypeID for a StringType.
91MlirTypeID omStringTypeGetTypeID(void) { return wrap(StringType::getTypeID()); }
92
93/// Is the Type a MapType.
94bool omTypeIsAMapType(MlirType type) { return isa<MapType>(unwrap(type)); }
95
96/// Return a key type of a map.
97MlirType omMapTypeGetKeyType(MlirType type) {
98 return wrap(cast<MapType>(unwrap(type)).getKeyType());
99}
100
101//===----------------------------------------------------------------------===//
102// Evaluator data structures.
103//===----------------------------------------------------------------------===//
104
106
107/// Define our own wrap and unwrap instead of using the usual macro. This is To
108/// handle the std::shared_ptr reference counts appropriately. We want to always
109/// create *new* shared pointers to the EvaluatorValue when we wrap it for C, to
110/// increment the reference count. We want to use the shared_from_this
111/// functionality to ensure it is unwrapped into C++ with the correct reference
112/// count.
113
115 return OMEvaluatorValue{
116 static_cast<void *>((new EvaluatorValuePtr(std::move(object)))->get())};
117}
118
120 return static_cast<evaluator::EvaluatorValue *>(c.ptr)->shared_from_this();
121}
122
123//===----------------------------------------------------------------------===//
124// Evaluator API.
125//===----------------------------------------------------------------------===//
126
127/// Construct an Evaluator with an IR module.
129 // Just allocate and wrap the Evaluator.
130 return wrap(new Evaluator(unwrap(mod)));
131}
132
133/// Use the Evaluator to Instantiate an Object from its class name and actual
134/// parameters.
136 MlirAttribute className,
137 intptr_t nActualParams,
138 OMEvaluatorValue *actualParams) {
139 // Unwrap the Evaluator.
140 Evaluator *cppEvaluator = unwrap(evaluator);
141
142 // Unwrap the className, which the client must supply as a StringAttr.
143 StringAttr cppClassName = cast<StringAttr>(unwrap(className));
144
145 // Unwrap the actual parameters.
146 SmallVector<std::shared_ptr<evaluator::EvaluatorValue>> cppActualParams;
147 for (unsigned i = 0; i < nActualParams; i++)
148 cppActualParams.push_back(unwrap(actualParams[i]));
149
150 // Invoke the Evaluator to instantiate the Object.
151 auto result = cppEvaluator->instantiate(cppClassName, cppActualParams);
152
153 // If instantiation failed, return a null Object. A Diagnostic will be emitted
154 // in this case.
155 if (failed(result))
156 return OMEvaluatorValue();
157
158 // Wrap and return the Object.
159 return wrap(result.value());
160}
161
162/// Get the Module the Evaluator is built from.
163MlirModule omEvaluatorGetModule(OMEvaluator evaluator) {
164 // Just unwrap the Evaluator, get the Module, and wrap it.
165 return wrap(unwrap(evaluator)->getModule());
166}
167
168//===----------------------------------------------------------------------===//
169// Object API.
170//===----------------------------------------------------------------------===//
171
172/// Query if the Object is null.
174 // Just check if the Object shared pointer is null.
175 return !object.ptr;
176}
177
178/// Get the Type from an Object, which will be a ClassType.
180 return wrap(llvm::cast<Object>(unwrap(object).get())->getType());
181}
182
183/// Get the hash for the object.
185 return llvm::hash_value(llvm::cast<Object>(unwrap(object).get()));
186}
187
188/// Check if two objects are same.
190 return llvm::cast<Object>(unwrap(object).get()) ==
191 llvm::cast<Object>(unwrap(other).get());
192}
193
194/// Get an ArrayAttr with the names of the fields in an Object.
196 return wrap(llvm::cast<Object>(unwrap(object).get())->getFieldNames());
197}
198
200 return wrap(llvm::cast<evaluator::MapValue>(unwrap(value).get())->getType());
201}
202
203/// Get an ArrayAttr with the keys in a Map.
205 return wrap(llvm::cast<evaluator::MapValue>(unwrap(object).get())->getKeys());
206}
207
208/// Get a field from an Object, which must contain a field of that name.
210 MlirAttribute name) {
211 // Unwrap the Object and get the field of the name, which the client must
212 // supply as a StringAttr.
213 FailureOr<EvaluatorValuePtr> result =
214 llvm::cast<Object>(unwrap(object).get())
215 ->getField(cast<StringAttr>(unwrap(name)));
216
217 // If getField failed, return a null EvaluatorValue. A Diagnostic will be
218 // emitted in this case.
219 if (failed(result))
220 return OMEvaluatorValue();
221
222 return OMEvaluatorValue{wrap(result.value())};
223}
224
225//===----------------------------------------------------------------------===//
226// EvaluatorValue API.
227//===----------------------------------------------------------------------===//
228
229// Get a context from an EvaluatorValue.
230MlirContext omEvaluatorValueGetContext(OMEvaluatorValue evaluatorValue) {
231 return wrap(unwrap(evaluatorValue)->getContext());
232}
233
234// Get location from an EvaluatorValue.
235MlirLocation omEvaluatorValueGetLoc(OMEvaluatorValue evaluatorValue) {
236 return wrap(unwrap(evaluatorValue)->getLoc());
237}
238
239// Query if the EvaluatorValue is null.
241 // Check if the pointer is null.
242 return !evaluatorValue.ptr;
243}
244
245/// Query if the EvaluatorValue is an Object.
247 // Check if the Object is non-null.
248 return isa<evaluator::ObjectValue>(unwrap(evaluatorValue).get());
249}
250
251/// Query if the EvaluatorValue is a Primitive.
253 // Check if the Attribute is non-null.
254 return isa<evaluator::AttributeValue>(unwrap(evaluatorValue).get());
255}
256
257/// Get the Primitive from an EvaluatorValue, which must contain a Primitive.
258MlirAttribute omEvaluatorValueGetPrimitive(OMEvaluatorValue evaluatorValue) {
259 // Assert the Attribute is non-null, and return it.
260 assert(omEvaluatorValueIsAPrimitive(evaluatorValue));
261 return wrap(
262 llvm::cast<evaluator::AttributeValue>(unwrap(evaluatorValue).get())
263 ->getAttr());
264}
265
266/// Get the Primitive from an EvaluatorValue, which must contain a Primitive.
268 // Assert the Attribute is non-null, and return it.
269 return wrap(evaluator::AttributeValue::get(unwrap(primitive)));
270}
271
272/// Query if the EvaluatorValue is a List.
274 return isa<evaluator::ListValue>(unwrap(evaluatorValue).get());
275}
276
277/// Get the List from an EvaluatorValue, which must contain a List.
278/// TODO: This can be removed.
280 // Assert the List is non-null, and return it.
281 assert(omEvaluatorValueIsAList(evaluatorValue));
282 return evaluatorValue;
283}
284
285/// Get the length of the List.
287 return cast<evaluator::ListValue>(unwrap(evaluatorValue).get())
288 ->getElements()
289 .size();
290}
291
292/// Get an element of the List.
294 intptr_t pos) {
295 return wrap(cast<evaluator::ListValue>(unwrap(evaluatorValue).get())
296 ->getElements()[pos]);
297}
298
299/// Query if the EvaluatorValue is a Tuple.
301 return isa<evaluator::TupleValue>(unwrap(evaluatorValue).get());
302}
303
304/// Get the length of the Tuple.
306 return cast<evaluator::TupleValue>(unwrap(evaluatorValue).get())
307 ->getElements()
308 .size();
309}
310
311/// Get an element of the Tuple.
313 intptr_t pos) {
314 return wrap(cast<evaluator::TupleValue>(unwrap(evaluatorValue).get())
315 ->getElements()[pos]);
316}
317
318/// Get an element of the Map.
320 MlirAttribute attr) {
321 const auto &elements =
322 cast<evaluator::MapValue>(unwrap(evaluatorValue).get())->getElements();
323 const auto &it = elements.find(unwrap(attr));
324 if (it != elements.end())
325 return wrap(it->second);
326 return OMEvaluatorValue{nullptr};
327}
328
329/// Query if the EvaluatorValue is a map.
331 return isa<evaluator::MapValue>(unwrap(evaluatorValue).get());
332}
333
335 return isa<evaluator::BasePathValue>(unwrap(evaluatorValue).get());
336}
337
339 return wrap(std::make_shared<evaluator::BasePathValue>(unwrap(context)));
340}
341
343 return isa<evaluator::PathValue>(unwrap(evaluatorValue).get());
344}
345
346MlirAttribute omEvaluatorPathGetAsString(OMEvaluatorValue evaluatorValue) {
347 const auto *path = cast<evaluator::PathValue>(unwrap(evaluatorValue).get());
348 return wrap((Attribute)path->getAsString());
349}
350
351/// Query if the EvaluatorValue is a Reference.
353 return isa<evaluator::ReferenceValue>(unwrap(evaluatorValue).get());
354}
355
356/// Dereference a Reference EvaluatorValue. Emits an error and returns null if
357/// the Reference cannot be dereferenced.
360 // Assert the EvaluatorValue is a Reference.
361 assert(omEvaluatorValueIsAReference(evaluatorValue));
362
363 // Attempt to get the final EvaluatorValue from the Reference.
364 auto result =
365 llvm::cast<evaluator::ReferenceValue>(unwrap(evaluatorValue).get())
366 ->getStrippedValue();
367
368 // If this failed, an error diagnostic has been emitted, and we return null.
369 if (failed(result))
370 return {};
371
372 // If this succeeded, wrap the EvaluatorValue and return it.
373 return wrap(result.value());
374}
375
376//===----------------------------------------------------------------------===//
377// ReferenceAttr API.
378//===----------------------------------------------------------------------===//
379
380bool omAttrIsAReferenceAttr(MlirAttribute attr) {
381 return isa<ReferenceAttr>(unwrap(attr));
382}
383
384MlirAttribute omReferenceAttrGetInnerRef(MlirAttribute referenceAttr) {
385 return wrap(
386 (Attribute)cast<ReferenceAttr>(unwrap(referenceAttr)).getInnerRef());
387}
388
389//===----------------------------------------------------------------------===//
390// IntegerAttr API.
391//===----------------------------------------------------------------------===//
392
393bool omAttrIsAIntegerAttr(MlirAttribute attr) {
394 return isa<circt::om::IntegerAttr>(unwrap(attr));
395}
396
397MlirAttribute omIntegerAttrGetInt(MlirAttribute attr) {
398 return wrap(cast<circt::om::IntegerAttr>(unwrap(attr)).getValue());
399}
400
401MlirAttribute omIntegerAttrGet(MlirAttribute attr) {
402 auto integerAttr = cast<mlir::IntegerAttr>(unwrap(attr));
403 return wrap(
404 circt::om::IntegerAttr::get(integerAttr.getContext(), integerAttr));
405}
406
407/// Get a string representation of an om::IntegerAttr.
408MlirStringRef omIntegerAttrToString(MlirAttribute attr) {
409 mlir::IntegerAttr integerAttr =
410 cast<circt::om::IntegerAttr>(unwrap(attr)).getValue();
411 SmallVector<char> str;
412 integerAttr.getValue().toString(
413 str, /*Radix=*/10, /*Signed=*/integerAttr.getType().isSignedInteger());
414 return wrap(StringAttr::get(integerAttr.getContext(), str).getValue());
415}
416
417//===----------------------------------------------------------------------===//
418// ListAttr API.
419//===----------------------------------------------------------------------===//
420
421bool omAttrIsAListAttr(MlirAttribute attr) {
422 return isa<ListAttr>(unwrap(attr));
423}
424
425intptr_t omListAttrGetNumElements(MlirAttribute attr) {
426 auto listAttr = llvm::cast<ListAttr>(unwrap(attr));
427 return static_cast<intptr_t>(listAttr.getElements().size());
428}
429
430MlirAttribute omListAttrGetElement(MlirAttribute attr, intptr_t pos) {
431 auto listAttr = llvm::cast<ListAttr>(unwrap(attr));
432 return wrap(listAttr.getElements()[pos]);
433}
434
435MlirAttribute omListAttrGet(MlirType elementType, intptr_t numElements,
436 const MlirAttribute *elements) {
437 SmallVector<Attribute, 8> attrs;
438 (void)unwrapList(static_cast<size_t>(numElements), elements, attrs);
439 auto type = unwrap(elementType);
440 auto *ctx = type.getContext();
441 return wrap(ListAttr::get(ctx, type, ArrayAttr::get(ctx, attrs)));
442}
443
444//===----------------------------------------------------------------------===//
445// MapAttr API.
446//===----------------------------------------------------------------------===//
447
448bool omAttrIsAMapAttr(MlirAttribute attr) { return isa<MapAttr>(unwrap(attr)); }
449
450intptr_t omMapAttrGetNumElements(MlirAttribute attr) {
451 auto mapAttr = llvm::cast<MapAttr>(unwrap(attr));
452 return static_cast<intptr_t>(mapAttr.getElements().size());
453}
454
455MlirIdentifier omMapAttrGetElementKey(MlirAttribute attr, intptr_t pos) {
456 auto mapAttr = llvm::cast<MapAttr>(unwrap(attr));
457 return wrap(mapAttr.getElements().getValue()[pos].getName());
458}
459
460MlirAttribute omMapAttrGetElementValue(MlirAttribute attr, intptr_t pos) {
461 auto mapAttr = llvm::cast<MapAttr>(unwrap(attr));
462 return wrap(mapAttr.getElements().getValue()[pos].getValue());
463}
DEFINE_C_API_PTR_METHODS(CirctFirtoolFirtoolOptions, circt::firtool::FirtoolOptions) CirctFirtoolFirtoolOptions circtFirtoolOptionsCreateDefault()
Definition Firtool.cpp:18
assert(baseType &&"element must be base type")
MlirType uint64_t numElements
Definition CHIRRTL.cpp:30
MlirType elementType
Definition CHIRRTL.cpp:29
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(CHIRRTL, chirrtl, circt::chirrtl::CHIRRTLDialect) MlirType chirrtlTypeGetCMemory(MlirContext ctx
static Location getLoc(DefSlot slot)
Definition Mem2Reg.cpp:217
bool omTypeIsAFrozenBasePathType(MlirType type)
Is the Type a FrozenBasePathType.
Definition OM.cpp:50
bool omEvaluatorValueIsABasePath(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a BasePath.
Definition OM.cpp:334
MlirAttribute omMapAttrGetElementValue(MlirAttribute attr, intptr_t pos)
Definition OM.cpp:460
bool omEvaluatorValueIsNull(OMEvaluatorValue evaluatorValue)
Definition OM.cpp:240
MlirContext omEvaluatorValueGetContext(OMEvaluatorValue evaluatorValue)
Definition OM.cpp:230
MlirAttribute omReferenceAttrGetInnerRef(MlirAttribute referenceAttr)
Definition OM.cpp:384
bool omTypeIsAStringType(MlirType type)
Is the Type a StringType.
Definition OM.cpp:81
static OMEvaluatorValue wrap(EvaluatorValuePtr object)
Define our own wrap and unwrap instead of using the usual macro.
Definition OM.cpp:114
MlirAttribute omEvaluatorPathGetAsString(OMEvaluatorValue evaluatorValue)
Get a string representation of a Path.
Definition OM.cpp:346
bool omEvaluatorValueIsAPath(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a Path.
Definition OM.cpp:342
MlirIdentifier omMapAttrGetElementKey(MlirAttribute attr, intptr_t pos)
Definition OM.cpp:455
bool omAttrIsAListAttr(MlirAttribute attr)
Definition OM.cpp:421
OMEvaluatorValue omEvaluatorListGetElement(OMEvaluatorValue evaluatorValue, intptr_t pos)
Get an element of the List.
Definition OM.cpp:293
bool omTypeIsAMapType(MlirType type)
Is the Type a MapType.
Definition OM.cpp:94
OMEvaluatorValue omEvaluatorValueFromPrimitive(MlirAttribute primitive)
Get the Primitive from an EvaluatorValue, which must contain a Primitive.
Definition OM.cpp:267
MlirStringRef omIntegerAttrToString(MlirAttribute attr)
Get a string representation of an om::IntegerAttr.
Definition OM.cpp:408
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:135
MlirType omEvaluatorMapGetType(OMEvaluatorValue value)
Get the Type from a Map, which will be a MapType.
Definition OM.cpp:199
intptr_t omListAttrGetNumElements(MlirAttribute attr)
Definition OM.cpp:425
MlirAttribute omEvaluatorObjectGetFieldNames(OMEvaluatorValue object)
Get an ArrayAttr with the names of the fields in an Object.
Definition OM.cpp:195
bool omAttrIsAIntegerAttr(MlirAttribute attr)
Definition OM.cpp:393
OMEvaluatorValue omEvaluatorObjectGetField(OMEvaluatorValue object, MlirAttribute name)
Get a field from an Object, which must contain a field of that name.
Definition OM.cpp:209
MlirLocation omEvaluatorValueGetLoc(OMEvaluatorValue evaluatorValue)
Definition OM.cpp:235
bool omEvaluatorValueIsAMap(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a map.
Definition OM.cpp:330
MlirTypeID omListTypeGetTypeID(void)
Get the TypeID for a ListType.
Definition OM.cpp:73
MlirType omMapTypeGetKeyType(MlirType type)
Return a key type of a map.
Definition OM.cpp:97
MlirTypeID omFrozenBasePathTypeGetTypeID(void)
Get the TypeID for a FrozenBasePathType.
Definition OM.cpp:55
MlirTypeID omStringTypeGetTypeID(void)
Get the TypeID for a StringType.
Definition OM.cpp:91
MlirType omStringTypeGet(MlirContext ctx)
Get a StringType.
Definition OM.cpp:86
bool omTypeIsAClassType(MlirType type)
Is the Type a ClassType.
Definition OM.cpp:39
OMEvaluatorValue omEvaluatorTupleGetElement(OMEvaluatorValue evaluatorValue, intptr_t pos)
Get an element of the Tuple.
Definition OM.cpp:312
MlirIdentifier omClassTypeGetName(MlirType type)
Get the name for a ClassType.
Definition OM.cpp:45
OMEvaluatorValue omEvaluatorValueGetReferenceValue(OMEvaluatorValue evaluatorValue)
Dereference a Reference EvaluatorValue.
Definition OM.cpp:359
bool omTypeIsAListType(MlirType type)
Is the Type a ListType.
Definition OM.cpp:70
intptr_t omEvaluatorListGetNumElements(OMEvaluatorValue evaluatorValue)
Get the length of the List.
Definition OM.cpp:286
MlirAttribute omListAttrGet(MlirType elementType, intptr_t numElements, const MlirAttribute *elements)
Definition OM.cpp:435
MlirAttribute omEvaluatorValueGetPrimitive(OMEvaluatorValue evaluatorValue)
Get the Primitive from an EvaluatorValue, which must contain a Primitive.
Definition OM.cpp:258
MlirAttribute omEvaluatorMapGetKeys(OMEvaluatorValue object)
Get an ArrayAttr with the keys in a Map.
Definition OM.cpp:204
MlirAttribute omIntegerAttrGetInt(MlirAttribute attr)
Given an om::IntegerAttr, return the mlir::IntegerAttr.
Definition OM.cpp:397
bool omEvaluatorValueIsAList(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a List.
Definition OM.cpp:273
bool omTypeIsAFrozenPathType(MlirType type)
Is the Type a FrozenPathType.
Definition OM.cpp:60
bool omAttrIsAMapAttr(MlirAttribute attr)
Definition OM.cpp:448
OMEvaluatorValue omEvaluatorMapGetElement(OMEvaluatorValue evaluatorValue, MlirAttribute attr)
Get an element of the Map.
Definition OM.cpp:319
bool omEvaluatorValueIsAPrimitive(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a Primitive.
Definition OM.cpp:252
bool omEvaluatorValueIsATuple(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a Tuple.
Definition OM.cpp:300
bool omEvaluatorObjectIsNull(OMEvaluatorValue object)
Query if the Object is null.
Definition OM.cpp:173
MlirModule omEvaluatorGetModule(OMEvaluator evaluator)
Get the Module the Evaluator is built from.
Definition OM.cpp:163
OMEvaluator omEvaluatorNew(MlirModule mod)
Construct an Evaluator with an IR module.
Definition OM.cpp:128
OMEvaluatorValue omEvaluatorBasePathGetEmpty(MlirContext context)
Create an empty BasePath.
Definition OM.cpp:338
MlirAttribute omListAttrGetElement(MlirAttribute attr, intptr_t pos)
Definition OM.cpp:430
bool omTypeIsAAnyType(MlirType type)
Is the Type an AnyType.
Definition OM.cpp:33
MlirTypeID omAnyTypeGetTypeID(void)
Get the TypeID for an AnyType.
Definition OM.cpp:36
MlirTypeID omFrozenPathTypeGetTypeID(void)
Get the TypeID for a FrozenPathType.
Definition OM.cpp:65
intptr_t omMapAttrGetNumElements(MlirAttribute attr)
Definition OM.cpp:450
MlirType omEvaluatorObjectGetType(OMEvaluatorValue object)
Get the Type from an Object, which will be a ClassType.
Definition OM.cpp:179
intptr_t omEvaluatorTupleGetNumElements(OMEvaluatorValue evaluatorValue)
Get the length of the Tuple.
Definition OM.cpp:305
bool omAttrIsAReferenceAttr(MlirAttribute attr)
Definition OM.cpp:380
static EvaluatorValuePtr unwrap(OMEvaluatorValue c)
Definition OM.cpp:119
MlirAttribute omIntegerAttrGet(MlirAttribute attr)
Get an om::IntegerAttr from mlir::IntegerAttr.
Definition OM.cpp:401
OMEvaluatorValue omEvaluatorValueGetList(OMEvaluatorValue evaluatorValue)
Get the List from an EvaluatorValue, which must contain a List.
Definition OM.cpp:279
bool omEvaluatorValueIsAObject(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is an Object.
Definition OM.cpp:246
MlirType omListTypeGetElementType(MlirType type)
Definition OM.cpp:76
MlirTypeID omClassTypeGetTypeID()
Get the TypeID for a ClassType.
Definition OM.cpp:42
bool omEvaluatorValueIsAReference(OMEvaluatorValue evaluatorValue)
Query if the EvaluatorValue is a Reference.
Definition OM.cpp:352
unsigned omEvaluatorObjectGetHash(OMEvaluatorValue object)
Get the hash for the object.
Definition OM.cpp:184
bool omEvaluatorObjectIsEq(OMEvaluatorValue object, OMEvaluatorValue other)
Check if two objects are same.
Definition OM.cpp:189
evaluator::EvaluatorValuePtr EvaluatorValuePtr
Definition Evaluator.h:421
Definition om.py:1
A value type for use in C APIs that just wraps a pointer to an Object.
Definition OM.h:96
void * ptr
Definition OM.h:97
A value type for use in C APIs that just wraps a pointer to an Evaluator.
Definition OM.h:85
An Evaluator, which is constructed with an IR module and can instantiate Objects.
Definition Evaluator.h:429
FailureOr< evaluator::EvaluatorValuePtr > instantiate(StringAttr className, ArrayRef< EvaluatorValuePtr > actualParams)
Instantiate an Object with its class name and actual parameters.
friend std::shared_ptr< EvaluatorValue > get(Attribute attr, LocationAttr loc)
Base class for evaluator runtime values.
Definition Evaluator.h:48