CIRCT 23.0.0git
Loading...
Searching...
No Matches
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
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#include "llvm/Support/Debug.h"
27
28#include <queue>
29#include <utility>
30
31namespace circt {
32namespace om {
33
34namespace evaluator {
35class EvaluatorValue;
36
37/// A value of an object in memory. It is either a composite Object, or a
38/// primitive Attribute. Further refinement is expected.
39using EvaluatorValuePtr = std::shared_ptr<EvaluatorValue>;
40
41/// The fields of a composite Object, currently represented as a map. Further
42/// refinement is expected.
44
45/// Base class for evaluator runtime values.
46/// Enables the shared_from_this functionality so Evaluator Value pointers can
47/// be passed through the CAPI and unwrapped back into C++ smart pointers with
48/// the appropriate reference count.
49class EvaluatorValue : public std::enable_shared_from_this<EvaluatorValue> {
50public:
51 // Implement LLVM RTTI.
52 enum class Kind { Attr, Object, List, Reference, BasePath, Path };
53 EvaluatorValue(MLIRContext *ctx, Kind kind, Location loc)
54 : kind(kind), ctx(ctx), loc(loc) {}
55 Kind getKind() const { return kind; }
56 MLIRContext *getContext() const { return ctx; }
57
58 // Return true the value is fully evaluated.
59 // Unknown values are considered fully evaluated.
60 bool isFullyEvaluated() const { return fullyEvaluated; }
62 assert(!fullyEvaluated && "should not mark twice");
63 fullyEvaluated = true;
64 }
65
66 /// Return true if the value is unknown (has unknown in its fan-in).
67 /// A value is unknown if it depends on an UnknownValueOp or if any of its
68 /// inputs are unknown. Unknown values propagate through operations.
69 bool isUnknown() const { return unknown; }
70
71 /// Mark this value as unknown.
72 /// This also marks the value as fully evaluated if it isn't already, since
73 /// unknown values are considered fully evaluated. This maintains the
74 /// invariant that unknown implies fullyEvaluated.
75 void markUnknown() {
76 unknown = true;
77 if (!fullyEvaluated)
79 }
80
81 /// Return the associated MLIR context.
82 MLIRContext *getContext() { return ctx; }
83
84 // Return a MLIR type which the value represents.
85 Type getType() const;
86
87 // Finalize the evaluator value. Strip intermidiate reference values.
88 LogicalResult finalize();
89
90 // Return the Location associated with the Value.
91 Location getLoc() const { return loc; }
92 // Set the Location associated with the Value.
93 void setLoc(Location l) { loc = l; }
94 // Set the Location, if it is unknown.
95 void setLocIfUnknown(Location l) {
96 if (isa<UnknownLoc>(loc))
97 loc = l;
98 }
99
100private:
101 const Kind kind;
102 MLIRContext *ctx;
103 Location loc;
104 bool fullyEvaluated = false;
105 bool finalized = false;
106 bool unknown = false;
107};
108
109/// Values which can be used as pointers to different values.
110/// ReferenceValue is replaced with its element and erased at the end of
111/// evaluation.
113public:
114 ReferenceValue(Type type, Location loc)
116 type(type) {}
117
118 // Implement LLVM RTTI.
119 static bool classof(const EvaluatorValue *e) {
120 return e->getKind() == Kind::Reference;
121 }
122
123 Type getValueType() const { return type; }
124 EvaluatorValuePtr getValue() const { return value; }
126 value = std::move(newValue);
128 }
129
130 // Finalize the value.
131 LogicalResult finalizeImpl();
132
133 // Return the first non-reference value that is reachable from the reference.
134 FailureOr<EvaluatorValuePtr> getStrippedValue() const {
135 llvm::SmallPtrSet<ReferenceValue *, 4> visited;
136 auto currentValue = value;
137 while (auto *v = dyn_cast<ReferenceValue>(currentValue.get())) {
138 // Detect a cycle.
139 if (!visited.insert(v).second)
140 return failure();
141 currentValue = v->getValue();
142 }
143 return success(currentValue);
144 }
145
146private:
148 Type type;
149};
150
151/// Values which can be directly representable by MLIR attributes.
153public:
154 Attribute getAttr() const { return attr; }
155 template <typename AttrTy>
156 AttrTy getAs() const {
157 return dyn_cast<AttrTy>(attr);
158 }
159 static bool classof(const EvaluatorValue *e) {
160 return e->getKind() == Kind::Attr;
161 }
162
163 // Set Attribute for partially evaluated case.
164 LogicalResult setAttr(Attribute attr);
165
166 // Finalize the value.
167 LogicalResult finalizeImpl();
168
169 Type getType() const { return type; }
170
171 // Factory methods that create AttributeValue objects
172 static std::shared_ptr<EvaluatorValue> get(Attribute attr,
173 LocationAttr loc = {});
174 static std::shared_ptr<EvaluatorValue> get(Type type, LocationAttr loc = {});
175
176private:
177 // Make AttributeValue constructible only by the factory methods
178 struct PrivateTag {};
179
180 // Constructor that requires a PrivateTag
181 AttributeValue(PrivateTag, Attribute attr, Location loc)
183 type(cast<TypedAttr>(attr).getType()) {
185 }
186
187 // Constructor for partially evaluated AttributeValue
190
191 Attribute attr = {};
192 Type type;
193
194 // Friend declaration for the factory methods
195 friend std::shared_ptr<EvaluatorValue> get(Attribute attr, LocationAttr loc);
196 friend std::shared_ptr<EvaluatorValue> get(Type type, LocationAttr loc);
197};
198
199// This perform finalization to `value`.
200static inline LogicalResult finalizeEvaluatorValue(EvaluatorValuePtr &value) {
201 if (failed(value->finalize()))
202 return failure();
203 if (auto *ref = llvm::dyn_cast<ReferenceValue>(value.get())) {
204 auto v = ref->getStrippedValue();
205 if (failed(v))
206 return v;
207 value = v.value();
208 }
209 return success();
210}
211
212/// A List which contains variadic length of elements with the same type.
213class ListValue : public EvaluatorValue {
214public:
215 ListValue(om::ListType type, SmallVector<EvaluatorValuePtr> elements,
216 Location loc)
218 elements(std::move(elements)) {
220 }
221
222 void setElements(SmallVector<EvaluatorValuePtr> newElements) {
223 elements = std::move(newElements);
225 }
226
227 // Finalize the value.
228 LogicalResult finalizeImpl();
229
230 // Partially evaluated value.
231 ListValue(om::ListType type, Location loc)
233
234 const auto &getElements() const { return elements; }
235
236 /// Return the type of the value, which is a ListType.
237 om::ListType getListType() const { return type; }
238
239 /// Implement LLVM RTTI.
240 static bool classof(const EvaluatorValue *e) {
241 return e->getKind() == Kind::List;
242 }
243
244private:
245 om::ListType type;
246 SmallVector<EvaluatorValuePtr> elements;
247};
248
249/// A composite Object, which has a type and fields.
251public:
252 ObjectValue(om::ClassLike cls, ObjectFields fields, Location loc)
254 fields(std::move(fields)) {
256 }
257
258 // Partially evaluated value.
259 ObjectValue(om::ClassLike cls, Location loc)
261
262 om::ClassLike getClassOp() const { return cls; }
263 const auto &getFields() const { return fields; }
264
266 fields = std::move(newFields);
268 }
269
270 /// Return the type of the value, which is a ClassType.
271 om::ClassType getObjectType() const {
272 auto clsNonConst = const_cast<om::ClassLike &>(cls);
273 return ClassType::get(clsNonConst.getContext(),
274 FlatSymbolRefAttr::get(clsNonConst.getSymNameAttr()));
275 }
276
277 Type getType() const { return getObjectType(); }
278
279 /// Implement LLVM RTTI.
280 static bool classof(const EvaluatorValue *e) {
281 return e->getKind() == Kind::Object;
282 }
283
284 /// Get a field of the Object by name.
285 FailureOr<EvaluatorValuePtr> getField(StringAttr field);
286 FailureOr<EvaluatorValuePtr> getField(StringRef field) {
287 return getField(StringAttr::get(getContext(), field));
288 }
289
290 /// Get all the field names of the Object.
291 ArrayAttr getFieldNames();
292
293 // Finalize the evaluator value.
294 LogicalResult finalizeImpl();
295
296private:
297 om::ClassLike cls;
299};
300
301/// A Basepath value.
303public:
304 BasePathValue(MLIRContext *context);
305
306 /// Create a path value representing a basepath.
307 BasePathValue(om::PathAttr path, Location loc);
308
309 om::PathAttr getPath() const;
310
311 /// Set the basepath which this path is relative to.
312 void setBasepath(const BasePathValue &basepath);
313
314 /// Finalize the evaluator value.
315 LogicalResult finalizeImpl() { return success(); }
316
317 /// Implement LLVM RTTI.
318 static bool classof(const EvaluatorValue *e) {
319 return e->getKind() == Kind::BasePath;
320 }
321
322private:
323 om::PathAttr path;
324};
325
326/// A Path value.
327class PathValue : public EvaluatorValue {
328public:
329 /// Create a path value representing a regular path.
330 PathValue(om::TargetKindAttr targetKind, om::PathAttr path, StringAttr module,
331 StringAttr ref, StringAttr field, Location loc);
332
333 static PathValue getEmptyPath(Location loc);
334
335 om::TargetKindAttr getTargetKind() const { return targetKind; }
336
337 om::PathAttr getPath() const { return path; }
338
339 StringAttr getModule() const { return module; }
340
341 StringAttr getRef() const { return ref; }
342
343 StringAttr getField() const { return field; }
344
345 StringAttr getAsString() const;
346
347 void setBasepath(const BasePathValue &basepath);
348
349 // Finalize the evaluator value.
350 LogicalResult finalizeImpl() { return success(); }
351
352 /// Implement LLVM RTTI.
353 static bool classof(const EvaluatorValue *e) {
354 return e->getKind() == Kind::Path;
355 }
356
357private:
358 om::TargetKindAttr targetKind;
359 om::PathAttr path;
360 StringAttr module;
361 StringAttr ref;
362 StringAttr field;
363};
364
365} // namespace evaluator
366
369
370SmallVector<EvaluatorValuePtr>
372 ArrayRef<Attribute> attributes);
373
374/// An Evaluator, which is constructed with an IR module and can instantiate
375/// Objects. Further refinement is expected.
377public:
378 /// Construct an Evaluator with an IR module.
379 Evaluator(ModuleOp mod);
380
381 /// Instantiate an Object with its class name and actual parameters.
382 FailureOr<evaluator::EvaluatorValuePtr>
383 instantiate(StringAttr className, ArrayRef<EvaluatorValuePtr> actualParams);
384
385 /// Get the Module this Evaluator is built from.
386 mlir::ModuleOp getModule();
387
388 FailureOr<evaluator::EvaluatorValuePtr>
389 getPartiallyEvaluatedValue(Type type, Location loc);
390
392 SmallVectorImpl<std::shared_ptr<evaluator::EvaluatorValue>> *;
393
394 using ObjectKey = std::pair<Value, ActualParameters>;
395
396private:
397 bool isFullyEvaluated(Value value, ActualParameters key) {
398 return isFullyEvaluated({value, key});
399 }
400
402 auto val = objects.lookup(key);
403 return val && val->isFullyEvaluated();
404 }
405
406 FailureOr<EvaluatorValuePtr>
407 getOrCreateValue(Value value, ActualParameters actualParams, Location loc);
408 FailureOr<EvaluatorValuePtr>
409 allocateObjectInstance(StringAttr clasName, ActualParameters actualParams);
410
411 /// Evaluate a Value in a Class body according to the small expression grammar
412 /// described in the rationale document. The actual parameters are the values
413 /// supplied at the current instantiation of the Class being evaluated.
414 FailureOr<EvaluatorValuePtr>
415 evaluateValue(Value value, ActualParameters actualParams, Location loc);
416
417 /// Evaluator dispatch functions for the small expression grammar.
418 FailureOr<EvaluatorValuePtr> evaluateParameter(BlockArgument formalParam,
419 ActualParameters actualParams,
420 Location loc);
421
422 FailureOr<EvaluatorValuePtr>
423 evaluateConstant(ConstantOp op, ActualParameters actualParams, Location loc);
424
425 FailureOr<EvaluatorValuePtr>
426 evaluateIntegerBinaryArithmetic(IntegerBinaryArithmeticOp op,
427 ActualParameters actualParams, Location loc);
428
429 /// Instantiate an Object with its class name and actual parameters.
430 FailureOr<EvaluatorValuePtr>
431 evaluateObjectInstance(StringAttr className, ActualParameters actualParams,
432 Location loc, ObjectKey instanceKey = {});
433 FailureOr<EvaluatorValuePtr>
434 evaluateObjectInstance(ObjectOp op, ActualParameters actualParams);
435 FailureOr<EvaluatorValuePtr>
436 evaluateObjectField(ObjectFieldOp op, ActualParameters actualParams,
437 Location loc);
438 FailureOr<EvaluatorValuePtr> evaluateListCreate(ListCreateOp op,
439 ActualParameters actualParams,
440 Location loc);
441 FailureOr<EvaluatorValuePtr> evaluateListConcat(ListConcatOp op,
442 ActualParameters actualParams,
443 Location loc);
444 FailureOr<EvaluatorValuePtr>
445 evaluateStringConcat(StringConcatOp op, ActualParameters actualParams,
446 Location loc);
447 FailureOr<EvaluatorValuePtr>
448 evaluateBinaryEquality(BinaryEqualityOp op, ActualParameters actualParams,
449 Location loc);
450 FailureOr<evaluator::EvaluatorValuePtr>
451 evaluateBasePathCreate(FrozenBasePathCreateOp op,
452 ActualParameters actualParams, Location loc);
453 FailureOr<evaluator::EvaluatorValuePtr>
454 evaluatePathCreate(FrozenPathCreateOp op, ActualParameters actualParams,
455 Location loc);
456 FailureOr<evaluator::EvaluatorValuePtr>
457 evaluateEmptyPath(FrozenEmptyPathOp op, ActualParameters actualParams,
458 Location loc);
459 FailureOr<evaluator::EvaluatorValuePtr>
460 evaluateUnknownValue(UnknownValueOp op, Location loc);
461
462 LogicalResult evaluatePropertyAssert(PropertyAssertOp op,
463 ActualParameters actualParams);
464
465 FailureOr<evaluator::EvaluatorValuePtr> createUnknownValue(Type type,
466 Location loc);
467
468 FailureOr<ActualParameters>
469 createParametersFromOperands(ValueRange range, ActualParameters actualParams,
470 Location loc);
471
472 /// The symbol table for the IR module the Evaluator was constructed with.
473 /// Used to look up class definitions.
474 SymbolTable symbolTable;
475
476 /// This uniquely stores vectors that represent parameters.
477 SmallVector<
478 std::unique_ptr<SmallVector<std::shared_ptr<evaluator::EvaluatorValue>>>>
480
481 /// A worklist that tracks values which needs to be fully evaluated.
482 std::queue<ObjectKey> worklist;
483
484 /// A queue of pending property assertions to be evaluated after the worklist
485 /// is fully drained. Each entry is a (PropertyAssertOp, ActualParameters)
486 /// pair. Property assertions are deferred because their operands may be
487 /// ReferenceValues that are not yet resolved when the class body is first
488 /// processed.
489 std::queue<std::pair<PropertyAssertOp, ActualParameters>> pendingAsserts;
490
491 /// Evaluator value storage. Return an evaluator value for the given
492 /// instantiation context (a pair of Value and parameters).
493 DenseMap<ObjectKey, std::shared_ptr<evaluator::EvaluatorValue>> objects;
494
495#ifndef NDEBUG
496 /// Current nesting depth for debug output indentation.
497 unsigned debugNesting = 0;
498
499 /// RAII helper to increment/decrement debugNesting.
501 unsigned &depth;
502 DebugNesting(unsigned &depth) : depth(depth) { ++depth; }
504 };
505
506 raw_ostream &dbgs(unsigned extra = 0) {
507 return llvm::dbgs().indent(debugNesting * 2 + extra * 2);
508 }
509
510 llvm::indent indent(unsigned extra = 0) {
511 return llvm::indent(debugNesting, 2) + extra;
512 }
513#endif
514};
515
516/// Helper to enable printing objects in Diagnostics.
517static inline mlir::Diagnostic &
518operator<<(mlir::Diagnostic &diag,
519 const evaluator::EvaluatorValue &evaluatorValue) {
520 if (auto *attr = llvm::dyn_cast<evaluator::AttributeValue>(&evaluatorValue))
521 diag << attr->getAttr();
522 else if (auto *object =
523 llvm::dyn_cast<evaluator::ObjectValue>(&evaluatorValue))
524 diag << "Object(" << object->getType() << ")";
525 else if (auto *list = llvm::dyn_cast<evaluator::ListValue>(&evaluatorValue))
526 diag << "List(" << list->getType() << ")";
527 else if (auto *ref =
528 llvm::dyn_cast<evaluator::ReferenceValue>(&evaluatorValue))
529 diag << "Reference(" << ref->getValueType() << ")";
530 else if (llvm::isa<evaluator::BasePathValue>(&evaluatorValue))
531 diag << "BasePath()";
532 else if (llvm::isa<evaluator::PathValue>(&evaluatorValue))
533 diag << "Path()";
534 else
535 assert(false && "unhandled evaluator value");
536
537 // Add unknown marker if the value is unknown
538 if (evaluatorValue.isUnknown())
539 diag << " [unknown]";
540 return diag;
541}
542
543/// Helper to enable printing objects in Diagnostics.
544static inline mlir::Diagnostic &
545operator<<(mlir::Diagnostic &diag, const EvaluatorValuePtr &evaluatorValue) {
546 return diag << *evaluatorValue.get();
547}
548
549#ifndef NDEBUG
550/// Helper to enable printing objects to raw_ostream (e.g., llvm::dbgs()).
551/// Delegates to the Diagnostic overload via an intermediate string.
552static inline llvm::raw_ostream &
553operator<<(llvm::raw_ostream &os,
554 const evaluator::EvaluatorValue &evaluatorValue) {
555 std::string buf;
556 llvm::raw_string_ostream ss(buf);
557 mlir::Diagnostic diag(UnknownLoc::get(evaluatorValue.getContext()),
558 mlir::DiagnosticSeverity::Note);
559 diag << evaluatorValue;
560 ss << diag;
561 return os << ss.str();
562}
563
564static inline llvm::raw_ostream &
565operator<<(llvm::raw_ostream &os, const EvaluatorValuePtr &evaluatorValue) {
566 if (evaluatorValue)
567 return os << *evaluatorValue.get();
568 return os << "<null>";
569}
570#endif // NDEBUG
571
572} // namespace om
573} // namespace circt
574
575#endif // CIRCT_DIALECT_OM_EVALUATOR_EVALUATOR_H
assert(baseType &&"element must be base type")
static std::unique_ptr< Context > context
An Evaluator, which is constructed with an IR module and can instantiate Objects.
Definition Evaluator.h:376
FailureOr< evaluator::EvaluatorValuePtr > evaluateBasePathCreate(FrozenBasePathCreateOp op, ActualParameters actualParams, Location loc)
FailureOr< evaluator::EvaluatorValuePtr > evaluateEmptyPath(FrozenEmptyPathOp op, ActualParameters actualParams, Location loc)
SymbolTable symbolTable
The symbol table for the IR module the Evaluator was constructed with.
Definition Evaluator.h:474
FailureOr< evaluator::EvaluatorValuePtr > getPartiallyEvaluatedValue(Type type, Location loc)
Definition Evaluator.cpp:70
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...
FailureOr< EvaluatorValuePtr > evaluateConstant(ConstantOp op, ActualParameters actualParams, Location loc)
Evaluator dispatch function for constants.
FailureOr< EvaluatorValuePtr > evaluateIntegerBinaryArithmetic(IntegerBinaryArithmeticOp op, ActualParameters actualParams, Location loc)
FailureOr< EvaluatorValuePtr > evaluateStringConcat(StringConcatOp op, ActualParameters actualParams, Location loc)
Evaluator dispatch function for String concatenation.
LogicalResult evaluatePropertyAssert(PropertyAssertOp op, ActualParameters actualParams)
Evaluator dispatch function for property assertions.
mlir::ModuleOp getModule()
Get the Module this Evaluator is built from.
Definition Evaluator.cpp:30
FailureOr< EvaluatorValuePtr > evaluateObjectField(ObjectFieldOp op, ActualParameters actualParams, Location loc)
Evaluator dispatch function for Object fields.
FailureOr< evaluator::EvaluatorValuePtr > createUnknownValue(Type type, Location loc)
Create an unknown value of the specified type.
SmallVector< std::unique_ptr< SmallVector< std::shared_ptr< evaluator::EvaluatorValue > > > > actualParametersBuffers
This uniquely stores vectors that represent parameters.
Definition Evaluator.h:479
bool isFullyEvaluated(Value value, ActualParameters key)
Definition Evaluator.h:397
FailureOr< EvaluatorValuePtr > allocateObjectInstance(StringAttr clasName, ActualParameters actualParams)
std::queue< ObjectKey > worklist
A worklist that tracks values which needs to be fully evaluated.
Definition Evaluator.h:482
llvm::indent indent(unsigned extra=0)
Definition Evaluator.h:510
unsigned debugNesting
Current nesting depth for debug output indentation.
Definition Evaluator.h:497
FailureOr< evaluator::EvaluatorValuePtr > evaluateUnknownValue(UnknownValueOp op, Location loc)
Evaluate an unknown value.
raw_ostream & dbgs(unsigned extra=0)
Definition Evaluator.h:506
FailureOr< evaluator::EvaluatorValuePtr > instantiate(StringAttr className, ArrayRef< EvaluatorValuePtr > actualParams)
Instantiate an Object with its class name and actual parameters.
FailureOr< EvaluatorValuePtr > getOrCreateValue(Value value, ActualParameters actualParams, Location loc)
SmallVectorImpl< std::shared_ptr< evaluator::EvaluatorValue > > * ActualParameters
Definition Evaluator.h:392
DenseMap< ObjectKey, std::shared_ptr< evaluator::EvaluatorValue > > objects
Evaluator value storage.
Definition Evaluator.h:493
FailureOr< EvaluatorValuePtr > evaluateBinaryEquality(BinaryEqualityOp op, ActualParameters actualParams, Location loc)
FailureOr< EvaluatorValuePtr > evaluateListCreate(ListCreateOp op, ActualParameters actualParams, Location loc)
Evaluator dispatch function for List creation.
FailureOr< EvaluatorValuePtr > evaluateListConcat(ListConcatOp op, ActualParameters actualParams, Location loc)
Evaluator dispatch function for List concatenation.
std::pair< Value, ActualParameters > ObjectKey
Definition Evaluator.h:394
FailureOr< EvaluatorValuePtr > evaluateParameter(BlockArgument formalParam, ActualParameters actualParams, Location loc)
Evaluator dispatch functions for the small expression grammar.
FailureOr< EvaluatorValuePtr > evaluateObjectInstance(StringAttr className, ActualParameters actualParams, Location loc, ObjectKey instanceKey={})
Instantiate an Object with its class name and actual parameters.
FailureOr< evaluator::EvaluatorValuePtr > evaluatePathCreate(FrozenPathCreateOp op, ActualParameters actualParams, Location loc)
FailureOr< ActualParameters > createParametersFromOperands(ValueRange range, ActualParameters actualParams, Location loc)
Evaluator dispatch function for Object instances.
bool isFullyEvaluated(ObjectKey key)
Definition Evaluator.h:401
std::queue< std::pair< PropertyAssertOp, ActualParameters > > pendingAsserts
A queue of pending property assertions to be evaluated after the worklist is fully drained.
Definition Evaluator.h:489
Values which can be directly representable by MLIR attributes.
Definition Evaluator.h:152
LogicalResult setAttr(Attribute attr)
friend std::shared_ptr< EvaluatorValue > get(Attribute attr, LocationAttr loc)
static bool classof(const EvaluatorValue *e)
Definition Evaluator.h:159
AttributeValue(PrivateTag, Attribute attr, Location loc)
Definition Evaluator.h:181
friend std::shared_ptr< EvaluatorValue > get(Type type, LocationAttr loc)
AttributeValue(PrivateTag, Type type, Location loc)
Definition Evaluator.h:188
static bool classof(const EvaluatorValue *e)
Implement LLVM RTTI.
Definition Evaluator.h:318
LogicalResult finalizeImpl()
Finalize the evaluator value.
Definition Evaluator.h:315
void setBasepath(const BasePathValue &basepath)
Set the basepath which this path is relative to.
BasePathValue(om::PathAttr path, Location loc)
Create a path value representing a basepath.
Base class for evaluator runtime values.
Definition Evaluator.h:49
EvaluatorValue(MLIRContext *ctx, Kind kind, Location loc)
Definition Evaluator.h:53
void markUnknown()
Mark this value as unknown.
Definition Evaluator.h:75
MLIRContext * getContext()
Return the associated MLIR context.
Definition Evaluator.h:82
bool isUnknown() const
Return true if the value is unknown (has unknown in its fan-in).
Definition Evaluator.h:69
MLIRContext * getContext() const
Definition Evaluator.h:56
A List which contains variadic length of elements with the same type.
Definition Evaluator.h:213
static bool classof(const EvaluatorValue *e)
Implement LLVM RTTI.
Definition Evaluator.h:240
const auto & getElements() const
Definition Evaluator.h:234
ListValue(om::ListType type, Location loc)
Definition Evaluator.h:231
void setElements(SmallVector< EvaluatorValuePtr > newElements)
Definition Evaluator.h:222
SmallVector< EvaluatorValuePtr > elements
Definition Evaluator.h:246
ListValue(om::ListType type, SmallVector< EvaluatorValuePtr > elements, Location loc)
Definition Evaluator.h:215
om::ListType getListType() const
Return the type of the value, which is a ListType.
Definition Evaluator.h:237
A composite Object, which has a type and fields.
Definition Evaluator.h:250
om::ClassType getObjectType() const
Return the type of the value, which is a ClassType.
Definition Evaluator.h:271
FailureOr< EvaluatorValuePtr > getField(StringAttr field)
Get a field of the Object by name.
const auto & getFields() const
Definition Evaluator.h:263
FailureOr< EvaluatorValuePtr > getField(StringRef field)
Definition Evaluator.h:286
ArrayAttr getFieldNames()
Get all the field names of the Object.
static bool classof(const EvaluatorValue *e)
Implement LLVM RTTI.
Definition Evaluator.h:280
void setFields(llvm::SmallDenseMap< StringAttr, EvaluatorValuePtr > newFields)
Definition Evaluator.h:265
ObjectValue(om::ClassLike cls, Location loc)
Definition Evaluator.h:259
om::ClassLike getClassOp() const
Definition Evaluator.h:262
llvm::SmallDenseMap< StringAttr, EvaluatorValuePtr > fields
Definition Evaluator.h:298
ObjectValue(om::ClassLike cls, ObjectFields fields, Location loc)
Definition Evaluator.h:252
StringAttr getModule() const
Definition Evaluator.h:339
StringAttr StringAttr ref
Definition Evaluator.h:361
om::TargetKindAttr getTargetKind() const
Definition Evaluator.h:335
StringAttr getField() const
Definition Evaluator.h:343
om::TargetKindAttr targetKind
Definition Evaluator.h:358
void setBasepath(const BasePathValue &basepath)
om::PathAttr getPath() const
Definition Evaluator.h:337
static bool classof(const EvaluatorValue *e)
Implement LLVM RTTI.
Definition Evaluator.h:353
static PathValue getEmptyPath(Location loc)
StringAttr getRef() const
Definition Evaluator.h:341
Values which can be used as pointers to different values.
Definition Evaluator.h:112
EvaluatorValuePtr getValue() const
Definition Evaluator.h:124
static bool classof(const EvaluatorValue *e)
Definition Evaluator.h:119
ReferenceValue(Type type, Location loc)
Definition Evaluator.h:114
FailureOr< EvaluatorValuePtr > getStrippedValue() const
Definition Evaluator.h:134
void setValue(EvaluatorValuePtr newValue)
Definition Evaluator.h:125
static LogicalResult finalizeEvaluatorValue(EvaluatorValuePtr &value)
Definition Evaluator.h:200
std::shared_ptr< EvaluatorValue > EvaluatorValuePtr
A value of an object in memory.
Definition Evaluator.h:39
evaluator::EvaluatorValuePtr EvaluatorValuePtr
Definition Evaluator.h:368
static mlir::Diagnostic & operator<<(mlir::Diagnostic &diag, const evaluator::EvaluatorValue &evaluatorValue)
Helper to enable printing objects in Diagnostics.
Definition Evaluator.h:518
SmallVector< EvaluatorValuePtr > getEvaluatorValuesFromAttributes(MLIRContext *context, ArrayRef< Attribute > attributes)
Definition Evaluator.cpp:35
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition om.py:1
RAII helper to increment/decrement debugNesting.
Definition Evaluator.h:500