1 | //===--- CIRGenTypeCache.h - Commonly used LLVM types and info -*- 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 | // This structure provides a set of common types useful during CIR emission. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #ifndef LLVM_CLANG_LIB_CIR_CIRGENTYPECACHE_H |
14 | #define LLVM_CLANG_LIB_CIR_CIRGENTYPECACHE_H |
15 | |
16 | #include "clang/AST/CharUnits.h" |
17 | #include "clang/CIR/Dialect/IR/CIRTypes.h" |
18 | |
19 | namespace clang::CIRGen { |
20 | |
21 | /// This structure provides a set of types that are commonly used |
22 | /// during IR emission. It's initialized once in CodeGenModule's |
23 | /// constructor and then copied around into new CIRGenFunction's. |
24 | struct CIRGenTypeCache { |
25 | CIRGenTypeCache() = default; |
26 | |
27 | // ClangIR void type |
28 | cir::VoidType VoidTy; |
29 | |
30 | // ClangIR signed integral types of common sizes |
31 | cir::IntType SInt8Ty; |
32 | cir::IntType SInt16Ty; |
33 | cir::IntType SInt32Ty; |
34 | cir::IntType SInt64Ty; |
35 | cir::IntType SInt128Ty; |
36 | |
37 | // ClangIR unsigned integral type of common sizes |
38 | cir::IntType UInt8Ty; |
39 | cir::IntType UInt16Ty; |
40 | cir::IntType UInt32Ty; |
41 | cir::IntType UInt64Ty; |
42 | cir::IntType UInt128Ty; |
43 | |
44 | // ClangIR floating-point types with fixed formats |
45 | cir::FP16Type FP16Ty; |
46 | cir::BF16Type BFloat16Ty; |
47 | cir::SingleType FloatTy; |
48 | cir::DoubleType DoubleTy; |
49 | cir::FP80Type FP80Ty; |
50 | cir::FP128Type FP128Ty; |
51 | |
52 | mlir::Type PtrDiffTy; |
53 | |
54 | /// The size and alignment of a pointer into the generic address space. |
55 | union { |
56 | unsigned char PointerAlignInBytes; |
57 | unsigned char PointerSizeInBytes; |
58 | }; |
59 | |
60 | clang::CharUnits getPointerAlign() const { |
61 | return clang::CharUnits::fromQuantity(Quantity: PointerAlignInBytes); |
62 | } |
63 | }; |
64 | |
65 | } // namespace clang::CIRGen |
66 | |
67 | #endif // LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENTYPECACHE_H |
68 | |