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 "llvm/IR/CallingConv.h"
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 {
36 /// i8, i16, i32, and i64
37 llvm::IntegerType *Int8Ty, *Int16Ty, *Int32Ty, *Int64Ty;
39 llvm::Type *FloatTy, *DoubleTy;
42 llvm::IntegerType *IntTy;
44 /// intptr_t, size_t, and ptrdiff_t, which we assume are the same size.
46 llvm::IntegerType *IntPtrTy;
47 llvm::IntegerType *SizeTy;
48 llvm::IntegerType *PtrDiffTy;
51 /// void* in address space 0
53 llvm::PointerType *VoidPtrTy;
54 llvm::PointerType *Int8PtrTy;
57 /// void** in address space 0
59 llvm::PointerType *VoidPtrPtrTy;
60 llvm::PointerType *Int8PtrPtrTy;
63 /// The size and alignment of the builtin C type 'int'. This comes
64 /// up enough in various ABI lowering tasks to be worth pre-computing.
66 unsigned char IntSizeInBytes;
67 unsigned char IntAlignInBytes;
69 CharUnits getIntSize() const {
70 return CharUnits::fromQuantity(IntSizeInBytes);
72 CharUnits getIntAlign() const {
73 return CharUnits::fromQuantity(IntAlignInBytes);
76 /// The width of a pointer into the generic address space.
77 unsigned char PointerWidthInBits;
79 /// The size and alignment of a pointer into the generic address space.
81 unsigned char PointerAlignInBytes;
82 unsigned char PointerSizeInBytes;
83 unsigned char SizeSizeInBytes; // sizeof(size_t)
84 unsigned char SizeAlignInBytes;
86 CharUnits getSizeSize() const {
87 return CharUnits::fromQuantity(SizeSizeInBytes);
89 CharUnits getSizeAlign() const {
90 return CharUnits::fromQuantity(SizeAlignInBytes);
92 CharUnits getPointerSize() const {
93 return CharUnits::fromQuantity(PointerSizeInBytes);
95 CharUnits getPointerAlign() const {
96 return CharUnits::fromQuantity(PointerAlignInBytes);
99 llvm::CallingConv::ID RuntimeCC;
100 llvm::CallingConv::ID getRuntimeCC() const { return RuntimeCC; }
101 llvm::CallingConv::ID BuiltinCC;
102 llvm::CallingConv::ID getBuiltinCC() const { return BuiltinCC; }
105 } // end namespace CodeGen
106 } // end namespace clang