clang 19.0.0git
ABIInfoImpl.h
Go to the documentation of this file.
1//===- ABIInfoImpl.h --------------------------------------------*- 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_ABIINFOIMPL_H
10#define LLVM_CLANG_LIB_CODEGEN_ABIINFOIMPL_H
11
12#include "ABIInfo.h"
13#include "CGCXXABI.h"
14
15namespace clang::CodeGen {
16
17/// DefaultABIInfo - The default implementation for ABI specific
18/// details. This implementation provides information which results in
19/// self-consistent and sensible LLVM IR generation, but does not
20/// conform to any particular ABI.
21class DefaultABIInfo : public ABIInfo {
22public:
24
25 virtual ~DefaultABIInfo();
26
29
30 void computeInfo(CGFunctionInfo &FI) const override;
31
33 QualType Ty) const override;
34};
35
36// Helper for coercing an aggregate argument or return value into an integer
37// array of the same size (including padding) and alignment. This alternate
38// coercion happens only for the RenderScript ABI and can be removed after
39// runtimes that rely on it are no longer supported.
40//
41// RenderScript assumes that the size of the argument / return value in the IR
42// is the same as the size of the corresponding qualified type. This helper
43// coerces the aggregate type into an array of the same size (including
44// padding). This coercion is used in lieu of expansion of struct members or
45// other canonical coercions that return a coerced-type of larger size.
46//
47// Ty - The argument / return value type
48// Context - The associated ASTContext
49// LLVMContext - The associated LLVMContext
51 llvm::LLVMContext &LLVMContext);
52
53void AssignToArrayRange(CodeGen::CGBuilderTy &Builder, llvm::Value *Array,
54 llvm::Value *Value, unsigned FirstIndex,
55 unsigned LastIndex);
56
58
60
62
64
66 const ABIInfo &Info);
67
68/// Pass transparent unions as if they were the type of the first element. Sema
69/// should ensure that all elements of the union have the same "machine type".
71
72// Dynamically round a pointer up to a multiple of the given alignment.
74 llvm::Value *Ptr, CharUnits Align);
75
76/// Emit va_arg for a platform using the common void* representation,
77/// where arguments are simply emitted in an array of slots on the stack.
78///
79/// This version implements the core direct-value passing rules.
80///
81/// \param SlotSize - The size and alignment of a stack slot.
82/// Each argument will be allocated to a multiple of this number of
83/// slots, and all the slots will be aligned to this value.
84/// \param AllowHigherAlign - The slot alignment is not a cap;
85/// an argument type with an alignment greater than the slot size
86/// will be emitted on a higher-alignment address, potentially
87/// leaving one or more empty slots behind as padding. If this
88/// is false, the returned address might be less-aligned than
89/// DirectAlign.
90/// \param ForceRightAdjust - Default is false. On big-endian platform and
91/// if the argument is smaller than a slot, set this flag will force
92/// right-adjust the argument in its slot irrespective of the type.
94 llvm::Type *DirectTy, CharUnits DirectSize,
95 CharUnits DirectAlign, CharUnits SlotSize,
96 bool AllowHigherAlign,
97 bool ForceRightAdjust = false);
98
99/// Emit va_arg for a platform using the common void* representation,
100/// where arguments are simply emitted in an array of slots on the stack.
101///
102/// \param IsIndirect - Values of this type are passed indirectly.
103/// \param ValueInfo - The size and alignment of this type, generally
104/// computed with getContext().getTypeInfoInChars(ValueTy).
105/// \param SlotSizeAndAlign - The size and alignment of a stack slot.
106/// Each argument will be allocated to a multiple of this number of
107/// slots, and all the slots will be aligned to this value.
108/// \param AllowHigherAlign - The slot alignment is not a cap;
109/// an argument type with an alignment greater than the slot size
110/// will be emitted on a higher-alignment address, potentially
111/// leaving one or more empty slots behind as padding.
112/// \param ForceRightAdjust - Default is false. On big-endian platform and
113/// if the argument is smaller than a slot, set this flag will force
114/// right-adjust the argument in its slot irrespective of the type.
116 QualType ValueTy, bool IsIndirect,
117 TypeInfoChars ValueInfo, CharUnits SlotSizeAndAlign,
118 bool AllowHigherAlign, bool ForceRightAdjust = false);
119
121 llvm::BasicBlock *Block1, Address Addr2,
122 llvm::BasicBlock *Block2, const llvm::Twine &Name = "");
123
124/// isEmptyField - Return true iff a the field is "empty", that is it
125/// is an unnamed bit-field or an (array of) empty record(s). If
126/// AsIfNoUniqueAddr is true, then C++ record fields are considered empty if
127/// the [[no_unique_address]] attribute would have made them empty.
128bool isEmptyField(ASTContext &Context, const FieldDecl *FD, bool AllowArrays,
129 bool AsIfNoUniqueAddr = false);
130
131/// isEmptyRecord - Return true iff a structure contains only empty
132/// fields. Note that a structure with a flexible array member is not
133/// considered empty. If AsIfNoUniqueAddr is true, then C++ record fields are
134/// considered empty if the [[no_unique_address]] attribute would have made
135/// them empty.
136bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays,
137 bool AsIfNoUniqueAddr = false);
138
139/// isSingleElementStruct - Determine if a structure is a "single
140/// element struct", i.e. it has exactly one non-empty field or
141/// exactly one field which is itself a single element
142/// struct. Structures with flexible array members are never
143/// considered single element structs.
144///
145/// \return The field declaration for the single non-empty field, if
146/// it exists.
148
150 const ABIArgInfo &AI);
151
152bool isSIMDVectorType(ASTContext &Context, QualType Ty);
153
155
156} // namespace clang::CodeGen
157
158#endif // LLVM_CLANG_LIB_CODEGEN_ABIINFOIMPL_H
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
Implements C++ ABI-specific semantic analysis functions.
Definition: CXXABI.h:29
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
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:45
CodeGen::CodeGenTypes & CGT
Definition: ABIInfo.h:47
An aligned address.
Definition: Address.h:29
Implements C++ ABI-specific code generation functions.
Definition: CGCXXABI.h:43
RecordArgABI
Specify how one should pass an argument of a record type.
Definition: CGCXXABI.h:154
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
DefaultABIInfo - The default implementation for ABI specific details.
Definition: ABIInfoImpl.h:21
DefaultABIInfo(CodeGen::CodeGenTypes &CGT)
Definition: ABIInfoImpl.h:23
ABIArgInfo classifyArgumentType(QualType RetTy) const
Definition: ABIInfoImpl.cpp:17
ABIArgInfo classifyReturnType(QualType RetTy) const
Definition: ABIInfoImpl.cpp:45
void computeInfo(CGFunctionInfo &FI) const override
Definition: ABIInfoImpl.cpp:67
Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty) const override
EmitVAArg - Emit the target dependent code to load a value of.
Definition: ABIInfoImpl.cpp:74
Represents a member of a struct/union/class.
Definition: Decl.h:3025
A (possibly-)qualified type.
Definition: Type.h:737
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:5091
The base class of the type hierarchy.
Definition: Type.h:1606
CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT, CGCXXABI &CXXABI)
bool classifyReturnType(const CGCXXABI &CXXABI, CGFunctionInfo &FI, const ABIInfo &Info)
Address EmitVAArgInstr(CodeGenFunction &CGF, Address VAListAddr, QualType Ty, const ABIArgInfo &AI)
Address emitVoidPtrDirectVAArg(CodeGenFunction &CGF, Address VAListAddr, llvm::Type *DirectTy, CharUnits DirectSize, CharUnits DirectAlign, CharUnits SlotSize, bool AllowHigherAlign, bool ForceRightAdjust=false)
Emit va_arg for a platform using the common void* representation, where arguments are simply emitted ...
Address emitVoidPtrVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType ValueTy, bool IsIndirect, TypeInfoChars ValueInfo, CharUnits SlotSizeAndAlign, bool AllowHigherAlign, bool ForceRightAdjust=false)
Emit va_arg for a platform using the common void* representation, where arguments are simply emitted ...
bool isRecordWithSIMDVectorType(ASTContext &Context, QualType Ty)
Address emitMergePHI(CodeGenFunction &CGF, Address Addr1, llvm::BasicBlock *Block1, Address Addr2, llvm::BasicBlock *Block2, const llvm::Twine &Name="")
bool isEmptyField(ASTContext &Context, const FieldDecl *FD, bool AllowArrays, bool AsIfNoUniqueAddr=false)
isEmptyField - Return true iff a the field is "empty", that is it is an unnamed bit-field or an (arra...
ABIArgInfo coerceToIntArray(QualType Ty, ASTContext &Context, llvm::LLVMContext &LLVMContext)
Definition: ABIInfoImpl.cpp:79
llvm::Value * emitRoundPointerUpToAlignment(CodeGenFunction &CGF, llvm::Value *Ptr, CharUnits Align)
bool isAggregateTypeForABI(QualType T)
const Type * isSingleElementStruct(QualType T, ASTContext &Context)
isSingleElementStruct - Determine if a structure is a "single element struct", i.e.
llvm::Type * getVAListElementType(CodeGenFunction &CGF)
void AssignToArrayRange(CodeGen::CGBuilderTy &Builder, llvm::Value *Array, llvm::Value *Value, unsigned FirstIndex, unsigned LastIndex)
Definition: ABIInfoImpl.cpp:89
QualType useFirstFieldIfTransparentUnion(QualType Ty)
Pass transparent unions as if they were the type of the first element.
bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays, bool AsIfNoUniqueAddr=false)
isEmptyRecord - Return true iff a structure contains only empty fields.
bool isSIMDVectorType(ASTContext &Context, QualType Ty)