Converting unboxed sum types in StgCmm

Dan Doel dan.doel at gmail.com
Thu Sep 10 05:24:57 UTC 2015


Some of the SSE types are too big for that even on 64 bit, I think.
Like DoubleX8#.

On Thu, Sep 10, 2015 at 1:16 AM, Johan Tibell <johan.tibell at gmail.com> wrote:
> I wonder if rewriting any aliased pointer field as Any in Stg and any
> non-pointer field as Word# would work. I suspect that not all non-pointer
> fields (e.g. Double# on 32-bit) can be represented as Word#.
>
> On Wed, Sep 9, 2015 at 3:22 PM, Johan Tibell <johan.tibell at gmail.com> wrote:
>>
>> Hi!
>>
>> The original idea for implementing the backend part of the unboxed sums
>> proposal was to convert from the core representation to the actual data
>> representation (i.e. a tag followed by some pointer and non-pointer fields)
>> in the unarise stg-to-stg pass.
>>
>> I have now realized that this won't work. The problem is that stg is too
>> strongly typed. When we "desugar" sum types we need to convert functions
>> receiving a value e.g. from
>>
>>     f :: (# Bool | Char #) -> ...
>>
>> to
>>
>>     f :: NonPointer {-# tag#-} -> Pointer {-# Bool or Char #-} -> ...
>>
>> Since stg is still typed with normal Haskell types (e.g. Bool, Char, etc),
>> this is not possible, as we cannot represent an argument which has two
>> different types.
>>
>> It seems to me that we will have to do the conversion in the stg-to-cmm
>> pass, which is quite a bit more involved. For example, StgCmmEnv.idToReg
>> function will have to change from
>>
>>     idToReg :: DynFlags -> NonVoid Id -> LocalReg
>>
>> to
>>
>>     idToReg :: DynFlags -> NonVoid Id -> [LocalReg]
>>
>> to accommodate the fact that we might need more than one register to store
>> a binder.
>>
>> Any ideas for a better solution?
>>
>> -- Johan
>>
>
>
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>


More information about the ghc-devs mailing list