<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>It looks like what I have (shown) is correct.<div>The shift count is always an INTEGER.</div><div>32bit targets have:</div><div><br></div><div><br></div><div>Shift(Word32, Int32);<br>Shift(Word64, Int32);<br><br></div><div><br></div><div>64bit targets have:</div><div>Shift(Word32, Int64);<br>Shift(Word64, Int64);<br><br><br></div><div>I might have something wrong where I didn't show.</div><div>The M3CG_Ops.i3 comment is wrong.</div><div>The type of the value to shift and the count are never the same.</div><div><br></div><div><br></div><div>The only place the frontend uses this is builtinWord/Shift.mg.</div><div>Everywhere else, when I looked quickly, is explicit ShiftLeft or ShiftRight.</div><div>For those the count is unsigned.</div><div>Oh. Those look wrong too.</div><div>The front end uses an integer-based subrange for the parameter:</div><div><br></div><div>m3front/builtinWord/Shift.mg:</div><div><div>PROCEDURE Initialize (r: INTEGER) =</div><div><span style="font-size: 12pt; ">...</span></div><div><span style="font-size: 12pt; "> sub := SubrangeType.New (TInt.Zero, max, Int.T, FALSE);</span></div></div><div><br></div><div><br></div><div>So it is:</div><div><br></div><div><br></div><div>32bit targets:</div><div><div><span style="font-size: 12pt; ">ShiftLeft or Right</span>(Word32, Word32);<br>ShiftLeft or Right(Word64, Word32);<br><br></div><div><br></div><div>64bit targets:</div><div>ShiftLeft or Right(Word32, Word64);<br>ShiftLeft or Right(Word64, Word64);<br></div></div><div><br></div><div><br></div><div>which also doesn't agree with M3CG_Ops.i3.</div><div><br></div><div><br></div><div>Possibly "Rep" should abstract out the shift count type and not just the value to shift.</div><div>Perhaps it should be:</div><div><br></div><div><div>32bit and 64 bit targets:</div><div><div><span style="font-size: 12pt; ">ShiftLeft or Right</span>(Word32, Word32);<br>ShiftLeft or Right(Word64, Word64);<br></div></div><div><br></div><div>and perhaps it should be:</div><div><br></div><div>32bit:</div><div><div>Shift(Word32, Int32);<br>Shift(Word64, Int64);<br><br></div><div><br></div><div>64bit:</div><div>Shift(Word32, Int64);<br>Shift(Word64, Int64);<br></div></div><div><br></div><div><br></div><div>there are arguments for various combinations and what we have isn't crazy.</div><div>It just disagrees with comments in M3CG_Ops.i3.</div><div> The shift count doesn't really need to be widened to match the value.</div><div> If this were C with its prevalent "int", shift could remain just 32 bits always. (or even 16)</div><div> But Modula-3 favors INTEGER/ptrdiff_t and widening even when 32bits is plenty.</div><div><br></div><div><br></div><div><br></div> - Jay</div><div><br><div><div id="SkyDrivePlaceholder"></div><hr id="stopSpelling">From: jay.krell@cornell.edu<br>To: m3devel@elegosoft.com<br>Date: Sat, 22 Sep 2012 18:00:36 +0000<br>Subject: [M3devel] m3cg shift value/count types<br><br>
<style><!--
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:12pt;font-family:Calibri;}
--></style>
<div dir="ltr"><div>M3CG_Ops.i3:</div><div><br></div><div>shift (t: IType); (* s1.t := Word.Shift (s1.t, s0.t); pop *)</div><div><span style="font-size:12pt">rotate (t: IType); (* s1.t := Word.Rotate (s1.t, s0.t); pop *)</span></div><div><br></div><br>This doesn't seem right to me.<div><br></div><div>s0 is signed.</div><div>s1 is not</div><div><br></div><div>I have it implemented as:</div><div><br></div><div><div>#define m3_shift_T(T) static T m3_shift_##T(T value,INTEGER shift)...</div></div><div><br></div><div>where T is UINT32 or UINT64.</div><div><br></div><div>"shift" can vary..I'll look at the frontend...</div><div><br></div><div> - Jay</div> </div></div></div> </div></body>
</html>