|
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"
|
@@ -2487,22 +2488,28 @@ EmitAsmStores(CodeGenFunction &CGF, const AsmStmt &S,
|
2487 | 2488 | // ResultTypeRequiresCast elements correspond to the first
|
2488 | 2489 | // ResultTypeRequiresCast.size() elements of RegResults.
|
2489 | 2490 | if ((i < ResultTypeRequiresCast.size()) && ResultTypeRequiresCast[i]) {
|
2490 |
| - unsigned Size = CGF.getContext().getTypeSize(ResultRegQualTys[i]); |
2491 |
| - Address A = Dest.getAddress(CGF).withElementType(ResultRegTypes[i]); |
2492 |
| - if (CGF.getTargetHooks().isScalarizableAsmOperand(CGF, TruncTy)) { |
2493 |
| - Builder.CreateStore(Tmp, A); |
2494 |
| - continue; |
2495 |
| - } |
| 2491 | + if (ResultRegQualTys[i]->isRVVSizelessBuiltinType() && |
| 2492 | + Tmp->getType()->isStructTy()) { |
| 2493 | + Address A = Dest.getAddress(CGF).withElementType(ResultRegTypes[i]); |
| 2494 | + Dest = CGF.MakeAddrLValue(A, ResultRegQualTys[i]); |
| 2495 | + } else { |
| 2496 | + unsigned Size = CGF.getContext().getTypeSize(ResultRegQualTys[i]); |
| 2497 | + Address A = Dest.getAddress(CGF).withElementType(ResultRegTypes[i]); |
| 2498 | + if (CGF.getTargetHooks().isScalarizableAsmOperand(CGF, TruncTy)) { |
| 2499 | + Builder.CreateStore(Tmp, A); |
| 2500 | + continue; |
| 2501 | + } |
2496 | 2502 |
|
2497 |
| - QualType Ty = |
2498 |
| - CGF.getContext().getIntTypeForBitwidth(Size, /*Signed=*/false); |
2499 |
| - if (Ty.isNull()) { |
2500 |
| - const Expr *OutExpr = S.getOutputExpr(i); |
2501 |
| - CGM.getDiags().Report(OutExpr->getExprLoc(), |
2502 |
| - diag::err_store_value_to_reg); |
2503 |
| - return; |
| 2503 | + QualType Ty = |
| 2504 | + CGF.getContext().getIntTypeForBitwidth(Size, /*Signed=*/false); |
| 2505 | + if (Ty.isNull()) { |
| 2506 | + const Expr *OutExpr = S.getOutputExpr(i); |
| 2507 | + CGM.getDiags().Report(OutExpr->getExprLoc(), |
| 2508 | + diag::err_store_value_to_reg); |
| 2509 | + return; |
| 2510 | + } |
| 2511 | + Dest = CGF.MakeAddrLValue(A, Ty); |
2504 | 2512 | }
|
2505 |
| - Dest = CGF.MakeAddrLValue(A, Ty); |
2506 | 2513 | }
|
2507 | 2514 | CGF.EmitStoreThroughLValue(RValue::get(Tmp), Dest);
|
2508 | 2515 | }
|
@@ -2648,7 +2655,10 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
|
2648 | 2655 | ResultTruncRegTypes.push_back(Ty);
|
2649 | 2656 | ResultTypeRequiresCast.push_back(RequiresCast);
|
2650 | 2657 |
|
2651 |
| - if (RequiresCast) { |
| 2658 | + // Allow RVV tuple type (aggregate of homogeneous scalable vector) to be |
| 2659 | + // pushed into return type of inline asm call. |
| 2660 | + if (RequiresCast && |
| 2661 | + !(QTy->isRVVSizelessBuiltinType() && Ty->isStructTy())) { |
2652 | 2662 | unsigned Size = getContext().getTypeSize(QTy);
|
2653 | 2663 | Ty = llvm::IntegerType::get(getLLVMContext(), Size);
|
2654 | 2664 | }
|
|
0 commit comments