From 7971d91bbf903b894936e663e67e03ffc0c29004 Mon Sep 17 00:00:00 2001 From: Sergei Barannikov Date: Thu, 18 May 2023 04:28:31 +0300 Subject: [PATCH] [clang][CodeGen] Reformat ABIInfo.h (NFC) Preparatory change for D148094. --- clang/lib/CodeGen/ABIInfo.h | 239 ++++++++++++++++++++++---------------------- 1 file changed, 118 insertions(+), 121 deletions(-) diff --git a/clang/lib/CodeGen/ABIInfo.h b/clang/lib/CodeGen/ABIInfo.h index 1dffa41..5ce9eab 100644 --- a/clang/lib/CodeGen/ABIInfo.h +++ b/clang/lib/CodeGen/ABIInfo.h @@ -15,131 +15,128 @@ #include "llvm/IR/Type.h" namespace llvm { - class Value; - class LLVMContext; - class DataLayout; - class Type; -} +class Value; +class LLVMContext; +class DataLayout; +class Type; +} // namespace llvm namespace clang { - class ASTContext; - class CodeGenOptions; - class TargetInfo; +class ASTContext; +class CodeGenOptions; +class TargetInfo; namespace CodeGen { - class ABIArgInfo; - class Address; - class CGCXXABI; - class CGFunctionInfo; - class CodeGenFunction; - class CodeGenTypes; - - // FIXME: All of this stuff should be part of the target interface - // somehow. It is currently here because it is not clear how to factor - // the targets to support this, since the Targets currently live in a - // layer below types n'stuff. - - - /// ABIInfo - Target specific hooks for defining how a type should be - /// passed or returned from functions. - class ABIInfo { - protected: - CodeGen::CodeGenTypes &CGT; - llvm::CallingConv::ID RuntimeCC; - public: - ABIInfo(CodeGen::CodeGenTypes &cgt) - : CGT(cgt), RuntimeCC(llvm::CallingConv::C) {} - - virtual ~ABIInfo(); - - virtual bool allowBFloatArgsAndRet() const { return false; } - - CodeGen::CGCXXABI &getCXXABI() const; - ASTContext &getContext() const; - llvm::LLVMContext &getVMContext() const; - const llvm::DataLayout &getDataLayout() const; - const TargetInfo &getTarget() const; - const CodeGenOptions &getCodeGenOpts() const; - - /// Return the calling convention to use for system runtime - /// functions. - llvm::CallingConv::ID getRuntimeCC() const { - return RuntimeCC; - } - - virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0; - - /// EmitVAArg - Emit the target dependent code to load a value of - /// \arg Ty from the va_list pointed to by \arg VAListAddr. - - // FIXME: This is a gaping layering violation if we wanted to drop - // the ABI information any lower than CodeGen. Of course, for - // VAArg handling it has to be at this level; there is no way to - // abstract this out. - virtual CodeGen::Address EmitVAArg(CodeGen::CodeGenFunction &CGF, +class ABIArgInfo; +class Address; +class CGCXXABI; +class CGFunctionInfo; +class CodeGenFunction; +class CodeGenTypes; + +// FIXME: All of this stuff should be part of the target interface +// somehow. It is currently here because it is not clear how to factor +// the targets to support this, since the Targets currently live in a +// layer below types n'stuff. + +/// ABIInfo - Target specific hooks for defining how a type should be +/// passed or returned from functions. +class ABIInfo { +protected: + CodeGen::CodeGenTypes &CGT; + llvm::CallingConv::ID RuntimeCC; + +public: + ABIInfo(CodeGen::CodeGenTypes &cgt) + : CGT(cgt), RuntimeCC(llvm::CallingConv::C) {} + + virtual ~ABIInfo(); + + virtual bool allowBFloatArgsAndRet() const { return false; } + + CodeGen::CGCXXABI &getCXXABI() const; + ASTContext &getContext() const; + llvm::LLVMContext &getVMContext() const; + const llvm::DataLayout &getDataLayout() const; + const TargetInfo &getTarget() const; + const CodeGenOptions &getCodeGenOpts() const; + + /// Return the calling convention to use for system runtime + /// functions. + llvm::CallingConv::ID getRuntimeCC() const { return RuntimeCC; } + + virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0; + + /// EmitVAArg - Emit the target dependent code to load a value of + /// \arg Ty from the va_list pointed to by \arg VAListAddr. + + // FIXME: This is a gaping layering violation if we wanted to drop + // the ABI information any lower than CodeGen. Of course, for + // VAArg handling it has to be at this level; there is no way to + // abstract this out. + virtual CodeGen::Address EmitVAArg(CodeGen::CodeGenFunction &CGF, + CodeGen::Address VAListAddr, + QualType Ty) const = 0; + + bool isAndroid() const; + bool isOHOSFamily() const; + + /// Emit the target dependent code to load a value of + /// \arg Ty from the \c __builtin_ms_va_list pointed to by \arg VAListAddr. + virtual CodeGen::Address EmitMSVAArg(CodeGen::CodeGenFunction &CGF, CodeGen::Address VAListAddr, - QualType Ty) const = 0; - - bool isAndroid() const; - bool isOHOSFamily() const; - - /// Emit the target dependent code to load a value of - /// \arg Ty from the \c __builtin_ms_va_list pointed to by \arg VAListAddr. - virtual CodeGen::Address EmitMSVAArg(CodeGen::CodeGenFunction &CGF, - CodeGen::Address VAListAddr, - QualType Ty) const; - - virtual bool isHomogeneousAggregateBaseType(QualType Ty) const; - - virtual bool isHomogeneousAggregateSmallEnough(const Type *Base, - uint64_t Members) const; - virtual bool isZeroLengthBitfieldPermittedInHomogeneousAggregate() const; - - bool isHomogeneousAggregate(QualType Ty, const Type *&Base, - uint64_t &Members) const; - - // Implement the Type::IsPromotableIntegerType for ABI specific needs. The - // only difference is that this considers bit-precise integer types as well. - bool isPromotableIntegerTypeForABI(QualType Ty) const; - - /// A convenience method to return an indirect ABIArgInfo with an - /// expected alignment equal to the ABI alignment of the given type. - CodeGen::ABIArgInfo - getNaturalAlignIndirect(QualType Ty, bool ByVal = true, - bool Realign = false, - llvm::Type *Padding = nullptr) const; - - CodeGen::ABIArgInfo - getNaturalAlignIndirectInReg(QualType Ty, bool Realign = false) const; - }; - - /// Target specific hooks for defining how a type should be passed or returned - /// from functions with one of the Swift calling conventions. - class SwiftABIInfo { - protected: - CodeGenTypes &CGT; - bool SwiftErrorInRegister; - - public: - SwiftABIInfo(CodeGen::CodeGenTypes &CGT, bool SwiftErrorInRegister) - : CGT(CGT), SwiftErrorInRegister(SwiftErrorInRegister) {} - - virtual ~SwiftABIInfo(); - - /// Returns true if an aggregate which expands to the given type sequence - /// should be passed / returned indirectly. - virtual bool shouldPassIndirectly(ArrayRef ComponentTys, - bool AsReturnValue) const; - - /// Returns true if the given vector type is legal from Swift's calling - /// convention perspective. - virtual bool isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy, - unsigned NumElts) const; - - /// Returns true if swifterror is lowered to a register by the target ABI. - bool isSwiftErrorInRegister() const { return SwiftErrorInRegister; }; - }; -} // end namespace CodeGen -} // end namespace clang + QualType Ty) const; + + virtual bool isHomogeneousAggregateBaseType(QualType Ty) const; + + virtual bool isHomogeneousAggregateSmallEnough(const Type *Base, + uint64_t Members) const; + virtual bool isZeroLengthBitfieldPermittedInHomogeneousAggregate() const; + + bool isHomogeneousAggregate(QualType Ty, const Type *&Base, + uint64_t &Members) const; + + // Implement the Type::IsPromotableIntegerType for ABI specific needs. The + // only difference is that this considers bit-precise integer types as well. + bool isPromotableIntegerTypeForABI(QualType Ty) const; + + /// A convenience method to return an indirect ABIArgInfo with an + /// expected alignment equal to the ABI alignment of the given type. + CodeGen::ABIArgInfo + getNaturalAlignIndirect(QualType Ty, bool ByVal = true, bool Realign = false, + llvm::Type *Padding = nullptr) const; + + CodeGen::ABIArgInfo getNaturalAlignIndirectInReg(QualType Ty, + bool Realign = false) const; +}; + +/// Target specific hooks for defining how a type should be passed or returned +/// from functions with one of the Swift calling conventions. +class SwiftABIInfo { +protected: + CodeGenTypes &CGT; + bool SwiftErrorInRegister; + +public: + SwiftABIInfo(CodeGen::CodeGenTypes &CGT, bool SwiftErrorInRegister) + : CGT(CGT), SwiftErrorInRegister(SwiftErrorInRegister) {} + + virtual ~SwiftABIInfo(); + + /// Returns true if an aggregate which expands to the given type sequence + /// should be passed / returned indirectly. + virtual bool shouldPassIndirectly(ArrayRef ComponentTys, + bool AsReturnValue) const; + + /// Returns true if the given vector type is legal from Swift's calling + /// convention perspective. + virtual bool isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy, + unsigned NumElts) const; + + /// Returns true if swifterror is lowered to a register by the target ABI. + bool isSwiftErrorInRegister() const { return SwiftErrorInRegister; }; +}; +} // end namespace CodeGen +} // end namespace clang #endif -- 2.7.4