Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIRRTL][GrandCentral] Remove legacy Augmented types. #7592

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions include/circt/Dialect/FIRRTL/FIRRTLAttributes.td
Original file line number Diff line number Diff line change
Expand Up @@ -101,44 +101,6 @@ def AugmentedGroundType : AugmentedType<"AugmentedGroundType"> {
let assemblyFormat = "`<` $underlying `>`";
}

def AugmentedStringType : AugmentedType<"AugmentedStringType"> {
let summary = "GrandCentral AugmentedStringType";
let extraClassDeclaration = hasName;
let mnemonic = "augmentedString";
let assemblyFormat = "`<` $underlying `>`";
}
def AugmentedBooleanType : AugmentedType<"AugmentedBooleanType"> {
let summary = "GrandCentral AugmentedBooleanType";
let extraClassDeclaration = hasName;
let mnemonic = "augmentedBoolean";
let assemblyFormat = "`<` $underlying `>`";
}
def AugmentedIntegerType : AugmentedType<"AugmentedIntegerType"> {
let summary = "GrandCentral AugmentedIntegerType";
let extraClassDeclaration = hasName;
let mnemonic = "augmentedInteger";
let assemblyFormat = "`<` $underlying `>`";
}
def AugmentedDoubleType : AugmentedType<"AugmentedDoubleType"> {
let summary = "GrandCentral AugmentedDoubleType";
let extraClassDeclaration = hasName;
let mnemonic = "augmentedDouble";
let assemblyFormat = "`<` $underlying `>`";
}
def AugmentedLiteralType : AugmentedType<"AugmentedLiteralType"> {
let summary = "GrandCentral AugmentedLiteralType";
let extraClassDeclaration = hasName;
let mnemonic = "augmentedLiteral";
let assemblyFormat = "`<` $underlying `>`";
}
def AugmentedDeletedType : AugmentedType<"AugmentedDeletedType"> {
let summary = "GrandCentral AugmentedDeletedType";
let extraClassDeclaration = hasName;
let mnemonic = "augmentedDeleted";
let assemblyFormat = "`<` $underlying `>`";
}


def ParamDeclAttr : AttrDef<FIRRTLDialect, "ParamDecl", [TypedAttrInterface]> {
let summary = "Module or instance parameter definition";
let description = [{
Expand Down
74 changes: 2 additions & 72 deletions lib/Dialect/FIRRTL/Transforms/GrandCentral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,7 @@ struct VerbatimBuilder {

/// A wrapper around a string that is used to encode a type which cannot be
/// represented by an mlir::Type for some reason. This is currently used to
/// represent either an interface, a n-dimensional vector of interfaces, or a
/// tombstone for an actually unsupported type (e.g., an AugmentedBooleanType).
/// represent either an interface or an n-dimensional vector of interfaces.
struct VerbatimType {
/// The textual representation of the type.
std::string str;
Expand Down Expand Up @@ -1140,28 +1139,6 @@ parseAugmentedType(ApplyState &state, DictionaryAttr augmentedType,
return DictionaryAttr::getWithSorted(context, attrs);
}

// Any of the following are known and expected, but are legacy AugmentedTypes
// do not have a target:
// - AugmentedStringType
// - AugmentedBooleanType
// - AugmentedIntegerType
// - AugmentedDoubleType
bool isIgnorable =
llvm::StringSwitch<bool>(classBase)
.Cases("StringType", "BooleanType", "IntegerType", "DoubleType", true)
.Default(false);
if (isIgnorable) {
NamedAttrList attrs;
attrs.append("class", classAttr);
attrs.append("name", name);
auto value =
tryGetAs<Attribute>(augmentedType, root, "value", loc, clazz, path);
if (!value)
return std::nullopt;
attrs.append("value", value);
return DictionaryAttr::getWithSorted(context, attrs);
}

// Anything else is unexpected or a user error if they manually wrote
// annotations. Print an error and error out.
mlir::emitError(loc, "found unknown AugmentedType '" + classAttr.getValue() +
Expand Down Expand Up @@ -1256,24 +1233,6 @@ std::optional<Attribute> GrandCentralPass::fromAttr(Attribute attr) {
<< "' that does not have a scattered leaf to connect "
"to in the circuit "
"(was the leaf deleted or constant prop'd away?)";
} else if (classBase == "StringType") {
if (auto name = dict.getAs<StringAttr>("name"))
return AugmentedStringTypeAttr::get(&getContext(), dict);
} else if (classBase == "BooleanType") {
if (auto name = dict.getAs<StringAttr>("name"))
return AugmentedBooleanTypeAttr::get(&getContext(), dict);
} else if (classBase == "IntegerType") {
if (auto name = dict.getAs<StringAttr>("name"))
return AugmentedIntegerTypeAttr::get(&getContext(), dict);
} else if (classBase == "DoubleType") {
if (auto name = dict.getAs<StringAttr>("name"))
return AugmentedDoubleTypeAttr::get(&getContext(), dict);
} else if (classBase == "LiteralType") {
if (auto name = dict.getAs<StringAttr>("name"))
return AugmentedLiteralTypeAttr::get(&getContext(), dict);
} else if (classBase == "DeletedType") {
if (auto name = dict.getAs<StringAttr>("name"))
return AugmentedDeletedTypeAttr::get(&getContext(), dict);
} else {
emitCircuitError() << "has an invalid AugmentedType";
}
Expand Down Expand Up @@ -1413,24 +1372,13 @@ bool GrandCentralPass::traverseField(

return anyFailed;
})
.Case<AugmentedStringTypeAttr>([&](auto a) { return false; })
.Case<AugmentedBooleanTypeAttr>([&](auto a) { return false; })
.Case<AugmentedIntegerTypeAttr>([&](auto a) { return false; })
.Case<AugmentedDoubleTypeAttr>([&](auto a) { return false; })
.Case<AugmentedLiteralTypeAttr>([&](auto a) { return false; })
.Case<AugmentedDeletedTypeAttr>([&](auto a) { return false; })
.Default([](auto a) { return true; });
}

std::optional<TypeSum> GrandCentralPass::computeField(
Attribute field, IntegerAttr id, StringAttr prefix, VerbatimBuilder &path,
SmallVector<VerbatimXMRbuilder> &xmrElems,
SmallVector<InterfaceElemsBuilder> &interfaceBuilder) {

auto unsupported = [&](StringRef name, StringRef kind) {
return VerbatimType({("// <unsupported " + kind + " type>").str(), false});
};

return TypeSwitch<Attribute, std::optional<TypeSum>>(field)
.Case<AugmentedGroundTypeAttr>(
[&](AugmentedGroundTypeAttr ground) -> std::optional<TypeSum> {
Expand Down Expand Up @@ -1491,25 +1439,7 @@ std::optional<TypeSum> GrandCentralPass::computeField(
interfaceBuilder);
assert(ifaceName && *ifaceName);
return VerbatimType({ifaceName->str(), true});
})
.Case<AugmentedStringTypeAttr>([&](auto field) -> TypeSum {
return unsupported(field.getName().getValue(), "string");
})
.Case<AugmentedBooleanTypeAttr>([&](auto field) -> TypeSum {
return unsupported(field.getName().getValue(), "boolean");
})
.Case<AugmentedIntegerTypeAttr>([&](auto field) -> TypeSum {
return unsupported(field.getName().getValue(), "integer");
})
.Case<AugmentedDoubleTypeAttr>([&](auto field) -> TypeSum {
return unsupported(field.getName().getValue(), "double");
})
.Case<AugmentedLiteralTypeAttr>([&](auto field) -> TypeSum {
return unsupported(field.getName().getValue(), "literal");
})
.Case<AugmentedDeletedTypeAttr>([&](auto field) -> TypeSum {
return unsupported(field.getName().getValue(), "deleted");
});
});
}

/// Traverse an Annotation that is an AugmentedBundleType. During traversal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,6 @@ circuit Top :
; CHECK-NEXT: Sub_vecOfBundle sub_vecOfBundle[2]();
; CHECK-NEXT: // The second element of an external port
; CHECK-NEXT: logic ext_port_1;
; CHECK-NEXT: // <unsupported string type> foo_string;
; CHECK-NEXT: // <unsupported integer type> foo_integer;
; CHECK-NEXT: // <unsupported double type> foo_double;
; CHECK-NEXT: // <unsupported boolean type> foo_boolean;
; CHECK-NEXT: endinterface

; EXTRACT: FILE "Wire{{[/\]}}firrtl{{[/\]}}gct{{[/\]}}VecOfBundle.sv"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,34 +705,6 @@
"class": "sifive.enterprise.grandcentral.GrandCentralView$UnknownGroundType$"
}
}
},
{
"name": "foo_string",
"tpe": {
"class": "sifive.enterprise.grandcentral.AugmentedStringType",
"value": "FOO"
}
},
{
"name": "foo_integer",
"tpe": {
"class": "sifive.enterprise.grandcentral.AugmentedIntegerType",
"value": 123
}
},
{
"name": "foo_double",
"tpe": {
"class": "sifive.enterprise.grandcentral.AugmentedDoubleType",
"value": 123.456
}
},
{
"name": "foo_boolean",
"tpe": {
"class": "sifive.enterprise.grandcentral.AugmentedBooleanType",
"value": true
}
}
]
}
Expand Down
68 changes: 0 additions & 68 deletions test/Dialect/FIRRTL/annotations.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -1105,74 +1105,6 @@ firrtl.circuit "GCTInterface" attributes {

// -----

firrtl.circuit "Foo" attributes {rawAnnotations = [
{
class = "sifive.enterprise.grandcentral.ViewAnnotation",
companion = "~Foo|Bar_companion",
name = "Bar",
parent = "~Foo|Foo",
view =
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "View",
elements = [
{
description = "a string",
name = "string",
tpe =
{
class = "sifive.enterprise.grandcentral.AugmentedStringType",
value = "hello"
}
},
{
description = "a boolean",
name = "boolean",
tpe =
{
class = "sifive.enterprise.grandcentral.AugmentedBooleanType",
value = false
}
},
{
description = "an integer",
name = "integer",
tpe =
{
class = "sifive.enterprise.grandcentral.AugmentedIntegerType",
value = 42 : i64
}
},
{
description = "a double",
name = "double",
tpe =
{
class = "sifive.enterprise.grandcentral.AugmentedDoubleType",
value = 3.140000e+00 : f64
}
}
]
}
}
]} {
firrtl.module private @Bar_companion() {
firrtl.skip
}
firrtl.module @Foo() {
firrtl.instance Bar_companion @Bar_companion()
}
}

// CHECK-LABEL: firrtl.circuit "Foo"
// CHECK-SAME: annotations = [{class = "[[_:.+]]AugmentedBundleType", [[_:.+]] elements = [{
// CHECK-SAME: "sifive.enterprise.grandcentral.AugmentedStringType"
// CHECK-SAME: "sifive.enterprise.grandcentral.AugmentedBooleanType"
// CHECK-SAME: "sifive.enterprise.grandcentral.AugmentedIntegerType"
// CHECK-SAME: "sifive.enterprise.grandcentral.AugmentedDoubleType"

// -----

// SiFive-custom annotations related to the GrandCentral utility. These
// annotations do not conform to standard SingleTarget or NoTarget format and
// need to be manually split up.
Expand Down
Loading
Loading