<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Meiryo UI";
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@Meiryo UI";
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Meiryo UI","sans-serif";
        color:black;
        font-weight:normal;
        font-style:normal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:89358133;
        mso-list-type:hybrid;
        mso-list-template-ids:1882993286 873005071 873005081 873005083 873005071 873005081 873005083 873005071 873005081 873005083;}
@list l0:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-PH" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">Hi All,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">In the target we are implementing, function return for i64 and f64 types has a different processing.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">For types i8 to i32, and f32, the return values are stored in their designated return registers (like how other targets does it).
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">For i64 and f64 types, in the function call, after pushing the function parameters into the stack, the address of the allocated return memory space is assigned to a 16-bit register
 (In our case, ER0). This is done by assigning the frame pointer register into ER0 and then adding the offset to it. So the output assembly code would somewhat look like the following:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">Expected Target ASM output for i64 function call with i64 return type:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">1    push qr0                    ;; 64-bit parameter pushed into the stack<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">2    mov er0, fp                ;; Assign the frame pointer into er0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">3    add er0, #-32            ;; Add the frame pointer offset to er0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">4    bl _fn                        ;; Function call fn<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">5    add sp, #8                 ;; SP adjustment<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">In function fn:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">1 ;; function prologue processing here...<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">2 mov er8, er0                 ;; frame pointer location of retval is transferred to er8 (will be used at line 4)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">3 ;; function processing here... Assuming that the i64 value to be returned is stored at qr0...<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">4 lea [er8]                       ;;  i64 return processing starts here. Load effective address from [er8]<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">5 st qr0, [ea]                   ;; Store the i64 value into the effective address memory location.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">6 ;; function epilogue processing here...<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">From my investigations so far, i64 types should call a custom function in the calling convention for processing this return type. Also, that LowerCall should be modified to
 have the assigning of frame pointer into er0 and that LowerReturn should be modified in order to store qr0 into the effective address. Please correct me if I’m wrong.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">My questions are:<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-family:"Meiryo UI","sans-serif";color:black"><span style="mso-list:Ignore">1.<span style="font:7.0pt "Times New Roman"">   
</span></span></span><![endif]><span style="font-family:"Meiryo UI","sans-serif";color:black">Are there any target examples that also has this kind of behavior? If there are please let me know so I could study on it.<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-family:"Meiryo UI","sans-serif";color:black"><span style="mso-list:Ignore">2.<span style="font:7.0pt "Times New Roman"">   
</span></span></span><![endif]><span style="font-family:"Meiryo UI","sans-serif";color:black">Where does the assigning of frame pointer+offset(frame index?) fall? I am currently suspecting that it should be in the LowerCall function.
<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-family:"Meiryo UI","sans-serif";color:black"><span style="mso-list:Ignore">3.<span style="font:7.0pt "Times New Roman"">   
</span></span></span><![endif]><span style="font-family:"Meiryo UI","sans-serif";color:black">If my assumption that question #2 falls in LowerCall function is correct, how do I retrieve the created frame index from the LowerCall function in the LowerReturn
 function?<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-family:"Meiryo UI","sans-serif";color:black"><span style="mso-list:Ignore">4.<span style="font:7.0pt "Times New Roman"">   
</span></span></span><![endif]><span style="font-family:"Meiryo UI","sans-serif";color:black">I also suspect that the affected functions are not limited to LowerCall and LowerReturn, if you have suggestions on which ISelLowering Class functions I should investigate
 on, please let me know.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">Thank you very much in advance for your help!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">Sincerely,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI","sans-serif";color:black">Miguel Inigo J. Manalac<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
JAPANESE: このメールは、宛先に書かれている方のみに送信することを意図しております。誤ってそれ以外の方に送信された場合は、申し訳ございませんが、送信者までお知らせいただき、受信されたメールを削除していただきますようお願いいたします。また、コンピュータ・ウィルスの混入等によってメールの欠落・不整合・遅滞等が発生し、何らのご不便をおかけすることが生じても弊社はその責任を負いません。 ENGLISH: This e-mail is intended for the person(s) to which it
 is addressed. If you have received it by mistake, please notify the sender and delete the received email. In addition, our company shall not assume any responsibility even if it causes any inconvenience, such as loss of mail, inconsistencies, delays, etc.,
 due to the inclusion of computer viruses.
</body>
</html>