From: Jeffrey Scofield <jeffsco@psellos.com>
To: Caml List <caml-list@inria.fr>
Cc: Jeffrey Scofield <jeffsco@psellos.com>
Subject: [Caml-list] ARM code generator problem
Date: Fri, 10 Aug 2012 14:41:43 -0700 [thread overview]
Message-ID: <51E93001-B3AB-4B8D-B46C-7ACA11346C38@psellos.com> (raw)
Greetings,
While working on porting OCaml 4.00.0 to iOS, I ran across
what looks like a problem in the ARM code generation.
If you look at asmcomp/arm/emit.mlp you see lots of places where
s14 is used as a scratch register. The one that showed up in my
code is the code sequence for float_of_int:
| Lop(Ifloatofint) ->
` fmsr s14, {emit_reg i.arg.(0)}\n`;
` fsitod {emit_reg i.res.(0)}, s14\n`; 2
Note that the emitted code always uses s14 (unconditionally). This
suggests that s14 should be set aside as a scratch register.
However, s14 is also an alias for the low order part of d7. If you look
at asmcomp/arm/proc.ml you'll see that d7 is used as a general purpose
register.
The result is that a value in d7 is sometimes destroyed by a use
of s14 as a scratch register. In my code it was a call to float_of_int
that destroyed a float value being kept in d7.
I'm wondering if there's any wisdom on the list about this problem.
I don't see anything about it on Mantis.
For my own project, I think I can solve this simply by leaving d7 out of
the list of general registers in proc.ml. However, this might be a bit
drastic. Maybe there is a more subtle and wise solution.
You can read about OCaml4-on-iOS progress in my sporadic blog:
http://psellos.com/2012/07/2012.07.ocamlxarm-ocaml4-1.html
I can provide my OCaml code and the generated ARM code if it will help
show the problem. I haven't (yet) tried to whittle it down to a small
case.
Regards,
Jeffrey
next reply other threads:[~2012-08-10 21:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-10 21:41 Jeffrey Scofield [this message]
2012-08-11 8:00 ` Benedikt Meurer
2012-08-11 8:13 ` Benedikt Meurer
2012-08-11 8:57 ` Jeffrey Scofield
2012-08-11 9:48 ` [Caml-list] " Benedikt Meurer
2012-08-11 8:52 ` [Caml-list] " Jeffrey Scofield
2012-08-13 19:21 ` [Caml-list] " Jeffrey Scofield
2012-08-14 7:11 ` Benedikt Meurer
2012-08-17 4:26 ` Jeffrey Scofield
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51E93001-B3AB-4B8D-B46C-7ACA11346C38@psellos.com \
--to=jeffsco@psellos.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox