LLVM 23.0.0git
IRTypeMapper.h
Go to the documentation of this file.
1//===---- IRTypeMapper.h - Maps LLVM ABI Types to LLVM IR Types ---------===//
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/// \file
10/// Maps LLVM ABI type representations back to corresponding LLVM IR types.
11/// Used by frontends after the ABI library has computed argument/return
12/// classification: coerce-to types in the ABI representation must be
13/// translated to llvm::Type before being handed back to the IR builder.
14///
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_ABI_IRTYPEMAPPER_H
18#define LLVM_ABI_IRTYPEMAPPER_H
19
20#include "llvm/ABI/Types.h"
21#include "llvm/ADT/DenseMap.h"
22
23namespace llvm {
24class LLVMContext;
25class Type;
26class StructType;
27class DataLayout;
28
29namespace abi {
30
32public:
33 IRTypeMapper(LLVMContext &Ctx, const DataLayout &DL) : Context(Ctx), DL(DL) {}
34
35 llvm::Type *convertType(const abi::Type *ABIType);
36
37 void clearCache() { TypeCache.clear(); }
38
39private:
40 LLVMContext &Context;
41 const DataLayout &DL;
42
44
45 llvm::Type *convertArrayType(const abi::ArrayType *AT);
46 llvm::Type *convertVectorType(const abi::VectorType *VT);
47 llvm::Type *convertRecordType(const abi::RecordType *RT);
48 llvm::Type *convertComplexType(const abi::ComplexType *CT);
49 llvm::Type *convertMemberPointerType(const abi::MemberPointerType *MPT);
50
51 llvm::StructType *createStructFromFields(ArrayRef<abi::FieldInfo> Fields,
52 TypeSize Size, Align Alignment,
53 bool IsUnion);
54 llvm::Type *createPaddingType(uint64_t PaddingBits);
55};
56
57} // namespace abi
58} // namespace llvm
59
60#endif // LLVM_ABI_ABITYPEMAPPER_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file defines the DenseMap class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:39
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
Class to represent struct types.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
IRTypeMapper(LLVMContext &Ctx, const DataLayout &DL)
llvm::Type * convertType(const abi::Type *ABIType)
Represents the ABI-specific view of a type in LLVM.
Definition Types.h:43
This file defines the type system for the LLVMABI library, which mirrors ABI-relevant aspects of fron...
@ IsUnion
Definition Types.h:255
This is an optimization pass for GlobalISel generic memory operations.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39