<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Nov 1, 2007, at 6:43 PM, Devang Patel wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><br><div><div>On Nov 1, 2007, at 1:53 PM, Duncan Sands wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Finally, I made one change which I think wise but others might</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">consider pointless and suboptimal: in an unpacked struct the</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">amount of space allocated for a field is now given by the ABI</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">size rather than getTypeStoreSize.<span class="Apple-converted-space">  </span>I did this because every</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">other place that reserves memory for a type (eg: alloca) now</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">uses getABITypeSize, and I didn't want to make an exception</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">for unpacked structs, i.e. I did it to make things more uniform.</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">This only effects structs containing long doubles and arbitrary</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">precision integers.<span class="Apple-converted-space">  </span>If someone wants to pack these types more</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">tightly they can always use a packed struct.</font></div> </blockquote></div><br><div>Naively, I just used getTypeSizeInBits() clang yesterday. I'll sync up clang once dust settles on llvm side in next day or two. </div><div><br class="khtml-block-placeholder"></div><div>Now, how far we are from ability to use arbitrary precision integers to represent struct bit fields directly ?</div><div><br class="khtml-block-placeholder"></div><div>translating</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>struct STest4 {char a; int b:2; int c:3; int d; } st4;</div><div>into</div><div>        %struct.STest4 = type { i8, i2, i3, i32 }</div><div>instead of</div><div>        %struct.STest4 = type { i8, i8, i32 }</div><div>?:)</div><div><br></div></div></blockquote>We won't ever want to do that.  "apints in structs" will be stored with their extra bits as garbage: they won't pack together. {i2, i3} will take two bytes for example.  In practice, we will always have to compile the above into  { i8, i8, i32 }.</div><div><br class="webkit-block-placeholder"></div><div>-Chris</div></body></html>