Comparar commits
3 Commits
0bee0c799b
...
953c3ad48d
| Autor | SHA1 | Fecha | |
|---|---|---|---|
|
953c3ad48d
|
|||
|
5e7980a770
|
|||
|
5022cfb5ee
|
30
.github/workflows/ci.yml
vendido
30
.github/workflows/ci.yml
vendido
@@ -17,29 +17,28 @@ jobs:
|
||||
matrix:
|
||||
rust: [stable, beta, nightly]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
toolchain: ${{ matrix.rust }}
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cargo/git
|
||||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Cache cargo build
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: target
|
||||
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
||||
@@ -61,19 +60,16 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release --verbose
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: alecc-linux-x86_64
|
||||
path: target/release/alecc
|
||||
@@ -86,14 +82,12 @@ jobs:
|
||||
matrix:
|
||||
target: [i686-unknown-linux-gnu, aarch64-unknown-linux-gnu]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
target: ${{ matrix.target }}
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Install cross
|
||||
run: cargo install cross
|
||||
@@ -102,7 +96,7 @@ jobs:
|
||||
run: cross build --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: alecc-${{ matrix.target }}
|
||||
path: target/${{ matrix.target }}/release/alecc
|
||||
|
||||
@@ -98,7 +98,8 @@ fn bench_optimizer(c: &mut Criterion) {
|
||||
b.iter(|| {
|
||||
let mut prog_copy = black_box(program.clone());
|
||||
let mut optimizer = Optimizer::new(OptimizationLevel::None);
|
||||
black_box(optimizer.optimize(&mut prog_copy).unwrap());
|
||||
optimizer.optimize(&mut prog_copy).unwrap();
|
||||
black_box(());
|
||||
})
|
||||
});
|
||||
|
||||
@@ -106,7 +107,8 @@ fn bench_optimizer(c: &mut Criterion) {
|
||||
b.iter(|| {
|
||||
let mut prog_copy = black_box(program.clone());
|
||||
let mut optimizer = Optimizer::new(OptimizationLevel::Moderate);
|
||||
black_box(optimizer.optimize(&mut prog_copy).unwrap());
|
||||
optimizer.optimize(&mut prog_copy).unwrap();
|
||||
black_box(());
|
||||
})
|
||||
});
|
||||
|
||||
@@ -114,7 +116,8 @@ fn bench_optimizer(c: &mut Criterion) {
|
||||
b.iter(|| {
|
||||
let mut prog_copy = black_box(program.clone());
|
||||
let mut optimizer = Optimizer::new(OptimizationLevel::Aggressive);
|
||||
black_box(optimizer.optimize(&mut prog_copy).unwrap());
|
||||
optimizer.optimize(&mut prog_copy).unwrap();
|
||||
black_box(());
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ impl CodeGenerator {
|
||||
let stack_space = parameters.len() * 8;
|
||||
// Always reserve at least 8 bytes to maintain 16-byte alignment after rbp push
|
||||
let min_space = if stack_space == 0 { 8 } else { stack_space };
|
||||
let aligned_space = ((min_space + 15) / 16) * 16; // Round up to 16-byte boundary
|
||||
let aligned_space = min_space.div_ceil(16) * 16; // Round up to 16-byte boundary
|
||||
self.emit_line(&format!(" sub rsp, {}", aligned_space));
|
||||
|
||||
// Store parameters from registers (x86_64 calling convention)
|
||||
@@ -1267,7 +1267,7 @@ impl CodeGenerator {
|
||||
|
||||
match self.target {
|
||||
Target::I386 | Target::Amd64 => {
|
||||
self.emit_line(&format!(" test eax, eax"));
|
||||
self.emit_line(" test eax, eax");
|
||||
self.emit_line(&format!(" {} {}", instruction, label));
|
||||
}
|
||||
Target::Arm64 => {
|
||||
|
||||
@@ -119,7 +119,7 @@ impl Compiler {
|
||||
let preprocessed = self.preprocess(&source, input_file).await?;
|
||||
fs::write(&output_path, preprocessed)
|
||||
.await
|
||||
.map_err(|e| AleccError::IoError(e))?;
|
||||
.map_err(AleccError::IoError)?;
|
||||
return Ok(output_path);
|
||||
} else {
|
||||
self.preprocess(&source, input_file).await?
|
||||
@@ -149,7 +149,7 @@ impl Compiler {
|
||||
let output_path = self.get_output_path(input_file, "s")?;
|
||||
fs::write(&output_path, assembly)
|
||||
.await
|
||||
.map_err(|e| AleccError::IoError(e))?;
|
||||
.map_err(AleccError::IoError)?;
|
||||
return Ok(output_path);
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ impl Compiler {
|
||||
let asm_path = self.create_temp_file("s")?;
|
||||
fs::write(&asm_path, assembly)
|
||||
.await
|
||||
.map_err(|e| AleccError::IoError(e))?;
|
||||
.map_err(AleccError::IoError)?;
|
||||
|
||||
// Assemble
|
||||
let obj_path = self.assemble_file(&asm_path).await?;
|
||||
@@ -215,9 +215,9 @@ impl Compiler {
|
||||
// Skip malformed include
|
||||
}
|
||||
}
|
||||
} else if trimmed.starts_with("#define") {
|
||||
} else if let Some(stripped) = trimmed.strip_prefix("#define") {
|
||||
// Handle #define (simplified)
|
||||
let parts: Vec<&str> = trimmed[7..].split_whitespace().collect();
|
||||
let parts: Vec<&str> = stripped.split_whitespace().collect();
|
||||
if !parts.is_empty() {
|
||||
let key = parts[0].to_string();
|
||||
let value = if parts.len() > 1 {
|
||||
@@ -330,17 +330,17 @@ impl Compiler {
|
||||
|
||||
match self.target {
|
||||
Target::I386 => {
|
||||
command.args(&["--32"]);
|
||||
command.args(["--32"]);
|
||||
}
|
||||
Target::Amd64 => {
|
||||
command.args(&["--64"]);
|
||||
command.args(["--64"]);
|
||||
}
|
||||
Target::Arm64 => {
|
||||
// Default options for aarch64
|
||||
}
|
||||
}
|
||||
|
||||
command.args(&[
|
||||
command.args([
|
||||
"-o",
|
||||
&obj_path.to_string_lossy(),
|
||||
&asm_file.to_string_lossy(),
|
||||
|
||||
@@ -218,7 +218,7 @@ impl Linker {
|
||||
Ok(command)
|
||||
}
|
||||
|
||||
fn add_standard_startup_files(&self, _command: &mut Vec<String>) -> Result<()> {
|
||||
fn add_standard_startup_files(&self, _command: &mut [String]) -> Result<()> {
|
||||
// Skip startup files when we have our own _start
|
||||
// This prevents conflicts with our custom _start implementation
|
||||
Ok(())
|
||||
@@ -257,7 +257,7 @@ impl Linker {
|
||||
fn get_gcc_lib_path(&self) -> Result<String> {
|
||||
// Try to find GCC library path
|
||||
let output = Command::new("gcc")
|
||||
.args(&["-print-libgcc-file-name"])
|
||||
.args(["-print-libgcc-file-name"])
|
||||
.output()
|
||||
.map_err(|e| AleccError::LinkerError {
|
||||
message: format!("Failed to find GCC library path: {}", e),
|
||||
|
||||
Referencia en una nueva incidencia
Block a user