File tree Expand file tree Collapse file tree 2 files changed +33
-6
lines changed Expand file tree Collapse file tree 2 files changed +33
-6
lines changed Original file line number Diff line number Diff line change @@ -4197,16 +4197,26 @@ class NVPTXTargetCodeGenInfo : public TargetCodeGenInfo {
41974197ABIArgInfo NVPTXABIInfo::classifyReturnType (QualType RetTy) const {
41984198 if (RetTy->isVoidType ())
41994199 return ABIArgInfo::getIgnore ();
4200- if (isAggregateTypeForABI (RetTy))
4201- return ABIArgInfo::getIndirect (0 );
4202- return ABIArgInfo::getDirect ();
4200+
4201+ // note: this is different from default ABI
4202+ if (!RetTy->isScalarType ())
4203+ return ABIArgInfo::getDirect ();
4204+
4205+ // Treat an enum type as its underlying type.
4206+ if (const EnumType *EnumTy = RetTy->getAs <EnumType>())
4207+ RetTy = EnumTy->getDecl ()->getIntegerType ();
4208+
4209+ return (RetTy->isPromotableIntegerType () ?
4210+ ABIArgInfo::getExtend () : ABIArgInfo::getDirect ());
42034211}
42044212
42054213ABIArgInfo NVPTXABIInfo::classifyArgumentType (QualType Ty) const {
4206- if (isAggregateTypeForABI (Ty))
4207- return ABIArgInfo::getIndirect (0 );
4214+ // Treat an enum type as its underlying type.
4215+ if (const EnumType *EnumTy = Ty->getAs <EnumType>())
4216+ Ty = EnumTy->getDecl ()->getIntegerType ();
42084217
4209- return ABIArgInfo::getDirect ();
4218+ return (Ty->isPromotableIntegerType () ?
4219+ ABIArgInfo::getExtend () : ABIArgInfo::getDirect ());
42104220}
42114221
42124222void NVPTXABIInfo::computeInfo (CGFunctionInfo &FI) const {
Original file line number Diff line number Diff line change 1+ // RUN: %clang_cc1 -triple nvptx-unknown-unknown -S -o - %s -emit-llvm | FileCheck %s
2+ // RUN: %clang_cc1 -triple nvptx64-unknown-unknown -S -o - %s -emit-llvm | FileCheck %s
3+
4+ typedef struct float4_s {
5+ float x , y , z , w ;
6+ } float4_t ;
7+
8+ float4_t my_function (void );
9+
10+ // CHECK-DAG: declare %struct.float4_s @my_function
11+
12+ float bar (void ) {
13+ float4_t ret ;
14+ // CHECK-DAG: call %struct.float4_s @my_function
15+ ret = my_function ();
16+ return ret .x ;
17+ }
You can’t perform that action at this time.
0 commit comments