feat(ir): construir CFG a partir do TAC#147
Merged
Merged
Conversation
Adds src/ir/cfg.rs implementing leader-based basic block partitioning and successor/predecessor wiring from a TacFunction, closes #25.
7 tasks
HugoFreitass
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Descrição
Implementa
src/ir/cfg.rs, construindo o Control Flow Graph (CFG) a partir de umaTacFunction, conforme #25.O que foi adicionado
BlockId/BasicBlock { id, instrs, succs, preds }identify_leaders(instrs: &[TacInstr]) -> HashSet<usize>— identifica índices que iniciam blocos (início da função, alvos de Label, instrução após Jump/CondJump)build_cfg(func: &TacFunction) -> Cfg— particiona instruções em blocos e conecta via succs/preds com base em Jump/CondJump/fallthroughCfg { blocks, entry, exit }com métodospredecessors/successorsDisplayparaCfg, útil para debugTestes
straight_line_code_is_one_blockif_else_produces_three_blockswhile_loop_has_back_edge(verifica aresta de volta)cfg_entry_has_no_predecessorsCI
cargo build --all,cargo test --all,cargo clippy -- -D warningsecargo fmt --checkpassam localmente.Closes #25