fun processir externs (Tree.FUNCTION (id, ir)) =
let
- val name = "_l3_" ^ (Symbol.name id)
+ val name = "_l4_" ^ (Symbol.name id)
fun realname s = if (List.exists (fn n => s = n) externs)
then s
- else "_l3_" ^ s
+ else "_l4_" ^ s
val _ = Flag.guard flag_verbose say ("Processing function: " ^ name)
val _ = Flag.guard flag_verbose say " Generating proto-x86_64 code..."
val assem = Codegen.codegen ir
val _ = Flag.guard flag_assem
- (fn () => List.app (TextIO.print o (x86.prettyprint x86.Long)) assem) ()
+ (fn () => List.app (TextIO.print o (x86.prettyprint)) assem) ()
val _ = Flag.guard flag_verbose say " Analyzing liveness..."
val (preds, liveness) = Liveness.liveness assem;
(fn (asm, liv) =>
TextIO.print (
let
- val xpp = x86.prettyprint x86.Long asm
+ val xpp = x86.prettyprint asm
val xpp = String.extract (xpp, 0, SOME (size xpp - 1))
val spaces = implode (List.tabulate (40 - size xpp, fn _ => #" ")) handle size => ""
val lpp = Liveness.prettyprint liv
(fn () => List.app (TextIO.print o
(fn (t, i) =>
(Temp.name t) ^ " => " ^ (
- if (i <= x86.regtonum x86.R14D)
+ if (i <= x86.regtonum x86.R13D)
then (x86.prettyprint_oper x86.Long (x86.REG (x86.numtoreg i)))
else
- "spill[" ^ Int.toString (i - x86.regtonum x86.R14D) ^ "]")
+ "spill[" ^ Int.toString (i - x86.regtonum x86.R13D) ^ "]")
^ "--"^ Int.toString i ^ "\n"))
colors) ()
val _ = Flag.guard flag_verbose say ("Parsing... " ^ source)
val ast = Parse.parse source
+ val (_, funcs) = ast
val _ = Flag.guard flag_ast
(fn () => say (Ast.Print.pp_program ast)) ()
-
- val externs = List.mapPartial
- (fn (Ast.Function _) => NONE
- | (Ast.Extern (_, s, _)) => SOME (Symbol.name s)) ast
-
+
+ val externs = Symbol.mapPartiali
+ (fn (a, b) => case (AstUtils.Function.data b)
+ of Ast.Extern _ => SOME(Symbol.name a)
+ | _ => NONE
+ ) funcs
+
val _ = Flag.guard flag_verbose say "Checking..."
val ast = TypeChecker.typecheck ast
-
+
val _ = Flag.guard flag_verbose say "Translating..."
val ir = Trans.translate ast
val _ = Flag.guard flag_ir (fn () => say (Tree.Print.pp_program ir)) ()
- val output = foldr (fn (func, code) => (processir externs func) ^ code)
- (".file\t\"" ^ source ^ "\"\n.ident\t\"15-411 L3 compiler by czl@ and jwise@\"\n") ir
+ val output = foldr (fn (func, code) => (processir ("calloc" (* lololololol *) :: (Symbol.elems externs)) func) ^ code)
+ (".file\t\"" ^ source ^ "\"\n.ident\t\"15-411 L4 compiler by czl@ and jwise@\"\n") ir
val afname = stem source ^ ".s"
val _ = Flag.guard flag_verbose say ("Writing assembly to " ^ afname ^ " ...")