aboutsummaryrefslogtreecommitdiffstats
path: root/arm
diff options
context:
space:
mode:
authorXavier Leroy <xavierleroy@users.noreply.github.com>2015-04-22 14:27:12 +0200
committerXavier Leroy <xavierleroy@users.noreply.github.com>2015-04-22 14:27:12 +0200
commit0bf99217426a44046ef0aaa7f84a9b2a3646ed89 (patch)
treee4f983980a5001792b90ed8f3dbd8fa241e43eb1 /arm
parent08b2b46f15e70b11c044e4e9a7c8438a96d57ed7 (diff)
parentca4aa822693f4d98de99fd3f13c1523d733e1cb0 (diff)
downloadcompcert-0bf99217426a44046ef0aaa7f84a9b2a3646ed89.tar.gz
compcert-0bf99217426a44046ef0aaa7f84a9b2a3646ed89.zip
Merge pull request #40 from AbsInt/inline-asm
GCC-style extended inline asm. The subset implemented is: - zero or one output - output constraints "=r" (to register) or "=m" (to memory) - zero, one or several inputs - input constraints "r" (in register), "m" (in memory), "i" and "n" (compile-time integer constant) - clobbered registers (the 3rd argument) - both anonymous (%3) and named (%[name]) operands - modifiers %R and %Q to refer to the most significant / least significant part of a register pair holding a 64-bit integer. (Undocumented GCC ARM feature.) All asm statements are treated as "volatile", possibly modifying memory and condition codes.
Diffstat (limited to 'arm')
-rw-r--r--arm/CBuiltins.ml4
-rw-r--r--arm/TargetPrinter.ml6
2 files changed, 7 insertions, 3 deletions
diff --git a/arm/CBuiltins.ml b/arm/CBuiltins.ml
index 17aa5115..00de4df7 100644
--- a/arm/CBuiltins.ml
+++ b/arm/CBuiltins.ml
@@ -55,3 +55,7 @@ let builtins = {
let size_va_list = 4
let va_list_scalar = true
+
+(* Expand memory references inside extended asm statements. Used in C2C. *)
+
+let asm_mem_argument arg = Printf.sprintf "[%s, #0]" arg
diff --git a/arm/TargetPrinter.ml b/arm/TargetPrinter.ml
index df17e595..c77572db 100644
--- a/arm/TargetPrinter.ml
+++ b/arm/TargetPrinter.ml
@@ -1003,9 +1003,9 @@ module Target (Opt: PRINTER_OPTIONS) : TARGET =
(Int32.to_int (camlint_of_coqint al)) args
| EF_annot_val(txt, targ) ->
print_annot_val oc (extern_atom txt) args res
- | EF_inline_asm txt ->
- fprintf oc "%s begin inline assembly\n" comment;
- fprintf oc " %s\n" (extern_atom txt);
+ | EF_inline_asm(txt, sg, clob) ->
+ fprintf oc "%s begin inline assembly\n\t" comment;
+ PrintAnnot.print_inline_asm preg oc (extern_atom txt) sg args res;
fprintf oc "%s end inline assembly\n" comment;
5 (* hoping this is an upper bound... *)
| _ ->