clang 20.0.0git
WebAssembly.cpp
Go to the documentation of this file.
1//===- WebAssembly.cpp ----------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "ABIInfoImpl.h"
10#include "TargetInfo.h"
11
12using namespace clang;
13using namespace clang::CodeGen;
14
15//===----------------------------------------------------------------------===//
16// WebAssembly ABI Implementation
17//
18// This is a very simple ABI that relies a lot on DefaultABIInfo.
19//===----------------------------------------------------------------------===//
20
21class WebAssemblyABIInfo final : public ABIInfo {
22 DefaultABIInfo defaultInfo;
24
25public:
28 : ABIInfo(CGT), defaultInfo(CGT), Kind(Kind) {}
29
30private:
31 ABIArgInfo classifyReturnType(QualType RetTy) const;
32 ABIArgInfo classifyArgumentType(QualType Ty) const;
33
34 // DefaultABIInfo's classifyReturnType and classifyArgumentType are
35 // non-virtual, but computeInfo and EmitVAArg are virtual, so we
36 // overload them.
37 void computeInfo(CGFunctionInfo &FI) const override {
38 if (!getCXXABI().classifyReturnType(FI))
39 FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
40 for (auto &Arg : FI.arguments())
41 Arg.info = classifyArgumentType(Arg.type);
42 }
43
44 RValue EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
45 AggValueSlot Slot) const override;
46};
47
49public:
50 explicit