================ @@ -0,0 +1,172 @@ +//===----- ABIFunctionInfo.h - ABI Function Information ----- C++ ---------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Defines ABIFunctionInfo and associated types used in representing the +// ABI-coerced types for function arguments and return values. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ABI_ABIFUNCTIONINFO_H +#define LLVM_ABI_ABIFUNCTIONINFO_H + +#include "ABIInfo.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/FoldingSet.h" +#include "llvm/IR/CallingConv.h" +#include "llvm/Support/TrailingObjects.h" + +namespace llvm { +namespace abi { + +struct FunctionABIInfo { + llvm::CallingConv::ID CC = llvm::CallingConv::C; + llvm::CallingConv::ID EffectiveCC = llvm::CallingConv::C; + + // Core ABI attributes + bool NoReturn = false; + bool NoUnwind = false; + bool HasSRet = false; + bool IsVariadic = false; + bool IsInstanceMethod = false; + // Are these ABI Relavent(?) + bool IsChainCall = false; + bool IsDelegateCall = false; + + // Register usage controls + bool HasRegParm = false; + unsigned RegParm = 0; + bool NoCallerSavedRegs = false; + // Security/extensions(are they ABI related?) + bool NoCfCheck = false; + bool CmseNSCall = false; + + // Optimization hints + bool ReturnsRetained = false; + unsigned MaxVectorWidth = 0; + + FunctionABIInfo() = default; + FunctionABIInfo(llvm::CallingConv::ID CC) : CC(CC), EffectiveCC(CC) {} +}; + +// Not an Immediate requirement for BPF +struct RequiredArgs { +private: + unsigned NumRequired; + static constexpr unsigned All = ~0U; + +public: + RequiredArgs() : NumRequired(All) {} + explicit RequiredArgs(unsigned N) : NumRequired(N) {} + + static RequiredArgs forPrototypedFunction(unsigned NumArgs) { + return RequiredArgs(NumArgs); + } + + static RequiredArgs forVariadicFunction(unsigned NumRequired) { + return RequiredArgs(NumRequired); + } + + bool allowsOptionalArgs() const { return NumRequired != All; } + + unsigned getNumRequiredArgs() const { + return allowsOptionalArgs() ? NumRequired : 0; + } + + bool operator==(const RequiredArgs &Other) const { + return NumRequired == Other.NumRequired; + } +}; + +// Implementation detail of ABIFunctionInfo, factored out so it can be named +// in the TrailingObjects base class of ABIFunctionInfo. +struct ABIFunctionInfoArgInfo { + const Type *ABIType; + ABIArgInfo ArgInfo; + + ABIFunctionInfoArgInfo() + : ABIType(nullptr), ArgInfo(ABIArgInfo::getDirect()) {} + ABIFunctionInfoArgInfo(Type *T) + : ABIType(T), ArgInfo(ABIArgInfo::getDirect()) {} + ABIFunctionInfoArgInfo(Type *T, ABIArgInfo A) : ABIType(T), ArgInfo(A) {} +}; + +class ABIFunctionInfo final ---------------- nikic wrote:
Having both FunctionABIInfo and ABIFunctionInfo is pretty confusing... do these need to be separate? https://github.com/llvm/llvm-project/pull/140112 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits