forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeGenTypeCache.h
130 lines (107 loc) · 3.46 KB
/
CodeGenTypeCache.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//===--- CodeGenTypeCache.h - Commonly used LLVM types and info -*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This structure provides a set of common types useful during IR emission.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENTYPECACHE_H
#define LLVM_CLANG_LIB_CODEGEN_CODEGENTYPECACHE_H
#include "clang/AST/CharUnits.h"
#include "clang/Basic/AddressSpaces.h"
#include "llvm/IR/CallingConv.h"
namespace llvm {
class Type;
class IntegerType;
class PointerType;
}
namespace clang {
namespace CodeGen {
/// This structure provides a set of types that are commonly used
/// during IR emission. It's initialized once in CodeGenModule's
/// constructor and then copied around into new CodeGenFunctions.
struct CodeGenTypeCache {
/// void
llvm::Type *VoidTy;
/// i8, i16, i32, and i64
llvm::IntegerType *Int8Ty, *Int16Ty, *Int32Ty, *Int64Ty;
/// half, bfloat, float, double
llvm::Type *HalfTy, *BFloatTy, *FloatTy, *DoubleTy;
/// int
llvm::IntegerType *IntTy;
/// char
llvm::IntegerType *CharTy;
/// intptr_t, size_t, and ptrdiff_t, which we assume are the same size.
union {
llvm::IntegerType *IntPtrTy;
llvm::IntegerType *SizeTy;
llvm::IntegerType *PtrDiffTy;
};
/// void* in address space 0
union {
llvm::PointerType *VoidPtrTy;
llvm::PointerType *Int8PtrTy;
};
/// void** in address space 0
union {
llvm::PointerType *VoidPtrPtrTy;
llvm::PointerType *Int8PtrPtrTy;
};
/// void* in alloca address space
union {
llvm::PointerType *AllocaVoidPtrTy;
llvm::PointerType *AllocaInt8PtrTy;
};
/// void* in default globals address space
union {
llvm::PointerType *GlobalsVoidPtrTy;
llvm::PointerType *GlobalsInt8PtrTy;
};
/// The size and alignment of the builtin C type 'int'. This comes
/// up enough in various ABI lowering tasks to be worth pre-computing.
union {
unsigned char IntSizeInBytes;
unsigned char IntAlignInBytes;
};
CharUnits getIntSize() const {
return CharUnits::fromQuantity(IntSizeInBytes);
}
CharUnits getIntAlign() const {
return CharUnits::fromQuantity(IntAlignInBytes);
}
/// The width of a pointer into the generic address space.
unsigned char PointerWidthInBits;
/// The size and alignment of a pointer into the generic address space.
union {
unsigned char PointerAlignInBytes;
unsigned char PointerSizeInBytes;
};
/// The size and alignment of size_t.
union {
unsigned char SizeSizeInBytes; // sizeof(size_t)
unsigned char SizeAlignInBytes;
};
LangAS ASTAllocaAddressSpace;
CharUnits getSizeSize() const {
return CharUnits::fromQuantity(SizeSizeInBytes);
}
CharUnits getSizeAlign() const {
return CharUnits::fromQuantity(SizeAlignInBytes);
}
CharUnits getPointerSize() const {
return CharUnits::fromQuantity(PointerSizeInBytes);
}
CharUnits getPointerAlign() const {
return CharUnits::fromQuantity(PointerAlignInBytes);
}
llvm::CallingConv::ID RuntimeCC;
llvm::CallingConv::ID getRuntimeCC() const { return RuntimeCC; }
LangAS getASTAllocaAddressSpace() const { return ASTAllocaAddressSpace; }
};
} // end namespace CodeGen
} // end namespace clang
#endif