CIRCT  18.0.0git
Evaluator.h
Go to the documentation of this file.
1 //===- Evaluator.h - Object Model dialect evaluator -----------------------===//
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 // This file contains the Object Model dialect declaration.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef CIRCT_DIALECT_OM_EVALUATOR_EVALUATOR_H
14 #define CIRCT_DIALECT_OM_EVALUATOR_EVALUATOR_H
15 
16 #include "circt/Dialect/OM/OMOps.h"
17 #include "circt/Support/LLVM.h"
18 #include "mlir/IR/BuiltinOps.h"
19 #include "mlir/IR/Diagnostics.h"
20 #include "mlir/IR/Location.h"
21 #include "mlir/IR/MLIRContext.h"
22 #include "mlir/IR/SymbolTable.h"
23 #include "mlir/Support/LogicalResult.h"
24 #include "llvm/ADT/SmallPtrSet.h"
25 #include "llvm/ADT/SmallString.h"
26 
27 #include <queue>
28 #include <utility>
29 
30 namespace circt {
31 namespace om {
32 
33 namespace evaluator {
34 struct EvaluatorValue;
35 
36 /// A value of an object in memory. It is either a composite Object, or a
37 /// primitive Attribute. Further refinement is expected.
38 using EvaluatorValuePtr = std::shared_ptr<EvaluatorValue>;
39 
40 /// The fields of a composite Object, currently represented as a map. Further
41 /// refinement is expected.
43 
44 /// Base class for evaluator runtime values.
45 /// Enables the shared_from_this functionality so Evaluator Value pointers can
46 /// be passed through the CAPI and unwrapped back into C++ smart pointers with
47 /// the appropriate reference count.
48 struct EvaluatorValue : std::enable_shared_from_this<EvaluatorValue> {
49  // Implement LLVM RTTI.
50  enum class Kind { Attr, Object, List, Tuple, Map, Reference, BasePath, Path };
51  EvaluatorValue(MLIRContext *ctx, Kind kind, Location loc)
52  : kind(kind), ctx(ctx), loc(loc) {}
53  Kind getKind() const { return kind; }
54  MLIRContext *getContext() const { return ctx; }
55 
56  // Return true the value is fully evaluated.
57  bool isFullyEvaluated() const { return fullyEvaluated; }
59  assert(!fullyEvaluated && "should not mark twice");
60  fullyEvaluated = true;
61  }
62 
63  /// Return the associated MLIR context.
64  MLIRContext *getContext() { return ctx; }
65 
66  // Return a MLIR type which the value represents.
67  Type getType() const;
68 
69  // Finalize the evaluator value. Strip intermidiate reference values.
70  LogicalResult finalize();
71 
72  // Return the Location associated with the Value.
73  Location getLoc() const { return loc; }
74  // Set the Location associated with the Value.
75  void setLoc(Location l) { loc = l; }
76  // Set the Location, if it is unknown.
77  void setLocIfUnknown(Location l) {
78  if (isa<UnknownLoc>(loc))
79  loc = l;
80  }
81 
82 private:
83  const Kind kind;
84  MLIRContext *ctx;
85  Location loc;
86  bool fullyEvaluated = false;
87  bool finalized = false;
88 };
89 
90 /// Values which can be used as pointers to different values.
91 /// ReferenceValue is replaced with its element and erased at the end of
92 /// evaluation.
94  ReferenceValue(Type type, Location loc)
95  : EvaluatorValue(type.getContext(), Kind::Reference, loc), value(nullptr),
96  type(type) {}
97 
98  // Implement LLVM RTTI.
99  static bool classof(const EvaluatorValue *e) {
100  return e->getKind() == Kind::Reference;
101  }
102 
103  Type getValueType() const { return type; }
104  EvaluatorValuePtr getValue() const { return value; }
105  void setValue(EvaluatorValuePtr newValue) {
106  value = std::move(newValue);
108  }
109 
110  // Finalize the value.
111  LogicalResult finalizeImpl();
112 
113  // Return the first non-reference value that is reachable from the reference.
115  llvm::SmallPtrSet<ReferenceValue *, 4> visited;
116  auto currentValue = value;
117  while (auto *v = dyn_cast<ReferenceValue>(currentValue.get())) {
118  // Detect a cycle.
119  if (!visited.insert(v).second)
120  return failure();
121  currentValue = v->getValue();
122  }
123  return success(currentValue);
124  }
125 
126 private:
128  Type type;
129 };
130 
131 /// Values which can be directly representable by MLIR attributes.
133  AttributeValue(Attribute attr)
134  : AttributeValue(attr, mlir::UnknownLoc::get(attr.getContext())) {}
135  AttributeValue(Attribute attr, Location loc)
136  : EvaluatorValue(attr.getContext(), Kind::Attr, loc), attr(attr) {
138  }
139  Attribute getAttr() const { return attr; }
140  template <typename AttrTy>
141  AttrTy getAs() const {
142  return dyn_cast<AttrTy>(attr);
143  }
144  static bool classof(const EvaluatorValue *e) {
145  return e->getKind() == Kind::Attr;
146  }
147 
148  // Finalize the value.
149  LogicalResult finalizeImpl() { return success(); }
150 
151  Type getType() const { return attr.cast<TypedAttr>().getType(); }
152 
153 private:
154  Attribute attr = {};
155 };
156 
157 // This perform finalization to `value`.
158 static inline LogicalResult finalizeEvaluatorValue(EvaluatorValuePtr &value) {
159  if (failed(value->finalize()))
160  return failure();
161  if (auto *ref = llvm::dyn_cast<ReferenceValue>(value.get())) {
162  auto v = ref->getStrippedValue();
163  if (failed(v))
164  return v;
165  value = v.value();
166  }
167  return success();
168 }
169 
170 /// A List which contains variadic length of elements with the same type.
172  ListValue(om::ListType type, SmallVector<EvaluatorValuePtr> elements,
173  Location loc)
174  : EvaluatorValue(type.getContext(), Kind::List, loc), type(type),
175  elements(std::move(elements)) {
177  }
178 
179  void setElements(SmallVector<EvaluatorValuePtr> newElements) {
180  elements = std::move(newElements);
182  }
183 
184  // Finalize the value.
185  LogicalResult finalizeImpl();
186 
187  // Partially evaluated value.
188  ListValue(om::ListType type, Location loc)
189  : EvaluatorValue(type.getContext(), Kind::List, loc), type(type) {}
190 
191  const auto &getElements() const { return elements; }
192 
193  /// Return the type of the value, which is a ListType.
194  om::ListType getListType() const { return type; }
195 
196  /// Implement LLVM RTTI.
197  static bool classof(const EvaluatorValue *e) {
198  return e->getKind() == Kind::List;
199  }
200 
201 private:
202  om::ListType type;
203  SmallVector<EvaluatorValuePtr> elements;
204 };
205 
206 /// A Map value.
208  MapValue(om::MapType type, DenseMap<Attribute, EvaluatorValuePtr> elements,
209  Location loc)
211  elements(std::move(elements)) {
213  }
214 
215  // Partially evaluated value.
216  MapValue(om::MapType type, Location loc)
217  : EvaluatorValue(type.getContext(), Kind::Map, loc), type(type) {}
218 
219  const auto &getElements() const { return elements; }
220  void setElements(DenseMap<Attribute, EvaluatorValuePtr> newElements) {
221  elements = std::move(newElements);
223  }
224 
225  // Finalize the evaluator value.
226  LogicalResult finalizeImpl();
227 
228  /// Return the type of the value, which is a MapType.
229  om::MapType getMapType() const { return type; }
230 
231  /// Return an array of keys in the ascending order.
232  ArrayAttr getKeys();
233 
234  /// Implement LLVM RTTI.
235  static bool classof(const EvaluatorValue *e) {
236  return e->getKind() == Kind::Map;
237  }
238 
239 private:
240  om::MapType type;
241  DenseMap<Attribute, EvaluatorValuePtr> elements;
242 };
243 
244 /// A composite Object, which has a type and fields.
246  ObjectValue(om::ClassOp cls, ObjectFields fields, Location loc)
248  fields(std::move(fields)) {
250  }
251 
252  // Partially evaluated value.
253  ObjectValue(om::ClassOp cls, Location loc)
255 
256  om::ClassOp getClassOp() const { return cls; }
257  const auto &getFields() const { return fields; }
258 
260  fields = std::move(newFields);
262  }
263 
264  /// Return the type of the value, which is a ClassType.
265  om::ClassType getObjectType() const {
266  auto clsConst = const_cast<ClassOp &>(cls);
267  return ClassType::get(clsConst.getContext(),
268  FlatSymbolRefAttr::get(clsConst.getNameAttr()));
269  }
270 
271  Type getType() const { return getObjectType(); }
272 
273  /// Implement LLVM RTTI.
274  static bool classof(const EvaluatorValue *e) {
275  return e->getKind() == Kind::Object;
276  }
277 
278  /// Get a field of the Object by name.
279  FailureOr<EvaluatorValuePtr> getField(StringAttr field);
281  return getField(StringAttr::get(getContext(), field));
282  }
283 
284  /// Get all the field names of the Object.
285  ArrayAttr getFieldNames();
286 
287  // Finalize the evaluator value.
288  LogicalResult finalizeImpl();
289 
290 private:
291  om::ClassOp cls;
293 };
294 
295 /// Tuple values.
297  using TupleElements = llvm::SmallVector<EvaluatorValuePtr>;
298  TupleValue(TupleType type, TupleElements tupleElements, Location loc)
299  : EvaluatorValue(type.getContext(), Kind::Tuple, loc), type(type),
300  elements(std::move(tupleElements)) {
302  }
303 
304  // Partially evaluated value.
305  TupleValue(TupleType type, Location loc)
306  : EvaluatorValue(type.getContext(), Kind::Tuple, loc), type(type) {}
307 
308  void setElements(TupleElements newElements) {
309  elements = std::move(newElements);
311  }
312 
313  LogicalResult finalizeImpl() {
314  for (auto &&value : elements)
315  if (failed(finalizeEvaluatorValue(value)))
316  return failure();
317 
318  return success();
319  }
320  /// Implement LLVM RTTI.
321  static bool classof(const EvaluatorValue *e) {
322  return e->getKind() == Kind::Tuple;
323  }
324 
325  /// Return the type of the value, which is a TupleType.
326  TupleType getTupleType() const { return type; }
327 
328  const TupleElements &getElements() const { return elements; }
329 
330 private:
331  TupleType type;
333 };
334 
335 /// A Basepath value.
337  BasePathValue(MLIRContext *context);
338 
339  /// Create a path value representing a basepath.
340  BasePathValue(om::PathAttr path, Location loc);
341 
342  om::PathAttr getPath() const;
343 
344  /// Set the basepath which this path is relative to.
345  void setBasepath(const BasePathValue &basepath);
346 
347  /// Finalize the evaluator value.
348  LogicalResult finalizeImpl() { return success(); }
349 
350  /// Implement LLVM RTTI.
351  static bool classof(const EvaluatorValue *e) {
352  return e->getKind() == Kind::BasePath;
353  }
354 
355 private:
356  om::PathAttr path;
357 };
358 
359 /// A Path value.
361  /// Create a path value representing a regular path.
362  PathValue(om::TargetKindAttr targetKind, om::PathAttr path, StringAttr module,
363  StringAttr ref, StringAttr field, Location loc);
364 
365  static PathValue getEmptyPath(Location loc);
366 
367  om::TargetKindAttr getTargetKind() const { return targetKind; }
368 
369  om::PathAttr getPath() const { return path; }
370 
371  StringAttr getModule() const { return module; }
372 
373  StringAttr getRef() const { return ref; }
374 
375  StringAttr getField() const { return field; }
376 
377  StringAttr getAsString() const;
378 
379  void setBasepath(const BasePathValue &basepath);
380 
381  // Finalize the evaluator value.
382  LogicalResult finalizeImpl() { return success(); }
383 
384  /// Implement LLVM RTTI.
385  static bool classof(const EvaluatorValue *e) {
386  return e->getKind() == Kind::Path;
387  }
388 
389 private:
390  om::TargetKindAttr targetKind;
391  om::PathAttr path;
392  StringAttr module;
393  StringAttr ref;
394  StringAttr field;
395 };
396 
397 } // namespace evaluator
398 
401 
402 SmallVector<EvaluatorValuePtr>
403 getEvaluatorValuesFromAttributes(MLIRContext *context,
404  ArrayRef<Attribute> attributes);
405 
406 /// An Evaluator, which is constructed with an IR module and can instantiate
407 /// Objects. Further refinement is expected.
408 struct Evaluator {
409  /// Construct an Evaluator with an IR module.
410  Evaluator(ModuleOp mod);
411 
412  /// Instantiate an Object with its class name and actual parameters.
414  instantiate(StringAttr className, ArrayRef<EvaluatorValuePtr> actualParams);
415 
416  /// Get the Module this Evaluator is built from.
417  mlir::ModuleOp getModule();
418 
420  getPartiallyEvaluatedValue(Type type, Location loc);
421 
423  SmallVectorImpl<std::shared_ptr<evaluator::EvaluatorValue>> *;
424 
425  using ObjectKey = std::pair<Value, ActualParameters>;
426 
427 private:
429  return isFullyEvaluated({value, key});
430  }
431 
433  auto val = objects.lookup(key);
434  return val && val->isFullyEvaluated();
435  }
436 
438  getOrCreateValue(Value value, ActualParameters actualParams, Location loc);
440  allocateObjectInstance(StringAttr clasName, ActualParameters actualParams);
441 
442  /// Evaluate a Value in a Class body according to the small expression grammar
443  /// described in the rationale document. The actual parameters are the values
444  /// supplied at the current instantiation of the Class being evaluated.
446  evaluateValue(Value value, ActualParameters actualParams, Location loc);
447 
448  /// Evaluator dispatch functions for the small expression grammar.
449  FailureOr<EvaluatorValuePtr> evaluateParameter(BlockArgument formalParam,
450  ActualParameters actualParams,
451  Location loc);
452 
454  evaluateConstant(ConstantOp op, ActualParameters actualParams, Location loc);
455  /// Instantiate an Object with its class name and actual parameters.
457  evaluateObjectInstance(StringAttr className, ActualParameters actualParams,
458  Location loc, ObjectKey instanceKey = {});
460  evaluateObjectInstance(ObjectOp op, ActualParameters actualParams);
462  evaluateObjectField(ObjectFieldOp op, ActualParameters actualParams,
463  Location loc);
465  ActualParameters actualParams,
466  Location loc);
468  evaluateTupleCreate(TupleCreateOp op, ActualParameters actualParams,
469  Location loc);
471  evaluateTupleGet(TupleGetOp op, ActualParameters actualParams, Location loc);
473  evaluateMapCreate(MapCreateOp op, ActualParameters actualParams,
474  Location loc);
476  evaluateBasePathCreate(FrozenBasePathCreateOp op,
477  ActualParameters actualParams, Location loc);
479  evaluatePathCreate(FrozenPathCreateOp op, ActualParameters actualParams,
480  Location loc);
482  evaluateEmptyPath(FrozenEmptyPathOp op, ActualParameters actualParams,
483  Location loc);
484 
486  createParametersFromOperands(ValueRange range, ActualParameters actualParams,
487  Location loc);
488 
489  /// The symbol table for the IR module the Evaluator was constructed with.
490  /// Used to look up class definitions.
491  SymbolTable symbolTable;
492 
493  /// This uniquely stores vectors that represent parameters.
494  SmallVector<
495  std::unique_ptr<SmallVector<std::shared_ptr<evaluator::EvaluatorValue>>>>
497 
498  /// A worklist that tracks values which needs to be fully evaluated.
499  std::queue<ObjectKey> worklist;
500 
501  /// Evaluator value storage. Return an evaluator value for the given
502  /// instantiation context (a pair of Value and parameters).
503  DenseMap<ObjectKey, std::shared_ptr<evaluator::EvaluatorValue>> objects;
504 };
505 
506 /// Helper to enable printing objects in Diagnostics.
507 static inline mlir::Diagnostic &
508 operator<<(mlir::Diagnostic &diag,
509  const evaluator::EvaluatorValue &evaluatorValue) {
510  if (auto *attr = llvm::dyn_cast<evaluator::AttributeValue>(&evaluatorValue))
511  diag << attr->getAttr();
512  else if (auto *object =
513  llvm::dyn_cast<evaluator::ObjectValue>(&evaluatorValue))
514  diag << "Object(" << object->getType() << ")";
515  else if (auto *list = llvm::dyn_cast<evaluator::ListValue>(&evaluatorValue))
516  diag << "List(" << list->getType() << ")";
517  else if (auto *map = llvm::dyn_cast<evaluator::MapValue>(&evaluatorValue))
518  diag << "Map(" << map->getType() << ")";
519  else if (llvm::isa<evaluator::BasePathValue>(&evaluatorValue))
520  diag << "BasePath()";
521  else if (llvm::isa<evaluator::PathValue>(&evaluatorValue))
522  diag << "Path()";
523  else
524  assert(false && "unhandled evaluator value");
525  return diag;
526 }
527 
528 /// Helper to enable printing objects in Diagnostics.
529 static inline mlir::Diagnostic &
530 operator<<(mlir::Diagnostic &diag, const EvaluatorValuePtr &evaluatorValue) {
531  return diag << *evaluatorValue.get();
532 }
533 
534 } // namespace om
535 } // namespace circt
536 
537 #endif // CIRCT_DIALECT_OM_EVALUATOR_EVALUATOR_H
lowerAnnotationsNoRefTypePorts FirtoolPreserveValuesMode value
Definition: Firtool.cpp:95
assert(baseType &&"element must be base type")
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
Definition: CalyxOps.cpp:53
static LogicalResult finalizeEvaluatorValue(EvaluatorValuePtr &value)
Definition: Evaluator.h:158
std::shared_ptr< EvaluatorValue > EvaluatorValuePtr
A value of an object in memory.
Definition: Evaluator.h:38
evaluator::EvaluatorValuePtr EvaluatorValuePtr
Definition: Evaluator.h:400
static mlir::Diagnostic & operator<<(mlir::Diagnostic &diag, const evaluator::EvaluatorValue &evaluatorValue)
Helper to enable printing objects in Diagnostics.
Definition: Evaluator.h:508
SmallVector< EvaluatorValuePtr > getEvaluatorValuesFromAttributes(MLIRContext *context, ArrayRef< Attribute > attributes)
Definition: Evaluator.cpp:34
This file defines an intermediate representation for circuits acting as an abstraction for constraint...
Definition: DebugAnalysis.h:21
Definition: om.py:1
An Evaluator, which is constructed with an IR module and can instantiate Objects.
Definition: Evaluator.h:408
FailureOr< evaluator::EvaluatorValuePtr > evaluateBasePathCreate(FrozenBasePathCreateOp op, ActualParameters actualParams, Location loc)
Definition: Evaluator.cpp:557
FailureOr< evaluator::EvaluatorValuePtr > evaluateEmptyPath(FrozenEmptyPathOp op, ActualParameters actualParams, Location loc)
Definition: Evaluator.cpp:590
SymbolTable symbolTable
The symbol table for the IR module the Evaluator was constructed with.
Definition: Evaluator.h:491
FailureOr< evaluator::EvaluatorValuePtr > getPartiallyEvaluatedValue(Type type, Location loc)
Definition: Evaluator.cpp:74
FailureOr< EvaluatorValuePtr > evaluateValue(Value value, ActualParameters actualParams, Location loc)
Evaluate a Value in a Class body according to the small expression grammar described in the rationale...
Definition: Evaluator.cpp:324
FailureOr< EvaluatorValuePtr > evaluateConstant(ConstantOp op, ActualParameters actualParams, Location loc)
Evaluator dispatch function for constants.
Definition: Evaluator.cpp:390
mlir::ModuleOp getModule()
Get the Module this Evaluator is built from.
Definition: Evaluator.cpp:29
FailureOr< EvaluatorValuePtr > evaluateObjectField(ObjectFieldOp op, ActualParameters actualParams, Location loc)
Evaluator dispatch function for Object fields.
Definition: Evaluator.cpp:435
SmallVector< std::unique_ptr< SmallVector< std::shared_ptr< evaluator::EvaluatorValue > > > > actualParametersBuffers
This uniquely stores vectors that represent parameters.
Definition: Evaluator.h:496
bool isFullyEvaluated(Value value, ActualParameters key)
Definition: Evaluator.h:428
std::queue< ObjectKey > worklist
A worklist that tracks values which needs to be fully evaluated.
Definition: Evaluator.h:499
Evaluator(ModuleOp mod)
Construct an Evaluator with an IR module.
Definition: Evaluator.cpp:26
FailureOr< evaluator::EvaluatorValuePtr > evaluateMapCreate(MapCreateOp op, ActualParameters actualParams, Location loc)
Evaluator dispatch function for Map creation.
Definition: Evaluator.cpp:528
FailureOr< evaluator::EvaluatorValuePtr > instantiate(StringAttr className, ArrayRef< EvaluatorValuePtr > actualParams)
Instantiate an Object with its class name and actual parameters.
Definition: Evaluator.cpp:279
FailureOr< EvaluatorValuePtr > getOrCreateValue(Value value, ActualParameters actualParams, Location loc)
Definition: Evaluator.cpp:110
SmallVectorImpl< std::shared_ptr< evaluator::EvaluatorValue > > * ActualParameters
Definition: Evaluator.h:423
DenseMap< ObjectKey, std::shared_ptr< evaluator::EvaluatorValue > > objects
Evaluator value storage.
Definition: Evaluator.h:503
FailureOr< EvaluatorValuePtr > evaluateListCreate(ListCreateOp op, ActualParameters actualParams, Location loc)
Evaluator dispatch function for List creation.
Definition: Evaluator.cpp:474
FailureOr< EvaluatorValuePtr > allocateObjectInstance(StringAttr clasName, ActualParameters actualParams)
std::pair< Value, ActualParameters > ObjectKey
Definition: Evaluator.h:425
FailureOr< EvaluatorValuePtr > evaluateParameter(BlockArgument formalParam, ActualParameters actualParams, Location loc)
Evaluator dispatch functions for the small expression grammar.
Definition: Evaluator.cpp:381
FailureOr< EvaluatorValuePtr > evaluateObjectInstance(StringAttr className, ActualParameters actualParams, Location loc, ObjectKey instanceKey={})
Instantiate an Object with its class name and actual parameters.
Definition: Evaluator.cpp:182
FailureOr< EvaluatorValuePtr > evaluateTupleGet(TupleGetOp op, ActualParameters actualParams, Location loc)
Evaluator dispatch function for List creation.
Definition: Evaluator.cpp:516
FailureOr< EvaluatorValuePtr > evaluateTupleCreate(TupleCreateOp op, ActualParameters actualParams, Location loc)
Evaluator dispatch function for Tuple creation.
Definition: Evaluator.cpp:497
FailureOr< evaluator::EvaluatorValuePtr > evaluatePathCreate(FrozenPathCreateOp op, ActualParameters actualParams, Location loc)
Definition: Evaluator.cpp:574
FailureOr< ActualParameters > createParametersFromOperands(ValueRange range, ActualParameters actualParams, Location loc)
Evaluator dispatch function for Object instances.
Definition: Evaluator.cpp:399
bool isFullyEvaluated(ObjectKey key)
Definition: Evaluator.h:432
Values which can be directly representable by MLIR attributes.
Definition: Evaluator.h:132
static bool classof(const EvaluatorValue *e)
Definition: Evaluator.h:144
AttributeValue(Attribute attr, Location loc)
Definition: Evaluator.h:135
BasePathValue(MLIRContext *context)
Definition: Evaluator.cpp:689
static bool classof(const EvaluatorValue *e)
Implement LLVM RTTI.
Definition: Evaluator.h:351
LogicalResult finalizeImpl()
Finalize the evaluator value.
Definition: Evaluator.h:348
void setBasepath(const BasePathValue &basepath)
Set the basepath which this path is relative to.
Definition: Evaluator.cpp:703
BasePathValue(om::PathAttr path, Location loc)
Create a path value representing a basepath.
Base class for evaluator runtime values.
Definition: Evaluator.h:48
EvaluatorValue(MLIRContext *ctx, Kind kind, Location loc)
Definition: Evaluator.h:51
MLIRContext * getContext() const
Definition: Evaluator.h:54
MLIRContext * getContext()
Return the associated MLIR context.
Definition: Evaluator.h:64
A List which contains variadic length of elements with the same type.
Definition: Evaluator.h:171
static bool classof(const EvaluatorValue *e)
Implement LLVM RTTI.
Definition: Evaluator.h:197
ListValue(om::ListType type, Location loc)
Definition: Evaluator.h:188
void setElements(SmallVector< EvaluatorValuePtr > newElements)
Definition: Evaluator.h:179
SmallVector< EvaluatorValuePtr > elements
Definition: Evaluator.h:203
ListValue(om::ListType type, SmallVector< EvaluatorValuePtr > elements, Location loc)
Definition: Evaluator.h:172
const auto & getElements() const
Definition: Evaluator.h:191
om::ListType getListType() const
Return the type of the value, which is a ListType.
Definition: Evaluator.h:194
const auto & getElements() const
Definition: Evaluator.h:219
MapValue(om::MapType type, DenseMap< Attribute, EvaluatorValuePtr > elements, Location loc)
Definition: Evaluator.h:208
ArrayAttr getKeys()
Return an array of keys in the ascending order.
Definition: Evaluator.cpp:636
void setElements(DenseMap< Attribute, EvaluatorValuePtr > newElements)
Definition: Evaluator.h:220
MapValue(om::MapType type, Location loc)
Definition: Evaluator.h:216
static bool classof(const EvaluatorValue *e)
Implement LLVM RTTI.
Definition: Evaluator.h:235
om::MapType getMapType() const
Return the type of the value, which is a MapType.
Definition: Evaluator.h:229
DenseMap< Attribute, EvaluatorValuePtr > elements
Definition: Evaluator.h:241
A composite Object, which has a type and fields.
Definition: Evaluator.h:245
const auto & getFields() const
Definition: Evaluator.h:257
om::ClassType getObjectType() const
Return the type of the value, which is a ClassType.
Definition: Evaluator.h:265
FailureOr< EvaluatorValuePtr > getField(StringAttr field)
Get a field of the Object by name.
Definition: Evaluator.cpp:602
ObjectValue(om::ClassOp cls, ObjectFields fields, Location loc)
Definition: Evaluator.h:246
FailureOr< EvaluatorValuePtr > getField(StringRef field)
Definition: Evaluator.h:280
ObjectValue(om::ClassOp cls, Location loc)
Definition: Evaluator.h:253
ArrayAttr getFieldNames()
Get all the field names of the Object.
Definition: Evaluator.cpp:611
static bool classof(const EvaluatorValue *e)
Implement LLVM RTTI.
Definition: Evaluator.h:274
void setFields(llvm::SmallDenseMap< StringAttr, EvaluatorValuePtr > newFields)
Definition: Evaluator.h:259
om::ClassOp getClassOp() const
Definition: Evaluator.h:256
llvm::SmallDenseMap< StringAttr, EvaluatorValuePtr > fields
Definition: Evaluator.h:292
StringAttr getModule() const
Definition: Evaluator.h:371
StringAttr getAsString() const
Definition: Evaluator.cpp:728
LogicalResult finalizeImpl()
Definition: Evaluator.h:382
om::TargetKindAttr getTargetKind() const
Definition: Evaluator.h:367
StringAttr getField() const
Definition: Evaluator.h:375
om::TargetKindAttr targetKind
Definition: Evaluator.h:390
void setBasepath(const BasePathValue &basepath)
Definition: Evaluator.cpp:773
om::PathAttr getPath() const
Definition: Evaluator.h:369
PathValue(om::TargetKindAttr targetKind, om::PathAttr path, StringAttr module, StringAttr ref, StringAttr field, Location loc)
Create a path value representing a regular path.
Definition: Evaluator.cpp:716
static bool classof(const EvaluatorValue *e)
Implement LLVM RTTI.
Definition: Evaluator.h:385
static PathValue getEmptyPath(Location loc)
Definition: Evaluator.cpp:722
StringAttr getRef() const
Definition: Evaluator.h:373
Values which can be used as pointers to different values.
Definition: Evaluator.h:93
EvaluatorValuePtr getValue() const
Definition: Evaluator.h:104
FailureOr< EvaluatorValuePtr > getStrippedValue() const
Definition: Evaluator.h:114
static bool classof(const EvaluatorValue *e)
Definition: Evaluator.h:99
ReferenceValue(Type type, Location loc)
Definition: Evaluator.h:94
void setValue(EvaluatorValuePtr newValue)
Definition: Evaluator.h:105
static bool classof(const EvaluatorValue *e)
Implement LLVM RTTI.
Definition: Evaluator.h:321
const TupleElements & getElements() const
Definition: Evaluator.h:328
TupleValue(TupleType type, Location loc)
Definition: Evaluator.h:305
TupleType getTupleType() const
Return the type of the value, which is a TupleType.
Definition: Evaluator.h:326
llvm::SmallVector< EvaluatorValuePtr > TupleElements
Definition: Evaluator.h:297
TupleValue(TupleType type, TupleElements tupleElements, Location loc)
Definition: Evaluator.h:298
void setElements(TupleElements newElements)
Definition: Evaluator.h:308