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