1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Objective Caml *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* Automatique. Distributed only by permission. *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
1995-08-13 02:31:50 -07:00
|
|
|
open Clflags
|
|
|
|
|
1995-07-02 09:47:24 -07:00
|
|
|
let compile_file filename =
|
1997-07-26 02:01:39 -07:00
|
|
|
Compilenv.reset "test";
|
1995-11-21 12:27:50 -08:00
|
|
|
Emit.begin_assembly();
|
1995-07-02 09:47:24 -07:00
|
|
|
let ic = open_in filename in
|
|
|
|
let lb = Lexing.from_channel ic in
|
|
|
|
try
|
|
|
|
while true do
|
|
|
|
Asmgen.compile_phrase(Parsecmm.phrase Lexcmm.token lb)
|
|
|
|
done
|
|
|
|
with
|
|
|
|
End_of_file ->
|
1995-11-21 12:27:50 -08:00
|
|
|
close_in ic; Emit.end_assembly()
|
1995-07-02 09:47:24 -07:00
|
|
|
| Lexcmm.Error msg ->
|
|
|
|
close_in ic; Lexcmm.report_error lb msg
|
|
|
|
| Parsing.Parse_error ->
|
|
|
|
close_in ic;
|
|
|
|
prerr_string "Syntax error near character ";
|
|
|
|
prerr_int (Lexing.lexeme_start lb);
|
|
|
|
prerr_newline()
|
|
|
|
| Parsecmmaux.Error msg ->
|
|
|
|
close_in ic; Parsecmmaux.report_error msg
|
|
|
|
| x ->
|
|
|
|
close_in ic; raise x
|
|
|
|
|
1996-10-24 07:17:48 -07:00
|
|
|
let usage = "Usage: codegen <options> <files>\noptions are:"
|
|
|
|
|
1995-07-02 09:47:24 -07:00
|
|
|
let main() =
|
1996-10-24 07:17:48 -07:00
|
|
|
Arg.parse [
|
|
|
|
"-dcmm", Arg.Set dump_cmm, "";
|
|
|
|
"-dsel", Arg.Set dump_selection, "";
|
1995-08-13 02:31:50 -07:00
|
|
|
"-dlive", Arg.Unit(fun () -> dump_live := true;
|
1996-10-24 07:17:48 -07:00
|
|
|
Printmach.print_live := true), "";
|
|
|
|
"-dspill", Arg.Set dump_spill, "";
|
|
|
|
"-dsplit", Arg.Set dump_split, "";
|
|
|
|
"-dinterf", Arg.Set dump_interf, "";
|
|
|
|
"-dprefer", Arg.Set dump_prefer, "";
|
|
|
|
"-dalloc", Arg.Set dump_regalloc, "";
|
|
|
|
"-dreload", Arg.Set dump_reload, "";
|
|
|
|
"-dscheduling", Arg.Set dump_scheduling, "";
|
|
|
|
"-dlinear", Arg.Set dump_linear, ""
|
|
|
|
] compile_file usage
|
1995-07-02 09:47:24 -07:00
|
|
|
|
|
|
|
let _ = Printexc.catch main (); exit 0
|
|
|
|
|