[GHC] #13442: Add a coercion/cast operator to CMM

GHC ghc-devs at haskell.org
Sun Mar 19 03:34:16 UTC 2017


#13442: Add a coercion/cast operator to CMM
-------------------------------------+-------------------------------------
        Reporter:  erikd             |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.4.1
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by rwbarton):

 Take any old function that calculates with `Double` like
 {{{#!hs
 f :: Double -> Double
 f x = x + 1
 }}}
 and compile it with `-O -ddump-cmm`, and it will do things like
 {{{
        cOz:
            _sOd::F64 = %MO_F_Add_W64(F64[R1 + 7], 1.0 :: W64);
            I64[Hp - 8] = GHC.Types.D#_con_info;
            F64[Hp] = _sOd::F64;
            R1 = Hp - 7;
            Sp = Sp + 8;
            call (P64[Sp])(R1) args: 8, res: 0, upd: 8;
 }}}
 `F64[A]` is the way to denote the 64-bit floating point quantity at
 address `A`. So internally Cmm has a representation of exactly the
 construct you need already. I'm just not sure whether it is possible to
 write that construct in a `.cmm` file.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13442#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list