<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Sure. Done.<div><br></div><div>-bw</div><div><br><div style=""><div>On Nov 21, 2013, at 8:44 AM, Justin Holewinski <<a href="mailto:justin.holewinski@gmail.com">justin.holewinski@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Hi Bill, can you please pull this into the 3.4 branch? This fixes an issue with struct arguments/returns.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Nov 20, 2013 at 3:35 PM, Justin Holewinski <span dir="ltr"><<a href="mailto:jholewinski@nvidia.com" target="_blank">jholewinski@nvidia.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: jholewinski<br>
Date: Wed Nov 20 14:35:34 2013<br>
New Revision: 195268<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=195268&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=195268&view=rev</a><br>
Log:<br>
[NVPTX] Update ABI handling<br>
<br>
For PTX, we want the target to handle struct returns directly.<br>
<br>
Added:<br>
cfe/trunk/test/CodeGen/nvptx-abi.c<br>
Modified:<br>
cfe/trunk/lib/CodeGen/TargetInfo.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=195268&r1=195267&r2=195268&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=195268&r1=195267&r2=195268&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Nov 20 14:35:34 2013<br>
@@ -4197,16 +4197,26 @@ private:<br>
ABIArgInfo NVPTXABIInfo::classifyReturnType(QualType RetTy) const {<br>
if (RetTy->isVoidType())<br>
return ABIArgInfo::getIgnore();<br>
- if (isAggregateTypeForABI(RetTy))<br>
- return ABIArgInfo::getIndirect(0);<br>
- return ABIArgInfo::getDirect();<br>
+<br>
+ // note: this is different from default ABI<br>
+ if (!RetTy->isScalarType())<br>
+ return ABIArgInfo::getDirect();<br>
+<br>
+ // Treat an enum type as its underlying type.<br>
+ if (const EnumType *EnumTy = RetTy->getAs<EnumType>())<br>
+ RetTy = EnumTy->getDecl()->getIntegerType();<br>
+<br>
+ return (RetTy->isPromotableIntegerType() ?<br>
+ ABIArgInfo::getExtend() : ABIArgInfo::getDirect());<br>
}<br>
<br>
ABIArgInfo NVPTXABIInfo::classifyArgumentType(QualType Ty) const {<br>
- if (isAggregateTypeForABI(Ty))<br>
- return ABIArgInfo::getIndirect(0);<br>
+ // Treat an enum type as its underlying type.<br>
+ if (const EnumType *EnumTy = Ty->getAs<EnumType>())<br>
+ Ty = EnumTy->getDecl()->getIntegerType();<br>
<br>
- return ABIArgInfo::getDirect();<br>
+ return (Ty->isPromotableIntegerType() ?<br>
+ ABIArgInfo::getExtend() : ABIArgInfo::getDirect());<br>
}<br>
<br>
void NVPTXABIInfo::computeInfo(CGFunctionInfo &FI) const {<br>
<br>
Added: cfe/trunk/test/CodeGen/nvptx-abi.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/nvptx-abi.c?rev=195268&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/nvptx-abi.c?rev=195268&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGen/nvptx-abi.c (added)<br>
+++ cfe/trunk/test/CodeGen/nvptx-abi.c Wed Nov 20 14:35:34 2013<br>
@@ -0,0 +1,17 @@<br>
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -S -o - %s -emit-llvm | FileCheck %s<br>
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -S -o - %s -emit-llvm | FileCheck %s<br>
+<br>
+typedef struct float4_s {<br>
+ float x, y, z, w;<br>
+} float4_t;<br>
+<br>
+float4_t my_function(void);<br>
+<br>
+// CHECK-DAG: declare %struct.float4_s @my_function<br>
+<br>
+float bar(void) {<br>
+ float4_t ret;<br>
+// CHECK-DAG: call %struct.float4_s @my_function<br>
+ ret = my_function();<br>
+ return ret.x;<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><br><div>Thanks,</div><div><br></div><div>Justin Holewinski</div>
</div>
</blockquote></div><br></div></body></html>