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

[Swift+WASM] Adopt SwiftABIInfo for WebAssembly. #235

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions lib/CodeGen/TargetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,10 +720,12 @@ ABIArgInfo DefaultABIInfo::classifyReturnType(QualType RetTy) const {
// This is a very simple ABI that relies a lot on DefaultABIInfo.
//===----------------------------------------------------------------------===//

class WebAssemblyABIInfo final : public DefaultABIInfo {
class WebAssemblyABIInfo final : public SwiftABIInfo {
DefaultABIInfo defaultInfo;

public:
explicit WebAssemblyABIInfo(CodeGen::CodeGenTypes &CGT)
: DefaultABIInfo(CGT) {}
: SwiftABIInfo(CGT), defaultInfo(CGT) {}

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

Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
QualType Ty) const override;

bool shouldPassIndirectlyForSwift(ArrayRef<llvm::Type*> scalars,
bool asReturnValue) const override {
return occupiesMoreThan(CGT, scalars, /*total*/ 4);
}

bool isSwiftErrorInRegister() const override {
return false;
}
};

class WebAssemblyTargetCodeGenInfo final : public TargetCodeGenInfo {
Expand Down Expand Up @@ -778,7 +789,7 @@ ABIArgInfo WebAssemblyABIInfo::classifyArgumentType(QualType Ty) const {
}

// Otherwise just do the default thing.
return DefaultABIInfo::classifyArgumentType(Ty);
return defaultInfo.classifyArgumentType(Ty);
}

ABIArgInfo WebAssemblyABIInfo::classifyReturnType(QualType RetTy) const {
Expand All @@ -798,7 +809,7 @@ ABIArgInfo WebAssemblyABIInfo::classifyReturnType(QualType RetTy) const {
}

// Otherwise just do the default thing.
return DefaultABIInfo::classifyReturnType(RetTy);
return defaultInfo.classifyReturnType(RetTy);
}

Address WebAssemblyABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
Expand Down