|
29 | 29 | #include "llvm/ADT/SmallSet.h"
|
30 | 30 | #include "llvm/ADT/StringExtras.h"
|
31 | 31 | #include "llvm/IR/Assumptions.h"
|
| 32 | +#include "llvm/IR/Constants.h" |
32 | 33 | #include "llvm/IR/DataLayout.h"
|
33 | 34 | #include "llvm/IR/InlineAsm.h"
|
34 | 35 | #include "llvm/IR/Intrinsics.h"
|
@@ -2399,22 +2400,27 @@ EmitAsmStores(CodeGenFunction &CGF, const AsmStmt &S,
|
2399 | 2400 | // ResultTypeRequiresCast elements correspond to the first
|
2400 | 2401 | // ResultTypeRequiresCast.size() elements of RegResults.
|
2401 | 2402 | if ((i < ResultTypeRequiresCast.size()) && ResultTypeRequiresCast[i]) {
|
2402 |
| - unsigned Size = CGF.getContext().getTypeSize(ResultRegQualTys[i]); |
2403 |
| - Address A = Dest.getAddress(CGF).withElementType(ResultRegTypes[i]); |
2404 |
| - if (CGF.getTargetHooks().isScalarizableAsmOperand(CGF, TruncTy)) { |
2405 |
| - Builder.CreateStore(Tmp, A); |
2406 |
| - continue; |
2407 |
| - } |
| 2403 | + if (ResultRegQualTys[i]->isRVVType() && Tmp->getType()->isStructTy()) { |
| 2404 | + Address A = Dest.getAddress(CGF).withElementType(ResultRegTypes[i]); |
| 2405 | + Dest = CGF.MakeAddrLValue(A, ResultRegQualTys[i]); |
| 2406 | + } else { |
| 2407 | + unsigned Size = CGF.getContext().getTypeSize(ResultRegQualTys[i]); |
| 2408 | + Address A = Dest.getAddress(CGF).withElementType(ResultRegTypes[i]); |
| 2409 | + if (CGF.getTargetHooks().isScalarizableAsmOperand(CGF, TruncTy)) { |
| 2410 | + Builder.CreateStore(Tmp, A); |
| 2411 | + continue; |
| 2412 | + } |
2408 | 2413 |
|
2409 |
| - QualType Ty = |
2410 |
| - CGF.getContext().getIntTypeForBitwidth(Size, /*Signed=*/false); |
2411 |
| - if (Ty.isNull()) { |
2412 |
| - const Expr *OutExpr = S.getOutputExpr(i); |
2413 |
| - CGM.getDiags().Report(OutExpr->getExprLoc(), |
2414 |
| - diag::err_store_value_to_reg); |
2415 |
| - return; |
| 2414 | + QualType Ty = |
| 2415 | + CGF.getContext().getIntTypeForBitwidth(Size, /*Signed=*/false); |
| 2416 | + if (Ty.isNull()) { |
| 2417 | + const Expr *OutExpr = S.getOutputExpr(i); |
| 2418 | + CGM.getDiags().Report(OutExpr->getExprLoc(), |
| 2419 | + diag::err_store_value_to_reg); |
| 2420 | + return; |
| 2421 | + } |
| 2422 | + Dest = CGF.MakeAddrLValue(A, Ty); |
2416 | 2423 | }
|
2417 |
| - Dest = CGF.MakeAddrLValue(A, Ty); |
2418 | 2424 | }
|
2419 | 2425 | CGF.EmitStoreThroughLValue(RValue::get(Tmp), Dest);
|
2420 | 2426 | }
|
@@ -2531,7 +2537,9 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
|
2531 | 2537 | ResultTruncRegTypes.push_back(Ty);
|
2532 | 2538 | ResultTypeRequiresCast.push_back(RequiresCast);
|
2533 | 2539 |
|
2534 |
| - if (RequiresCast) { |
| 2540 | + // Allow RVV tuple type (aggregate of homogeneous scalable vector) to be |
| 2541 | + // pushed into return type of inline asm call. |
| 2542 | + if (RequiresCast && !(QTy->isRVVType() && Ty->isStructTy())) { |
2535 | 2543 | unsigned Size = getContext().getTypeSize(QTy);
|
2536 | 2544 | Ty = llvm::IntegerType::get(getLLVMContext(), Size);
|
2537 | 2545 | }
|
|
0 commit comments