Skip to content

Commit

Permalink
removed defered parsing for formal body
Browse files Browse the repository at this point in the history
  • Loading branch information
dobios committed Aug 7, 2024
1 parent 5f30d59 commit 3fb9a2a
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions lib/Dialect/FIRRTL/Import/FIRParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4611,16 +4611,6 @@ struct FIRCircuitParser : public FIRParser {
unsigned indent;
};

struct DeferredBodyToParse {
Block &body;
FIRLexerCursor lexerCursor;
unsigned indent;
};

ParseResult parseFormalBody(const SymbolTable &circuitSymTbl,
DeferredBodyToParse &defferedBody);
SmallVector<DeferredBodyToParse, 0> deferredBodies;

ParseResult parseModuleBody(const SymbolTable &circuitSymTbl,
DeferredModuleToParse &deferredModule);

Expand Down Expand Up @@ -5165,29 +5155,6 @@ ParseResult FIRCircuitParser::parseModule(CircuitOp circuit, bool isPublic,
return success();
}

ParseResult
FIRCircuitParser::parseFormalBody(const SymbolTable &circuitSymTbl,
DeferredBodyToParse &defferedBody) {

// Create a custom lexer for formal body like in module body parser
FIRLexer formalBodyLexer(getLexer().getSourceMgr(), getContext());
// Reset the lexer to the top of the body
defferedBody.lexerCursor.restore(formalBodyLexer);
// Reuse a module context for this as strucutre is similar
FIRModuleContext context(getConstants(), formalBodyLexer, version);
// Default namespace
hw::InnerSymbolNamespace ns;
// Create the statement parser needed to parse the body content
FIRStmtParser stmtParser(defferedBody.body, context, ns, circuitSymTbl,
version);

// Parse the internal region
auto result = stmtParser.parseSimpleStmtBlock(defferedBody.indent);
if (failed(result))
return result;
return success();
}

ParseResult FIRCircuitParser::parseFormal(CircuitOp circuit, unsigned indent) {
auto startLoc = getToken().getLoc();
consumeToken(FIRToken::kw_formal);
Expand Down Expand Up @@ -5660,16 +5627,6 @@ ParseResult FIRCircuitParser::parseCircuit(
if (failed(anyFailed))
return failure();

// Next, parse all the deffered non-module bodies.
auto anyBodyFailed = mlir::failableParallelForEachN(
getContext(), 0, deferredBodies.size(), [&](size_t index) {
if (parseFormalBody(circuitSymTbl, deferredBodies[index]))
return failure();
return success();
});
if (failed(anyBodyFailed))
return failure();

// Helper to transform a layer name specification of the form `A::B::C` into
// a SymbolRefAttr.
auto parseLayerName = [&](StringRef name) {
Expand Down

0 comments on commit 3fb9a2a

Please sign in to comment.