<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=utf-8">
<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:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",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.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
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="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Thanks for your comments. I will fix that.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Sam<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Eric Christopher [mailto:echristo@gmail.com]
<br>
<b>Sent:</b> Saturday, March 25, 2017 1:52 AM<br>
<b>To:</b> Liu, Yaxun (Sam) <Yaxun.Liu@amd.com>; cfe-commits@lists.llvm.org<br>
<b>Subject:</b> Re: r298767 - [AMDGPU] Switch address space mapping by triple environment amdgiz<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Fri, Mar 24, 2017 at 8:58 PM Yaxun Liu via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Author: yaxunl<br>
Date: Fri Mar 24 22:46:25 2017<br>
New Revision: 298767<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=298767&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=298767&view=rev</a><br>
Log:<br>
[AMDGPU] Switch address space mapping by triple environment amdgiz<br>
<br>
For target environment amdgiz and amdgizcl (giz means Generic Is Zero), AMDGPU will use new address space mapping where generic address space is 0 and private address space is 5. The data layout is also changed correspondingly.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D31210" target="_blank">
https://reviews.llvm.org/D31210</a><br>
<br>
Added:<br>
cfe/trunk/test/CodeGenOpenCL/<a href="http://amdgpu-env-amdgiz.cl" target="_blank">amdgpu-env-amdgiz.cl</a><br>
Modified:<br>
cfe/trunk/lib/Basic/Targets.cpp<br>
<br>
Modified: cfe/trunk/lib/Basic/Targets.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=298767&r1=298766&r2=298767&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=298767&r1=298766&r2=298767&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Basic/Targets.cpp (original)<br>
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Mar 24 22:46:25 2017<br>
@@ -2027,14 +2027,23 @@ ArrayRef<const char *> NVPTXTargetInfo::<br>
return llvm::makeArrayRef(GCCRegNames);<br>
}<br>
<br>
-static const unsigned AMDGPUAddrSpaceMap[] = {<br>
- 1, // opencl_global<br>
- 3, // opencl_local<br>
- 2, // opencl_constant<br>
- 4, // opencl_generic<br>
- 1, // cuda_device<br>
- 2, // cuda_constant<br>
- 3 // cuda_shared<br>
+static const LangAS::Map AMDGPUPrivateIsZeroMap = {<br>
+ 1, // opencl_global<br>
+ 3, // opencl_local<br>
+ 2, // opencl_constant<br>
+ 4, // opencl_generic<br>
+ 1, // cuda_device<br>
+ 2, // cuda_constant<br>
+ 3 // cuda_shared<br>
+};<br>
+static const LangAS::Map AMDGPUGenericIsZeroMap = {<br>
+ 1, // opencl_global<br>
+ 3, // opencl_local<br>
+ 4, // opencl_constant<br>
+ 0, // opencl_generic<br>
+ 1, // cuda_device<br>
+ 4, // cuda_constant<br>
+ 3 // cuda_shared<br>
};<br>
<br>
// If you edit the description strings, make sure you update<br>
@@ -2044,15 +2053,39 @@ static const char *const DataLayoutStrin<br>
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"<br>
"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";<br>
<br>
-static const char *const DataLayoutStringSI =<br>
+static const char *const DataLayoutStringSIPrivateIsZero =<br>
"e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32"<br>
"-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"<br>
"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";<br>
<br>
+static const char *const DataLayoutStringSIGenericIsZero =<br>
+ "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32"<br>
+ "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"<br>
+ "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";<br>
+<br>
class AMDGPUTargetInfo final : public TargetInfo {<br>
static const Builtin::Info BuiltinInfo[];<br>
static const char * const GCCRegNames[];<br>
<br>
+ struct AddrSpace {<br>
+ unsigned Generic, Global, Local, Constant, Private;<br>
+ AddrSpace(bool IsGenericZero_ = false){<br>
+ if (IsGenericZero_) {<br>
+ Generic = 0;<br>
+ Global = 1;<br>
+ Local = 3;<br>
+ Constant = 4;<br>
+ Private = 5;<br>
+ } else {<br>
+ Generic = 4;<br>
+ Global = 1;<br>
+ Local = 3;<br>
+ Constant = 2;<br>
+ Private = 0;<br>
+ }<br>
+ }<br>
+ };<br>
+<br>
/// \brief The GPU profiles supported by the AMDGPU target.<br>
enum GPUKind {<br>
GK_NONE,<br>
@@ -2079,6 +2112,10 @@ class AMDGPUTargetInfo final : public Ta<br>
return TT.getArch() == llvm::Triple::amdgcn;<br>
}<br>
<br>
+ static bool isGenericZero(const llvm::Triple &TT) {<br>
+ return TT.getEnvironmentName() == "amdgiz" ||<br>
+ TT.getEnvironmentName() == "amdgizcl";<br>
+ }<br>
public:<br>
AMDGPUTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)<br>
: TargetInfo(Triple) ,<br>
@@ -2086,17 +2123,21 @@ public:<br>
hasFP64(false),<br>
hasFMAF(false),<br>
hasLDEXPF(false),<br>
- hasFullSpeedFP32Denorms(false){<br>
+ hasFullSpeedFP32Denorms(false),<br>
+ AS(isGenericZero(Triple)){<br>
if (getTriple().getArch() == llvm::Triple::amdgcn) {<br>
hasFP64 = true;<br>
hasFMAF = true;<br>
hasLDEXPF = true;<br>
}<br>
-<br>
+ auto IsGenericZero = isGenericZero(Triple);<br>
resetDataLayout(getTriple().getArch() == llvm::Triple::amdgcn ?<br>
- DataLayoutStringSI : DataLayoutStringR600);<br>
+ (IsGenericZero ? DataLayoutStringSIGenericIsZero :<br>
+ DataLayoutStringSIPrivateIsZero)<br>
+ : DataLayoutStringR600);<br>
<br>
- AddrSpaceMap = &AMDGPUAddrSpaceMap;<br>
+ AddrSpaceMap = IsGenericZero ? &AMDGPUGenericIsZeroMap :<br>
+ &AMDGPUPrivateIsZeroMap;<br>
UseAddrSpaceMapMangling = true;<br>
}<br>
<br>
@@ -2104,14 +2145,10 @@ public:<br>
if (GPU <= GK_CAYMAN)<br>
return 32;<br>
<br>
- switch(AddrSpace) {<br>
- default:<br>
- return 64;<br>
- case 0:<br>
- case 3:<br>
- case 5:<br>
- return 32;<br>
+ if (AddrSpace == AS.Private || AddrSpace == AS.Local) {<br>
+ return 32;<br>
}<br>
+ return 64;<br>
}<br>
<br>
uint64_t getMaxPointerWidth() const override {<br>
@@ -2304,12 +2341,13 @@ public:<br>
/// DWARF.<br>
Optional<unsigned> getDWARFAddressSpace(<br>
unsigned AddressSpace) const override {<br>
- switch (AddressSpace) {<br>
- case 0: // LLVM Private.<br>
- return 1; // DWARF Private.<br>
- case 3: // LLVM Local.<br>
- return 2; // DWARF Local.<br>
- default:<br>
+ const unsigned DWARF_Private = 1;<br>
+ const unsigned DWARF_Local = 2;<br>
+ if (AddressSpace == AS.Private) {<br>
+ return DWARF_Private;<br>
+ } else if (AddressSpace == AS.Local) {<br>
+ return DWARF_Local;<br>
+ } else {<br>
return None;<br>
}<br>
}<br>
@@ -2330,6 +2368,8 @@ public:<br>
uint64_t getNullPointerValue(unsigned AS) const override {<br>
return AS == LangAS::opencl_local ? ~0 : 0;<br>
}<br>
+<br>
+ const AddrSpace AS;<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Is there some reason to have this:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">a) At the end of the class,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">and<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">b) public?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">-eric<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"> };<br>
<br>
const Builtin::Info AMDGPUTargetInfo::BuiltinInfo[] = {<br>
<br>
Added: cfe/trunk/test/CodeGenOpenCL/<a href="http://amdgpu-env-amdgiz.cl" target="_blank">amdgpu-env-amdgiz.cl</a><br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl?rev=298767&view=auto" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl?rev=298767&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenOpenCL/<a href="http://amdgpu-env-amdgiz.cl" target="_blank">amdgpu-env-amdgiz.cl</a> (added)<br>
+++ cfe/trunk/test/CodeGenOpenCL/<a href="http://amdgpu-env-amdgiz.cl" target="_blank">amdgpu-env-amdgiz.cl</a> Fri Mar 24 22:46:25 2017<br>
@@ -0,0 +1,9 @@<br>
+// RUN: %clang_cc1 %s -O0 -triple amdgcn -emit-llvm -o - | FileCheck %s<br>
+// RUN: %clang_cc1 %s -O0 -triple amdgcn---opencl -emit-llvm -o - | FileCheck %s<br>
+// RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgiz -emit-llvm -o - | FileCheck -check-prefix=GIZ %s<br>
+// RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgizcl -emit-llvm -o - | FileCheck -check-prefix=GIZ %s<br>
+<br>
+// CHECK: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"<br>
+// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"<br>
+void foo(void) {}<br>
+<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</body>
</html>