Clang Project

clang_source_code/lib/CodeGen/CodeGenTypeCache.h
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.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENTYPECACHE_H
14#define LLVM_CLANG_LIB_CODEGEN_CODEGENTYPECACHE_H
15
16#include "clang/AST/CharUnits.h"
17#include "clang/Basic/AddressSpaces.h"
18#include "llvm/IR/CallingConv.h"
19
20namespace llvm {
21  class Type;
22  class IntegerType;
23  class PointerType;
24}
25
26namespace clang {
27namespace CodeGen {
28
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.
32struct CodeGenTypeCache {
33  /// void
34  llvm::Type *VoidTy;
35
36  /// i8, i16, i32, and i64
37  llvm::IntegerType *Int8Ty, *Int16Ty, *Int32Ty, *Int64Ty;
38  /// float, double
39  llvm::Type *HalfTy, *FloatTy, *DoubleTy;
40
41  /// int
42  llvm::IntegerType *IntTy;
43
44  /// intptr_t, size_t, and ptrdiff_t, which we assume are the same size.
45  union {
46    llvm::IntegerType *IntPtrTy;
47    llvm::IntegerType *SizeTy;
48    llvm::IntegerType *PtrDiffTy;
49  };
50
51  /// void* in address space 0
52  union {
53    llvm::PointerType *VoidPtrTy;
54    llvm::PointerType *Int8PtrTy;
55  };
56
57  /// void** in address space 0
58  union {
59    llvm::PointerType *VoidPtrPtrTy;
60    llvm::PointerType *Int8PtrPtrTy;
61  };
62
63  /// void* in alloca address space
64  union {
65    llvm::PointerType *AllocaVoidPtrTy;
66    llvm::PointerType *AllocaInt8PtrTy;
67  };
68
69  /// The size and alignment of the builtin C type 'int'.  This comes
70  /// up enough in various ABI lowering tasks to be worth pre-computing.
71  union {
72    unsigned char IntSizeInBytes;
73    unsigned char IntAlignInBytes;
74  };
75  CharUnits getIntSize() const {
76    return CharUnits::fromQuantity(IntSizeInBytes);
77  }
78  CharUnits getIntAlign() const {
79    return CharUnits::fromQuantity(IntAlignInBytes);
80  }
81
82  /// The width of a pointer into the generic address space.
83  unsigned char PointerWidthInBits;
84
85  /// The size and alignment of a pointer into the generic address space.
86  union {
87    unsigned char PointerAlignInBytes;
88    unsigned char PointerSizeInBytes;
89  };
90
91  /// The size and alignment of size_t.
92  union {
93    unsigned char SizeSizeInBytes// sizeof(size_t)
94    unsigned char SizeAlignInBytes;
95  };
96
97  LangAS ASTAllocaAddressSpace;
98
99  CharUnits getSizeSize() const {
100    return CharUnits::fromQuantity(SizeSizeInBytes);
101  }
102  CharUnits getSizeAlign() const {
103    return CharUnits::fromQuantity(SizeAlignInBytes);
104  }
105  CharUnits getPointerSize() const {
106    return CharUnits::fromQuantity(PointerSizeInBytes);
107  }
108  CharUnits getPointerAlign() const {
109    return CharUnits::fromQuantity(PointerAlignInBytes);
110  }
111
112  llvm::CallingConv::ID RuntimeCC;
113  llvm::CallingConv::ID getRuntimeCC() const { return RuntimeCC; }
114
115  LangAS getASTAllocaAddressSpace() const { return ASTAllocaAddressSpace; }
116};
117
118}  // end namespace CodeGen
119}  // end namespace clang
120
121#endif
122
clang::CodeGen::CodeGenTypeCache::VoidTy
clang::CodeGen::CodeGenTypeCache::Int8Ty
clang::CodeGen::CodeGenTypeCache::Int16Ty
clang::CodeGen::CodeGenTypeCache::Int32Ty
clang::CodeGen::CodeGenTypeCache::Int64Ty
clang::CodeGen::CodeGenTypeCache::HalfTy
clang::CodeGen::CodeGenTypeCache::FloatTy
clang::CodeGen::CodeGenTypeCache::DoubleTy
clang::CodeGen::CodeGenTypeCache::IntTy
clang::CodeGen::CodeGenTypeCache::(anonymous union)::IntPtrTy
clang::CodeGen::CodeGenTypeCache::(anonymous union)::SizeTy
clang::CodeGen::CodeGenTypeCache::(anonymous union)::PtrDiffTy
clang::CodeGen::CodeGenTypeCache::(anonymous union)::VoidPtrTy
clang::CodeGen::CodeGenTypeCache::(anonymous union)::Int8PtrTy
clang::CodeGen::CodeGenTypeCache::(anonymous union)::VoidPtrPtrTy
clang::CodeGen::CodeGenTypeCache::(anonymous union)::Int8PtrPtrTy
clang::CodeGen::CodeGenTypeCache::(anonymous union)::AllocaVoidPtrTy
clang::CodeGen::CodeGenTypeCache::(anonymous union)::AllocaInt8PtrTy
clang::CodeGen::CodeGenTypeCache::(anonymous union)::IntSizeInBytes
clang::CodeGen::CodeGenTypeCache::(anonymous union)::IntAlignInBytes
clang::CodeGen::CodeGenTypeCache::getIntSize
clang::CodeGen::CodeGenTypeCache::getIntAlign
clang::CodeGen::CodeGenTypeCache::PointerWidthInBits
clang::CodeGen::CodeGenTypeCache::(anonymous union)::PointerAlignInBytes
clang::CodeGen::CodeGenTypeCache::(anonymous union)::PointerSizeInBytes
clang::CodeGen::CodeGenTypeCache::(anonymous union)::SizeSizeInBytes
clang::CodeGen::CodeGenTypeCache::(anonymous union)::SizeAlignInBytes
clang::CodeGen::CodeGenTypeCache::ASTAllocaAddressSpace
clang::CodeGen::CodeGenTypeCache::getSizeSize
clang::CodeGen::CodeGenTypeCache::getSizeAlign
clang::CodeGen::CodeGenTypeCache::getPointerSize
clang::CodeGen::CodeGenTypeCache::getPointerAlign
clang::CodeGen::CodeGenTypeCache::RuntimeCC
clang::CodeGen::CodeGenTypeCache::getRuntimeCC
clang::CodeGen::CodeGenTypeCache::getASTAllocaAddressSpace