1 //===--- CodeGenTypeCache.h - Commonly used LLVM types and info -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This structure provides a set of common types useful during IR emission.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENTYPECACHE_H
15 #define LLVM_CLANG_LIB_CODEGEN_CODEGENTYPECACHE_H
17 #include "clang/AST/CharUnits.h"
18 #include "clang/Basic/AddressSpaces.h"
19 #include "llvm/IR/CallingConv.h"
30 /// This structure provides a set of types that are commonly used
31 /// during IR emission. It's initialized once in CodeGenModule's
32 /// constructor and then copied around into new CodeGenFunctions.
33 struct CodeGenTypeCache {
37 /// i8, i16, i32, and i64
38 llvm::IntegerType *Int8Ty, *Int16Ty, *Int32Ty, *Int64Ty;
40 llvm::Type *FloatTy, *DoubleTy;
43 llvm::IntegerType *IntTy;
45 /// intptr_t, size_t, and ptrdiff_t, which we assume are the same size.
47 llvm::IntegerType *IntPtrTy;
48 llvm::IntegerType *SizeTy;
49 llvm::IntegerType *PtrDiffTy;
52 /// void* in address space 0
54 llvm::PointerType *VoidPtrTy;
55 llvm::PointerType *Int8PtrTy;
58 /// void** in address space 0
60 llvm::PointerType *VoidPtrPtrTy;
61 llvm::PointerType *Int8PtrPtrTy;
64 /// void* in alloca address space
66 llvm::PointerType *AllocaVoidPtrTy;
67 llvm::PointerType *AllocaInt8PtrTy;
70 /// The size and alignment of the builtin C type 'int'. This comes
71 /// up enough in various ABI lowering tasks to be worth pre-computing.
73 unsigned char IntSizeInBytes;
74 unsigned char IntAlignInBytes;
76 CharUnits getIntSize() const {
77 return CharUnits::fromQuantity(IntSizeInBytes);
79 CharUnits getIntAlign() const {
80 return CharUnits::fromQuantity(IntAlignInBytes);
83 /// The width of a pointer into the generic address space.
84 unsigned char PointerWidthInBits;
86 /// The size and alignment of a pointer into the generic address space.
88 unsigned char PointerAlignInBytes;
89 unsigned char PointerSizeInBytes;
92 /// The size and alignment of size_t.
94 unsigned char SizeSizeInBytes; // sizeof(size_t)
95 unsigned char SizeAlignInBytes;
98 LangAS ASTAllocaAddressSpace;
100 CharUnits getSizeSize() const {
101 return CharUnits::fromQuantity(SizeSizeInBytes);
103 CharUnits getSizeAlign() const {
104 return CharUnits::fromQuantity(SizeAlignInBytes);
106 CharUnits getPointerSize() const {
107 return CharUnits::fromQuantity(PointerSizeInBytes);
109 CharUnits getPointerAlign() const {
110 return CharUnits::fromQuantity(PointerAlignInBytes);
113 llvm::CallingConv::ID RuntimeCC;
114 llvm::CallingConv::ID getRuntimeCC() const { return RuntimeCC; }
115 llvm::CallingConv::ID BuiltinCC;
116 llvm::CallingConv::ID getBuiltinCC() const { return BuiltinCC; }
118 LangAS getASTAllocaAddressSpace() const { return ASTAllocaAddressSpace; }
121 } // end namespace CodeGen
122 } // end namespace clang