<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'><div> ps, you can't even do this portably in C.</div><div><br></div><div><br></div><div> struct A </div><div> { </div><div> char a; </div><div> int b; </div><div> };</div><div><br></div><div><br></div><div> </div><div> will have padding between a and b on all systems. </div><div> The way to eliminate it varies by compiler, #pragma pack for Visual C++,</div><div> something else with gcc. </div><div> And might result in an alignment fault.</div><div><br></div><div><br></div><div> And we do have this wacky LAZYALIGN pragma that that might make it work. </div><div> Really that pragma is weird. You might get the packed layout, but you'll</div><div> also get alignment faults on some targets, unless we decompose the reads</div><div> into byte by byte -- assuming this isn't hardware access that demands a single access.</div><div><br></div><div><br></div><div>In C you have a chance with:</div><div><br></div><div>struct A</div><div>{</div><div> char a;</div><div> char b[4];</div><div>};</div><div><br></div><div>and then maybe</div><div>A a;</div><div><br></div><div>*(int*)&a.b;</div><div><br></div><div><br></div><div>but it will fault on most target -- but not x86/amd64.</div><div><br></div><div><br></div><div>If you don't need one read, you can do:</div><div><br></div><div><br></div><div> int c = a.b[0] </div><div> b <<= 8; b |= a.b[1]; </div><div> b <<= 8; b |= a.b[2];</div><div> b <<= 8; b |= a.b[3]; </div><div><br></div><div><br></div><div>or such.</div><div><br></div><div>You can do like that in Modula-3 also.</div><div><br></div><div><br></div><div>So I don't see a strong need to support these things.</div><div><br></div><div><br></div><div> - Jay</div><br><div><hr id="stopSpelling">From: jay.krell@cornell.edu<br>To: hosking@purdue.edu<br>CC: m3devel@elegosoft.com<br>Subject: RE: [M3devel] Target.Allow_packed_byte_aligned<br>Date: Mon, 21 Sep 2015 02:51:08 +0000<br><br>
<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}
.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}
--></style>
<div dir="ltr">I don't believe this is portable.<div>Such code would only compile for x86/amd64 targets.</div><div>I think.</div><div>We want to cater to such target-specific constructs?</div><div>I should confirm it is target-specific?</div><div>I want to eliminate gratuitous target-specific aspects and devolve the IR to having essentially 3 variables -- word size and endian and NT vs. posix. Fewer if I can manage to.</div><div><br></div><div><br></div><div> - Jay<br><br><br><div><hr id="ecxstopSpelling">Subject: Re: [M3devel] Target.Allow_packed_byte_aligned<br>From: hosking@purdue.edu<br>Date: Mon, 21 Sep 2015 12:47:07 +1000<br>CC: m3devel@elegosoft.com<br>To: jay.krell@cornell.edu<br><br><div>Packed types are part of the language and their behavior should be preserved. Just because we don't use it on the libraries others do!<br><br>Sent from my iPhone</div><div><br>On Sep 21, 2015, at 12:19 PM, Jay K <<a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a>> wrote:<br><br></div><blockquote><div>
<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}
.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}
--></style>
<div dir="ltr">I don't think so.<div>I built the system with it.</div><div>Granted, only one target.</div><div><br></div><div>If we had something like</div><div>TYPE T = BITS BITSIZE(INTEGER) + 8 FOR PACKED RECORD</div><div> a: CHAR</div><div> b:INTEGER</div><div>END;</div><div><br></div><div>I think it'd break that.</div><div>I'm not sure we any longer use packed types.</div><div>And such things would only work for x86/amd64 I believe.</div><div><br></div><div> - Jay<br><br><br><div><hr id="ecxstopSpelling">Subject: Re: [M3devel] Target.Allow_packed_byte_aligned<br>From: <a href="mailto:hosking@purdue.edu">hosking@purdue.edu</a><br>Date: Mon, 21 Sep 2015 10:44:59 +1000<br>CC: <a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>To: <a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br><br><div>We should be careful here. Might break something, no?<br><br>Sent from my iPhone</div><div><br>On Sep 21, 2015, at 2:53 AM, Jay K <<a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a>> wrote:<br><br></div><blockquote><div>
<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}
.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}
--></style>
<div dir="ltr">I propose that Allow_packed_byte_aligned be set to FALSE for <span style="font-size:12pt;">all targets.</span><div><br></div><div>Or make it const.</div><div><br></div><div><br></div><div><span style="font-size:12pt;">Or remove it.</span></div><div><br></div><div><br></div><div>This will degrade slightly x86/amd64 but in, I speculate, fairly rare paths.</div><div>Specifically, if you manage to create a packed type with unaligned fields,</div><div>presumably loads/stores get converted to multiple aligned loads/stores followed</div><div>by putting stuff back together. The occurrence of the unaligned fields should</div><div>be very rare in the first place.</div><div><br></div><div><br></div><div><span style="font-size:12pt;">I does not affect any other target.</span></div><div><br></div><div><br></div><div>Granted, x86 and amd64 are the most common targets.</div><div><br></div><div><br></div><div>Ok?</div><div> - Jay<br><br><br></div> !
</div>
</div></blockquote><blockquote><div><span>_______________________________________________</span><br><span>M3devel mailing list</span><br><span><a href="mailto:M3devel@elegosoft.com">M3devel@elegosoft.com</a></span><br><span><a href="https://mail.elegosoft.com/cgi-bin/mailman/listinfo/m3devel" target="_blank">https://mail.elegosoft.com/cgi-bin/mailman/listinfo/m3devel</a></span><br></div></blockquote></div></div> </div>
</div></blockquote></div></div> </div></div> </div></body>
</html>