[M3devel] m3cg right shift signed?

Rodney M. Bates rodney_bates at lcwb.coop
Tue Jun 9 18:05:51 CEST 2015


I'm a little unclear what you are asking.  I see several places in M3CG_Ops.i3 which
call for sign-extension, e.g., load, widen, extract* and any way of pushing on the IR stack.
While signed right shift is clearly a good primitive to sign-extend, all these IR ops leave
leave this to the code generator, which is good, because the available machine opcodes will
be target dependent.

As for set_range, this too leaves it to the code generator when the word whose bits are to
be set is 32 or 64 bits.  For smaller, CG lowers this itself, using more primitive
bit-twiddling operators.  But it looks like the shifts it generates must be zero-filling,
to work right.

As for the shift IR operators themselves, M3CG_Ops.i3 defines them as the same as the shifts
in Word, none of which is sign-filling.

On 06/08/2015 08:44 PM, Jay wrote:
> (Not at propercomputer but sending anyway.)
>
> Is right shift of a signed type meant to be supported and well defined in the IR? I thought not, and assert so in the C backend. But it occurs now, from m3front/cg/set_range or such. Maybe change that to not? Surely unsigned types are adequate here?
>
>   - Jay
>

-- 
Rodney Bates
rodney.m.bates at acm.org



More information about the M3devel mailing list