r195268 - [NVPTX] Update ABI handling

Justin Holewinski justin.holewinski at gmail.com
Thu Nov 21 08:44:21 PST 2013


Hi Bill, can you please pull this into the 3.4 branch?  This fixes an issue
with struct arguments/returns.


On Wed, Nov 20, 2013 at 3:35 PM, Justin Holewinski
<jholewinski at nvidia.com>wrote:

> Author: jholewinski
> Date: Wed Nov 20 14:35:34 2013
> New Revision: 195268
>
> URL: http://llvm.org/viewvc/llvm-project?rev=195268&view=rev
> Log:
> [NVPTX] Update ABI handling
>
> For PTX, we want the target to handle struct returns directly.
>
> Added:
>     cfe/trunk/test/CodeGen/nvptx-abi.c
> Modified:
>     cfe/trunk/lib/CodeGen/TargetInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=195268&r1=195267&r2=195268&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Nov 20 14:35:34 2013
> @@ -4197,16 +4197,26 @@ private:
>  ABIArgInfo NVPTXABIInfo::classifyReturnType(QualType RetTy) const {
>    if (RetTy->isVoidType())
>      return ABIArgInfo::getIgnore();
> -  if (isAggregateTypeForABI(RetTy))
> -    return ABIArgInfo::getIndirect(0);
> -  return ABIArgInfo::getDirect();
> +
> +  // note: this is different from default ABI
> +  if (!RetTy->isScalarType())
> +    return ABIArgInfo::getDirect();
> +
> +  // Treat an enum type as its underlying type.
> +  if (const EnumType *EnumTy = RetTy->getAs<EnumType>())
> +    RetTy = EnumTy->getDecl()->getIntegerType();
> +
> +  return (RetTy->isPromotableIntegerType() ?
> +          ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
>  }
>
>  ABIArgInfo NVPTXABIInfo::classifyArgumentType(QualType Ty) const {
> -  if (isAggregateTypeForABI(Ty))
> -    return ABIArgInfo::getIndirect(0);
> +  // Treat an enum type as its underlying type.
> +  if (const EnumType *EnumTy = Ty->getAs<EnumType>())
> +    Ty = EnumTy->getDecl()->getIntegerType();
>
> -  return ABIArgInfo::getDirect();
> +  return (Ty->isPromotableIntegerType() ?
> +          ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
>  }
>
>  void NVPTXABIInfo::computeInfo(CGFunctionInfo &FI) const {
>
> Added: cfe/trunk/test/CodeGen/nvptx-abi.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/nvptx-abi.c?rev=195268&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/CodeGen/nvptx-abi.c (added)
> +++ cfe/trunk/test/CodeGen/nvptx-abi.c Wed Nov 20 14:35:34 2013
> @@ -0,0 +1,17 @@
> +// RUN: %clang_cc1 -triple nvptx-unknown-unknown -S -o - %s -emit-llvm |
> FileCheck %s
> +// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -S -o - %s -emit-llvm
> | FileCheck %s
> +
> +typedef struct float4_s {
> +  float x, y, z, w;
> +} float4_t;
> +
> +float4_t my_function(void);
> +
> +// CHECK-DAG: declare %struct.float4_s @my_function
> +
> +float bar(void) {
> +  float4_t ret;
> +// CHECK-DAG: call %struct.float4_s @my_function
> +  ret = my_function();
> +  return ret.x;
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



-- 

Thanks,

Justin Holewinski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131121/822e1e89/attachment.html>


More information about the cfe-commits mailing list