<div dir="ltr">


















<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span lang="EN-US">Currently we are trying to implement
AIX special alignment rule on the top of Itanium ABI in Clang. On AIX,  in
aggregates, the first member of double/long double is aligned according to its
natural alignment value; subsequent double/long double of the aggregate are
aligned on 4-byte boundaries.</span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span lang="EN-US"> </span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span lang="EN-US">This rule is recursive. It applies
all the way to the inner most nested members. An example is as the following:</span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span lang="EN-US"> </span><span></span></p>

<p class="MsoNormal" style="margin:3pt 0cm;font-size:12pt;font-family:"Times New Roman",serif"><span style="font-size:9pt;font-family:"Courier New";color:black">struct D {<br>
        double d;<br>
        int i;<br>
};</span><span></span></p>

<p class="MsoNormal" style="margin:3pt 0cm;font-size:12pt;font-family:"Times New Roman",serif"><span style="font-size:9pt;font-family:"Courier New";color:black"> </span><span></span></p>

<p class="MsoNormal" style="margin:3pt 0cm;font-size:12pt;font-family:"Times New Roman",serif"><span style="font-size:9pt;font-family:"Courier New";color:black">struct IntFirst {<br>
        int i;<br>
        struct D d;<br>
};</span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span style="color:black"> </span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span style="color:black">The size of struct D is 16, class alignment is 8;</span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span style="color:black">The size of struct IntFirst is 20, class alignment is 4;</span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"> <span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span lang="EN-US">So our current idea is to have an alignment
field to record nested struct info and pass the special alignment value all the
way back to the ourter most aggregate.</span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span lang="EN-US"> </span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span lang="EN-US">And based on this idea, there are
two possible ways.</span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span lang="EN-US"> </span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span lang="EN-US">1. </span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span lang="EN-US">The first one is that we introduced
a new field in class </span><i>ASTRecordLayout</i><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">Called
`<i>AIXOffsetAlignment</i>`  which represents the special AIX alignment
for the object that<span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">contains
floating-point member or sub-member. This is for AIX-ABI only.<span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"> <span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">The
proposed change has been put on Phabricator under review: <a href="https://reviews.llvm.org/D78563" style="color:rgb(5,99,193);text-decoration:underline"><span style="color:rgb(5,99,193)">https://reviews.llvm.org/D78563</span></a>
<span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"> <span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><b>Pros:<span></span></b></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">-
The design is cleaner. It is clear that such field is for AIX and it does not
affect any other target <span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span>   </span>in terms of functionality.<span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:rgb(209,210,211);background:rgb(34,37,41) none repeat scroll 0% 0%"><span style="font-variant-ligatures:common-ligatures;font-variant-caps:normal;text-decoration-style:initial;text-decoration-color:initial;float:none;word-spacing:0px"><br>
<br>
</span><span></span></span></p>



<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><b><span style="font-variant-ligatures:common-ligatures;font-variant-caps:normal;text-decoration-style:initial;text-decoration-color:initial;float:none;word-spacing:0px">Cons:<span></span></span></b></p>

<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">- All other targets using ItaniumRecordLayoutBuilder will
also have to pay the price to keep <span></span></p>

<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span>   </span>updating this `<i>AIXOffsetAlignment`
</i>along the common code path by using <i>`<span class="gmail-nf">UpdateAlignment</span></i>`.
<span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"> <span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">2.<span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">The
second possible way we have in mind is to overload the usage of current
Microsoft-ABI only alignment field <i>`RequiredAlignment</i>` and rename it to
`<i>TargetSpecialAlignment</i>` instead of the above first way to create a new
alignment field.<span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">This
alignment field will function the same in Itanium ABI part for AIX. Meanwhile,
because the current `RequiredAlignment` is only used in MS code, renaming will
not affect MS code path functionally.<span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"> <span></span></p>

<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><b>Pro:<span></span></b></p>

<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">- Class ASTRecordLayout does not need to construct one
more field `AIXOffsetAlignment` compared to the method one.<span></span></p>

<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">- Instead of having each target add new fields for their
special alignment rules, we could have one field that handles all the potential
alignment differences for every target.<br>
<br>
<span></span></p>

<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt 3pt;text-align:justify;font-size:12pt;font-family:"Times New Roman",serif"> <span></span></p>

<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt 3pt;text-align:justify;font-size:12pt;font-family:"Times New Roman",serif"><b>Cons:<span></span></b></p>

<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">-  Still, all other targets using ItaniumRecordLayoutBuilder
will also have to pay the price to <span>  </span><span></span></p>

<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span>   </span>keep updating this
`TargetSpecialAlignment` along the common code path by using <span></span></p>

<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span>   </span>`UpdateAlignment`.<span></span></p>

<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">-  By overloading the usage, it may create
confusion when more targets try to utilize it in the <span></span></p>

<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span>   </span>future. <span></span></p>

<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">-  The degree of willingness of sharing this
current MS-only alignment field is unknown.<span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"> <span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"> <span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">I
would like to see how people think about the above two ways. Which one is
better? Any concerns about either one? Or any other <span lang="EN-US">ideas to suggest?</span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span lang="EN-US"> </span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">Please
let me know if there are any questions about my current proposal and design.
Your feedback is appreciated.<span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"> <span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">Regards,<span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"> <span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif">Xiangling
Liao<span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"> <span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span lang="EN-US"> </span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span style="font-size:14pt;font-family:"Helvetica Neue"" lang="EN-US"> </span><span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span lang="EN-US"> </span><span></span></p>

<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;font-size:12pt;font-family:"Times New Roman",serif"><span> </span></p>





</div>