[RISCV] Add shrinkwrap test cases showing gaps in current impl
[llvm-project.git] / clang / lib / CodeGen / CodeGenTypeCache.h
blobe273ebe3b060f2288a167005fa3c06c5e036c475
1 //===--- CodeGenTypeCache.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 IR emission.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENTYPECACHE_H
14 #define LLVM_CLANG_LIB_CODEGEN_CODEGENTYPECACHE_H
16 #include "clang/AST/CharUnits.h"
17 #include "clang/Basic/AddressSpaces.h"
18 #include "llvm/IR/CallingConv.h"
20 namespace llvm {
21 class Type;
22 class IntegerType;
23 class PointerType;
26 namespace clang {
27 namespace CodeGen {
29 /// This structure provides a set of types that are commonly used
30 /// during IR emission. It's initialized once in CodeGenModule's
31 /// constructor and then copied around into new CodeGenFunctions.
32 struct CodeGenTypeCache {
33 /// void
34 llvm::Type *VoidTy;
36 /// i8, i16, i32, and i64
37 llvm::IntegerType *Int8Ty, *Int16Ty, *Int32Ty, *Int64Ty;
38 /// half, bfloat, float, double
39 llvm::Type *HalfTy, *BFloatTy, *FloatTy, *DoubleTy;
41 /// int
42 llvm::IntegerType *IntTy;
44 /// char
45 llvm::IntegerType *CharTy;
47 /// intptr_t, size_t, and ptrdiff_t, which we assume are the same size.
48 union {
49 llvm::IntegerType *IntPtrTy;
50 llvm::IntegerType *SizeTy;
51 llvm::IntegerType *PtrDiffTy;
54 /// void*, void** in the target's default address space (often 0)
55 union {
56 llvm::PointerType *UnqualPtrTy;
57 llvm::PointerType *VoidPtrTy;
58 llvm::PointerType *Int8PtrTy;
59 llvm::PointerType *VoidPtrPtrTy;
60 llvm::PointerType *Int8PtrPtrTy;
63 /// void* in alloca address space
64 union {
65 llvm::PointerType *AllocaVoidPtrTy;
66 llvm::PointerType *AllocaInt8PtrTy;
69 /// void* in default globals address space
70 union {
71 llvm::PointerType *GlobalsVoidPtrTy;
72 llvm::PointerType *GlobalsInt8PtrTy;
75 /// void* in the address space for constant globals
76 llvm::PointerType *ConstGlobalsPtrTy;
78 /// The size and alignment of the builtin C type 'int'. This comes
79 /// up enough in various ABI lowering tasks to be worth pre-computing.
80 union {
81 unsigned char IntSizeInBytes;
82 unsigned char IntAlignInBytes;
84 CharUnits getIntSize() const {
85 return CharUnits::fromQuantity(IntSizeInBytes);
87 CharUnits getIntAlign() const {
88 return CharUnits::fromQuantity(IntAlignInBytes);
91 /// The width of a pointer into the generic address space.
92 unsigned char PointerWidthInBits;
94 /// The size and alignment of a pointer into the generic address space.
95 union {
96 unsigned char PointerAlignInBytes;
97 unsigned char PointerSizeInBytes;
100 /// The size and alignment of size_t.
101 union {
102 unsigned char SizeSizeInBytes; // sizeof(size_t)
103 unsigned char SizeAlignInBytes;
106 LangAS ASTAllocaAddressSpace;
108 CharUnits getSizeSize() const {
109 return CharUnits::fromQuantity(SizeSizeInBytes);
111 CharUnits getSizeAlign() const {
112 return CharUnits::fromQuantity(SizeAlignInBytes);
114 CharUnits getPointerSize() const {
115 return CharUnits::fromQuantity(PointerSizeInBytes);
117 CharUnits getPointerAlign() const {
118 return CharUnits::fromQuantity(PointerAlignInBytes);
121 llvm::CallingConv::ID RuntimeCC;
122 llvm::CallingConv::ID getRuntimeCC() const { return RuntimeCC; }
124 LangAS getASTAllocaAddressSpace() const { return ASTAllocaAddressSpace; }
127 } // end namespace CodeGen
128 } // end namespace clang
130 #endif