================ @@ -0,0 +1,337 @@ +//===----- ABIFunctionInfo.h - ABI Function Information ----- C++ ---------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Defines ABIFunctionInfo and associated types used in representing the +// ABI-coerced types for function arguments and return values. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ABI_ABIFUNCTIONINFO_H +#define LLVM_ABI_ABIFUNCTIONINFO_H + +#include "llvm/ABI/Types.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/IR/CallingConv.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/TrailingObjects.h" + +namespace llvm { +namespace abi { + +/// ABIArgInfo - Helper class to encapsulate information about how a +/// specific type should be passed to or returned from a function. +class ABIArgInfo { +public: + enum Kind { + Direct, + Extend, + Indirect, + IndirectAliased, + Ignore, + Expand, + CoerceAndExpand, + InAlloca + }; + +private: + Kind TheKind; + const Type *CoercionType; + const Type *PaddingType; + struct DirectAttrInfo { + unsigned Offset; + unsigned Align; + }; + + struct IndirectAttrInfo { + unsigned Align; + unsigned AddrSpace; + }; + + union { + DirectAttrInfo DirectAttr; + IndirectAttrInfo IndirectAttr; + }; + bool InReg : 1; + bool PaddingInReg : 1; + bool SignExt : 1; + bool ZeroExt : 1; + unsigned IndirectAlign : 16; + bool IndirectByVal : 1; + bool IndirectRealign : 1; + bool CanBeFlattened : 1; + + ABIArgInfo(Kind K = Direct) + : TheKind(K), CoercionType(nullptr), InReg(false), PaddingInReg(false), + SignExt(false), ZeroExt(false), IndirectAlign(0), IndirectByVal(false) { + } + +public: + static ABIArgInfo getDirect(const Type *T = nullptr, unsigned Offset = 0, + const Type *Padding = nullptr, + bool CanBeFlattened = true, unsigned Align = 0) { + ABIArgInfo AI(Direct); + AI.CoercionType = T; + AI.PaddingType = Padding; + AI.DirectAttr.Offset = Offset; + AI.DirectAttr.Align = Align; + AI.CanBeFlattened = CanBeFlattened; + return AI; + } + + static ABIArgInfo getIndirectAliased(unsigned Align, unsigned AddrSpace = 0, + bool Realign = false, + const Type *Padding = nullptr) { + ABIArgInfo AI(IndirectAliased); + AI.IndirectAttr.Align = Align; + AI.IndirectAttr.AddrSpace = AddrSpace; + AI.IndirectRealign = Realign; + AI.PaddingType = Padding; + return AI; + } + static ABIArgInfo getDirectInReg(const Type *T = nullptr) { + ABIArgInfo AI = getDirect(T); + AI.InReg = true; + return AI; + } + static ABIArgInfo getExtend(const Type *T = nullptr) { ---------------- nikic wrote:
```suggestion static ABIArgInfo getExtend(const Type *T) { ``` Shouldn't have nullptr default if next line asserts it's not nullptr :) https://github.com/llvm/llvm-project/pull/140112 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits