21 assert(ABIType &&
"convertType requires a non-null ABI type");
23 auto It = TypeCache.find(ABIType);
24 if (It != TypeCache.end())
29 switch (ABIType->getKind()) {
78 TypeCache[ABIType] = Result;
86 if (ValueSize == AtomicSize)
89 assert(ValueSize < AtomicSize &&
"atomic type cannot shrink its value type");
92 (AtomicSize - ValueSize) / 8)};
105llvm::Type *IRTypeMapper::convertVectorType(
const abi::VectorType *VT) {
113llvm::Type *IRTypeMapper::convertTupleType(
const abi::TupleType *TT) {
115 SmallVector<llvm::Type *, 4>
Elements(
TT->getNumVectors(), VecTy);
119llvm::Type *IRTypeMapper::convertRecordType(
const abi::RecordType *RT) {
124 SmallVector<llvm::Type *, 8> FieldTypes;
133llvm::Type *IRTypeMapper::convertComplexType(
const abi::ComplexType *CT) {
140IRTypeMapper::convertMemberPointerType(
const abi::MemberPointerType *MPT) {
141 llvm::Type *
IntPtrTy = DL.getIntPtrType(Context);
149llvm::Type *IRTypeMapper::createPaddingType(
uint64_t PaddingBits) {
150 if (PaddingBits == 0)
152 assert(PaddingBits % 8 == 0 &&
153 "sub-byte padding cannot be expressed as an llvm::Type");
160 TypeSize
Size, Align Alignment,
162 SmallVector<llvm::Type *, 16> FieldTypes;
165 llvm::Type *LargestFieldType =
nullptr;
167 for (
const auto &
Field : Fields) {
169 uint64_t FieldSize =
Field.FieldType->getSizeInBits().getFixedValue();
170 if (FieldSize > LargestFieldSize) {
171 LargestFieldSize = FieldSize;
172 LargestFieldType = FieldType;
175 if (LargestFieldType) {
178 if (LargestFieldSize < UnionSizeBits) {
179 if (llvm::Type *PaddingType =
180 createPaddingType(UnionSizeBits - LargestFieldSize))
186 for (
const auto &
Field : Fields) {
187 assert(!
Field.IsBitField &&
"bitfields should not reach IR type mapping");
189 if (
Field.OffsetInBits > CurrentOffset) {
190 uint64_t AlignBits = DL.getABITypeAlign(FieldType).value() * 8;
192 AlignBits ?
alignTo(CurrentOffset, AlignBits) : CurrentOffset;
193 if (NaturalNextOffset !=
Field.OffsetInBits) {
194 if (llvm::Type *PaddingType =
195 createPaddingType(
Field.OffsetInBits - CurrentOffset))
198 CurrentOffset =
Field.OffsetInBits;
201 CurrentOffset +=
Field.FieldType->getSizeInBits().getFixedValue();
204 if (CurrentOffset < TotalSizeBits) {
205 if (llvm::Type *PaddingType =
206 createPaddingType(TotalSizeBits - CurrentOffset))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
Maps LLVM ABI type representations back to corresponding LLVM IR types.
OptimizedStructLayoutField Field
This file defines the SmallVector class.
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
static constexpr ElementCount getFixed(ScalarTy MinVal)
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
static LLVM_ABI PointerType * get(LLVMContext &C, unsigned AddressSpace)
This constructs an opaque pointer to an object in a numbered address space.
void push_back(const T &Elt)
static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
static LLVM_ABI TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types={}, ArrayRef< unsigned > Ints={})
Return a target extension type having the specified name and optional type and integer parameters.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
static LLVM_ABI Type * getFloatingPointTy(LLVMContext &C, const fltSemantics &S)
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
const Type * getElementType() const
bool isMatrixType() const
uint64_t getNumElements() const
const Type * getValueType() const
const Type * getElementType() const
LLVM_ABI llvm::Type * convertType(const abi::Type *ABIType)
bool isFunctionPointer() const
ArrayRef< FieldInfo > getFields() const
StructPacking getPacking() const
Represents the ABI-specific view of a type in LLVM.
TypeSize getSizeInBits() const
Align getAlignment() const
ElementCount getNumElements() const
const Type * getElementType() const
constexpr ScalarTy getFixedValue() const
This file defines the type system for the LLVMABI library, which mirrors ABI-relevant aspects of fron...
ElementType
The element type of an SRV or UAV resource.
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
PointerUnion< const Value *, const PseudoSourceValue * > ValueType