Skip to content

Commit 0bf9921

Browse files
committed
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.
2 parents 08b2b46 + ca4aa82 commit 0bf9921

33 files changed

+604
-76
lines changed

.depend

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ backend/Locations.vo backend/Locations.glob backend/Locations.v.beautified: back
7878
$(ARCH)/Conventions1.vo $(ARCH)/Conventions1.glob $(ARCH)/Conventions1.v.beautified: $(ARCH)/Conventions1.v lib/Coqlib.vo common/AST.vo common/Events.vo backend/Locations.vo
7979
backend/Conventions.vo backend/Conventions.glob backend/Conventions.v.beautified: backend/Conventions.v lib/Coqlib.vo common/AST.vo backend/Locations.vo $(ARCH)/Conventions1.vo
8080
backend/LTL.vo backend/LTL.glob backend/LTL.v.beautified: backend/LTL.v lib/Coqlib.vo lib/Maps.vo common/AST.vo lib/Integers.vo common/Values.vo common/Events.vo common/Memory.vo common/Globalenvs.vo common/Smallstep.vo $(ARCH)/Op.vo backend/Locations.vo backend/Conventions.vo
81-
backend/Allocation.vo backend/Allocation.glob backend/Allocation.v.beautified: backend/Allocation.v lib/FSetAVLplus.vo $(ARCH)/Archi.vo lib/Coqlib.vo lib/Ordered.vo common/Errors.vo lib/Maps.vo lib/Lattice.vo common/AST.vo lib/Integers.vo common/Memdata.vo $(ARCH)/Op.vo backend/Registers.vo backend/RTL.vo backend/Kildall.vo backend/Locations.vo backend/Conventions.vo backend/RTLtyping.vo backend/LTL.vo
81+
backend/Allocation.vo backend/Allocation.glob backend/Allocation.v.beautified: backend/Allocation.v lib/FSetAVLplus.vo $(ARCH)/Archi.vo lib/Coqlib.vo lib/Ordered.vo common/Errors.vo lib/Maps.vo lib/Lattice.vo common/AST.vo lib/Integers.vo lib/Floats.vo common/Memdata.vo $(ARCH)/Op.vo backend/Registers.vo backend/RTL.vo backend/Kildall.vo backend/Locations.vo backend/Conventions.vo backend/RTLtyping.vo backend/LTL.vo
8282
backend/Allocproof.vo backend/Allocproof.glob backend/Allocproof.v.beautified: backend/Allocproof.v $(ARCH)/Archi.vo lib/Coqlib.vo lib/Ordered.vo common/Errors.vo lib/Maps.vo lib/Lattice.vo common/AST.vo lib/Integers.vo common/Values.vo common/Memory.vo common/Events.vo common/Globalenvs.vo common/Smallstep.vo $(ARCH)/Op.vo backend/Registers.vo backend/RTL.vo backend/RTLtyping.vo backend/Kildall.vo backend/Locations.vo backend/Conventions.vo backend/LTL.vo backend/Allocation.vo
8383
backend/Tunneling.vo backend/Tunneling.glob backend/Tunneling.v.beautified: backend/Tunneling.v lib/Coqlib.vo lib/Maps.vo lib/UnionFind.vo common/AST.vo backend/LTL.vo
8484
backend/Tunnelingproof.vo backend/Tunnelingproof.glob backend/Tunnelingproof.v.beautified: backend/Tunnelingproof.v lib/Coqlib.vo lib/Maps.vo lib/UnionFind.vo common/AST.vo common/Values.vo common/Memory.vo common/Events.vo common/Globalenvs.vo common/Smallstep.vo $(ARCH)/Op.vo backend/Locations.vo backend/LTL.vo backend/Tunneling.vo
@@ -107,7 +107,7 @@ cfrontend/Cstrategy.vo cfrontend/Cstrategy.glob cfrontend/Cstrategy.v.beautified
107107
cfrontend/Cexec.vo cfrontend/Cexec.glob cfrontend/Cexec.v.beautified: cfrontend/Cexec.v lib/Axioms.vo lib/Coqlib.vo common/Errors.vo lib/Maps.vo lib/Integers.vo lib/Floats.vo common/Values.vo common/AST.vo common/Memory.vo common/Events.vo common/Globalenvs.vo common/Determinism.vo cfrontend/Ctypes.vo cfrontend/Cop.vo cfrontend/Csyntax.vo cfrontend/Csem.vo cfrontend/Cstrategy.vo
108108
cfrontend/Initializers.vo cfrontend/Initializers.glob cfrontend/Initializers.v.beautified: cfrontend/Initializers.v lib/Coqlib.vo lib/Maps.vo common/Errors.vo lib/Integers.vo lib/Floats.vo common/Values.vo common/AST.vo common/Memory.vo common/Globalenvs.vo cfrontend/Ctypes.vo cfrontend/Cop.vo cfrontend/Csyntax.vo
109109
cfrontend/Initializersproof.vo cfrontend/Initializersproof.glob cfrontend/Initializersproof.v.beautified: cfrontend/Initializersproof.v lib/Coqlib.vo common/Errors.vo lib/Maps.vo lib/Integers.vo lib/Floats.vo common/Values.vo common/AST.vo common/Memory.vo common/Globalenvs.vo common/Events.vo common/Smallstep.vo cfrontend/Ctypes.vo cfrontend/Cop.vo cfrontend/Csyntax.vo cfrontend/Csem.vo cfrontend/Initializers.vo
110-
cfrontend/SimplExpr.vo cfrontend/SimplExpr.glob cfrontend/SimplExpr.v.beautified: cfrontend/SimplExpr.v lib/Coqlib.vo common/Errors.vo lib/Integers.vo lib/Floats.vo common/Values.vo common/AST.vo cfrontend/Ctypes.vo cfrontend/Cop.vo cfrontend/Csyntax.vo cfrontend/Clight.vo
110+
cfrontend/SimplExpr.vo cfrontend/SimplExpr.glob cfrontend/SimplExpr.v.beautified: cfrontend/SimplExpr.v lib/Coqlib.vo common/Errors.vo lib/Integers.vo lib/Floats.vo common/Values.vo common/Memory.vo common/AST.vo cfrontend/Ctypes.vo cfrontend/Cop.vo cfrontend/Csyntax.vo cfrontend/Clight.vo
111111
cfrontend/SimplExprspec.vo cfrontend/SimplExprspec.glob cfrontend/SimplExprspec.v.beautified: cfrontend/SimplExprspec.v lib/Coqlib.vo common/Errors.vo lib/Maps.vo lib/Integers.vo lib/Floats.vo common/Memory.vo common/AST.vo cfrontend/Ctypes.vo cfrontend/Cop.vo cfrontend/Csyntax.vo cfrontend/Clight.vo cfrontend/SimplExpr.vo
112112
cfrontend/SimplExprproof.vo cfrontend/SimplExprproof.glob cfrontend/SimplExprproof.v.beautified: cfrontend/SimplExprproof.v lib/Coqlib.vo lib/Maps.vo common/AST.vo common/Errors.vo lib/Integers.vo common/Values.vo common/Memory.vo common/Events.vo common/Smallstep.vo common/Globalenvs.vo cfrontend/Ctypes.vo cfrontend/Cop.vo cfrontend/Csyntax.vo cfrontend/Csem.vo cfrontend/Cstrategy.vo cfrontend/Clight.vo cfrontend/SimplExpr.vo cfrontend/SimplExprspec.vo
113113
cfrontend/Clight.vo cfrontend/Clight.glob cfrontend/Clight.v.beautified: cfrontend/Clight.v lib/Coqlib.vo common/Errors.vo lib/Maps.vo lib/Integers.vo lib/Floats.vo common/Values.vo common/AST.vo common/Memory.vo common/Events.vo common/Globalenvs.vo common/Smallstep.vo cfrontend/Ctypes.vo cfrontend/Cop.vo

arm/CBuiltins.ml

+4
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ let builtins = {
5555

5656
let size_va_list = 4
5757
let va_list_scalar = true
58+
59+
(* Expand memory references inside extended asm statements. Used in C2C. *)
60+
61+
let asm_mem_argument arg = Printf.sprintf "[%s, #0]" arg

arm/TargetPrinter.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1003,9 +1003,9 @@ module Target (Opt: PRINTER_OPTIONS) : TARGET =
10031003
(Int32.to_int (camlint_of_coqint al)) args
10041004
| EF_annot_val(txt, targ) ->
10051005
print_annot_val oc (extern_atom txt) args res
1006-
| EF_inline_asm txt ->
1007-
fprintf oc "%s begin inline assembly\n" comment;
1008-
fprintf oc " %s\n" (extern_atom txt);
1006+
| EF_inline_asm(txt, sg, clob) ->
1007+
fprintf oc "%s begin inline assembly\n\t" comment;
1008+
PrintAnnot.print_inline_asm preg oc (extern_atom txt) sg args res;
10091009
fprintf oc "%s end inline assembly\n" comment;
10101010
5 (* hoping this is an upper bound... *)
10111011
| _ ->

backend/CMparser.mly

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ let mkef sg toks =
6060
if sg.sig_args = [] then raise Parsing.Parse_error;
6161
EF_annot_val(intern_string txt, List.hd sg.sig_args)
6262
| [EFT_tok "inline_asm"; EFT_string txt] ->
63-
EF_inline_asm(intern_string txt)
63+
EF_inline_asm(intern_string txt, sg, [])
6464
| _ ->
6565
raise Parsing.Parse_error
6666

backend/CSE.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ Definition transfer (f: function) (approx: PMap.t VA.t) (pc: node) (before: numb
476476
empty_numbering
477477
| Ibuiltin ef args res s =>
478478
match ef with
479-
| EF_external _ _ | EF_malloc | EF_free | EF_inline_asm _ =>
479+
| EF_external _ _ | EF_malloc | EF_free | EF_inline_asm _ _ _ =>
480480
empty_numbering
481481
| EF_builtin _ _ | EF_vstore _ | EF_vstore_global _ _ _ =>
482482
set_unknown (kill_all_loads before) res

backend/PrintAnnot.ml

+23-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,29 @@ let print_annot_val print_preg oc txt args =
148148
print_annot_text print_preg "<internal error>" oc txt
149149
(List.map (fun r -> AA_base r) args)
150150

151-
(* Print CompCert version and command-line as asm comment *)
151+
(** Inline assembly *)
152+
153+
let re_asm_param = Str.regexp "%%\\|%[0-9]+"
154+
155+
let print_inline_asm print_preg oc txt sg args res =
156+
let operands =
157+
if sg.sig_res = None then args else res @ args in
158+
let print_fragment = function
159+
| Str.Text s ->
160+
output_string oc s
161+
| Str.Delim "%%" ->
162+
output_char oc '%'
163+
| Str.Delim s ->
164+
let n = int_of_string (String.sub s 1 (String.length s - 1)) in
165+
try
166+
print_preg oc (List.nth operands n)
167+
with Failure _ ->
168+
fprintf oc "<bad parameter %s>" s in
169+
List.iter print_fragment (Str.full_split re_asm_param txt);
170+
fprintf oc "\n"
171+
172+
173+
(** Print CompCert version and command-line as asm comment *)
152174

153175
let print_version_and_options oc comment =
154176
fprintf oc "%s File generated by CompCert %s\n" comment Configuration.version;

backend/Regalloc.ml

+17-1
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,9 @@ let add_interfs_live g live v =
510510
let add_interfs_list g v vl =
511511
List.iter (IRC.add_interf g v) vl
512512

513+
let add_interfs_list_mreg g vl mr =
514+
List.iter (fun v -> IRC.add_interf g v (L (R mr))) vl
515+
513516
let rec add_interfs_pairwise g = function
514517
| [] -> ()
515518
| v1 :: vl -> add_interfs_list g v1 vl; add_interfs_pairwise g vl
@@ -578,7 +581,20 @@ let add_interfs_instr g instr live =
578581
add_interfs_pairwise g res;
579582
add_interfs_destroyed g across (destroyed_by_builtin ef);
580583
begin match ef, args, res with
581-
| EF_annot_val _, [arg], [res] -> IRC.add_pref g arg res (* like a move *)
584+
| EF_annot_val _, [arg], [res] ->
585+
(* like a move *)
586+
IRC.add_pref g arg res
587+
| EF_inline_asm(txt, sg, clob), _, _ ->
588+
(* clobbered regs interfere with live set
589+
and also with res and args for GCC compatibility *)
590+
List.iter (fun c ->
591+
match Machregsaux.register_by_name (extern_atom c) with
592+
| None -> ()
593+
| Some mr ->
594+
add_interfs_destroyed g across [mr];
595+
add_interfs_list_mreg g args mr;
596+
if sg.sig_res <> None then add_interfs_list_mreg g res mr)
597+
clob
582598
| _ -> ()
583599
end
584600
| Xannot(ef, args) ->

cfrontend/C2C.ml

+34-14
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,14 @@ let currentLocation = ref Cutil.no_loc
114114

115115
let updateLoc l = currentLocation := l
116116

117-
let numErrors = ref 0
118-
119117
let error msg =
120-
incr numErrors;
121-
eprintf "%aError: %s\n" Cutil.printloc !currentLocation msg
118+
Cerrors.error "%aError: %s" Cutil.formatloc !currentLocation msg
122119

123120
let unsupported msg =
124-
incr numErrors;
125-
eprintf "%aUnsupported feature: %s\n" Cutil.printloc !currentLocation msg
121+
Cerrors.error "%aUnsupported feature: %s" Cutil.formatloc !currentLocation msg
126122

127123
let warning msg =
128-
eprintf "%aWarning: %s\n" Cutil.printloc !currentLocation msg
124+
Cerrors.warning "%aWarning: %s\n" Cutil.formatloc !currentLocation msg
129125

130126
let string_of_errmsg msg =
131127
let string_of_err = function
@@ -831,6 +827,30 @@ and convertExprList env el =
831827
| [] -> Enil
832828
| e1 :: el' -> Econs(convertExpr env e1, convertExprList env el')
833829

830+
(* Extended assembly *)
831+
832+
let convertAsm loc env txt outputs inputs clobber =
833+
let (txt', output', inputs') =
834+
ExtendedAsm.transf_asm loc env txt outputs inputs clobber in
835+
let clobber' =
836+
List.map intern_string clobber in
837+
let ty_res =
838+
match output' with None -> TVoid [] | Some e -> e.etyp in
839+
(* Build the Ebuiltin expression *)
840+
let e =
841+
let tinputs = convertTypArgs env [] inputs' in
842+
let toutput = convertTyp env ty_res in
843+
Ebuiltin(EF_inline_asm(intern_string txt',
844+
signature_of_type tinputs toutput cc_default,
845+
clobber'),
846+
tinputs,
847+
convertExprList env inputs',
848+
convertTyp env ty_res) in
849+
(* Add an assignment to the output, if any *)
850+
match output' with
851+
| None -> e
852+
| Some lhs -> Eassign (convertLvalue env lhs, e, typeof e)
853+
834854
(* Separate the cases of a switch statement body *)
835855

836856
type switchlabel =
@@ -891,7 +911,9 @@ let rec convertStmt ploc env s =
891911
| C.Sdo e ->
892912
add_lineno ploc s.sloc (swrap (Ctyping.sdo (convertExpr env e)))
893913
| C.Sseq(s1, s2) ->
894-
Ssequence(convertStmt ploc env s1, convertStmt s1.sloc env s2)
914+
let s1' = convertStmt ploc env s1 in
915+
let s2' = convertStmt s1.sloc env s2 in
916+
Ssequence(s1', s2')
895917
| C.Sif(e, s1, s2) ->
896918
let te = convertExpr env e in
897919
add_lineno ploc s.sloc
@@ -940,11 +962,11 @@ let rec convertStmt ploc env s =
940962
unsupported "nested blocks"; Sskip
941963
| C.Sdecl _ ->
942964
unsupported "inner declarations"; Sskip
943-
| C.Sasm txt ->
965+
| C.Sasm(attrs, txt, outputs, inputs, clobber) ->
944966
if not !Clflags.option_finline_asm then
945967
unsupported "inline 'asm' statement (consider adding option -finline-asm)";
946968
add_lineno ploc s.sloc
947-
(Sdo (Ebuiltin (EF_inline_asm (intern_string txt), Tnil, Enil, Tvoid)))
969+
(Sdo (convertAsm s.sloc env txt outputs inputs clobber))
948970

949971
and convertSwitch ploc env is_64 = function
950972
| [] ->
@@ -1211,7 +1233,7 @@ let public_globals gl =
12111233
(** Convert a [C.program] into a [Csyntax.program] *)
12121234

12131235
let convertProgram p =
1214-
numErrors := 0;
1236+
Cerrors.reset();
12151237
stringNum := 0;
12161238
Hashtbl.clear decl_atom;
12171239
Hashtbl.clear stringTable;
@@ -1236,9 +1258,7 @@ let convertProgram p =
12361258
prog_main = intern_string "main";
12371259
prog_types = typs;
12381260
prog_comp_env = ce } in
1239-
if !numErrors > 0
1240-
then None
1241-
else Some p'
1261+
if Cerrors.check_errors () then None else Some p'
12421262
with Env.Error msg ->
12431263
error (Env.error_message msg); None
12441264

cfrontend/Cexec.v

+8-8
Original file line numberDiff line numberDiff line change
@@ -405,18 +405,18 @@ Hypothesis do_external_function_complete:
405405
do_external_function id sg ge w vargs m = Some(w', t, vres, m').
406406

407407
Variable do_inline_assembly:
408-
ident -> Senv.t -> world -> list val -> mem -> option (world * trace * val * mem).
408+
ident -> signature -> Senv.t -> world -> list val -> mem -> option (world * trace * val * mem).
409409

410410
Hypothesis do_inline_assembly_sound:
411-
forall txt ge vargs m t vres m' w w',
412-
do_inline_assembly txt ge w vargs m = Some(w', t, vres, m') ->
413-
inline_assembly_sem txt ge vargs m t vres m' /\ possible_trace w t w'.
411+
forall txt sg ge vargs m t vres m' w w',
412+
do_inline_assembly txt sg ge w vargs m = Some(w', t, vres, m') ->
413+
inline_assembly_sem txt sg ge vargs m t vres m' /\ possible_trace w t w'.
414414

415415
Hypothesis do_inline_assembly_complete:
416-
forall txt ge vargs m t vres m' w w',
417-
inline_assembly_sem txt ge vargs m t vres m' ->
416+
forall txt sg ge vargs m t vres m' w w',
417+
inline_assembly_sem txt sg ge vargs m t vres m' ->
418418
possible_trace w t w' ->
419-
do_inline_assembly txt ge w vargs m = Some(w', t, vres, m').
419+
do_inline_assembly txt sg ge w vargs m = Some(w', t, vres, m').
420420

421421
Definition do_ef_volatile_load (chunk: memory_chunk)
422422
(w: world) (vargs: list val) (m: mem) : option (world * trace * val * mem) :=
@@ -541,7 +541,7 @@ Definition do_external (ef: external_function):
541541
| EF_memcpy sz al => do_ef_memcpy sz al
542542
| EF_annot text targs => do_ef_annot text targs
543543
| EF_annot_val text targ => do_ef_annot_val text targ
544-
| EF_inline_asm text => do_inline_assembly text ge
544+
| EF_inline_asm text sg clob => do_inline_assembly text sg ge
545545
end.
546546

547547
Lemma do_ef_external_sound:

cfrontend/PrintCsyntax.ml

+30
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ let rec expr p (prec, e) =
236236
expr (prec1, a1) (name_binop op) expr (prec2, a2)
237237
| Ecast(a1, ty) ->
238238
fprintf p "(%s) %a" (name_type ty) expr (prec', a1)
239+
| Eassign(res, Ebuiltin(EF_inline_asm(txt, sg, clob), _, args, _), _) ->
240+
extended_asm p txt (Some res) args clob
239241
| Eassign(a1, a2, _) ->
240242
fprintf p "%a =@ %a" expr (prec1, a1) expr (prec2, a2)
241243
| Eassignop(op, a1, a2, _, _) ->
@@ -262,6 +264,8 @@ let rec expr p (prec, e) =
262264
(extern_atom txt) exprlist (false, args)
263265
| Ebuiltin(EF_external(id, sg), _, args, _) ->
264266
fprintf p "%s@[<hov 1>(%a)@]" (extern_atom id) exprlist (true, args)
267+
| Ebuiltin(EF_inline_asm(txt, sg, clob), _, args, _) ->
268+
extended_asm p txt None args clob
265269
| Ebuiltin(_, _, args, _) ->
266270
fprintf p "<unknown builtin>@[<hov 1>(%a)@]" exprlist (true, args)
267271
| Eparen(a1, tycast, ty) ->
@@ -277,6 +281,32 @@ and exprlist p (first, rl) =
277281
expr p (2, r);
278282
exprlist p (false, rl)
279283

284+
and extended_asm p txt res args clob =
285+
fprintf p "asm volatile (@[<hv 0>%S" (extern_atom txt);
286+
fprintf p "@ :";
287+
begin match res with
288+
| None -> ()
289+
| Some e -> fprintf p " \"=r\"(%a)" expr (0, e)
290+
end;
291+
let rec inputs p (first, el) =
292+
match el with
293+
| Enil -> ()
294+
| Econs(e1, el) ->
295+
if not first then fprintf p ",@ ";
296+
fprintf p "\"r\"(%a)" expr (0, e1);
297+
inputs p (false, el) in
298+
fprintf p "@ : @[<hov 0>%a@]" inputs (true, args);
299+
begin match clob with
300+
| [] -> ()
301+
| c1 :: cl ->
302+
fprintf p "@ : @[<hov 0>%S" (extern_atom c1);
303+
List.iter
304+
(fun c -> fprintf p ",@ %S" (extern_atom c))
305+
cl;
306+
fprintf p "@]"
307+
end;
308+
fprintf p ")@]"
309+
280310
let print_expr p e = expr p (0, e)
281311
let print_exprlist p el = exprlist p (true, el)
282312

common/AST.v

+4-3
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ Inductive external_function : Type :=
584584
(** Another form of annotation that takes one argument, produces
585585
an event carrying the text and the value of this argument,
586586
and returns the value of the argument. *)
587-
| EF_inline_asm (text: ident).
587+
| EF_inline_asm (text: ident) (sg: signature) (clobbers: list ident).
588588
(** Inline [asm] statements. Semantically, treated like an
589589
annotation with no parameters ([EF_annot text nil]). To be
590590
used with caution, as it can invalidate the semantic
@@ -606,7 +606,7 @@ Definition ef_sig (ef: external_function): signature :=
606606
| EF_memcpy sz al => mksignature (Tint :: Tint :: nil) None cc_default
607607
| EF_annot text targs => mksignature targs None cc_default
608608
| EF_annot_val text targ => mksignature (targ :: nil) (Some targ) cc_default
609-
| EF_inline_asm text => mksignature nil None cc_default
609+
| EF_inline_asm text sg clob => sg
610610
end.
611611

612612
(** Whether an external function should be inlined by the compiler. *)
@@ -624,7 +624,7 @@ Definition ef_inline (ef: external_function) : bool :=
624624
| EF_memcpy sz al => true
625625
| EF_annot text targs => true
626626
| EF_annot_val text targ => true
627-
| EF_inline_asm text => true
627+
| EF_inline_asm text sg clob => true
628628
end.
629629

630630
(** Whether an external function must reload its arguments. *)
@@ -642,6 +642,7 @@ Proof.
642642
generalize ident_eq signature_eq chunk_eq typ_eq zeq Int.eq_dec; intros.
643643
decide equality.
644644
apply list_eq_dec. auto.
645+
apply list_eq_dec. auto.
645646
Defined.
646647
Global Opaque external_function_eq.
647648

common/Events.v

+4-4
Original file line numberDiff line numberDiff line change
@@ -1449,10 +1449,10 @@ Axiom external_functions_properties:
14491449

14501450
(** We treat inline assembly similarly. *)
14511451

1452-
Parameter inline_assembly_sem: ident -> extcall_sem.
1452+
Parameter inline_assembly_sem: ident -> signature -> extcall_sem.
14531453

14541454
Axiom inline_assembly_properties:
1455-
forall id, extcall_properties (inline_assembly_sem id) (mksignature nil None cc_default) nil.
1455+
forall id sg, extcall_properties (inline_assembly_sem id sg) sg nil.
14561456

14571457
(** ** Combined semantics of external calls *)
14581458

@@ -1479,8 +1479,8 @@ Definition external_call (ef: external_function): extcall_sem :=
14791479
| EF_free => extcall_free_sem
14801480
| EF_memcpy sz al => extcall_memcpy_sem sz al
14811481
| EF_annot txt targs => extcall_annot_sem txt targs
1482-
| EF_annot_val txt targ=> extcall_annot_val_sem txt targ
1483-
| EF_inline_asm txt => inline_assembly_sem txt
1482+
| EF_annot_val txt targ => extcall_annot_val_sem txt targ
1483+
| EF_inline_asm txt sg clb => inline_assembly_sem txt sg
14841484
end.
14851485

14861486
Theorem external_call_spec:

common/PrintAST.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ let name_of_external = function
5353
sprintf "memcpy size %s align %s " (Z.to_string sz) (Z.to_string al)
5454
| EF_annot(text, targs) -> sprintf "annot %S" (extern_atom text)
5555
| EF_annot_val(text, targ) -> sprintf "annot_val %S" (extern_atom text)
56-
| EF_inline_asm text -> sprintf "inline_asm %S" (extern_atom text)
56+
| EF_inline_asm(text, sg, clob) -> sprintf "inline_asm %S" (extern_atom text)
5757

5858
let rec print_annot_arg px oc = function
5959
| AA_base x -> px oc x

cparser/C.mli

+5-1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ and init =
190190
| Init_struct of ident * (field * init) list
191191
| Init_union of ident * field * init
192192

193+
(** GCC extended asm *)
194+
195+
type asm_operand = string option * string * exp
196+
193197
(** Statements *)
194198

195199
type stmt = { sdesc: stmt_desc; sloc: location }
@@ -210,7 +214,7 @@ and stmt_desc =
210214
| Sreturn of exp option
211215
| Sblock of stmt list
212216
| Sdecl of decl
213-
| Sasm of string
217+
| Sasm of attributes * string * asm_operand list * asm_operand list * string list
214218

215219
and slabel =
216220
| Slabel of string

0 commit comments

Comments
 (0)