- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCodeGen.h
More file actions
Latest commit
executable file
·33 lines (28 loc) · 1.67 KB
/
Copy pathCodeGen.h
File metadata and controls
executable file
·33 lines (28 loc) · 1.67 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
#ifndef CODEGEN_H
#defineCODEGEN_H
#include<llvm/ADT/ArrayRef.h>
#include<llvm/IR/LLVMContext.h>
#include<llvm/PassManager.h>
#include<llvm/IR/Module.h>
#include<llvm/IR/Function.h>
#include<llvm/IR/BasicBlock.h>
#include<llvm/IR/IRBuilder.h>
#include"llvm/Support/raw_ostream.h"
#include"llvm/Support/raw_os_ostream.h"
#include<string>
#include<iostream>
#include<fstream>
#include<map>
#include"main.h"
usingnamespacellvm;
voidmakeProgram(ast_program ast);
voidmakeClassHeader(Module* mod,ast_classdecl *classDecl,std::map<std::string,ConstantInt*> &classFields);
voidmakeClassBody(Module* mod,ast_classdecl *classDecl,std::map<std::string,Value*> &varScope,std::map<std::string,ConstantInt*> &classFields);
voidmakeMethodHeaders(Module* mod, ast_methoddecl* methodDecl);
voidmakeMethodBody(Module* mod, ast_methoddecl* methodDecl,std::map<std::string,Value*> &varScope,std::map<std::string,ConstantInt*> &classFields);
BasicBlock* makeVarDeclaration(Module* mod, ast_vardecl* varDecl,std::map<std::string,Value*> &varScope, Function* parentFunc = nullptr, BasicBlock* parentBB = nullptr);
BasicBlock* makeStatement(Module* mod,ast_stmt* stmt, std::map<std::string,Value*> &varScope, Function* parentFunc=nullptr, BasicBlock* parentBB=nullptr,std::map<std::string,ConstantInt*> *classFields = nullptr);
std::tuple<Value*,BasicBlock*> makeExpression(Module* mod, ast_expr* expr,std::map<std::string,Value*> &varScope, Function* parentFunc = nullptr, BasicBlock* parentBB = nullptr,std::map<std::string,ConstantInt*> *classFields = nullptr);
Type* makeType(Module* mod, ast_type typeToMake);
voidattachNewBasicBlock(Module* mod, BasicBlock* parentBB, BasicBlock* &bbToAttach);
#endif