aboutsummaryrefslogtreecommitdiffstats
path: root/ia32
diff options
context:
space:
mode:
authorXavier Leroy <xavierleroy@users.noreply.github.com>2015-03-31 10:19:44 +0200
committerXavier Leroy <xavierleroy@users.noreply.github.com>2015-03-31 10:19:44 +0200
commit47a6b116069cff9c71466bde1fd87d0775ec9175 (patch)
treecc6402162b64512db1f82ebbb5c94606f14ee3a8 /ia32
parent14f3f0dfb90c74b7e1bc96c4aee74fb88dd7923b (diff)
parentc1205952ab7e3be09cd1a0a9a4d4ee9ddeefe1ea (diff)
downloadcompcert-47a6b116069cff9c71466bde1fd87d0775ec9175.tar.gz
compcert-47a6b116069cff9c71466bde1fd87d0775ec9175.zip
Merge pull request #33 from AbsInt/struct-passing
ABI conformance for passing function arguments and returning function results of struct and union types
Diffstat (limited to 'ia32')
-rw-r--r--ia32/TargetPrinter.ml19
1 files changed, 15 insertions, 4 deletions
diff --git a/ia32/TargetPrinter.ml b/ia32/TargetPrinter.ml
index 888a7e72..c00dfc57 100644
--- a/ia32/TargetPrinter.ml
+++ b/ia32/TargetPrinter.ml
@@ -801,8 +801,10 @@ module Target(System: SYSTEM):TARGET =
| Pjmp_l(l) ->
fprintf oc " jmp %a\n" label (transl_label l)
| Pjmp_s(f, sg) ->
+ assert (not sg.sig_cc.cc_structret);
fprintf oc " jmp %a\n" symbol f
| Pjmp_r(r, sg) ->
+ assert (not sg.sig_cc.cc_structret);
fprintf oc " jmp *%a\n" ireg r
| Pjcc(c, l) ->
let l = transl_label l in
@@ -818,12 +820,21 @@ module Target(System: SYSTEM):TARGET =
fprintf oc " jmp *%a(, %a, 4)\n" label l ireg r;
jumptables := (l, tbl) :: !jumptables
| Pcall_s(f, sg) ->
- fprintf oc " call %a\n" symbol f
+ fprintf oc " call %a\n" symbol f;
+ if sg.sig_cc.cc_structret then
+ fprintf oc " pushl %%eax\n"
| Pcall_r(r, sg) ->
- fprintf oc " call *%a\n" ireg r
+ fprintf oc " call *%a\n" ireg r;
+ if sg.sig_cc.cc_structret then
+ fprintf oc " pushl %%eax\n"
| Pret ->
- fprintf oc " ret\n"
- (** Pseudo-instructions *)
+ if (!current_function_sig).sig_cc.cc_structret then begin
+ fprintf oc " movl 0(%%esp), %%eax\n";
+ fprintf oc " ret $4\n"
+ end else begin
+ fprintf oc " ret\n"
+ end
+ (** Pseudo-instructions *)
| Plabel(l) ->
fprintf oc "%a:\n" label (transl_label l)
| Pallocframe(sz, ofs_ra, ofs_link) ->