Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
TypeMap.hpp
Go to the documentation of this file.
1#ifndef PROTEUS_FRONTEND_TYPEMAP_HPP
2#define PROTEUS_FRONTEND_TYPEMAP_HPP
3
4#include <llvm/IR/DerivedTypes.h>
5#include <llvm/IR/LLVMContext.h>
6#include <llvm/IR/Type.h>
7
8#include <cstddef>
9
10namespace proteus {
11using namespace llvm;
12
13template <typename T> struct TypeMap;
14
15template <> struct TypeMap<void> {
16 static Type *get(llvm::LLVMContext &Ctx) { return Type::getVoidTy(Ctx); }
17
18 static Type *getPointerElemType(llvm::LLVMContext &) { return nullptr; }
19};
20
21template <> struct TypeMap<float> {
22 static Type *get(llvm::LLVMContext &Ctx) { return Type::getFloatTy(Ctx); }
23
24 static Type *getPointerElemType(llvm::LLVMContext &) { return nullptr; }
25};
26
27template <> struct TypeMap<double> {
28 static Type *get(llvm::LLVMContext &Ctx) { return Type::getDoubleTy(Ctx); }
29
30 static Type *getPointerElemType(llvm::LLVMContext &) { return nullptr; }
31};
32
33template <> struct TypeMap<size_t> {
34 static Type *get(llvm::LLVMContext &Ctx) { return Type::getInt64Ty(Ctx); }
35
36 static Type *getPointerElemType(llvm::LLVMContext &) { return nullptr; }
37};
38
39template <> struct TypeMap<int> {
40 static Type *get(llvm::LLVMContext &Ctx) { return Type::getInt32Ty(Ctx); }
41
42 static Type *getPointerElemType(llvm::LLVMContext &) { return nullptr; }
43
44 static bool isSigned() { return true; }
45};
46
47template <> struct TypeMap<bool> {
48 static Type *get(llvm::LLVMContext &Ctx) { return Type::getInt1Ty(Ctx); }
49
50 static Type *getPointerElemType(llvm::LLVMContext &) { return nullptr; }
51};
52
53template <> struct TypeMap<double &> {
54 static Type *get(llvm::LLVMContext &Ctx) {
55 return PointerType::getUnqual(Ctx);
56 }
57
58 static Type *getPointerElemType(llvm::LLVMContext &Ctx) {
59 return Type::getDoubleTy(Ctx);
60 }
61};
62
63template <> struct TypeMap<double *> {
64 static Type *get(llvm::LLVMContext &Ctx) {
65 return PointerType::getUnqual(Ctx);
66 }
67
68 static Type *getPointerElemType(llvm::LLVMContext &Ctx) {
69 return Type::getDoubleTy(Ctx);
70 }
71};
72
73template <> struct TypeMap<float *> {
74 static Type *get(llvm::LLVMContext &Ctx) {
75 return PointerType::getUnqual(Ctx);
76 }
77
78 static Type *getPointerElemType(llvm::LLVMContext &Ctx) {
79 return Type::getFloatTy(Ctx);
80 }
81};
82
83} // namespace proteus
84
85#endif // PROTEUS_FRONTEND_TYPEMAP_HPP
Definition Dispatcher.cpp:14
static Type * get(llvm::LLVMContext &Ctx)
Definition TypeMap.hpp:48
static Type * getPointerElemType(llvm::LLVMContext &)
Definition TypeMap.hpp:50
static Type * getPointerElemType(llvm::LLVMContext &)
Definition TypeMap.hpp:30
static Type * get(llvm::LLVMContext &Ctx)
Definition TypeMap.hpp:28
static Type * getPointerElemType(llvm::LLVMContext &Ctx)
Definition TypeMap.hpp:68
static Type * get(llvm::LLVMContext &Ctx)
Definition TypeMap.hpp:64
static Type * getPointerElemType(llvm::LLVMContext &Ctx)
Definition TypeMap.hpp:58
static Type * get(llvm::LLVMContext &Ctx)
Definition TypeMap.hpp:54
static Type * getPointerElemType(llvm::LLVMContext &)
Definition TypeMap.hpp:24
static Type * get(llvm::LLVMContext &Ctx)
Definition TypeMap.hpp:22
static Type * getPointerElemType(llvm::LLVMContext &Ctx)
Definition TypeMap.hpp:78
static Type * get(llvm::LLVMContext &Ctx)
Definition TypeMap.hpp:74
static bool isSigned()
Definition TypeMap.hpp:44
static Type * get(llvm::LLVMContext &Ctx)
Definition TypeMap.hpp:40
static Type * getPointerElemType(llvm::LLVMContext &)
Definition TypeMap.hpp:42
static Type * get(llvm::LLVMContext &Ctx)
Definition TypeMap.hpp:34
static Type * getPointerElemType(llvm::LLVMContext &)
Definition TypeMap.hpp:36
static Type * get(llvm::LLVMContext &Ctx)
Definition TypeMap.hpp:16
static Type * getPointerElemType(llvm::LLVMContext &)
Definition TypeMap.hpp:18
Definition TypeMap.hpp:13