Skip to content

Commit

Permalink
[FIX] fixing #19 + [FIX] fixing calling convention for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Cr0a3 committed Sep 9, 2024
1 parent aa84ead commit 896df53
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/CodeGen/calling_convention.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl MachineCallingConvention {
CallConv::SystemV => {
match arch {
Arch::X86_64 => vec![
Reg::x64(x64Reg::Rsi), Reg::x64(x64Reg::Rdi),
Reg::x64(x64Reg::Rdi), Reg::x64(x64Reg::Rsi),
Reg::x64(x64Reg::Rcx), Reg::x64(x64Reg::Rdx),
Reg::x64(x64Reg::R8), Reg::x64(x64Reg::R9)
],
Expand Down
1 change: 0 additions & 1 deletion src/CodeGen/compilation/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ impl CompilationHelper {

for arg in &node.inner2 {
let mut instr = MachineInstr::new(MachineMnemonic::Move);


let arg_reg = args.get(reg_args);

Expand Down
6 changes: 4 additions & 2 deletions src/CodeGen/compilation/ret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ impl CompilationHelper {
#[allow(missing_docs)]
pub fn compile_ret_ty(&mut self, node: &Return<Type>, mc_sink: &mut Vec<MachineInstr>, _: &Block) {
let mut instr = MachineInstr::new(MachineMnemonic::Move);
instr.add_operand(MachineOperand::Reg(self.call.return_reg(self.arch, node.inner1.into())) );

instr.set_out(MachineOperand::Reg(self.call.return_reg(self.arch, node.inner1.into())) );
instr.add_operand(MachineOperand::Imm(node.inner1.val() as i64));

mc_sink.push( instr );

mc_sink.push( MachineInstr::new(MachineMnemonic::Return) );
}
Expand Down
13 changes: 10 additions & 3 deletions tools/ytest/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use core::str;
use std::{fs::File, io::{Read, Write}};
use std::process::{exit, Command};

Expand Down Expand Up @@ -68,6 +69,8 @@ fn main() {
},
}

let mut found = String::new();

for cmd in parsed.cmd.split("&&") {
let args = cmd.replace("%s", path_str);
let args = unescaper::unescape(&args).unwrap();
Expand Down Expand Up @@ -105,13 +108,17 @@ fn main() {
cmd.arg( arg );
}

//let out = cmd.output().expect("failed to execute the process");
//println!("{}", String::from_utf8(out.stdout).unwrap());
let out = cmd.output().expect("failed to execute the process");
found.push_str(str::from_utf8(&out.stdout).unwrap());

match cmd.status() {
Ok(status) => {
if !status.success() {
println!("{}: the programm didn't exit sucessfull", "Error".red().bold());
if let Some(code) = status.code() {
println!("{}: the programm didn't exit sucessfull with code {}", "Error".red().bold(), code);
} else {
println!("{}: the programm didn't exit sucessfull", "Error".red().bold());
}
exit(-1)
}
},
Expand Down

0 comments on commit 896df53

Please sign in to comment.