Skip to content

Split behavior handling into frontend parse and backend IR generation#1

Open
zhouguangyuan0718 wants to merge 1 commit intollvm-20.1.0from
codex/refactor-behavior-parsing-to-separate-frontend-and-backend
Open

Split behavior handling into frontend parse and backend IR generation#1
zhouguangyuan0718 wants to merge 1 commit intollvm-20.1.0from
codex/refactor-behavior-parsing-to-separate-frontend-and-backend

Conversation

@zhouguangyuan0718
Copy link
Owner

Motivation

  • Separate the parsing of CoreDSL instruction metadata from LLVM IR emission so the front-end only records behavior structure while the back-end is responsible for generating IR, preserving existing semantics but enabling a clear frontend/backend split.

Description

  • Added behaviorTokens and behaviorLine to CDSLInstr and included Token.hpp so the front-end can record the token stream and starting line for each behavior: block (file: InstrInfo.hpp).
  • Introduced ParseCoreDSL2FrontEnd that parses instruction metadata and records behavior tokens, and GenerateBehaviorIR that replays those tokens to generate LLVM IR; updated public API in Parser.hpp and replaced the single-stage call in Main.cpp with the two-stage pipeline.
  • Reworked ParseBehaviour to stop recording tokens instead of emitting IR and implemented GenerateInstructionBehaviorIR which constructs a TokenStream in replay mode to re-run the behavior parsing/IR emission code (file: Parser.cpp).
  • Extended TokenStream with a replay mode and a constructor TokenStream(std::string&&, std::vector<Token>&&, int) so the backend can parse from the recorded token vector while preserving identifier indices and line numbering (files: TokenStream.hpp and TokenStream.cpp).
  • Added a small validation in the behavior IR generator to detect leftover tokens after parsing and surface a syntax error if present.

Testing

  • Ran git diff --check on the changes to ensure there are no whitespace/errors reported by the diff tooling and it completed with no issues.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant