aboutsummaryrefslogtreecommitdiffstats
path: root/backend/PrintAnnot.ml
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 /backend/PrintAnnot.ml
parent3d751c114fe4611a5b72e160127be09cf6c6cfec (diff)
downloadcompcert-kvx-1b5db339bb05f773a6a132be4c0b8cea54d50461.tar.gz
compcert-kvx-1b5db339bb05f773a6a132be4c0b8cea54d50461.zip
Experiment: support a subset of GCC's extended asm statements.
Diffstat (limited to 'backend/PrintAnnot.ml')
-rw-r--r--backend/PrintAnnot.ml24
1 files changed, 23 insertions, 1 deletions
diff --git a/backend/PrintAnnot.ml b/backend/PrintAnnot.ml
index 995f22dd..88f5d8d6 100644
--- a/backend/PrintAnnot.ml
+++ b/backend/PrintAnnot.ml
@@ -148,7 +148,29 @@ let print_annot_val print_preg oc txt args =
print_annot_text print_preg "<internal error>" oc txt
(List.map (fun r -> AA_base r) args)
-(* Print CompCert version and command-line as asm comment *)
+(** Inline assembly *)
+
+let re_asm_param = Str.regexp "%%\\|%[0-9]+"
+
+let print_inline_asm print_preg oc txt sg args res =
+ let operands =
+ if sg.sig_res = None then args else res @ args in
+ let print_fragment = function
+ | Str.Text s ->
+ output_string oc s
+ | Str.Delim "%%" ->
+ output_char oc '%'
+ | Str.Delim s ->
+ let n = int_of_string (String.sub s 1 (String.length s - 1)) in
+ try
+ print_preg oc (List.nth operands n)
+ with Failure _ ->
+ fprintf oc "<bad parameter %s>" s in
+ List.iter print_fragment (Str.full_split re_asm_param txt);
+ fprintf oc "\n"
+
+
+(** Print CompCert version and command-line as asm comment *)
let print_version_and_options oc comment =
fprintf oc "%s File generated by CompCert %s\n" comment Configuration.version;