Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/clang/lib/CIR/CodeGen/TargetInfo.cpp
213799 views
1
#include "TargetInfo.h"
2
#include "ABIInfo.h"
3
4
using namespace clang;
5
using namespace clang::CIRGen;
6
7
bool 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>(rd)) {
17
if (cxxrd->isDynamicClass())
18
return false;
19
20
for (const auto &I : cxxrd->bases())
21
if (!isEmptyRecordForLayout(context, I.getType()))
22
return false;
23
}
24
25
for (const auto *I : rd->fields())
26
if (!isEmptyFieldForLayout(context, I))
27
return false;
28
29
return true;
30
}
31
32
bool 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, fd->getType());
41
}
42
43
namespace {
44
45
class X8664ABIInfo : public ABIInfo {
46
public:
47
X8664ABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {}
48
};
49
50
class X8664TargetCIRGenInfo : public TargetCIRGenInfo {
51
public:
52
X8664TargetCIRGenInfo(CIRGenTypes &cgt)
53
: TargetCIRGenInfo(std::make_unique<X8664ABIInfo>(cgt)) {}
54
};
55
56
} // namespace
57
58
std::unique_ptr<TargetCIRGenInfo>
59
clang::CIRGen::createX8664TargetCIRGenInfo(CIRGenTypes &cgt) {
60
return std::make_unique<X8664TargetCIRGenInfo>(cgt);
61
}
62
63
ABIInfo::~ABIInfo() noexcept = default;
64
65
bool 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
74