<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 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
font-size:10.5pt;
font-family:DengXian;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:DengXian;
color:windowtext;}
span.pl-pds
{mso-style-name:pl-pds;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:DengXian;}
/* Page Definitions */
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></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="ZH-CN" link="#0563C1" vlink="#954F72" style="text-justify-trim:punctuation">
<div class="WordSection1">
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62">Hi all developers,<o:p></o:p></span></span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62">I’m currently working on a RISCV target with two address mode, 32 bit and 64 bit. And all the registers are 32bits.
<o:p></o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> The first thing I dose was changing the data layout of this target. So I change the data layout string to "e-m:e-p:64:64-p1:64:32-i64:64-n32-S128"
in clang/lib/Basic/Targets/RISCV.h and llvm/lib/TargetRISCV/RISCVTargteMachine.cpp.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> But I found that not work as expected, following is my test code:<o:p></o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> C language:<o:p></o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> int func() {<o:p></o:p></span></i></span></p>
<p class="MsoNormal" style="text-indent:22.5pt"><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> return sizeof(int*);<o:p></o:p></span></i></span></p>
<p class="MsoNormal" style="text-indent:22.5pt"><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62">}<o:p></o:p></span></i></span></p>
<p class="MsoNormal"><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> <o:p></o:p></span></i></span></p>
<p class="MsoNormal"><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"><o:p> </o:p></span></i></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> the IR code is :<o:p></o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> target datalayout =
</span></i></span><span class="pl-pds"><i><span style="font-size:9.0pt;color:#032F62">“</span></i></span><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62">e-m:e-p:64:64-p1:64:32-i64:64-n32-S128</span></i></span><span class="pl-pds"><i><span style="font-size:9.0pt;color:#032F62">”</span></i></span><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"><o:p></o:p></span></i></span></p>
<p class="MsoNormal"><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> target triple =
</span></i></span><span class="pl-pds"><i><span style="font-size:9.0pt;color:#032F62">“</span></i></span><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62">riscv32-unkown-unkown-elf</span></i></span><span class="pl-pds"><i><span style="font-size:9.0pt;color:#032F62">”</span></i></span><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"><o:p></o:p></span></i></span></p>
<p class="MsoNormal"><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> define dso_ocal i32 @func() local_unnamed_addr #0 {<o:p></o:p></span></i></span></p>
<p class="MsoNormal" style="text-indent:22.5pt"><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62">entry:<o:p></o:p></span></i></span></p>
<p class="MsoNormal" style="text-indent:22.5pt"><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> ret i32 4<o:p></o:p></span></i></span></p>
<p class="MsoNormal" style="text-indent:22.5pt"><span class="pl-pds"><i><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62">}<o:p></o:p></span></i></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> I see that the size of int* is 4 bytes, it is 32bits, not 64 bits as expected.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> Can you tell me if I am wrong in somewhere, or the way to change the pointer size correctly.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62"> Thank you all for your time and any help you can provide.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span class="pl-pds"><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#032F62">Lori<o:p></o:p></span></span></p>
</div>
</body>
</html>