Skip to content

Commit a1ae17b

Browse files
committed
[cc] cleanup: move files to cc/ir/
1 parent ba1f180 commit a1ae17b

File tree

9 files changed

+20
-21
lines changed

9 files changed

+20
-21
lines changed

cc/dce.rs renamed to cc/ir/dce.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// 3. Delete all unmarked instructions
1616
//
1717

18-
use crate::ir::{BasicBlockId, Function, Instruction, Opcode, PseudoId};
18+
use super::{BasicBlockId, Function, Instruction, Opcode, PseudoId};
1919
use std::collections::{HashSet, VecDeque};
2020

2121
// ============================================================================

cc/dominate.rs renamed to cc/ir/dominate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// - IDF computation: "A Linear Time Algorithm for Placing phi-nodes" by Sreedhar and Gao
1414
//
1515

16-
use crate::ir::{BasicBlockId, Function};
16+
use super::{BasicBlockId, Function};
1717
use std::collections::{HashMap, HashSet};
1818

1919
// ============================================================================
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// - Identity patterns: x - x -> 0, x ^ x -> 0, etc.
1515
//
1616

17-
use crate::ir::{Function, Instruction, Opcode, Pseudo, PseudoId, PseudoKind};
17+
use super::{Function, Instruction, Opcode, Pseudo, PseudoId, PseudoKind};
1818
use crate::types::TypeId;
1919

2020
// ============================================================================

cc/linearize.rs renamed to cc/ir/linearize.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
// Converts AST to SSA-style IR following sparse's design
1111
//
1212

13-
use crate::diag::Position;
14-
use crate::ir::{
13+
use super::ssa::ssa_convert;
14+
use super::{
1515
BasicBlock, BasicBlockId, Function, Initializer, Instruction, Module, Opcode, Pseudo, PseudoId,
1616
};
17+
use crate::diag::Position;
1718
use crate::parse::ast::{
1819
AssignOp, BinaryOp, BlockItem, Declaration, Designator, Expr, ExprKind, ExternalDecl, ForInit,
1920
FunctionDef, InitElement, Stmt, TranslationUnit, UnaryOp,
2021
};
21-
use crate::ssa::ssa_convert;
2222
use crate::strings::{StringId, StringTable};
2323
use crate::symbol::SymbolTable;
2424
use crate::target::Target;

cc/lower.rs renamed to cc/ir/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// - Phi elimination: Converts SSA phi nodes to copy instructions
1616
//
1717

18-
use crate::ir::{BasicBlockId, Function, Instruction, Module, Opcode};
18+
use super::{BasicBlockId, Function, Instruction, Module, Opcode};
1919
use std::collections::HashMap;
2020

2121
// ============================================================================

cc/ir.rs renamed to cc/ir/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
// optimization passes.
1515
//
1616

17+
pub mod dce;
18+
pub mod dominate;
19+
pub mod instcombine;
20+
pub mod linearize;
21+
pub mod lower;
22+
pub mod ssa;
23+
1724
use crate::diag::Position;
1825
use crate::types::TypeId;
1926
use std::collections::HashMap;

cc/ssa.rs renamed to cc/ir/ssa.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
// - Renames variables to complete SSA construction
1515
//
1616

17-
use crate::dominate::{compute_dominance_frontiers, domtree_build, idf_compute};
18-
use crate::ir::{
19-
BasicBlockId, Function, InsnRef, Instruction, Opcode, Pseudo, PseudoId, PseudoKind,
20-
};
17+
use super::dominate::{compute_dominance_frontiers, domtree_build, idf_compute};
18+
use super::{BasicBlockId, Function, InsnRef, Instruction, Opcode, Pseudo, PseudoId, PseudoKind};
2119
use crate::types::{TypeId, TypeTable};
2220
use std::collections::{HashMap, HashSet};
2321

cc/main.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,11 @@
1010
//
1111

1212
mod arch;
13-
mod dce;
1413
mod diag;
15-
mod dominate;
16-
mod instcombine;
1714
mod ir;
18-
mod linearize;
19-
mod lower;
2015
mod opt;
2116
mod os;
2217
mod parse;
23-
mod ssa;
2418
mod strings;
2519
mod symbol;
2620
mod target;
@@ -218,7 +212,7 @@ fn process_file(
218212
}
219213

220214
// Linearize to IR
221-
let mut module = linearize::linearize_with_debug(
215+
let mut module = ir::linearize::linearize_with_debug(
222216
&ast,
223217
&symbols,
224218
&types,
@@ -239,7 +233,7 @@ fn process_file(
239233
}
240234

241235
// Lower IR (phi elimination, etc.)
242-
lower::lower_module(&mut module);
236+
ir::lower::lower_module(&mut module);
243237

244238
// Generate assembly
245239
let emit_unwind_tables = !args.no_unwind_tables;

cc/opt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// used by optimization passes (InstCombine, DCE, etc.).
1313
//
1414

15-
use crate::dce;
16-
use crate::instcombine;
15+
use crate::ir::dce;
16+
use crate::ir::instcombine;
1717
use crate::ir::{Function, Module};
1818

1919
#[cfg(test)]

0 commit comments

Comments
 (0)