aboutsummaryrefslogtreecommitdiffstats
path: root/powerpc
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2015-04-17 16:30:43 +0200
committerXavier Leroy <xavier.leroy@inria.fr>2015-04-17 16:30:43 +0200
commit1b5db339bb05f773a6a132be4c0b8cea54d50461 (patch)
tree5c7c767bc107eca66fdf6795777821572c5ec5af /powerpc
parent3d751c114fe4611a5b72e160127be09cf6c6cfec (diff)
downloadcompcert-kvx-1b5db339bb05f773a6a132be4c0b8cea54d50461.tar.gz
compcert-kvx-1b5db339bb05f773a6a132be4c0b8cea54d50461.zip
Experiment: support a subset of GCC's extended asm statements.
Diffstat (limited to 'powerpc')
-rw-r--r--powerpc/Asmexpand.ml2
-rw-r--r--powerpc/CBuiltins.ml4
-rw-r--r--powerpc/TargetPrinter.ml17
3 files changed, 16 insertions, 7 deletions
diff --git a/powerpc/Asmexpand.ml b/powerpc/Asmexpand.ml
index 47895cb1..fbe5f782 100644
--- a/powerpc/Asmexpand.ml
+++ b/powerpc/Asmexpand.ml
@@ -523,7 +523,7 @@ let expand_instruction instr =
expand_builtin_memcpy (Z.to_int sz) (Z.to_int al) args
| EF_annot_val(txt, targ) ->
expand_annot_val txt targ args res
- | EF_inline_asm txt ->
+ | EF_inline_asm(txt, sg) ->
emit instr
| _ ->
assert false
diff --git a/powerpc/CBuiltins.ml b/powerpc/CBuiltins.ml
index 8840d2c3..222a4d94 100644
--- a/powerpc/CBuiltins.ml
+++ b/powerpc/CBuiltins.ml
@@ -90,3 +90,7 @@ let builtins = {
let size_va_list = 12
let va_list_scalar = false
+
+(* Expand memory references inside extended asm statements. Used in C2C. *)
+
+let asm_mem_argument arg = Printf.sprintf "0(%s)" arg
diff --git a/powerpc/TargetPrinter.ml b/powerpc/TargetPrinter.ml
index b3d228b3..49954998 100644
--- a/powerpc/TargetPrinter.ml
+++ b/powerpc/TargetPrinter.ml
@@ -284,10 +284,14 @@ module Target (System : SYSTEM):TARGET =
let ireg_or_zero oc r =
if r = GPR0 then output_string oc "0" else ireg oc r
- (* [preg] is only used for printing annotations.
- Use the full register names [rN] and [fN] to avoid
- ambiguity with constants. *)
let preg oc = function
+ | IR r -> ireg oc r
+ | FR r -> freg oc r
+ | _ -> assert false
+
+ (* For printing annotations, use the full register names [rN] and [fN]
+ to avoid ambiguity with constants. *)
+ let preg_annot oc = function
| IR r -> fprintf oc "r%s" (int_reg_name r)
| FR r -> fprintf oc "f%s" (float_reg_name r)
| _ -> assert false
@@ -327,7 +331,7 @@ module Target (System : SYSTEM):TARGET =
(int_of_string (Str.matched_group 2 txt))
end else begin
fprintf oc "%s annotation: " comment;
- PrintAnnot.print_annot_stmt preg "R1" oc txt targs args
+ PrintAnnot.print_annot_stmt preg_annot "R1" oc txt targs args
end
(* Determine if the displacement of a conditional branch fits the short form *)
@@ -646,9 +650,10 @@ module Target (System : SYSTEM):TARGET =
fprintf oc "%a:\n" label (transl_label lbl)
| Pbuiltin(ef, args, res) ->
begin match ef with
- | EF_inline_asm txt ->
+ | EF_inline_asm(txt, sg) ->
fprintf oc "%s begin inline assembly\n" comment;
- fprintf oc " %s\n" (extern_atom txt);
+ fprintf oc "\t";
+ PrintAnnot.print_inline_asm preg oc (extern_atom txt) sg args res;
fprintf oc "%s end inline assembly\n" comment
| _ ->
assert false