clang 19.0.0git
VE.cpp
Go to the documentation of this file.
1//===- VE.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// VE ABI Implementation.
17//
18namespace {
19class VEABIInfo : public DefaultABIInfo {
20public:
21 VEABIInfo(CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
22
23private:
26 void computeInfo(CGFunctionInfo &FI) const override;
27};
28} // end anonymous namespace
29
30ABIArgInfo VEABIInfo::classifyReturnType(QualType Ty) const {
31 if (Ty->isAnyComplexType())
32 return ABIArgInfo::getDirect();
33 uint64_t Size = getContext().getTypeSize(Ty);
34 if (Size < 64 && Ty->isIntegerType())
35 return ABIArgInfo::getExtend(Ty);
37}
38
39ABIArgInfo VEABIInfo::classifyArgumentType(QualType Ty) const {
40 if (Ty->isAnyComplexType())
41 return ABIArgInfo::getDirect();
42 uint64_t Size = getContext().getTypeSize(Ty);
43 if (Size < 64 && Ty->isIntegerType())
44 return ABIArgInfo::getExtend(Ty);
46}
47
48void VEABIInfo::computeInfo(CGFunctionInfo &FI) const {
50 for (auto &Arg : FI.arguments())
51 Arg.info = classifyArgumentType(Arg.type);
52}
53
54namespace {
55class VETargetCodeGenInfo : public TargetCodeGenInfo {
56public:
57 VETargetCodeGenInfo(CodeGenTypes &CGT)
58 : TargetCodeGenInfo(std::make_unique<VEABIInfo>(CGT)) {}
59 // VE ABI requires the arguments of variadic and prototype-less functions
60 // are passed in both registers and memory.
61 bool isNoProtoCallVariadic(const CallArgList &args,
62 const FunctionNoProtoType *fnType) const override {
63 return true;
64 }
65};
66} // end anonymous namespace
67
68std::unique_ptr<TargetCodeGenInfo>
70 return std::make_unique<VETargetCodeGenInfo>(CGM.getTypes());
71}
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
static ABIArgInfo getDirect(llvm::Type *T=nullptr, unsigned Offset=0, llvm::Type *Padding=nullptr, bool CanBeFlattened=true, unsigned Align=0)
static ABIArgInfo getExtend(QualType Ty, llvm::Type *T=nullptr)
CGFunctionInfo - Class to encapsulate the information about a function definition.
CanQualType getReturnType() const
MutableArrayRef< ArgInfo > arguments()
CallArgList - Type for representing both the value and type of arguments in a call.
Definition: CGCall.h:258
This class organizes the cross-function state that is used while generating LLVM code.
This class organizes the cross-module state that is used while lowering AST types to LLVM types.
Definition: CodeGenTypes.h:54
DefaultABIInfo - The default implementation for ABI specific details.
Definition: ABIInfoImpl.h:21
ABIArgInfo classifyArgumentType(QualType RetTy) const
Definition: ABIInfoImpl.cpp:17
ABIArgInfo classifyReturnType(QualType RetTy) const
Definition: ABIInfoImpl.cpp:45
void computeInfo(CGFunctionInfo &FI) const override
Definition: ABIInfoImpl.cpp:67
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues,...
Definition: TargetInfo.h:46
virtual bool isNoProtoCallVariadic(const CodeGen::CallArgList &args, const FunctionNoProtoType *fnType) const
Determine whether a call to an unprototyped functions under the given calling convention should use t...
Definition: TargetInfo.cpp:86
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition: Type.h:4611
A (possibly-)qualified type.
Definition: Type.h:940
bool isAnyComplexType() const
Definition: Type.h:7714
ABIArgInfo classifyArgumentType(CodeGenModule &CGM, CanQualType type)
Classify the rules for how to pass a particular type.
bool classifyReturnType(const CGCXXABI &CXXABI, CGFunctionInfo &FI, const ABIInfo &Info)
std::unique_ptr< TargetCodeGenInfo > createVETargetCodeGenInfo(CodeGenModule &CGM)
Definition: VE.cpp:69
The JSON file list parser is used to communicate input to InstallAPI.
unsigned long uint64_t
Definition: Format.h:5394