Skip to content

Commit

Permalink
Fix Emission Bugs (#42)
Browse files Browse the repository at this point in the history
* Fix unintentional fallthrough cases

* Remove bad alignment
  • Loading branch information
Yey007 authored May 15, 2024
1 parent 920d552 commit dfa89c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
![CI Status](https://github.com/ethanuppal/cs3110_compiler/actions/workflows/ci.yaml/badge.svg)

> "x86 is simple trust me bro"
> Last updated: 2024-05-15 00:23:21.691740
> Last updated: 2024-05-15 08:53:26.702436
```
$ ./main -h
Expand Down
10 changes: 5 additions & 5 deletions lib/backend/asm_emit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,16 @@ let emit_preamble ~text =
(Asm.Label.make ~is_global:false ~is_external:true debug_print_symbol))

let emit_cfg ~text cfg regalloc =
let entry = Cfg.entry_to cfg in
Asm.Section.add text
(Label
(Asm.Label.make ~is_global:true ~is_external:false
(mangle (Cfg.name_of cfg))));
(* no need to align here, we can assume as a callee that 8 bytes for the
return address was already pushed to the stack. *)
Asm.Section.add_all text
[
Push (Register RBP);
Mov (Register RBP, Register RSP);
Sub (Register RSP, Intermediate (align_offset var_size));
];
[ Push (Register RBP); Mov (Register RBP, Register RSP) ];
(* restore is done at returns *)
emit_save_registers text Asm.Register.callee_saved_data_registers;
Asm.Section.add text (Jmp (Label (Basic_block.label_for entry)));
Cfg.blocks_of cfg |> List.iter (emit_bb text cfg regalloc)

0 comments on commit dfa89c1

Please sign in to comment.