Skip to content

Commit

Permalink
[NFC] simplify get/cast -> getAs
Browse files Browse the repository at this point in the history
  • Loading branch information
darthscsi committed Oct 27, 2021
1 parent 6628939 commit 5f1d4ae
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions lib/Conversion/FIRRTLToHW/LowerToHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,25 +186,23 @@ static void moveVerifAnno(ModuleOp top, AnnotationSet &annos,
auto ctx = top.getContext();
if (!anno)
return;
if (auto _dir = anno.get("directory"))
if (auto dir = _dir.cast<StringAttr>()) {
SmallVector<NamedAttribute> old;
for (auto i : top->getAttrs())
old.push_back(i);
old.emplace_back(Identifier::get(attrBase, ctx),
hw::OutputFileAttr::getAsDirectory(ctx, dir.getValue()));
top->setAttrs(old);
}
if (auto _file = anno.get("filename"))
if (auto file = _file.cast<StringAttr>()) {
SmallVector<NamedAttribute> old;
for (auto i : top->getAttrs())
old.push_back(i);
old.emplace_back(Identifier::get(attrBase + ".bindfile", ctx),
hw::OutputFileAttr::getFromFilename(
ctx, file.getValue(), /*excludeFromFileList=*/true));
top->setAttrs(old);
}
if (auto dir = anno.getAs<StringAttr>("directory")) {
SmallVector<NamedAttribute> old;
for (auto i : top->getAttrs())
old.push_back(i);
old.emplace_back(Identifier::get(attrBase, ctx),
hw::OutputFileAttr::getAsDirectory(ctx, dir.getValue()));
top->setAttrs(old);
}
if (auto file = anno.getAs<StringAttr>("filename")) {
SmallVector<NamedAttribute> old;
for (auto i : top->getAttrs())
old.push_back(i);
old.emplace_back(Identifier::get(attrBase + ".bindfile", ctx),
hw::OutputFileAttr::getFromFilename(
ctx, file.getValue(), /*excludeFromFileList=*/true));
top->setAttrs(old);
}
}

static SmallVector<FirMemory> collectFIRRTLMemories(FModuleOp module) {
Expand Down

0 comments on commit 5f1d4ae

Please sign in to comment.