Skip to content

Commit

Permalink
Fix emission format
Browse files Browse the repository at this point in the history
  • Loading branch information
koba-e964 committed Dec 12, 2019
1 parent e31a073 commit 3fbf38f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/x86_64/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,12 @@ let h oc { name = Id.L(x); args = _; fargs = _; body = e; ret = _ } =

pub fn f(Prog(data, fundefs, e): Prog, id_gen: &mut IdGen) -> Result<Vec<Instr>, Error> {
let mut instrs = Vec::new();
instrs.push(Instr::Label(".data".to_string()));
instrs.push(Instr::Section(".data".to_string()));
instrs.push(Instr::BAlign(8));
for (id::L(x), d) in data.into_vec() {
// TODO
}
instrs.push(Instr::Section(".text".to_string()));
for fundef in fundefs.into_vec() {
h(&mut instrs, fundef, id_gen)?;
}
Expand Down
2 changes: 2 additions & 0 deletions src/x86_64/instr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub enum Instr {
Label(String),
BAlign(i32),
Globl(String),
Section(String),
// instructions
MovRR(R64, R64),
MovIR(i32, R64),
Expand All @@ -103,6 +104,7 @@ impl Display for Instr {
Instr::Label(s) => writeln!(f, "{}:", s)?,
Instr::BAlign(align) => writeln!(f, ".balign\t{}", align)?,
Instr::Globl(s) => writeln!(f, ".globl\t{}", s)?,
Instr::Section(name) => writeln!(f, "{}", name)?,
Instr::MovRR(src, dst) => writeln!(f, " movq {}, {}", src, dst)?,
Instr::MovIR(src, dst) => writeln!(f, " movq ${}, {}", src, dst)?,
Instr::MovMR(src, dst) => writeln!(f, " movq {}, {}", src, dst)?,
Expand Down

0 comments on commit 3fbf38f

Please sign in to comment.