Skip to content

Commit

Permalink
[FIX] fixed constant numbering
Browse files Browse the repository at this point in the history
  • Loading branch information
Cr0a3 committed Oct 15, 2024
1 parent a333906 commit 8c70ea9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/CodeGen/instr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -116,7 +114,7 @@ impl MachineInstr {

*operand = float.into();

index += 1;
module.const_index += 1;
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/IR/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ pub struct Module {
pub(crate) funcs: HashMap<String, Function>,
pub(crate) consts: HashMap<String, Const>,
pub(crate) dbg_registry: Option<DebugRegistry>,

/// The number of current constants
pub(crate) const_index: usize,
}

impl Module {
Expand All @@ -21,6 +24,7 @@ impl Module {
funcs: HashMap::new(),
consts: HashMap::new(),
dbg_registry: None,
const_index: 0,
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Obj/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/Target/x64/lower/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ pub(crate) fn x64_lower_load(sink: &mut Vec<X64MCInstr>, 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();
Expand Down

0 comments on commit 8c70ea9

Please sign in to comment.