-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypeStream.h
More file actions
43 lines (35 loc) · 1.16 KB
/
TypeStream.h
File metadata and controls
43 lines (35 loc) · 1.16 KB
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
#ifndef TINYCOMPILER_TYPESYSTEM_H
#define TINYCOMPILER_TYPESYSTEM_H
#include <llvm/IR/Type.h>
#include <llvm/IR/Value.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Module.h>
#include <string>
#include <map>
#include <vector>
#include "node.h"
using std::string;
using namespace llvm;
using TypeNamePair = std::pair<string,string>;
class TypeStream{
LLVMContext& context;
std::map<Type*,std::map<Type*,CastInst::CastOps>> _castTable;
void addCast(Type* from,Type* to,CastInst::CastOps op);
public:
Type* floatTy =Type::getFloatTy(context);
Type* intTy =Type::getInt32Ty(context);
Type* charTy =Type::getInt8Ty(context);
Type* doubleTy =Type::getFloatTy(context);
Type* stringTy = Type::getInt8PtrTy(context);
Type* voidTy = Type::getVoidTy(context);
Type* boolTy = Type::getInt1Ty(context);
TypeStream(LLVMContext& context);
Type* getVarType(const Identifier& value);
Type* getVarType(string typeStr);
Value* getDefaultValue(string typeStr,LLVMContext& context);
Value* cast(Value* value,Type* type,BasicBlock* block);
static string llvmTypeToString(Value* value);
static string llvmTypeToString(Type* value);
};
#endif