Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
Types.h
Go to the documentation of this file.
1#ifndef PROTEUS_PASS_TYPES_H
2#define PROTEUS_PASS_TYPES_H
3
4#include <llvm/IR/DerivedTypes.h>
5#include <llvm/IR/Module.h>
6#include <llvm/IR/Type.h>
7
8#include "Helpers.h"
9
10namespace proteus {
11
12using namespace llvm;
13
15 ProteusTypes(Module &M)
16 : PtrTy(PointerType::getUnqual(M.getContext())),
17 VoidTy(Type::getVoidTy(M.getContext())),
18 Int1Ty(Type::getInt1Ty(M.getContext())),
19 Int8Ty(Type::getInt8Ty(M.getContext())),
20 Int32Ty(Type::getInt32Ty(M.getContext())),
21 Int64Ty(Type::getInt64Ty(M.getContext())),
22 Int128Ty(Type::getInt128Ty(M.getContext())) {
23 // llvm.global.annotations entry format:
24 // ptr: (addrspace 1) Function pointer
25 // ptr: (addrspace 4) Annotations string
26 // ptr: (addrspace 4) Source file string
27 // i32: Line number,
28 // ptr: (addrspace 1) Arguments pointer
29 if (isDeviceCompilation(M)) {
30 constexpr unsigned GlobalAddressSpace = 1;
31 constexpr unsigned ConstAddressSpace = 4;
32 GlobalAnnotationEltTy = StructType::get(
33 PointerType::get(M.getContext(), GlobalAddressSpace),
34 PointerType::get(M.getContext(), ConstAddressSpace),
35 PointerType::get(M.getContext(), ConstAddressSpace), Int32Ty,
36 PointerType::get(M.getContext(), GlobalAddressSpace));
37 } else
39 StructType::get(PtrTy, PtrTy, PtrTy, Int32Ty, PtrTy);
40 }
41
42 Type *PtrTy = nullptr;
43 Type *VoidTy = nullptr;
44 Type *Int1Ty = nullptr;
45 Type *Int8Ty = nullptr;
46 Type *Int32Ty = nullptr;
47 Type *Int64Ty = nullptr;
48 Type *Int128Ty = nullptr;
49 StructType *GlobalAnnotationEltTy = nullptr;
50};
51
52} // namespace proteus
53
54#endif
Definition Dispatcher.cpp:14
bool isDeviceCompilation(Module &M)
Definition Helpers.h:50
Definition Types.h:14
ProteusTypes(Module &M)
Definition Types.h:15
Type * Int1Ty
Definition Types.h:44
Type * Int64Ty
Definition Types.h:47
Type * VoidTy
Definition Types.h:43
Type * Int128Ty
Definition Types.h:48
Type * Int32Ty
Definition Types.h:46
Type * PtrTy
Definition Types.h:42
Type * Int8Ty
Definition Types.h:45
StructType * GlobalAnnotationEltTy
Definition Types.h:49