1#include "TargetInfo.h"
2#include "ABIInfo.h"
3
4using namespace clang;
5using namespace clang::CIRGen;
6
7bool clang::CIRGen::isEmptyRecordForLayout(const ASTContext &context,
8 QualType t) {
9 const RecordType *rt = t->getAs<RecordType>();
10 if (!rt)
11 return false;
12
13 const RecordDecl *rd = rt->getDecl();
14
15 // If this is a C++ record, check the bases first.
16 if (const CXXRecordDecl *cxxrd = dyn_cast<CXXRecordDecl>(Val: rd)) {
17 if (cxxrd->isDynamicClass())
18 return false;
19
20 for (const auto &I : cxxrd->bases())
21 if (!isEmptyRecordForLayout(context, t: I.getType()))
22 return false;
23 }
24
25 for (const auto *I : rd->fields())
26 if (!isEmptyFieldForLayout(context, fd: I))
27 return false;
28
29 return true;
30}
31
32bool clang::CIRGen::isEmptyFieldForLayout(const ASTContext &context,
33 const FieldDecl *fd) {
34 if (fd->isZeroLengthBitField())
35 return true;
36
37 if (fd->isUnnamedBitField())
38 return false;
39
40 return isEmptyRecordForLayout(context, t: fd->getType());
41}
42
43namespace {
44
45class X8664ABIInfo : public ABIInfo {
46public:
47 X8664ABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {}
48};
49
50class X8664TargetCIRGenInfo : public TargetCIRGenInfo {
51public:
52 X8664TargetCIRGenInfo(CIRGenTypes &cgt)
53 : TargetCIRGenInfo(std::make_unique<X8664ABIInfo>(args&: cgt)) {}
54};
55
56} // namespace
57
58std::unique_ptr<TargetCIRGenInfo>
59clang::CIRGen::createX8664TargetCIRGenInfo(CIRGenTypes &cgt) {
60 return std::make_unique<X8664TargetCIRGenInfo>(args&: cgt);
61}
62
63ABIInfo::~ABIInfo() noexcept = default;
64
65bool TargetCIRGenInfo::isNoProtoCallVariadic(
66 const FunctionNoProtoType *fnType) const {
67 // The following conventions are known to require this to be false:
68 // x86_stdcall
69 // MIPS
70 // For everything else, we just prefer false unless we opt out.
71 return false;
72}
73

source code of clang/lib/CIR/CodeGen/TargetInfo.cpp