Coverage Report

Created: 2024-01-17 10:31

/src/llvm-project/clang/lib/CodeGen/Targets/VE.cpp
Line
Count
Source (jump to first uncovered line)
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
0
  VEABIInfo(CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
22
23
private:
24
  ABIArgInfo classifyReturnType(QualType RetTy) const;
25
  ABIArgInfo classifyArgumentType(QualType RetTy) const;
26
  void computeInfo(CGFunctionInfo &FI) const override;
27
};
28
} // end anonymous namespace
29
30
0
ABIArgInfo VEABIInfo::classifyReturnType(QualType Ty) const {
31
0
  if (Ty->isAnyComplexType())
32
0
    return ABIArgInfo::getDirect();
33
0
  uint64_t Size = getContext().getTypeSize(Ty);
34
0
  if (Size < 64 && Ty->isIntegerType())
35
0
    return ABIArgInfo::getExtend(Ty);
36
0
  return DefaultABIInfo::classifyReturnType(Ty);
37
0
}
38
39
0
ABIArgInfo VEABIInfo::classifyArgumentType(QualType Ty) const {
40
0
  if (Ty->isAnyComplexType())
41
0
    return ABIArgInfo::getDirect();
42
0
  uint64_t Size = getContext().getTypeSize(Ty);
43
0
  if (Size < 64 && Ty->isIntegerType())
44
0
    return ABIArgInfo::getExtend(Ty);
45
0
  return DefaultABIInfo::classifyArgumentType(Ty);
46
0
}
47
48
0
void VEABIInfo::computeInfo(CGFunctionInfo &FI) const {
49
0
  FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
50
0
  for (auto &Arg : FI.arguments())
51
0
    Arg.info = classifyArgumentType(Arg.type);
52
0
}
53
54
namespace {
55
class VETargetCodeGenInfo : public TargetCodeGenInfo {
56
public:
57
  VETargetCodeGenInfo(CodeGenTypes &CGT)
58
0
      : 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
0
                             const FunctionNoProtoType *fnType) const override {
63
0
    return true;
64
0
  }
65
};
66
} // end anonymous namespace
67
68
std::unique_ptr<TargetCodeGenInfo>
69
0
CodeGen::createVETargetCodeGenInfo(CodeGenModule &CGM) {
70
0
  return std::make_unique<VETargetCodeGenInfo>(CGM.getTypes());
71
0
}