summaryrefslogtreecommitdiff
path: root/powerpc/PrintAsm.ml
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-07-14 08:20:28 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-07-14 08:20:28 +0000
commit7c9500e438384c6c0ce478c8c73b3887137ac924 (patch)
treee2602aaed2ac1f735785ebfe37d7161037dd3dd1 /powerpc/PrintAsm.ml
parentbd85aba84475dd956af21c461c44a584958099d1 (diff)
Remove the PowerPC/MacOS X port, as MacOS no longer supports PowerPC.
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1980 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'powerpc/PrintAsm.ml')
-rw-r--r--powerpc/PrintAsm.ml210
1 files changed, 21 insertions, 189 deletions
diff --git a/powerpc/PrintAsm.ml b/powerpc/PrintAsm.ml
index 9d23ad9..3331a1c 100644
--- a/powerpc/PrintAsm.ml
+++ b/powerpc/PrintAsm.ml
@@ -23,11 +23,10 @@ open Asm
(* Recognition of target ABI and asm syntax *)
-type target = MacOS | Linux | Diab
+type target = Linux | Diab
let target =
match Configuration.system with
- | "macosx" -> MacOS
| "linux" -> Linux
| "diab" -> Diab
| _ -> invalid_arg ("System " ^ Configuration.system ^ " not supported")
@@ -61,43 +60,28 @@ let coqint oc n =
fprintf oc "%ld" (camlint_of_coqint n)
let raw_symbol oc s =
- match target with
- | MacOS -> fprintf oc "_%s" s
- | Linux|Diab -> fprintf oc "%s" s
+ fprintf oc "%s" s
let symbol oc symb =
- match target with
- | MacOS ->
- if IdentSet.mem symb !stubbed_functions
- then fprintf oc "L%s$stub" (extern_atom symb)
- else fprintf oc "_%s" (extern_atom symb)
- | Linux | Diab ->
- if IdentSet.mem symb !stubbed_functions
- then fprintf oc ".L%s$stub" (extern_atom symb)
- else fprintf oc "%s" (extern_atom symb)
+ if IdentSet.mem symb !stubbed_functions
+ then fprintf oc ".L%s$stub" (extern_atom symb)
+ else fprintf oc "%s" (extern_atom symb)
let symbol_offset oc (symb, ofs) =
symbol oc symb;
if ofs <> 0l then fprintf oc " + %ld" ofs
let label oc lbl =
- match target with
- | MacOS -> fprintf oc "L%d" lbl
- | Linux|Diab -> fprintf oc ".L%d" lbl
+ fprintf oc ".L%d" lbl
let label_low oc lbl =
- match target with
- | MacOS -> fprintf oc "lo16(L%d)" lbl
- | Linux|Diab -> fprintf oc ".L%d@l" lbl
+ fprintf oc ".L%d@l" lbl
let label_high oc lbl =
- match target with
- | MacOS -> fprintf oc "ha16(L%d)" lbl
- | Linux|Diab -> fprintf oc ".L%d@ha" lbl
+ fprintf oc ".L%d@ha" lbl
let comment =
match target with
- | MacOS -> ";"
| Linux -> "#"
| Diab -> ";"
@@ -106,23 +90,11 @@ let constant oc cst =
| Cint n ->
fprintf oc "%ld" (camlint_of_coqint n)
| Csymbol_low(s, n) ->
- begin match target with
- | MacOS ->
- fprintf oc "lo16(%a)" symbol_offset (s, camlint_of_coqint n)
- | Linux|Diab ->
- fprintf oc "(%a)@l" symbol_offset (s, camlint_of_coqint n)
- end
+ fprintf oc "(%a)@l" symbol_offset (s, camlint_of_coqint n)
| Csymbol_high(s, n) ->
- begin match target with
- | MacOS ->
- fprintf oc "ha16(%a)" symbol_offset (s, camlint_of_coqint n)
- | Linux|Diab ->
- fprintf oc "(%a)@ha" symbol_offset (s, camlint_of_coqint n)
- end
+ fprintf oc "(%a)@ha" symbol_offset (s, camlint_of_coqint n)
| Csymbol_sda(s, n) ->
begin match target with
- | MacOS ->
- assert false
| Linux ->
fprintf oc "(%a)@sda21" symbol_offset (s, camlint_of_coqint n)
| Diab ->
@@ -160,8 +132,8 @@ let float_reg_name = function
let ireg oc r =
begin match target with
- | MacOS|Diab -> output_char oc 'r'
- | Linux -> ()
+ | Diab -> output_char oc 'r'
+ | Linux -> ()
end;
output_string oc (int_reg_name r)
@@ -170,15 +142,15 @@ let ireg_or_zero oc r =
let freg oc r =
begin match target with
- | MacOS|Diab -> output_char oc 'f'
- | Linux -> ()
+ | Diab -> output_char oc 'f'
+ | Linux -> ()
end;
output_string oc (float_reg_name r)
let creg oc r =
match target with
- | MacOS|Diab -> fprintf oc "cr%d" r
- | Linux -> fprintf oc "%d" r
+ | Diab -> fprintf oc "cr%d" r
+ | Linux -> fprintf oc "%d" r
let preg oc = function
| IR r -> ireg oc r
@@ -187,20 +159,6 @@ let preg oc = function
(* Names of sections *)
-let name_of_section_MacOS = function
- | Section_text -> ".text"
- | Section_data _ -> ".data"
- | Section_small_data _ -> ".data"
- | Section_const -> ".const"
- | Section_small_const -> ".const"
- | Section_string -> ".const"
- | Section_literal -> ".literal8"
- | Section_jumptable -> ".const"
- | Section_user(s, wr, ex) ->
- sprintf ".section \"%s\", %s, %s"
- (if wr then "__DATA" else "__TEXT") s
- (if ex then "regular, pure_instructions" else "regular")
-
let name_of_section_Linux = function
| Section_text -> ".text"
| Section_data i -> if i then ".data" else "COMM"
@@ -234,7 +192,6 @@ let name_of_section_Diab = function
let name_of_section =
match target with
- | MacOS -> name_of_section_MacOS
| Linux -> name_of_section_Linux
| Diab -> name_of_section_Diab
@@ -882,10 +839,8 @@ let print_function oc name code =
fprintf oc " .globl %a\n" symbol name;
fprintf oc "%a:\n" symbol name;
print_instructions oc (label_positions PTree.empty 0 code) 0 code;
- if target <> MacOS then begin
- fprintf oc " .type %a, @function\n" symbol name;
- fprintf oc " .size %a, . - %a\n" symbol name symbol name
- end;
+ fprintf oc " .type %a, @function\n" symbol name;
+ fprintf oc " .size %a, . - %a\n" symbol name symbol name;
if !float_literals <> [] then begin
section oc lit;
fprintf oc " .align 3\n";
@@ -903,119 +858,8 @@ let print_function oc name code =
let re_variadic_stub = Str.regexp "\\(.*\\)\\$[if]*$"
-(* Stubs for MacOS X *)
-
-module Stubs_MacOS = struct
-
-(* Generation of stub code for variadic functions, e.g. printf.
- Calling conventions for variadic functions are:
- - always reserve 8 stack words (offsets 24 to 52) so that the
- variadic function can save there the integer registers parameters
- r3 ... r10
- - treat float arguments as pairs of integers, i.e. if we
- must pass them in registers, use a pair of integer registers
- for this purpose.
- The code we generate is:
- - allocate large enough stack frame
- - save return address
- - copy our arguments (registers and stack) to the stack frame,
- starting at offset 24
- - load relevant integer parameter registers r3...r10 from the
- stack frame, limited by the actual number of arguments
- - call the variadic thing
- - deallocate stack frame and return
-*)
-
-let variadic_stub oc stub_name fun_name ty_args =
- (* Compute total size of arguments *)
- let arg_size =
- List.fold_left
- (fun sz ty -> match ty with Tint -> sz + 4 | Tfloat -> sz + 8)
- 0 ty_args in
- (* Stack size is linkage area + argument size, with a minimum of 56 bytes *)
- let frame_size = max 56 (24 + arg_size) in
- fprintf oc " mflr r0\n";
- fprintf oc " stwu r1, %d(r1)\n" (-frame_size);
- fprintf oc " stw r0, %d(r1)\n" (frame_size + 4);
- (* Copy our parameters to our stack frame.
- As an optimization, don't copy parameters that are already in
- integer registers, since these stay in place. *)
- let rec copy gpr fpr src_ofs dst_ofs = function
- | [] -> ()
- | Tint :: rem ->
- if gpr > 10 then begin
- fprintf oc " lwz r0, %d(r1)\n" src_ofs;
- fprintf oc " stw r0, %d(r1)\n" dst_ofs
- end;
- copy (gpr + 1) fpr (src_ofs + 4) (dst_ofs + 4) rem
- | Tfloat :: rem ->
- if fpr <= 10 then begin
- fprintf oc " stfd f%d, %d(r1)\n" fpr dst_ofs
- end else begin
- fprintf oc " lfd f0, %d(r1)\n" src_ofs;
- fprintf oc " stfd f0, %d(r1)\n" dst_ofs
- end;
- copy (gpr + 2) (fpr + 1) (src_ofs + 8) (dst_ofs + 8) rem
- in copy 3 1 (frame_size + 24) 24 ty_args;
- (* Load the first parameters into integer registers.
- As an optimization, don't load parameters that are already
- in the correct integer registers. *)
- let rec load gpr ofs = function
- | [] -> ()
- | Tint :: rem ->
- load (gpr + 1) (ofs + 4) rem
- | Tfloat :: rem ->
- if gpr <= 10 then
- fprintf oc " lwz r%d, %d(r1)\n" gpr ofs;
- if gpr + 1 <= 10 then
- fprintf oc " lwz r%d, %d(r1)\n" (gpr + 1) (ofs + 4);
- load (gpr + 2) (ofs + 8) rem
- in load 3 24 ty_args;
- (* Call the function *)
- fprintf oc " addis r11, 0, ha16(L%s$ptr)\n" stub_name;
- fprintf oc " lwz r11, lo16(L%s$ptr)(r11)\n" stub_name;
- fprintf oc " mtctr r11\n";
- fprintf oc " bctrl\n";
- (* Free our frame and return *)
- fprintf oc " lwz r0, %d(r1)\n" (frame_size + 4);
- fprintf oc " mtlr r0\n";
- fprintf oc " addi r1, r1, %d\n" frame_size;
- fprintf oc " blr\n";
- (* The function pointer *)
- fprintf oc " .non_lazy_symbol_pointer\n";
- fprintf oc "L%s$ptr:\n" stub_name;
- fprintf oc " .indirect_symbol _%s\n" fun_name;
- fprintf oc " .long 0\n"
-
-(* Stubs for fixed-type functions are much simpler *)
-
-let non_variadic_stub oc name =
- fprintf oc " addis r11, 0, ha16(L%s$ptr)\n" name;
- fprintf oc " lwz r11, lo16(L%s$ptr)(r11)\n" name;
- fprintf oc " mtctr r11\n";
- fprintf oc " bctr\n";
- fprintf oc " .non_lazy_symbol_pointer\n";
- fprintf oc "L%s$ptr:\n" name;
- fprintf oc " .indirect_symbol _%s\n" name;
- fprintf oc " .long 0\n"
-
-let stub_function oc name sg =
- let name = extern_atom name in
- section oc Section_text;
- fprintf oc " .align 2\n";
- fprintf oc "L%s$stub:\n" name;
- if Str.string_match re_variadic_stub name 0
- then variadic_stub oc name (Str.matched_group 1 name) sg.sig_args
- else non_variadic_stub oc name
-
-let function_needs_stub name = true
-
-end
-
(* Stubs for EABI *)
-module Stubs_EABI = struct
-
let variadic_stub oc stub_name fun_name args =
section oc Section_text;
fprintf oc " .align 2\n";
@@ -1035,17 +879,7 @@ let stub_function oc name sg =
let function_needs_stub name =
Str.string_match re_variadic_stub (extern_atom name) 0
-end
-
-let function_needs_stub =
- match target with
- | MacOS -> Stubs_MacOS.function_needs_stub
- | Linux|Diab -> Stubs_EABI.function_needs_stub
-
-let stub_function =
- match target with
- | MacOS -> Stubs_MacOS.stub_function
- | Linux|Diab -> Stubs_EABI.stub_function
+(* Generation of whole programs *)
let print_fundef oc (name, defn) =
match defn with
@@ -1117,10 +951,8 @@ let print_var oc (name, v) =
fprintf oc " .globl %a\n" symbol name;
fprintf oc "%a:\n" symbol name;
print_init_data oc name v.gvar_init;
- if target <> MacOS then begin
- fprintf oc " .type %a, @object\n" symbol name;
- fprintf oc " .size %a, . - %a\n" symbol name symbol name
- end
+ fprintf oc " .type %a, @object\n" symbol name;
+ fprintf oc " .size %a, . - %a\n" symbol name symbol name
end else begin
let sz =
match v.gvar_init with [Init_space sz] -> sz | _ -> assert false in