Skip to content

Commit 2beb8e7

Browse files
[OM] Deprecate the OM Map and Tuple (#8606)
Remove the support for OM Map and Tuple. All the dependence on them have been removed. --------- Co-authored-by: Mike Urbach <mikeurbach@gmail.com>
1 parent e5603e1 commit 2beb8e7

File tree

19 files changed

+13
-975
lines changed

19 files changed

+13
-975
lines changed

include/circt-c/Dialect/OM.h

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,6 @@ MLIR_CAPI_EXPORTED MlirTypeID omListTypeGetTypeID(void);
6161
// Return a element type of a ListType.
6262
MLIR_CAPI_EXPORTED MlirType omListTypeGetElementType(MlirType type);
6363

64-
/// Is the Type a MapType.
65-
MLIR_CAPI_EXPORTED bool omTypeIsAMapType(MlirType type);
66-
67-
// Return a key type of a MapType.
68-
MLIR_CAPI_EXPORTED MlirType omMapTypeGetKeyType(MlirType type);
69-
7064
/// Is the Type a StringType.
7165
MLIR_CAPI_EXPORTED bool omTypeIsAStringType(MlirType type);
7266

@@ -187,31 +181,6 @@ omEvaluatorListGetNumElements(OMEvaluatorValue evaluatorValue);
187181
MLIR_CAPI_EXPORTED OMEvaluatorValue
188182
omEvaluatorListGetElement(OMEvaluatorValue evaluatorValue, intptr_t pos);
189183

190-
/// Query if the EvaluatorValue is a Tuple.
191-
MLIR_CAPI_EXPORTED bool
192-
omEvaluatorValueIsATuple(OMEvaluatorValue evaluatorValue);
193-
194-
/// Get the size of the tuple.
195-
MLIR_CAPI_EXPORTED intptr_t
196-
omEvaluatorTupleGetNumElements(OMEvaluatorValue evaluatorValue);
197-
198-
/// Get an element of the tuple.
199-
MLIR_CAPI_EXPORTED OMEvaluatorValue
200-
omEvaluatorTupleGetElement(OMEvaluatorValue evaluatorValue, intptr_t pos);
201-
202-
/// Get an element of the map.
203-
MLIR_CAPI_EXPORTED OMEvaluatorValue
204-
omEvaluatorMapGetElement(OMEvaluatorValue evaluatorValue, MlirAttribute attr);
205-
206-
MLIR_CAPI_EXPORTED MlirAttribute omEvaluatorMapGetKeys(OMEvaluatorValue object);
207-
208-
/// Query if the EvaluatorValue is a Map.
209-
MLIR_CAPI_EXPORTED bool omEvaluatorValueIsAMap(OMEvaluatorValue evaluatorValue);
210-
211-
/// Get the Type from a Map, which will be a MapType.
212-
MLIR_CAPI_EXPORTED MlirType
213-
omEvaluatorMapGetType(OMEvaluatorValue evaluatorValue);
214-
215184
/// Query if the EvaluatorValue is a BasePath.
216185
MLIR_CAPI_EXPORTED bool
217186
omEvaluatorValueIsABasePath(OMEvaluatorValue evaluatorValue);
@@ -275,20 +244,6 @@ MLIR_CAPI_EXPORTED MlirAttribute omListAttrGet(MlirType elementType,
275244
intptr_t numElements,
276245
const MlirAttribute *elements);
277246

278-
//===----------------------------------------------------------------------===//
279-
// MapAttr API
280-
//===----------------------------------------------------------------------===//
281-
282-
MLIR_CAPI_EXPORTED bool omAttrIsAMapAttr(MlirAttribute attr);
283-
284-
MLIR_CAPI_EXPORTED intptr_t omMapAttrGetNumElements(MlirAttribute attr);
285-
286-
MLIR_CAPI_EXPORTED MlirIdentifier omMapAttrGetElementKey(MlirAttribute attr,
287-
intptr_t pos);
288-
289-
MLIR_CAPI_EXPORTED MlirAttribute omMapAttrGetElementValue(MlirAttribute attr,
290-
intptr_t pos);
291-
292247
#ifdef __cplusplus
293248
}
294249
#endif

include/circt/Dialect/OM/Evaluator/Evaluator.h

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ using ObjectFields = SmallDenseMap<StringAttr, EvaluatorValuePtr>;
4747
/// the appropriate reference count.
4848
struct EvaluatorValue : std::enable_shared_from_this<EvaluatorValue> {
4949
// Implement LLVM RTTI.
50-
enum class Kind { Attr, Object, List, Tuple, Map, Reference, BasePath, Path };
50+
enum class Kind { Attr, Object, List, Reference, BasePath, Path };
5151
EvaluatorValue(MLIRContext *ctx, Kind kind, Location loc)
5252
: kind(kind), ctx(ctx), loc(loc) {}
5353
Kind getKind() const { return kind; }
@@ -224,44 +224,6 @@ struct ListValue : EvaluatorValue {
224224
SmallVector<EvaluatorValuePtr> elements;
225225
};
226226

227-
/// A Map value.
228-
struct MapValue : EvaluatorValue {
229-
MapValue(om::MapType type, DenseMap<Attribute, EvaluatorValuePtr> elements,
230-
Location loc)
231-
: EvaluatorValue(type.getContext(), Kind::Map, loc), type(type),
232-
elements(std::move(elements)) {
233-
markFullyEvaluated();
234-
}
235-
236-
// Partially evaluated value.
237-
MapValue(om::MapType type, Location loc)
238-
: EvaluatorValue(type.getContext(), Kind::Map, loc), type(type) {}
239-
240-
const auto &getElements() const { return elements; }
241-
void setElements(DenseMap<Attribute, EvaluatorValuePtr> newElements) {
242-
elements = std::move(newElements);
243-
markFullyEvaluated();
244-
}
245-
246-
// Finalize the evaluator value.
247-
LogicalResult finalizeImpl();
248-
249-
/// Return the type of the value, which is a MapType.
250-
om::MapType getMapType() const { return type; }
251-
252-
/// Return an array of keys in the ascending order.
253-
ArrayAttr getKeys();
254-
255-
/// Implement LLVM RTTI.
256-
static bool classof(const EvaluatorValue *e) {
257-
return e->getKind() == Kind::Map;
258-
}
259-
260-
private:
261-
om::MapType type;
262-
DenseMap<Attribute, EvaluatorValuePtr> elements;
263-
};
264-
265227
/// A composite Object, which has a type and fields.
266228
struct ObjectValue : EvaluatorValue {
267229
ObjectValue(om::ClassOp cls, ObjectFields fields, Location loc)
@@ -313,46 +275,6 @@ struct ObjectValue : EvaluatorValue {
313275
llvm::SmallDenseMap<StringAttr, EvaluatorValuePtr> fields;
314276
};
315277

316-
/// Tuple values.
317-
struct TupleValue : EvaluatorValue {
318-
using TupleElements = llvm::SmallVector<EvaluatorValuePtr>;
319-
TupleValue(TupleType type, TupleElements tupleElements, Location loc)
320-
: EvaluatorValue(type.getContext(), Kind::Tuple, loc), type(type),
321-
elements(std::move(tupleElements)) {
322-
markFullyEvaluated();
323-
}
324-
325-
// Partially evaluated value.
326-
TupleValue(TupleType type, Location loc)
327-
: EvaluatorValue(type.getContext(), Kind::Tuple, loc), type(type) {}
328-
329-
void setElements(TupleElements newElements) {
330-
elements = std::move(newElements);
331-
markFullyEvaluated();
332-
}
333-
334-
LogicalResult finalizeImpl() {
335-
for (auto &&value : elements)
336-
if (failed(finalizeEvaluatorValue(value)))
337-
return failure();
338-
339-
return success();
340-
}
341-
/// Implement LLVM RTTI.
342-
static bool classof(const EvaluatorValue *e) {
343-
return e->getKind() == Kind::Tuple;
344-
}
345-
346-
/// Return the type of the value, which is a TupleType.
347-
TupleType getTupleType() const { return type; }
348-
349-
const TupleElements &getElements() const { return elements; }
350-
351-
private:
352-
TupleType type;
353-
TupleElements elements;
354-
};
355-
356278
/// A Basepath value.
357279
struct BasePathValue : EvaluatorValue {
358280
BasePathValue(MLIRContext *context);
@@ -493,14 +415,6 @@ struct Evaluator {
493415
FailureOr<EvaluatorValuePtr> evaluateListConcat(ListConcatOp op,
494416
ActualParameters actualParams,
495417
Location loc);
496-
FailureOr<EvaluatorValuePtr>
497-
evaluateTupleCreate(TupleCreateOp op, ActualParameters actualParams,
498-
Location loc);
499-
FailureOr<EvaluatorValuePtr>
500-
evaluateTupleGet(TupleGetOp op, ActualParameters actualParams, Location loc);
501-
FailureOr<evaluator::EvaluatorValuePtr>
502-
evaluateMapCreate(MapCreateOp op, ActualParameters actualParams,
503-
Location loc);
504418
FailureOr<evaluator::EvaluatorValuePtr>
505419
evaluateBasePathCreate(FrozenBasePathCreateOp op,
506420
ActualParameters actualParams, Location loc);
@@ -543,8 +457,6 @@ operator<<(mlir::Diagnostic &diag,
543457
diag << "Object(" << object->getType() << ")";
544458
else if (auto *list = llvm::dyn_cast<evaluator::ListValue>(&evaluatorValue))
545459
diag << "List(" << list->getType() << ")";
546-
else if (auto *map = llvm::dyn_cast<evaluator::MapValue>(&evaluatorValue))
547-
diag << "Map(" << map->getType() << ")";
548460
else if (llvm::isa<evaluator::BasePathValue>(&evaluatorValue))
549461
diag << "BasePath()";
550462
else if (llvm::isa<evaluator::PathValue>(&evaluatorValue))

include/circt/Dialect/OM/OMAttributes.td

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,28 +81,6 @@ def OMListAttr : AttrDef<OMDialect, "List", [TypedAttrInterface]> {
8181
}];
8282
}
8383

84-
def MapAttr : AttrDef<OMDialect, "Map", [TypedAttrInterface]> {
85-
let summary = "An attribute that represents a string map";
86-
87-
let mnemonic = "map";
88-
89-
let parameters = (ins
90-
"mlir::Type": $valueType,
91-
"mlir::DictionaryAttr":$elements
92-
);
93-
94-
// TODO: Use custom assembly format to infer a type from elements.
95-
let assemblyFormat = [{
96-
`<` $valueType `,` $elements `>`
97-
}];
98-
99-
let genVerifyDecl = 1;
100-
101-
let extraClassDeclaration = [{
102-
mlir::Type getType();
103-
}];
104-
}
105-
10684
def OMPathAttr : AttrDef<OMDialect, "Path"> {
10785
let summary = "An attribute that represents an instance path";
10886

include/circt/Dialect/OM/OMOps.td

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -280,94 +280,6 @@ def ListConcatOp : OMOp<"list_concat", [Pure, SameOperandsAndResultType]> {
280280
let assemblyFormat = "$subLists attr-dict `:` type($result)";
281281
}
282282

283-
def TupleCreateOp : OMOp<"tuple_create", [Pure, InferTypeOpInterface]> {
284-
let summary = "Create a tuple of values";
285-
let description = [{
286-
Create a tuple from a sequence of inputs.
287-
288-
```
289-
%tuple = om.tuple_create %a, %b, %c : !om.ref, !om.string, !om.list<i32>
290-
```
291-
}];
292-
293-
let arguments = (ins Variadic<AnyType>:$inputs);
294-
let results = (outs
295-
TupleOf<[AnyType]>:$result
296-
);
297-
298-
let assemblyFormat = [{
299-
$inputs attr-dict `:` type($inputs)
300-
}];
301-
302-
let extraClassDeclaration = [{
303-
// Implement InferTypeOpInterface.
304-
static ::mlir::LogicalResult inferReturnTypes(
305-
::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location,
306-
::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
307-
::mlir::OpaqueProperties,
308-
::mlir::RegionRange regions,
309-
::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes);
310-
}];
311-
312-
}
313-
314-
def TupleGetOp : OMOp<"tuple_get", [Pure, InferTypeOpInterface]> {
315-
let summary = "Extract a value from a tuple";
316-
let description = [{
317-
Extract a value from a tuple.
318-
319-
```
320-
%value = om.tuple_get %a[0] : tuple<!om.ref, !om.string, !om.list<i32>>
321-
```
322-
}];
323-
324-
let arguments = (ins
325-
TupleOf<[AnyType]>:$input,
326-
I32Attr:$index
327-
);
328-
329-
let results = (outs
330-
AnyType:$result
331-
);
332-
333-
let assemblyFormat = [{
334-
$input `[` $index `]` attr-dict `:` type($input)
335-
}];
336-
337-
let extraClassDeclaration = [{
338-
// Implement InferTypeOpInterface.
339-
static ::mlir::LogicalResult inferReturnTypes(
340-
::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location,
341-
::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
342-
::mlir::OpaqueProperties, ::mlir::RegionRange regions,
343-
::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes);
344-
}];
345-
}
346-
347-
def MapKeyValuePair: Type<CPred<"::circt::om::isMapKeyValuePairType($_self)">,
348-
"a pair whose first element is an attribute",
349-
"::mlir::TupleType">;
350-
351-
def MapCreateOp : OMOp<"map_create", [Pure, SameTypeOperands]> {
352-
let summary = "Create a map";
353-
let description = [{
354-
Creates a map from a sequence of inputs.
355-
356-
```
357-
%map = om.map_create %e1, %e2 : !om.string, i8
358-
```
359-
where `%e1` and `e2` have !om.tuple<!om.string, i8> and
360-
`%map` has `!om.map<!om.string, i8>` type.
361-
}];
362-
363-
let arguments = (ins Variadic<MapKeyValuePair>:$inputs);
364-
let results = (outs
365-
MapType:$result
366-
);
367-
368-
let hasCustomAssemblyFormat = true;
369-
}
370-
371283
def BasePathCreateOp : OMOp<"basepath_create", [Pure,
372284
DeclareOpInterfaceMethods<SymbolUserOpInterface>
373285
]> {

include/circt/Dialect/OM/OMTypes.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@
1616
#include "mlir/IR/BuiltinAttributes.h"
1717
#include "mlir/IR/Types.h"
1818

19-
namespace circt::om {
20-
// Return true if the type is a pair whose first element is either string or
21-
// integer.
22-
bool isMapKeyValuePairType(mlir::Type);
23-
24-
} // namespace circt::om
19+
namespace circt::om {} // namespace circt::om
2520

2621
#define GET_TYPEDEF_CLASSES
2722
#include "circt/Dialect/OM/OMTypes.h.inc"

include/circt/Dialect/OM/OMTypes.td

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,6 @@ def ListType : TypeDef<OMDialect, "List", []> {
5151
];
5252
}
5353

54-
def MapType : TypeDef<OMDialect, "Map", []> {
55-
let summary = [{A type that represents a map. A key type must be either
56-
an integer or string type}];
57-
58-
let mnemonic = "map";
59-
let parameters = (ins "mlir::Type": $keyType, "mlir::Type":$valueType);
60-
let assemblyFormat = [{
61-
`<` $keyType `,` $valueType `>`
62-
}];
63-
64-
let builders = [
65-
AttrBuilderWithInferredContext<(ins "::mlir::Type":$keyType, "::mlir::Type":$valueType), [{
66-
return $_get(keyType.getContext(), keyType, valueType);
67-
}]>
68-
];
69-
70-
let genVerifyDecl = 1;
71-
}
72-
7354
def SymbolRefType : TypeDef<OMDialect, "SymbolRef", []> {
7455
let summary = "A type that represents a reference to a flat symbol reference.";
7556

0 commit comments

Comments
 (0)