@@ -1,13 +1,14 @@ |
| 1 | +mod compiler; |
| 2 | + |
| 1 | 3 | use std::collections::{BTreeMap, BTreeSet, VecDeque}; |
| 2 | 4 | use std::fs; |
| 3 | 5 | use std::path::{Path, PathBuf}; |
| 4 | 6 | use std::process::Command; |
| 5 | 7 | use std::sync::atomic::{AtomicU64, Ordering}; |
| 6 | 8 | |
| 7 | | -use armfortas::driver::{self, OptLevel}; |
| 8 | | -use armfortas::testing::{ |
| 9 | | - capture_from_path, CaptureFailure, CaptureRequest, CaptureResult, CapturedStage, FailureStage, |
| 10 | | - RunCapture, Stage, |
| 9 | +use crate::compiler::{ |
| 10 | + capture_from_path, compile_output, CaptureFailure, CaptureRequest, CaptureResult, |
| 11 | + CapturedStage, EmitMode, FailureStage, OptLevel, RunCapture, Stage, |
| 11 | 12 | }; |
| 12 | 13 | |
| 13 | 14 | const SUITE_EXTENSION: &str = "afs"; |
@@ -3446,17 +3447,13 @@ fn compile_with_driver( |
| 3446 | 3447 | return Err(format!("{} failed:\n{}", command, stderr.trim_end())); |
| 3447 | 3448 | } |
| 3448 | 3449 | } else { |
| 3449 | | - let opts = driver::Options { |
| 3450 | | - input: source.to_path_buf(), |
| 3451 | | - output: Some(output.to_path_buf()), |
| 3452 | | - emit_asm: matches!(mode, DriverEmitMode::Asm), |
| 3453 | | - emit_obj: matches!(mode, DriverEmitMode::Obj), |
| 3454 | | - emit_ir: false, |
| 3455 | | - preprocess_only: false, |
| 3456 | | - opt_level, |
| 3450 | + let emit_mode = match mode { |
| 3451 | + DriverEmitMode::Asm => EmitMode::Asm, |
| 3452 | + DriverEmitMode::Obj => EmitMode::Obj, |
| 3453 | + DriverEmitMode::Binary => EmitMode::Binary, |
| 3457 | 3454 | }; |
| 3458 | | - |
| 3459 | | - driver::compile(&opts).map_err(|detail| format!("{} failed:\n{}", command, detail))?; |
| 3455 | + compile_output(source, opt_level, emit_mode, output) |
| 3456 | + .map_err(|detail| format!("{} failed:\n{}", command, detail))?; |
| 3460 | 3457 | } |
| 3461 | 3458 | Ok(command) |
| 3462 | 3459 | } |
@@ -4658,10 +4655,10 @@ fn match_checks(checks: &[Check], output: &str, case_name: &str) -> Result<(), S |
| 4658 | 4655 | #[cfg(test)] |
| 4659 | 4656 | mod tests { |
| 4660 | 4657 | use super::*; |
| 4661 | | - use armfortas::ir::inst::{BlockParam, Function, Inst, InstKind, Module, Terminator, ValueId}; |
| 4662 | | - use armfortas::ir::types::{FloatWidth, IntWidth, IrType}; |
| 4663 | | - use armfortas::ir::verify::verify_module; |
| 4664 | | - use armfortas::lexer::{Position, Span}; |
| 4658 | + use crate::compiler::test_support::{ |
| 4659 | + verify_module, BlockParam, FloatWidth, Function, Inst, InstKind, IntWidth, IrType, |
| 4660 | + Module, Position, Span, Terminator, ValueId, |
| 4661 | + }; |
| 4665 | 4662 | |
| 4666 | 4663 | fn dummy_span() -> Span { |
| 4667 | 4664 | Span { |