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 {
4197
4197
ABIArgInfo NVPTXABIInfo::classifyReturnType (QualType RetTy) const {
4198
4198
if (RetTy->isVoidType ())
4199
4199
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 ());
4203
4211
}
4204
4212
4205
4213
ABIArgInfo 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 ();
4208
4217
4209
- return ABIArgInfo::getDirect ();
4218
+ return (Ty->isPromotableIntegerType () ?
4219
+ ABIArgInfo::getExtend () : ABIArgInfo::getDirect ());
4210
4220
}
4211
4221
4212
4222
void 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