Path: blob/main/contrib/llvm-project/clang/lib/CIR/CodeGen/TargetInfo.h
213799 views
//===---- TargetInfo.h - Encapsulate target details -------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// These classes wrap the information about a call or function definition used9// to handle ABI compliancy.10//11//===----------------------------------------------------------------------===//1213#ifndef LLVM_CLANG_LIB_CIR_TARGETINFO_H14#define LLVM_CLANG_LIB_CIR_TARGETINFO_H1516#include "ABIInfo.h"17#include "CIRGenTypes.h"1819#include <memory>20#include <utility>2122namespace clang::CIRGen {2324/// isEmptyFieldForLayout - Return true if the field is "empty", that is,25/// either a zero-width bit-field or an isEmptyRecordForLayout.26bool isEmptyFieldForLayout(const ASTContext &context, const FieldDecl *fd);2728/// isEmptyRecordForLayout - Return true if a structure contains only empty29/// base classes (per isEmptyRecordForLayout) and fields (per30/// isEmptyFieldForLayout). Note, C++ record fields are considered empty31/// if the [[no_unique_address]] attribute would have made them empty.32bool isEmptyRecordForLayout(const ASTContext &context, QualType t);3334class TargetCIRGenInfo {35std::unique_ptr<ABIInfo> info;3637public:38TargetCIRGenInfo(std::unique_ptr<ABIInfo> info) : info(std::move(info)) {}3940virtual ~TargetCIRGenInfo() = default;4142/// Returns ABI info helper for the target.43const ABIInfo &getABIInfo() const { return *info; }4445/// Determine whether a call to an unprototyped functions under46/// the given calling convention should use the variadic47/// convention or the non-variadic convention.48///49/// There's a good reason to make a platform's variadic calling50/// convention be different from its non-variadic calling51/// convention: the non-variadic arguments can be passed in52/// registers (better for performance), and the variadic arguments53/// can be passed on the stack (also better for performance). If54/// this is done, however, unprototyped functions *must* use the55/// non-variadic convention, because C99 states that a call56/// through an unprototyped function type must succeed if the57/// function was defined with a non-variadic prototype with58/// compatible parameters. Therefore, splitting the conventions59/// makes it impossible to call a variadic function through an60/// unprototyped type. Since function prototypes came out in the61/// late 1970s, this is probably an acceptable trade-off.62/// Nonetheless, not all platforms are willing to make it, and in63/// particularly x86-64 bends over backwards to make the64/// conventions compatible.65///66/// The default is false. This is correct whenever:67/// - the conventions are exactly the same, because it does not68/// matter and the resulting IR will be somewhat prettier in69/// certain cases; or70/// - the conventions are substantively different in how they pass71/// arguments, because in this case using the variadic convention72/// will lead to C99 violations.73///74/// However, some platforms make the conventions identical except75/// for passing additional out-of-band information to a variadic76/// function: for example, x86-64 passes the number of SSE77/// arguments in %al. On these platforms, it is desirable to78/// call unprototyped functions using the variadic convention so79/// that unprototyped calls to varargs functions still succeed.80///81/// Relatedly, platforms which pass the fixed arguments to this:82/// A foo(B, C, D);83/// differently than they would pass them to this:84/// A foo(B, C, D, ...);85/// may need to adjust the debugger-support code in Sema to do the86/// right thing when calling a function with no know signature.87virtual bool isNoProtoCallVariadic(const FunctionNoProtoType *fnType) const;88};8990std::unique_ptr<TargetCIRGenInfo> createX8664TargetCIRGenInfo(CIRGenTypes &cgt);9192} // namespace clang::CIRGen9394#endif // LLVM_CLANG_LIB_CIR_TARGETINFO_H959697