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
17namespace llvm {
18class Value;
19class LLVMContext;
20class DataLayout;
21class Type;
22} // namespace llvm
23
24namespace clang {
25class ASTContext;
26class CodeGenOptions;
27class TargetInfo;
28
29namespace CodeGen {
30class ABIArgInfo;
31class Address;
32class CGCXXABI;
33class CGFunctionInfo;
34class CodeGenFunction;
35class 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/// ABIInfo - Target specific hooks for defining how a type should be
43/// passed or returned from functions.
44class ABIInfo {
45protected:
47 llvm::CallingConv::ID RuntimeCC;
48
49public:
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.
66 llvm::CallingConv::ID getRuntimeCC() const { return RuntimeCC; }
67
68 virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0;
69
70 /// EmitVAArg - Emit the target dependent code to load a value of
71 /// \arg Ty from the va_list pointed to by \arg VAListAddr.
72
73 // FIXME: This is a gaping layering violation if we wanted to drop
74 // the ABI information any lower than CodeGen. Of course, for
75 // VAArg handling it has to be at this level; there is no way to
76 // abstract this out.
78 CodeGen::Address VAListAddr,
79 QualType Ty) const = 0;
80
81 bool isAndroid() const;
82 bool isOHOSFamily() const;
83
84 /// Emit the target dependent code to load a value of
85 /// \arg Ty from the \c __builtin_ms_va_list pointed to by \arg VAListAddr.
87 CodeGen::Address VAListAddr,
88 QualType Ty) const;
89
90 virtual bool isHomogeneousAggregateBaseType(QualType Ty) const;
91
93 uint64_t Members) const;
95
97 uint64_t &Members) const;
98
99 // Implement the Type::IsPromotableIntegerType for ABI specific needs. The
100 // only difference is that this considers bit-precise integer types as well.
102
103 /// A convenience method to return an indirect ABIArgInfo with an
104 /// expected alignment equal to the ABI alignment of the given type.
106 getNaturalAlignIndirect(QualType Ty, bool ByVal = true, bool Realign = false,
107 llvm::Type *Padding = nullptr) const;
108
110 bool Realign = false) const;
111};
112
113/// Target specific hooks for defining how a type should be passed or returned
114/// from functions with one of the Swift calling conventions.
116protected:
119
121 unsigned maxAllRegisters) const;
122
123public:
126
127 virtual ~SwiftABIInfo();
128
129 /// Returns true if an aggregate which expands to the given type sequence
130 /// should be passed / returned indirectly.
131 virtual bool shouldPassIndirectly(ArrayRef<llvm::Type *> ComponentTys,
132 bool AsReturnValue) const;
133
134 /// Returns true if the given vector type is legal from Swift's calling
135 /// convention perspective.
136 virtual bool isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
137 unsigned NumElts) const;
138
139 /// Returns true if swifterror is lowered to a register by the target ABI.
141};
142} // end namespace CodeGen
143} // end namespace clang
144
145#endif
MatchType Type
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
ABIInfo - Target specific hooks for defining how a type should be passed or returned from functions.
Definition: ABIInfo.h:44
const llvm::DataLayout & getDataLayout() const
Definition: TargetInfo.cpp:225
virtual bool allowBFloatArgsAndRet() const
Definition: ABIInfo.h:55
const CodeGenOptions & getCodeGenOpts() const
Definition: TargetInfo.cpp:233
ABIInfo(CodeGen::CodeGenTypes &cgt)
Definition: ABIInfo.h:50
CodeGen::CodeGenTypes & CGT
Definition: ABIInfo.h:46
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:99
bool isHomogeneousAggregate(QualType Ty, const Type *&Base, uint64_t &Members) const
isHomogeneousAggregate - Return true if a type is an ELFv2 homogeneous aggregate.
CodeGen::CGCXXABI & getCXXABI() const
Definition: TargetInfo.cpp:213
ASTContext & getContext() const
Definition: TargetInfo.cpp:217
virtual bool isHomogeneousAggregateBaseType(QualType Ty) const
Definition: TargetInfo.cpp:243
bool isPromotableIntegerTypeForABI(QualType Ty) const
Definition: TargetInfo.cpp:109
bool isOHOSFamily() const
Definition: TargetInfo.cpp:239
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.
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:86
virtual bool isHomogeneousAggregateSmallEnough(const Type *Base, uint64_t Members) const
Definition: TargetInfo.cpp:247
const TargetInfo & getTarget() const
Definition: TargetInfo.cpp:229
virtual bool isZeroLengthBitfieldPermittedInHomogeneousAggregate() const
Definition: TargetInfo.cpp:252
llvm::CallingConv::ID getRuntimeCC() const
Return the calling convention to use for system runtime functions.
Definition: ABIInfo.h:66
CodeGen::ABIArgInfo getNaturalAlignIndirectInReg(QualType Ty, bool Realign=false) const
Definition: TargetInfo.cpp:94
virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const =0
llvm::CallingConv::ID RuntimeCC
Definition: ABIInfo.h:47
llvm::LLVMContext & getVMContext() const
Definition: TargetInfo.cpp:221
An aligned address.
Definition: Address.h:29
Implements C++ ABI-specific code generation functions.
Definition: CGCXXABI.h:43
CGFunctionInfo - Class to encapsulate the information about a function definition.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-module state that is used while lowering AST types to LLVM types.
Definition: CodeGenTypes.h:54
Target specific hooks for defining how a type should be passed or returned from functions with one of...
Definition: ABIInfo.h:115
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
bool occupiesMoreThan(ArrayRef< llvm::Type * > scalarTypes, unsigned maxAllRegisters) const
Does the given lowering require more than the given number of registers when expanded?
Definition: TargetInfo.cpp:137
bool isSwiftErrorInRegister() const
Returns true if swifterror is lowered to a register by the target ABI.
Definition: ABIInfo.h:140
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
SwiftABIInfo(CodeGen::CodeGenTypes &CGT, bool SwiftErrorInRegister)
Definition: ABIInfo.h:124
A (possibly-)qualified type.
Definition: Type.h:736
Exposes information about the current target.
Definition: TargetInfo.h:206
The base class of the type hierarchy.
Definition: Type.h:1568
@ C
Languages that the frontend can parse and compile.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:269
YAML serialization mapping.
Definition: Dominators.h:30