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 
12 using namespace clang;
13 using namespace clang::CodeGen;
14 
15 //===----------------------------------------------------------------------===//
16 // VE ABI Implementation.
17 //
18 namespace {
19 class VEABIInfo : public DefaultABIInfo {
20 public:
21  VEABIInfo(CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
22 
23 private:
26  void computeInfo(CGFunctionInfo &FI) const override;
27 };
28 } // end anonymous namespace
29 
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 
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 
48 void VEABIInfo::computeInfo(CGFunctionInfo &FI) const {
50  for (auto &Arg : FI.arguments())
51  Arg.info = classifyArgumentType(Arg.type);
52 }
53 
54 namespace {
55 class VETargetCodeGenInfo : public TargetCodeGenInfo {
56 public:
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 
68 std::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:257
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
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues,...
Definition: TargetInfo.h:46
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition: Type.h:4623
A (possibly-)qualified type.
Definition: Type.h:940
bool isAnyComplexType() const
Definition: Type.h:7726
ABIArgInfo classifyReturnType(CodeGenModule &CGM, CanQualType type)
Classify the rules for how to return a particular type.
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:5433