Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 1cf0412

Browse files
committed
[Swift+WASM] Adopt SwiftABIInfo for WebAssembly.
1 parent 95cdf7c commit 1cf0412

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lib/CodeGen/TargetInfo.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -720,10 +720,12 @@ ABIArgInfo DefaultABIInfo::classifyReturnType(QualType RetTy) const {
720720
// This is a very simple ABI that relies a lot on DefaultABIInfo.
721721
//===----------------------------------------------------------------------===//
722722

723-
class WebAssemblyABIInfo final : public DefaultABIInfo {
723+
class WebAssemblyABIInfo final : public SwiftABIInfo {
724+
DefaultABIInfo defaultInfo;
725+
724726
public:
725727
explicit WebAssemblyABIInfo(CodeGen::CodeGenTypes &CGT)
726-
: DefaultABIInfo(CGT) {}
728+
: SwiftABIInfo(CGT), defaultInfo(CGT) {}
727729

728730
private:
729731
ABIArgInfo classifyReturnType(QualType RetTy) const;
@@ -741,6 +743,15 @@ class WebAssemblyABIInfo final : public DefaultABIInfo {
741743

742744
Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
743745
QualType Ty) const override;
746+
747+
bool shouldPassIndirectlyForSwift(ArrayRef<llvm::Type*> scalars,
748+
bool asReturnValue) const override {
749+
return occupiesMoreThan(CGT, scalars, /*total*/ 4);
750+
}
751+
752+
bool isSwiftErrorInRegister() const override {
753+
return false;
754+
}
744755
};
745756

746757
class WebAssemblyTargetCodeGenInfo final : public TargetCodeGenInfo {
@@ -778,7 +789,7 @@ ABIArgInfo WebAssemblyABIInfo::classifyArgumentType(QualType Ty) const {
778789
}
779790

780791
// Otherwise just do the default thing.
781-
return DefaultABIInfo::classifyArgumentType(Ty);
792+
return defaultInfo.classifyArgumentType(Ty);
782793
}
783794

784795
ABIArgInfo WebAssemblyABIInfo::classifyReturnType(QualType RetTy) const {
@@ -798,7 +809,7 @@ ABIArgInfo WebAssemblyABIInfo::classifyReturnType(QualType RetTy) const {
798809
}
799810

800811
// Otherwise just do the default thing.
801-
return DefaultABIInfo::classifyReturnType(RetTy);
812+
return defaultInfo.classifyReturnType(RetTy);
802813
}
803814

804815
Address WebAssemblyABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,

0 commit comments

Comments
 (0)