clang 20.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
32 RValue EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
33 AggValueSlot Slot) const override;
34};
35
36void AssignToArrayRange(CodeGen::CGBuilderTy &Builder, llvm::Value *Array,
37 llvm::Value *Value, unsigned FirstIndex,
38 unsigned LastIndex);
39
41
43
45
47
49 const ABIInfo &Info);
50
51/// Pass transparent unions as if they were the type of the first element. Sema
52/// should ensure that all elements of the union have the same "machine type".
54
55// Dynamically round a pointer up to a multiple of the given alignment.
57 llvm::Value *Ptr, CharUnits Align);
58
59/// Emit va_arg for a platform using the common void* representation,
60/// where arguments are simply emitted in an array of slots on the stack.
61///
62/// This version implements the core direct-value passing rules.
63///
64/// \param SlotSize - The size and alignment of a stack slot.
65/// Each argument will be allocated to a multiple of this number of
66/// slots, and all the slots will be aligned to this value.
67/// \param AllowHigherAlign - The slot alignment is not a cap;
68/// an argument type with an alignment greater than the slot size
69/// will be emitted on a higher-alignment address, potentially
70/// leaving one or more empty slots behind as padding. If this
71/// is false, the returned address might be less-aligned than
72/// DirectAlign.
73/// \param ForceRightAdjust - Default is false. On big-endian platform and
74/// if the argument is smaller than a slot, set this flag will force
75/// right-adjust the argument in its slot irrespective of the type.
77 llvm::Type *DirectTy, CharUnits DirectSize,
78 CharUnits DirectAlign, CharUnits SlotSize,
79 bool AllowHigherAlign,
80 bool ForceRightAdjust = false);
81
82/// Emit va_arg for a platform using the common void* representation,
83/// where arguments are simply emitted in an array of slots on the stack.
84///
85/// \param IsIndirect - Values of this type are passed indirectly.
86/// \param ValueInfo - The size and alignment of this type, generally
87/// computed with getContext().getTypeInfoInChars(ValueTy).
88/// \param SlotSizeAndAlign - The size and alignment of a stack slot.
89/// Each argument will be allocated to a multiple of this number of
90/// slots, and all the slots will be aligned to this value.
91/// \param AllowHigherAlign - The slot alignment is not a cap;
92/// an argument type with an alignment greater than the slot size
93/// will be emitted on a higher-alignment address, potentially
94/// leaving one or more empty slots behind as padding.
95/// \param ForceRightAdjust - Default is false. On big-endian platform and
96/// if the argument is smaller than a slot, set this flag will force
97/// right-adjust the argument in its slot irrespective of the type.
99 QualType ValueTy, bool IsIndirect,
100 TypeInfoChars ValueInfo, CharUnits SlotSizeAndAlign,
101 bool AllowHigherAlign, AggValueSlot Slot,
102 bool ForceRightAdjust = false);
103
105 llvm::BasicBlock *Block1, Address Addr2,
106 llvm::BasicBlock *Block2, const llvm::Twine &Name = "");
107
108/// isEmptyField - Return true iff a the field is "empty", that is it
109/// is an unnamed bit-field or an (array of) empty record(s). If
110/// AsIfNoUniqueAddr is true, then C++ record fields are considered empty if
111/// the [[no_unique_address]] attribute would have made them empty.
112bool isEmptyField(ASTContext &Context, const FieldDecl *FD, bool AllowArrays,
113 bool AsIfNoUniqueAddr = false);
114
115/// isEmptyRecord - Return true iff a structure contains only empty
116/// fields. Note that a structure with a flexible array member is not
117/// considered empty. If AsIfNoUniqueAddr is true, then C++ record fields are
118/// considered empty if the [[no_unique_address]] attribute would have made
119/// them empty.
120bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays,
121 bool AsIfNoUniqueAddr = false);
122
123/// isEmptyFieldForLayout - Return true iff the field is "empty", that is,
124/// either a zero-width bit-field or an \ref isEmptyRecordForLayout.
125bool isEmptyFieldForLayout(const ASTContext &Context, const FieldDecl *FD);
126
127/// isEmptyRecordForLayout - Return true iff a structure contains only empty
128/// base classes (per \ref isEmptyRecordForLayout) and fields (per
129/// \ref isEmptyFieldForLayout). Note, C++ record fields are considered empty
130/// if the [[no_unique_address]] attribute would have made them empty.
131bool isEmptyRecordForLayout(const ASTContext &Context, QualType T);
132
133/// isSingleElementStruct - Determine if a structure is a "single
134/// element struct", i.e. it has exactly one non-empty field or
135/// exactly one field which is itself a single element
136/// struct. Structures with flexible array members are never
137/// considered single element structs.
138///
139/// \return The field declaration for the single non-empty field, if
140/// it exists.
142
144 const ABIArgInfo &AI);
145
146bool isSIMDVectorType(ASTContext &Context, QualType Ty);
147
149
150} // namespace clang::CodeGen
151
152#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:188
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:47
CodeGen::CodeGenTypes & CGT
Definition: ABIInfo.h:49
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
Definition: Address.h:128
An aggregate value slot.
Definition: CGValue.h:504
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:150
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
RValue EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty, AggValueSlot Slot) const override
EmitVAArg - Emit the target dependent code to load a value of.
Definition: ABIInfoImpl.cpp:75
ABIArgInfo classifyReturnType(QualType RetTy) const
Definition: ABIInfoImpl.cpp:46
void computeInfo(CGFunctionInfo &FI) const override
Definition: ABIInfoImpl.cpp:68
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
Definition: CGValue.h:42
Represents a member of a struct/union/class.
Definition: Decl.h:3033
A (possibly-)qualified type.
Definition: Type.h:929
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:6072
The base class of the type hierarchy.
Definition: Type.h:1828
bool isEmptyRecordForLayout(const ASTContext &Context, QualType T)
isEmptyRecordForLayout - Return true iff a structure contains only empty base classes (per isEmptyRec...
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)
bool isEmptyFieldForLayout(const ASTContext &Context, const FieldDecl *FD)
isEmptyFieldForLayout - Return true iff the field is "empty", that is, either a zero-width bit-field ...
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 ...
bool isRecordWithSIMDVectorType(ASTContext &Context, QualType Ty)
RValue emitVoidPtrVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType ValueTy, bool IsIndirect, TypeInfoChars ValueInfo, CharUnits SlotSizeAndAlign, bool AllowHigherAlign, AggValueSlot Slot, bool ForceRightAdjust=false)
Emit va_arg for a platform using the common void* representation, where arguments are simply emitted ...
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...
llvm::Value * emitRoundPointerUpToAlignment(CodeGenFunction &CGF, llvm::Value *Ptr, CharUnits Align)
bool isAggregateTypeForABI(QualType T)
Definition: ABIInfoImpl.cpp:94
const Type * isSingleElementStruct(QualType T, ASTContext &Context)
isSingleElementStruct - Determine if a structure is a "single element struct", i.e.
llvm::Type * getVAListElementType(CodeGenFunction &CGF)
Definition: ABIInfoImpl.cpp:99
void AssignToArrayRange(CodeGen::CGBuilderTy &Builder, llvm::Value *Array, llvm::Value *Value, unsigned FirstIndex, unsigned LastIndex)
Definition: ABIInfoImpl.cpp:83
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)
const FunctionProtoType * T