clang  17.0.0git
ABIInfo.h
Go to the documentation of this file.
1 //===----- ABIInfo.h - ABI information access & encapsulation ---*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
10 #define LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
11 
12 #include "clang/AST/CharUnits.h"
13 #include "clang/AST/Type.h"
14 #include "llvm/IR/CallingConv.h"
15 #include "llvm/IR/Type.h"
16 
17 namespace llvm {
18  class Value;
19  class LLVMContext;
20  class DataLayout;
21  class Type;
22 }
23 
24 namespace clang {
25  class ASTContext;
26  class CodeGenOptions;
27  class TargetInfo;
28 
29 namespace CodeGen {
30  class ABIArgInfo;
31  class Address;
32  class CGCXXABI;
33  class CGFunctionInfo;
34  class CodeGenFunction;
35  class CodeGenTypes;
36 
37  // FIXME: All of this stuff should be part of the target interface
38  // somehow. It is currently here because it is not clear how to factor
39  // the targets to support this, since the Targets currently live in a
40  // layer below types n'stuff.
41 
42 
43  /// ABIInfo - Target specific hooks for defining how a type should be
44  /// passed or returned from functions.
45  class ABIInfo {
46  protected:
49  public:
51  : CGT(cgt), RuntimeCC(llvm::CallingConv::C) {}
52 
53  virtual ~ABIInfo();
54 
55  virtual bool allowBFloatArgsAndRet() const { return false; }
56 
58  ASTContext &getContext() const;
59  llvm::LLVMContext &getVMContext() const;
60  const llvm::DataLayout &getDataLayout() const;
61  const TargetInfo &getTarget() const;
62  const CodeGenOptions &getCodeGenOpts() const;
63 
64  /// Return the calling convention to use for system runtime
65  /// functions.
67  return RuntimeCC;
68  }
69 
70  virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0;
71 
72  /// EmitVAArg - Emit the target dependent code to load a value of
73  /// \arg Ty from the va_list pointed to by \arg VAListAddr.
74 
75  // FIXME: This is a gaping layering violation if we wanted to drop
76  // the ABI information any lower than CodeGen. Of course, for
77  // VAArg handling it has to be at this level; there is no way to
78  // abstract this out.
80  CodeGen::Address VAListAddr,
81  QualType Ty) const = 0;
82 
83  bool isAndroid() const;
84 
85  /// Emit the target dependent code to load a value of
86  /// \arg Ty from the \c __builtin_ms_va_list pointed to by \arg VAListAddr.
88  CodeGen::Address VAListAddr,
89  QualType Ty) const;
90 
91  virtual bool isHomogeneousAggregateBaseType(QualType Ty) const;
92 
93  virtual bool isHomogeneousAggregateSmallEnough(const Type *Base,
94  uint64_t Members) const;
96 
97  bool isHomogeneousAggregate(QualType Ty, const Type *&Base,
98  uint64_t &Members) const;
99 
100  // Implement the Type::IsPromotableIntegerType for ABI specific needs. The
101  // only difference is that this considers bit-precise integer types as well.
103 
104  /// A convenience method to return an indirect ABIArgInfo with an
105  /// expected alignment equal to the ABI alignment of the given type.
107  getNaturalAlignIndirect(QualType Ty, bool ByVal = true,
108  bool Realign = false,
109  llvm::Type *Padding = nullptr) const;
110 
112  getNaturalAlignIndirectInReg(QualType Ty, bool Realign = false) const;
113  };
114 
115  /// Target specific hooks for defining how a type should be passed or returned
116  /// from functions with one of the Swift calling conventions.
117  class SwiftABIInfo {
118  protected:
121 
122  public:
125 
126  virtual ~SwiftABIInfo();
127 
128  /// Returns true if an aggregate which expands to the given type sequence
129  /// should be passed / returned indirectly.
130  virtual bool shouldPassIndirectly(ArrayRef<llvm::Type *> ComponentTys,
131  bool AsReturnValue) const;
132 
133  /// Returns true if the given vector type is legal from Swift's calling
134  /// convention perspective.
135  virtual bool isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
136  unsigned NumElts) const;
137 
138  /// Returns true if swifterror is lowered to a register by the target ABI.
140  };
141 } // end namespace CodeGen
142 } // end namespace clang
143 
144 #endif
llvm
YAML serialization mapping.
Definition: Dominators.h:30
clang::CodeGen::SwiftABIInfo
Target specific hooks for defining how a type should be passed or returned from functions with one of...
Definition: ABIInfo.h:117
clang::CodeGen::SwiftABIInfo::shouldPassIndirectly
virtual bool shouldPassIndirectly(ArrayRef< llvm::Type * > ComponentTys, bool AsReturnValue) const
Returns true if an aggregate which expands to the given type sequence should be passed / returned ind...
Definition: TargetInfo.cpp:155
clang::CodeGen::ABIInfo::getRuntimeCC
llvm::CallingConv::ID getRuntimeCC() const
Return the calling convention to use for system runtime functions.
Definition: ABIInfo.h:66
clang::CodeGen::ABIInfo::getNaturalAlignIndirect
CodeGen::ABIArgInfo getNaturalAlignIndirect(QualType Ty, bool ByVal=true, bool Realign=false, llvm::Type *Padding=nullptr) const
A convenience method to return an indirect ABIArgInfo with an expected alignment equal to the ABI ali...
Definition: TargetInfo.cpp:85
clang::CodeGen::ABIInfo::ABIInfo
ABIInfo(CodeGen::CodeGenTypes &cgt)
Definition: ABIInfo.h:50
clang::CodeGen::ABIInfo::~ABIInfo
virtual ~ABIInfo()
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:736
clang::TargetInfo
Exposes information about the current target.
Definition: TargetInfo.h:205
clang::CodeGen::ABIInfo::isHomogeneousAggregateBaseType
virtual bool isHomogeneousAggregateBaseType(QualType Ty) const
Definition: TargetInfo.cpp:239
clang::CodeGen::ABIInfo::getCodeGenOpts
const CodeGenOptions & getCodeGenOpts() const
Definition: TargetInfo.cpp:233
clang::CodeGen::ABIInfo::getContext
ASTContext & getContext() const
Definition: TargetInfo.cpp:217
clang::CodeGen::ABIInfo::isZeroLengthBitfieldPermittedInHomogeneousAggregate
virtual bool isZeroLengthBitfieldPermittedInHomogeneousAggregate() const
Definition: TargetInfo.cpp:248
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1566
clang::CodeGen::ABIArgInfo
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
Definition: CGFunctionInfo.h:32
hlsl::uint64_t
unsigned long uint64_t
Definition: hlsl_basic_types.h:25
clang::CodeGen::ABIInfo::isHomogeneousAggregate
bool isHomogeneousAggregate(QualType Ty, const Type *&Base, uint64_t &Members) const
isHomogeneousAggregate - Return true if a type is an ELFv2 homogeneous aggregate.
Definition: TargetInfo.cpp:5169
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
clang::CodeGen::SwiftABIInfo::SwiftABIInfo
SwiftABIInfo(CodeGen::CodeGenTypes &CGT, bool SwiftErrorInRegister)
Definition: ABIInfo.h:123
clang::CodeGen::ABIInfo::getDataLayout
const llvm::DataLayout & getDataLayout() const
Definition: TargetInfo.cpp:225
clang::CodeGen::SwiftABIInfo::isLegalVectorType
virtual bool isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy, unsigned NumElts) const
Returns true if the given vector type is legal from Swift's calling convention perspective.
Definition: TargetInfo.cpp:160
clang::CodeGen::SwiftABIInfo::CGT
CodeGenTypes & CGT
Definition: ABIInfo.h:119
Type.h
clang::CallingConv
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:266
clang::CodeGen::Address
An aligned address.
Definition: Address.h:74
Base
clang::CodeGenOptions
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
Definition: CodeGenOptions.h:49
clang::CodeGen::ABIInfo::RuntimeCC
llvm::CallingConv::ID RuntimeCC
Definition: ABIInfo.h:48
CharUnits.h
clang::CodeGen::ABIInfo::computeInfo
virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const =0
clang::CodeGen::ABIInfo::EmitVAArg
virtual CodeGen::Address EmitVAArg(CodeGen::CodeGenFunction &CGF, CodeGen::Address VAListAddr, QualType Ty) const =0
EmitVAArg - Emit the target dependent code to load a value of.
clang::CodeGen::CodeGenFunction
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Definition: CodeGenFunction.h:232
llvm::ArrayRef
Definition: LLVM.h:34
Value
Value
Definition: UninitializedValues.cpp:102
clang::CodeGen::ABIInfo::getVMContext
llvm::LLVMContext & getVMContext() const
Definition: TargetInfo.cpp:221
clang::CodeGen::CodeGenTypes
This class organizes the cross-module state that is used while lowering AST types to LLVM types.
Definition: CodeGenTypes.h:54
clang::CodeGen::ABIInfo::getTarget
const TargetInfo & getTarget() const
Definition: TargetInfo.cpp:229
clang::CodeGen::ABIInfo::allowBFloatArgsAndRet
virtual bool allowBFloatArgsAndRet() const
Definition: ABIInfo.h:55
clang::CodeGen::CGFunctionInfo
CGFunctionInfo - Class to encapsulate the information about a function definition.
Definition: CGFunctionInfo.h:546
clang::CodeGen::SwiftABIInfo::isSwiftErrorInRegister
bool isSwiftErrorInRegister() const
Returns true if swifterror is lowered to a register by the target ABI.
Definition: ABIInfo.h:139
clang::CodeGen::ABIInfo::getNaturalAlignIndirectInReg
CodeGen::ABIArgInfo getNaturalAlignIndirectInReg(QualType Ty, bool Realign=false) const
Definition: TargetInfo.cpp:93
clang::Builtin::ID
ID
Definition: Builtins.h:64
clang
Definition: CalledOnceCheck.h:17
clang::CodeGen::ABIInfo::isPromotableIntegerTypeForABI
bool isPromotableIntegerTypeForABI(QualType Ty) const
Definition: TargetInfo.cpp:108
clang::CodeGen::ABIInfo::isAndroid
bool isAndroid() const
Definition: TargetInfo.cpp:237
clang::CodeGen::SwiftABIInfo::SwiftErrorInRegister
bool SwiftErrorInRegister
Definition: ABIInfo.h:120
clang::CodeGen::ABIInfo::CGT
CodeGen::CodeGenTypes & CGT
Definition: ABIInfo.h:47
clang::CodeGen::ABIInfo::getCXXABI
CodeGen::CGCXXABI & getCXXABI() const
Definition: TargetInfo.cpp:213
clang::CodeGen::CGCXXABI
Implements C++ ABI-specific code generation functions.
Definition: CGCXXABI.h:43
clang::CodeGen::ABIInfo::EmitMSVAArg
virtual CodeGen::Address EmitMSVAArg(CodeGen::CodeGenFunction &CGF, CodeGen::Address VAListAddr, QualType Ty) const
Emit the target dependent code to load a value of.
Definition: TargetInfo.cpp:98
clang::CharUnits
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
clang::CodeGen::SwiftABIInfo::~SwiftABIInfo
virtual ~SwiftABIInfo()
clang::CodeGen::ABIInfo
ABIInfo - Target specific hooks for defining how a type should be passed or returned from functions.
Definition: ABIInfo.h:45
clang::CodeGen::ABIInfo::isHomogeneousAggregateSmallEnough
virtual bool isHomogeneousAggregateSmallEnough(const Type *Base, uint64_t Members) const
Definition: TargetInfo.cpp:243
Type
MatchType Type
Definition: ASTMatchFinder.cpp:71