X-Git-Url: http://git.joshuawise.com/snipe.git/blobdiff_plain/de034162d9af50e6bfb454f4de67213d856137c4..d4e2479e280733505420e57db97768688ceda49a:/top/top.sml diff --git a/top/top.sml b/top/top.sml index 6a132c6..c03263f 100644 --- a/top/top.sml +++ b/top/top.sml @@ -104,7 +104,7 @@ struct val _ = Flag.guard Flags.verbose say ("Processing function: " ^ name) - val _ = Flag.guard Flags.verbose say " Generating proto-x86_64 code..." + val _ = Flag.guard Flags.verbose say " Generating proto-blargCPU code..." val assem = Codegen.codegen ir val _ = Flag.guard Flags.assem (fn () => List.app (TextIO.print o (Blarg.print)) assem) () @@ -142,26 +142,26 @@ struct (fn () => List.app (TextIO.print o (fn (t, i) => (Temp.name t) ^ " => " ^ ( - if (i <= Blarg.regtonum Blarg.R3) + if (i <= 10) then (Blarg.pp_oper (Blarg.REG (Blarg.numtoreg i))) else - "spill[" ^ Int.toString (i - Blarg.regtonum Blarg.R3) ^ "]") + "spill[" ^ Int.toString (i - 11) ^ "]") ^ "--"^ Int.toString i ^ "\n")) colors) () -(* val _ = Flag.guard Flags.verbose say " Solidifying blargCPU code..." + val _ = Flag.guard Flags.verbose say " Solidifying blargCPU code..." val x86 = Solidify.solidify colors assem val _ = Flag.guard Flags.verbose say " Optimizing final assembly..." val x86p = Optimizer.optimize_final (!enabledopts) x86 val _ = Flag.guard Flags.verbose say " Stringifying..." - val x86d = [x86.DIRECTIVE(".globl " ^ name), - x86.DIRECTIVE(name ^ ":")] + val x86d = [Blarg.DIRECTIVE(".globl " ^ name), + Blarg.DIRECTIVE(name ^ ":")] @ x86p - val code = Stringify.stringify realname x86d*) + val code = Stringify.stringify realname x86d in - "" + code end fun main (name, args) = @@ -213,10 +213,22 @@ struct val _ = Flag.guard Flags.verbose say "Optimizing whole-program IR..." val ir = Optimizer.optimize_ir (!enabledopts) ir val _ = Flag.guard Flags.ir (fn () => say (TreeUtils.Print.pp_program ir)) () - - val output = foldr (fn (func, code) => (processir ("calloc" (* lololololol *) :: (Symbol.elems externs)) func) ^ code) - (".file\t\"" ^ source ^ "\"\n.ident\t\"15-411 ASS compiler by czl@ and jwise@\"\n" ^ - ".ident \"Optimizations enabled: " ^ String.concat (map (fn x => (#shortname x) ^ " ") (!enabledopts)) ^ "\"\n") ir + + val code = map (fn func => processir ("calloc" (* lololololol *) :: (Symbol.elems externs)) func) ir + val strings = map (fn (sn, s) => String.concat ( + [Stringref.name sn, ": .word "] @ + (map (fn c => (Int.toString (ord c)) ^ ", ") (String.explode s)) @ + ["0\n"] + ) ) (Stringref.all ()) + + val output = + String.concat ( + ".file\t\"" :: source :: "\"\n" :: + ".ident\t\"15-411 ASS compiler by czl@ and jwise@\"\n" :: + ".ident \"Optimizations enabled: " :: (map (fn x => (#shortname x) ^ " ") (!enabledopts)) @ [ "\"\n" ] @ + code @ + [ ".section .rodata\n" ] @ + strings ) val afname = stem source ^ ".s" val _ = Flag.guard Flags.verbose say ("Writing assembly to " ^ afname ^ " ...")