[m-rev.] diff: add initial support for --target x86_64

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Jan 5 16:26:40 AEDT 2007


Estimated hours taken: 2
Branches: main

Add some preliminary infrastructure for the LLDS->x86_64 assembler
code generator that Fransiska is working on.

compiler/globals.m:
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
 	Recognise "x86_64" as a valid compilation target.

 	Add new options: `--x86_64' and `--x86_64-only' as synonyms
 	for `--target x86_64' and `--target x86_64 --target-code-only'.
 	XXX the new options are currently undocumented.

 	In the backend passes for the lowlevel backend branch
 	appropriately depending on whether we are generating C or
 	x86_64 assembler.

compiler/foreign.m:
 	When compiling to x86_64 assembler use C as the preferred foreign
 	language.

compiler/mlds.m:
compiler/ml_code_gen.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
 	Handle "x86_64" as a target in the MLDS backend.  This does
 	(and should) cause a compiler abort since "x86_64" is intended
 	to be an MLDS target language.

compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/modules.m:
 	Add placeholders for --target x86_64 in the build systems.

compiler/make_hlds_passes.m.
 	We don't currently support mutables with --target x86_64.

compiler/simplify.m:
 	We don't currently support runtime conditions on trace goals
 	with --target x86_64.

compiler/add_type.m:
compiler/compile_target_code.m:
compiler/granularity.m:
compiler/intermod.m:
 	Conform to the above changes.

Julien.

Index: compiler/add_type.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_type.m,v
retrieving revision 1.24
diff -u -r1.24 add_type.m
--- compiler/add_type.m	1 Dec 2006 15:03:49 -0000	1.24
+++ compiler/add_type.m	3 Jan 2007 03:43:14 -0000
@@ -449,6 +449,7 @@
              ; Target = target_il, LangStr = "IL"
              ; Target = target_java, LangStr = "Java"
              ; Target = target_asm, LangStr = "C"
+            ; Target = target_x86_64, LangStr = "C"
              ),
              MainPieces = [words("Error: no"), fixed(LangStr),
                  fixed("`pragma foreign_type'"), words("declaration for"),
Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.102
diff -u -r1.102 compile_target_code.m
--- compiler/compile_target_code.m	19 Dec 2006 04:09:02 -0000	1.102
+++ compiler/compile_target_code.m	3 Jan 2007 03:22:20 -0000
@@ -1007,6 +1007,7 @@
          ( Target = target_c
          ; Target = target_java
          ; Target = target_il
+        ; Target = target_x86_64
          ),
          join_module_list(Modules, Obj, ObjectsList, !IO)
      ),
Index: compiler/foreign.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/foreign.m,v
retrieving revision 1.68
diff -u -r1.68 foreign.m
--- compiler/foreign.m	3 Jan 2007 11:22:32 -0000	1.68
+++ compiler/foreign.m	5 Jan 2007 04:05:02 -0000
@@ -527,6 +527,8 @@
          ( ForeignTypeBody ^ java = yes(_) -> yes ; no )).
  have_foreign_type_for_backend(target_asm, ForeignTypeBody, Result) :-
      have_foreign_type_for_backend(target_c, ForeignTypeBody, Result).
+have_foreign_type_for_backend(target_x86_64, ForeignTypeBody, Result) :-
+    have_foreign_type_for_backend(target_c, ForeignTypeBody, Result).

  :- type exported_type
      --->    foreign(sym_name, list(foreign_type_assertion))
@@ -610,6 +612,17 @@
              MaybeC = no,
              unexpected(this_file, "to_exported_type: no C type")
          )
+    ;
+        Target = target_x86_64,
+        (
+            MaybeC = yes(Data),
+            Data = foreign_type_lang_data(c_type(NameStr), MaybeUserEqComp,
+                Assertions),
+            Name = unqualified(NameStr)
+        ;
+            MaybeC = no,
+            unexpected(this_file, "to_exported_type: no C type")
+        )
      ).

  is_foreign_type(foreign(_, Assertions)) = yes(Assertions).
Index: compiler/globals.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/globals.m,v
retrieving revision 1.78
diff -u -r1.78 globals.m
--- compiler/globals.m	2 Oct 2006 09:06:49 -0000	1.78
+++ compiler/globals.m	3 Jan 2007 12:06:24 -0000
@@ -42,10 +42,12 @@
                              % IL is the Microsoft .NET Intermediate Language.
      ;       target_java     % Generate Java.
                              % (Work in progress)
-    ;       target_asm.     % Compile directly to assembler via the GCC
+    ;       target_asm      % Compile directly to assembler via the GCC
                              % back-end. Do not go via C, instead generate GCC's
                              % internal `tree' data structure.
                              % (Work in progress.)
+    ;       target_x86_64.  % Compile directly to x86_64 assembler.
+                            % (Work in progress.)

  :- type foreign_language
      --->    lang_c
@@ -279,6 +281,7 @@
  convert_target_2("asm", target_asm).
  convert_target_2("il", target_il).
  convert_target_2("c", target_c).
+convert_target_2("x86_64", target_x86_64).

  convert_foreign_language(String, ForeignLanguage) :-
      convert_foreign_language_2(string.to_lower(String), ForeignLanguage).
@@ -320,6 +323,7 @@
  compilation_target_string(target_il)   = "IL".
  compilation_target_string(target_java) = "Java".
  compilation_target_string(target_asm)  = "asm".
+compilation_target_string(target_x86_64) = "x86_64".

  foreign_language_string(lang_c) = "C".
  foreign_language_string(lang_managed_cplusplus) = "Managed C++".
Index: compiler/granularity.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/granularity.m,v
retrieving revision 1.4
diff -u -r1.4 granularity.m
--- compiler/granularity.m	5 Dec 2006 03:50:50 -0000	1.4
+++ compiler/granularity.m	3 Jan 2007 11:47:47 -0000
@@ -153,6 +153,7 @@
              ( Target = target_il
              ; Target = target_java
              ; Target = target_asm
+            ; Target = target_x86_64
              ),
              % This should have caught by mercury_compile.m.
              unexpected(this_file, "runtime_granularity_test_in_goal: " ++
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.290
diff -u -r1.290 handle_options.m
--- compiler/handle_options.m	3 Jan 2007 10:54:04 -0000	1.290
+++ compiler/handle_options.m	5 Jan 2007 04:41:47 -0000
@@ -217,7 +217,7 @@
      ;
          Target = target_c,     % dummy
          add_error("Invalid target option " ++
-            "(must be `c', `asm', `il', or `java')", !Errors)
+            "(must be `c', `asm', `il', `java', or `x86_64')", !Errors)
      ),
      map.lookup(!.OptionTable, gc, GC_Method0),
      (
@@ -532,6 +532,7 @@
              ( Target = target_c
              ; Target = target_java
              ; Target = target_asm
+            ; Target = target_x86_64
              )
          ),

@@ -620,6 +621,7 @@
              ( Target = target_c
              ; Target = target_il
              ; Target = target_asm
+            ; Target = target_x86_64
              )
          ),
          % Generating assembler via the gcc back-end requires
@@ -631,6 +633,7 @@
              ( Target = target_c
              ; Target = target_il
              ; Target = target_java
+            ; Target = target_x86_64
              )
          ),

@@ -1113,6 +1116,7 @@
                      ( Target = target_c
                      ; Target = target_java
                      ; Target = target_asm
+                    ; Target = target_x86_64
                      )
                  )
              ;
@@ -1782,6 +1786,9 @@
              Target = target_java,
              BackendForeignLanguages = ["java"],
              set_option(optimize_constructor_last_call, bool(no), !Globals)
+        ;
+            Target = target_x86_64,
+            BackendForeignLanguages = ["c"]
          ),

          % Only set the backend foreign languages if they are unset.
Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.215
diff -u -r1.215 intermod.m
--- compiler/intermod.m	21 Dec 2006 06:33:58 -0000	1.215
+++ compiler/intermod.m	3 Jan 2007 11:49:06 -0000
@@ -1042,6 +1042,7 @@
      (
          ( Target = target_c
          ; Target = target_asm
+        ; Target = target_x86_64
          ),
          resolve_foreign_type_body_overloading_2(ModuleInfo, TypeCtor,
              MaybeC0, MaybeC, !Info)
@@ -1059,6 +1060,7 @@
          ( Target = target_c
          ; Target = target_asm
          ; Target = target_java
+        ; Target = target_x86_64
          ),
          MaybeIL = MaybeIL0
      ),
@@ -1070,6 +1072,7 @@
          ( Target = target_c
          ; Target = target_asm
          ; Target = target_il
+        ; Target = target_x86_64
          ),
          MaybeJava = MaybeJava0
      ).
Index: compiler/make.module_target.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.module_target.m,v
retrieving revision 1.51
diff -u -r1.51 make.module_target.m
--- compiler/make.module_target.m	1 Dec 2006 15:04:05 -0000	1.51
+++ compiler/make.module_target.m	5 Jan 2007 04:59:48 -0000
@@ -469,6 +469,9 @@
          !IO) :-
      compile_target_code.il_assemble(ErrorStream, ModuleName,
          Imports ^ has_main, Succeeded, !IO).
+build_object_code(_ModuleName, target_x86_64, _, _ErrorStream, _Imports,
+        _Succeeded, _, _) :-
+    sorry(this_file, "NYI mmc --make and target x86_64").

  :- pred compile_foreign_code_file(io.output_stream::in, pic::in,
      module_imports::in, foreign_code_file::in, bool::out,
@@ -557,6 +560,9 @@
      ;
          CompilationTarget = target_java,
          sorry(this_file, "object extension for java")
+    ;
+        CompilationTarget = target_x86_64,
+        sorry(this_file, "mmc --make NYI and target x86_64")
      ).

  %-----------------------------------------------------------------------------%
@@ -827,6 +833,9 @@
              ; CompilationTarget = target_java
              ),
              HeaderTargets0 = []
+        ;
+            CompilationTarget = target_x86_64,
+            sorry(this_file, "NYI mmc --make and target x86_64")
          ),

          (
@@ -952,6 +961,7 @@
      ;
          ( CompilationTarget = target_java
          ; CompilationTarget = target_il
+        ; CompilationTarget = target_x86_64
          ),
          ForeignFiles = ForeignFiles0
      ).
Index: compiler/make.program_target.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.64
diff -u -r1.64 make.program_target.m
--- compiler/make.program_target.m	5 Dec 2006 02:51:21 -0000	1.64
+++ compiler/make.program_target.m	3 Jan 2007 07:19:37 -0000
@@ -141,6 +141,9 @@
              IntermediateTargetType = module_target_java_code,
              % XXX Whoever finishes the Java backend can fill this in.
              ObjectTargetType = module_target_object_code(non_pic)
+        ;
+            CompilationTarget = target_x86_64,
+            sorry(this_file, "mmc --make and target x86_64")
          ),

          get_target_modules(IntermediateTargetType,
@@ -272,6 +275,7 @@
      ;
          ( CompilationTarget = target_java
          ; CompilationTarget = target_il
+        ; CompilationTarget = target_x86_64
          ),
          ObjectTargets = ForeignObjectTargets
      ).
@@ -430,7 +434,9 @@
          % after all the object files on the linker command line.
          AllObjects = InitObjects ++ ObjList ++ ForeignObjects ++ LinkObjects,
          (
-            CompilationTarget = target_c,
+            ( CompilationTarget = target_c
+            ; CompilationTarget = target_asm
+            ),
              % Run the link in a separate process so it can be killed
              % if an interrupt is received.
              call_in_forked_process(
@@ -438,13 +444,8 @@
                      FileType, MainModuleName, AllObjects),
                  Succeeded, !IO)
          ;
-            CompilationTarget = target_asm,
-            % Run the link in a separate process so it can
-            % be killed if an interrupt is received.
-            call_in_forked_process(
-                compile_target_code.link(ErrorStream,
-                    FileType, MainModuleName, AllObjects),
-                Succeeded, !IO)
+            CompilationTarget = target_x86_64,
+            sorry(this_file, "mmc --make and target x86_64")
          ;
              CompilationTarget = target_il,
              Succeeded = yes
Index: compiler/make_hlds_passes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_hlds_passes.m,v
retrieving revision 1.61
diff -u -r1.61 make_hlds_passes.m
--- compiler/make_hlds_passes.m	11 Dec 2006 07:46:25 -0000	1.61
+++ compiler/make_hlds_passes.m	3 Jan 2007 04:28:33 -0000
@@ -747,6 +747,7 @@
              ( CompilationTarget = target_il
              ; CompilationTarget = target_java
              ; CompilationTarget = target_asm
+            ; CompilationTarget = target_x86_64
              ),
              Pieces = [words("Error: foreign_name mutable attribute not yet"),
                  words("implemented for the"),
@@ -988,6 +989,7 @@
              ( Target = target_c
              ; Target = target_il
              ; Target = target_asm
+            ; Target = target_x86_64
              ),
              add_pragma_type_spec(Pragma, Context, !ModuleInfo, !QualInfo,
                  !Specs)
@@ -1402,6 +1404,7 @@
          ( CompilationTarget = target_il
          ; CompilationTarget = target_java
          ; CompilationTarget = target_asm
+        ; CompilationTarget = target_x86_64
          ),
          true
      ).
@@ -1819,6 +1822,7 @@
          ( Backend = target_il
          ; Backend = target_java
          ; Backend = target_asm
+        ; Backend = target_x86_64
          ),
          sorry(this_file, "we don't yet support mutables for non-C backends")
      ).
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.420
diff -u -r1.420 mercury_compile.m
--- compiler/mercury_compile.m	27 Dec 2006 03:44:11 -0000	1.420
+++ compiler/mercury_compile.m	5 Jan 2007 04:48:31 -0000
@@ -434,6 +434,7 @@
                      ( Target = target_c
                      ; Target = target_il
                      ; Target = target_asm
+                    ; Target = target_x86_64
                      ),
                      compile_with_module_options(MainModuleName,
                          OptionVariables, OptionArgs,
@@ -1321,6 +1322,7 @@
      ; CompilationTarget = target_il, TargetSuffix = ".il"
      ; CompilationTarget = target_java, TargetSuffix = ".java"
      ; CompilationTarget = target_asm, TargetSuffix = ".s"
+    ; CompilationTarget = target_x86_64, TargetSuffix = ".s"
      ),
      FindTargetFiles = usual_find_target_files(CompilationTarget,
          TargetSuffix, TopLevelModuleName).
@@ -1362,6 +1364,9 @@
      ;
          CompilationTarget = target_asm,
          TimestampSuffix = (Pic = yes -> ".pic_s_date" ; ".s_date")
+    ;
+        CompilationTarget = target_x86_64,
+        TimestampSuffix = ".s_date"
      ),
      FindTimestampFiles = find_timestamp_files_2(CompilationTarget,
          TimestampSuffix, TopLevelModuleName).
@@ -1533,6 +1538,7 @@
          (
              ( Target = target_c
              ; Target = target_asm
+            ; Target = target_x86_64
              ),
              %
              % Produce the grade independent header file <module>.mh
@@ -1629,6 +1635,15 @@
                  output_pass(!.HLDS, GlobalData, LLDS, ModuleName,
                      _CompileErrors, FactTableBaseFiles, !IO)
              )
+        ;
+            Target = target_x86_64,
+            backend_pass(!HLDS, GlobalData, LLDS, !DumpInfo, !IO),
+            % XXX Eventually we will call the LLDS->x86_64 asm code
+            % generator here and then output the assembler.  At the moment
+            % we just output the LLDS as C code.
+            output_pass(!.HLDS, GlobalData, LLDS, ModuleName,
+                _CompileErrors, _, !IO),
+            FactTableBaseFiles = []
          ),
          recompilation.usage.write_usage_file(!.HLDS, NestedSubModules,
              MaybeTimestamps, !IO),
@@ -3337,6 +3352,7 @@
              ( Target = target_il
              ; Target = target_java
              ; Target = target_asm
+            ; Target = target_x86_64
              ),
              GenerateInline = no
          ),
@@ -3904,6 +3920,7 @@
              ( Target = target_il
              ; Target = target_java
              ; Target = target_asm
+            ; Target = target_x86_64
              )
              % Leave the HLDS alone. We cannot implement parallelism,
              % so there is not point in controlling its granularity.
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.194
diff -u -r1.194 ml_code_gen.m
--- compiler/ml_code_gen.m	3 Jan 2007 11:22:32 -0000	1.194
+++ compiler/ml_code_gen.m	5 Jan 2007 05:06:29 -0000
@@ -902,6 +902,8 @@
      ).
  foreign_type_required_imports(target_java, _) = [].
  foreign_type_required_imports(target_asm, _) = [].
+foreign_type_required_imports(target_x86_64, _) = _ :-
+    unexpected(this_file, "target x86_64 and --high-level-code").

  :- pred ml_gen_defns(module_info::in, mlds_defns::out, io::di, io::uo) is det.

@@ -2413,6 +2415,10 @@
              ; Target = target_asm
              ),
              ml_gen_call_current_success_cont(Context, CallCont, !Info)
+        ;
+            Target = target_x86_64,
+            unexpected(this_file,
+                "target x86_64 with --high-level-code")
          )
      ;
          unexpected(this_file,
Index: compiler/ml_optimize.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_optimize.m,v
retrieving revision 1.47
diff -u -r1.47 ml_optimize.m
--- compiler/ml_optimize.m	23 Dec 2006 12:49:23 -0000	1.47
+++ compiler/ml_optimize.m	5 Jan 2007 05:06:03 -0000
@@ -455,6 +455,8 @@
  target_supports_break_and_continue_2(target_il) = no.
  target_supports_break_and_continue_2(target_java) = yes.
  % target_supports_break_and_continue_2(target_c_sharp) = yes.
+target_supports_break_and_continue_2(target_x86_64) = _ :-
+    unexpected(this_file, "target x86_64 with --high-level-code").

  %-----------------------------------------------------------------------------%

Index: compiler/ml_switch_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_switch_gen.m,v
retrieving revision 1.28
diff -u -r1.28 ml_switch_gen.m
--- compiler/ml_switch_gen.m	1 Dec 2006 15:04:08 -0000	1.28
+++ compiler/ml_switch_gen.m	5 Jan 2007 05:06:48 -0000
@@ -273,12 +273,16 @@
  target_supports_int_switch_2(target_il) = no.
  target_supports_int_switch_2(target_java) = yes.
  % target_supports_int_switch_2(c_sharp) = yes.
+target_supports_int_switch_2(target_x86_64) =
+    unexpected(this_file, "target x86_64 with --high-level code").

  target_supports_string_switch_2(target_c) = no.
  target_supports_string_switch_2(target_asm) = no.
  target_supports_string_switch_2(target_il) = no.
  target_supports_string_switch_2(target_java) = no.
  % target_supports_string_switch_2(c_sharp) = yes.
+target_supports_string_switch_2(target_x86_64) =
+    unexpected(this_file, "target x86_64 with --high-level code").

  target_supports_computed_goto_2(target_c) = yes.
  target_supports_computed_goto_2(target_asm) = no.
@@ -287,12 +291,16 @@
  target_supports_computed_goto_2(target_il) = yes.
  target_supports_computed_goto_2(target_java) = no.
  % target_supports_computed_goto_2(c_sharp) = no.
+target_supports_computed_goto_2(target_x86_64) =
+    unexpected(this_file, "target x86_64 with --high-level code").

  target_supports_goto_2(target_c) = yes.
  target_supports_goto_2(target_asm) = yes.
  target_supports_goto_2(target_il) = yes.
  target_supports_goto_2(target_java) = no.
  % target_supports_goto_2(c_sharp) = yes.
+target_supports_goto_2(target_x86_64) =
+    unexpected(this_file, "target x86_64 with --high-level code").

  %-----------------------------------------------------------------------------%

Index: compiler/ml_type_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_type_gen.m,v
retrieving revision 1.63
diff -u -r1.63 ml_type_gen.m
--- compiler/ml_type_gen.m	23 Dec 2006 12:49:23 -0000	1.63
+++ compiler/ml_type_gen.m	3 Jan 2007 07:29:43 -0000
@@ -725,6 +725,8 @@
  target_uses_constructors(target_il) = yes.
  target_uses_constructors(target_java) = yes.
  target_uses_constructors(target_asm) = no.
+target_uses_constructors(target_x86_64) =
+    unexpected(this_file, "target_x86_64 and --high-level-code").

  :- func target_uses_empty_base_classes(compilation_target) = bool.

@@ -732,6 +734,8 @@
  target_uses_empty_base_classes(target_il) = yes.
  target_uses_empty_base_classes(target_java) = yes.
  target_uses_empty_base_classes(target_asm) = no.
+target_uses_empty_base_classes(target_x86_64) = 
+    unexpected(this_file, "target_x86_64 and --high-level-code").

      % This should return yes if references to function parameters in
      % constructor functions must be qualified with the module name,
@@ -747,6 +751,8 @@
  target_requires_module_qualified_params(target_il) = no.
  target_requires_module_qualified_params(target_java) = yes.
  target_requires_module_qualified_params(target_asm) = no.
+target_requires_module_qualified_params(target_x86_64) = 
+    unexpected(this_file, "target_x86_64 with --high-level-code").

  :- func gen_constructor_function(globals, mlds_class_id,
      mlds_type, mlds_module_name, mlds_class_id, maybe(int), mlds_defns,
Index: compiler/ml_unify_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.109
diff -u -r1.109 ml_unify_gen.m
--- compiler/ml_unify_gen.m	1 Dec 2006 15:04:09 -0000	1.109
+++ compiler/ml_unify_gen.m	3 Jan 2007 07:30:38 -0000
@@ -527,6 +527,8 @@
  target_supports_inheritence(target_il) = yes.
  target_supports_inheritence(target_java) = yes.
  target_supports_inheritence(target_asm) = no.
+target_supports_inheritence(target_x86_64) =
+    unexpected(this_file, "target_x86_64 and --high-level-code").

  %-----------------------------------------------------------------------------%

Index: compiler/mlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds.m,v
retrieving revision 1.145
diff -u -r1.145 mlds.m
--- compiler/mlds.m	23 Dec 2006 12:49:22 -0000	1.145
+++ compiler/mlds.m	5 Jan 2007 05:07:08 -0000
@@ -1832,6 +1832,9 @@
                  sorry(this_file,
                      "mercury_type_to_mlds_type: No C foreign type")
              )
+        ;
+            Target = target_x86_64,
+            unexpected(this_file, "target x86_64 with --high-level-code")
          ),
          MLDSType = mlds_foreign_type(ForeignType)
      ;
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.207
diff -u -r1.207 mlds_to_c.m
--- compiler/mlds_to_c.m	23 Dec 2006 12:49:24 -0000	1.207
+++ compiler/mlds_to_c.m	3 Jan 2007 07:35:04 -0000
@@ -215,6 +215,7 @@
      ;
          ( Target = target_java
          ; Target = target_il
+        ; Target = target_x86_64
          ),
          unexpected(this_file, "expected target asm or target c")
      ).
@@ -378,6 +379,7 @@
          ( Target = target_il
          ; Target = target_java
          ; Target = target_asm
+        ; Target = target_x86_64
          )
      ),
      mlds_indent(Indent, !IO),
@@ -487,6 +489,7 @@
          ( Target = target_il
          ; Target = target_java
          ; Target = target_asm
+        ; Target = target_x86_64
          )
      ),
      mlds_indent(Indent, !IO),
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.416
diff -u -r1.416 modules.m
--- compiler/modules.m	21 Dec 2006 11:11:26 -0000	1.416
+++ compiler/modules.m	3 Jan 2007 07:39:27 -0000
@@ -3461,6 +3461,11 @@
                  Target = target_asm,
                  ForeignImportTargets = [ObjFileName, PicObjFileName],
                  ForeignImportExt = ".mh"
+            ;
+                % XXX These are just the C ones at the moment. 
+                Target = target_x86_64,
+                ForeignImportTargets = [ObjFileName, PicObjFileName],
+                ForeignImportExt = ".mh"
              ),
              WriteForeignImportTarget = (pred(ForeignImportTarget::in,
                      !.IO::di, !:IO::uo) is det :-
@@ -4274,6 +4279,7 @@
          ; Target = target_asm, Lang = lang_c
          ; Target = target_java, Lang = lang_java
          ; Target = target_il, Lang = lang_il
+        ; Target = target_x86_64, Lang = lang_c
          ),
          % Assume we need the `.mh' files for all imported modules
          % (we will if they define foreign types).
@@ -4653,6 +4659,7 @@
          ( Target = target_c
          ; Target = target_java
          ; Target = target_asm
+        ; Target = target_x86_64
          ),
          ForeignModulesAndExts = []
      ),
@@ -5214,6 +5221,7 @@
          ;
              ( Target = target_c
              ; Target = target_asm
+            ; Target = target_x86_64    % XXX this is only provisional.
              ),
              Rules = MainRule
          )
@@ -5307,6 +5315,7 @@
          ;
              ( Target = target_c
              ; Target = target_asm
+            ; Target = target_x86_64    % XXX This is only provisional.
              ),
              LibRules = LibRule
          )
Index: compiler/options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.542
diff -u -r1.542 options.m
--- compiler/options.m	19 Dec 2006 07:00:54 -0000	1.542
+++ compiler/options.m	5 Jan 2007 04:51:45 -0000
@@ -253,6 +253,9 @@
      ;       compile_to_c        % target c + target_code_only
      ;       java                % target java
      ;       java_only           % target java + target_code_only
+    % XXX The following options need to be documented.
+    ;       x86_64              % target x86_64
+    ;       x86_64_only         % target x86_64 + target_code_only

      % Compilation model options for optional features:

@@ -1024,6 +1027,8 @@
      compile_to_c                        -   special,
      java                                -   special,
      java_only                           -   special,
+    x86_64                              -   special,
+    x86_64_only                         -   special,

      % Optional feature compilation model options:
      % (a) Debuggging
@@ -1764,6 +1769,10 @@
  long_option("Java",                 java).
  long_option("java-only",            java_only).
  long_option("Java-only",            java_only).
+long_option("x86_64",               x86_64).
+long_option("x86-64",               x86_64).
+long_option("x86_64-only",          x86_64_only).
+long_option("x86-64-only",          x86_64_only).
  % Optional features compilation model options:
  % (a) debugging
  long_option("debug",                exec_trace).
@@ -2336,6 +2345,11 @@
  special_handler(java_only, none, OptionTable0, ok(OptionTable)) :-
      map.set(OptionTable0, target, string("java"), OptionTable1),
      map.set(OptionTable1, target_code_only, bool(yes), OptionTable).
+special_handler(x86_64, none, OptionTable0, ok(OptionTable)) :-
+    map.set(OptionTable0, target, string("x86_64"), OptionTable).
+special_handler(x86_64_only, none, OptionTable0, ok(OptionTable)) :-
+    map.set(OptionTable0, target, string("x86_64"), OptionTable1),
+    map.set(OptionTable1, target_code_only, bool(yes), OptionTable).
  special_handler(profiling, bool(Value), OptionTable0, ok(OptionTable)) :-
      map.set(OptionTable0, profile_time, bool(Value), OptionTable1),
      map.set(OptionTable1, profile_calls, bool(Value), OptionTable2),
Index: compiler/prog_foreign.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_foreign.m,v
retrieving revision 1.10
diff -u -r1.10 prog_foreign.m
--- compiler/prog_foreign.m	1 Dec 2006 15:04:15 -0000	1.10
+++ compiler/prog_foreign.m	3 Jan 2007 07:40:48 -0000
@@ -327,6 +327,15 @@
      % Nothing useful to do here, but when we add Java as a foreign language,
      % we should add it here.

+prefer_foreign_language(_Globals, target_x86_64, Lang1, Lang2) =
+    % When compiling to x86_64 assembler, C is always preferred over any
+    % other language.
+    ( Lang2 = lang_c, not Lang1 = lang_c ->
+        yes
+    ;
+        no
+    ).
+
  %-----------------------------------------------------------------------------%

  foreign_language(lang_c).
Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.202
diff -u -r1.202 simplify.m
--- compiler/simplify.m	27 Dec 2006 03:44:12 -0000	1.202
+++ compiler/simplify.m	3 Jan 2007 03:26:33 -0000
@@ -1485,6 +1485,7 @@
                              ( Target = target_il
                              ; Target = target_java
                              ; Target = target_asm
+                            ; Target = target_x86_64
                              ),
                              sorry(this_file, "NYI: runtime trace conditions "
                                  ++ "in languages other than C")
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list