diff --git a/src/CodeGen/instr.rs b/src/CodeGen/instr.rs index bee0008e..be82569b 100644 --- a/src/CodeGen/instr.rs +++ b/src/CodeGen/instr.rs @@ -74,13 +74,11 @@ impl MachineInstr { let mut out = Vec::new(); - let mut index = 0; - for operand in &mut self.operands { if let MachineOperand::Imm(imm) = operand { let imm = *imm; - let constant = module.addConst(&format!(".cimm{}", index)); + let constant = module.addConst(&format!(".cimm{}", module.const_index)); constant.private(); if self.meta == TypeMetadata::f32 { @@ -116,7 +114,7 @@ impl MachineInstr { *operand = float.into(); - index += 1; + module.const_index += 1; } } diff --git a/src/IR/module.rs b/src/IR/module.rs index ab77399d..aad2953b 100644 --- a/src/IR/module.rs +++ b/src/IR/module.rs @@ -12,6 +12,9 @@ pub struct Module { pub(crate) funcs: HashMap, pub(crate) consts: HashMap, pub(crate) dbg_registry: Option, + + /// The number of current constants + pub(crate) const_index: usize, } impl Module { @@ -21,6 +24,7 @@ impl Module { funcs: HashMap::new(), consts: HashMap::new(), dbg_registry: None, + const_index: 0, } } diff --git a/src/Obj/wrapper.rs b/src/Obj/wrapper.rs index 08db5094..4308e334 100644 --- a/src/Obj/wrapper.rs +++ b/src/Obj/wrapper.rs @@ -5,7 +5,7 @@ use object::{Architecture, BinaryFormat, Endianness, FileFlags, RelocationEncodi use crate::debug::DebugRegistry; use crate::prelude::Triple; -use crate::Target::{self, Arch, CallConv}; +use crate::Target::{self, Arch}; use std::collections::BTreeMap; use std::fmt::Display; use std::fs::File; @@ -344,7 +344,7 @@ impl ObjectBuilder { for link in &self.links { let (_, off, _, _, _, _) = syms.get(&link.from).expect("expectd valid link source"); - let (_, _, to_sym, ty, _, _) = syms.get(&link.to).expect("expected valid link destination"); + let (_, _, to_sym, _, _, _) = syms.get(&link.to).expect("expected valid link destination"); let addend = 0; let offset = -3; diff --git a/src/Target/x64/lower/stack.rs b/src/Target/x64/lower/stack.rs index 31c0af6e..4f051daa 100644 --- a/src/Target/x64/lower/stack.rs +++ b/src/Target/x64/lower/stack.rs @@ -78,8 +78,6 @@ pub(crate) fn x64_lower_load(sink: &mut Vec, instr: &MachineInstr) { let out = instr.out.expect("stack stores need a output"); let ptr = instr.operands.get(0).expect("stack stores need one operand"); - println!("ptr: {:?}", ptr); - let ptr: Operand = (*ptr).into(); let out = out.into();