caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] ARM code generator problem
@ 2012-08-10 21:41 Jeffrey Scofield
  2012-08-11  8:00 ` Benedikt Meurer
  0 siblings, 1 reply; 9+ messages in thread
From: Jeffrey Scofield @ 2012-08-10 21:41 UTC (permalink / raw)
  To: Caml List; +Cc: Jeffrey Scofield

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-08-17  4:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-10 21:41 [Caml-list] ARM code generator problem Jeffrey Scofield
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).