<div dir="ltr">hey Herbert, <div>I generally start with looking at the primops.cmm file for examples <a href="https://github.com/ghc/ghc/blob/master/rts/PrimOps.cmm#L572-L588">https://github.com/ghc/ghc/blob/master/rts/PrimOps.cmm#L572-L588</a></div>

<div><br></div><div>otoh, the comments in cmmparse.y indicate that's not quite "kosher"? or maybe the comments are a lie? <a href="https://github.com/ghc/ghc/blob/master/compiler/cmm/CmmParse.y#L24-L28">https://github.com/ghc/ghc/blob/master/compiler/cmm/CmmParse.y#L24-L28</a></div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jan 4, 2014 at 6:26 PM, Herbert Valerio Riedel <span dir="ltr"><<a href="mailto:hvr@gnu.org" target="_blank">hvr@gnu.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
According to Note [Syntax of .cmm files],<br>
<br>
| There are two ways to write .cmm code:<br>
|<br>
|  (1) High-level Cmm code delegates the stack handling to GHC, and<br>
|      never explicitly mentions Sp or registers.<br>
|<br>
|  (2) Low-level Cmm manages the stack itself, and must know about<br>
|      calling conventions.<br>
|<br>
| Whether you want high-level or low-level Cmm is indicated by the<br>
| presence of an argument list on a procedure.<br>
<br>
However, while working on integer-gmp I've been noticing in<br>
integer-gmp/cbits/gmp-wrappers.cmm that even though all Cmm procedures<br>
have been converted to high-level Cmm, they still reference the 'Sp'<br>
register, e.g.<br>
<br>
<br>
    #define GMP_TAKE1_RET1(name,mp_fun)       \<br>
    name (W_ ws1, P_ d1)                      \<br>
    {                                         \<br>
      W_ mp_tmp1;                             \<br>
      W_ mp_result1;                          \<br>
                                              \<br>
    again:                                    \<br>
      STK_CHK_GEN_N (2 * SIZEOF_MP_INT);      \<br>
      MAYBE_GC(again);                        \<br>
                                              \<br>
      mp_tmp1    = Sp - 1 * SIZEOF_MP_INT;    \<br>
      mp_result1 = Sp - 2 * SIZEOF_MP_INT;    \<br>
      ...                                     \<br>
<br>
<br>
So is this valid high-level Cmm code? What's the proper way to allocate<br>
Stack (and/or Heap) memory from high-level Cmm code?<br>
<br>
Cheers,<br>
  hvr<br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/ghc-devs" target="_blank">http://www.haskell.org/mailman/listinfo/ghc-devs</a><br>
</blockquote></div><br></div>