1 #ifndef LLVM_CODEGEN_VISITOR_H
2 #define LLVM_CODEGEN_VISITOR_H
7 #define PRINT_TYPE(t) if (t == VOID) printf("void"); \
8 else printf("i%d", _get_type_size(t))
10 #define PRINT_VALUE(n, i) if (n->kind == IDENTIFIER && n->parent->kind == PARAMETER) \
11 printf("%%%s", n->symbol->name); \
13 if (i == -1) printf("%d", ast_node_get_value_as_int(n)); \
14 else printf("%%%d", i); \
17 static Symbol
*symtab
;
18 static Symbol
*global_symtab
;
20 Visitor
*llvm_codegen_new();
22 void llvm_codegen_visit_program (struct _Visitor
*, struct AstNode
*);
23 void llvm_codegen_visit_programdecl (struct _Visitor
*, struct AstNode
*);
24 void llvm_codegen_visit_procfunc_list (struct _Visitor
*, struct AstNode
*);
25 void llvm_codegen_visit_procfunc (struct _Visitor
*, struct AstNode
*);
26 void llvm_codegen_visit_vardecl_list (struct _Visitor
*, struct AstNode
*);
27 void llvm_codegen_visit_vardecl (struct _Visitor
*, struct AstNode
*);
28 void llvm_codegen_visit_identifier_list (struct _Visitor
*, struct AstNode
*);
29 void llvm_codegen_visit_param_list (struct _Visitor
*, struct AstNode
*);
30 void llvm_codegen_visit_parameter (struct _Visitor
*, struct AstNode
*);
31 void llvm_codegen_visit_statement_list(struct _Visitor
*, struct AstNode
*);
32 void llvm_codegen_visit_printint_stmt (struct _Visitor
*, struct AstNode
*);
33 void llvm_codegen_visit_printchar_stmt (struct _Visitor
*, struct AstNode
*);
34 void llvm_codegen_visit_printbool_stmt (struct _Visitor
*, struct AstNode
*);
35 void llvm_codegen_visit_printline_stmt (struct _Visitor
*, struct AstNode
*);
36 void llvm_codegen_visit_assignment_stmt (struct _Visitor
*, struct AstNode
*);
37 void llvm_codegen_visit_if_stmt (struct _Visitor
*, struct AstNode
*);
38 void llvm_codegen_visit_while_stmt (struct _Visitor
*, struct AstNode
*);
39 void llvm_codegen_visit_for_stmt (struct _Visitor
*, struct AstNode
*);
40 void llvm_codegen_visit_binary_expr (struct _Visitor
*, struct AstNode
*);
41 void llvm_codegen_visit_notfactor (struct _Visitor
*, struct AstNode
*);
42 void llvm_codegen_visit_call (struct _Visitor
*, struct AstNode
*);
43 void llvm_codegen_visit_callparam_list (struct _Visitor
*, struct AstNode
*);
44 void llvm_codegen_visit_callparam (struct _Visitor
*, struct AstNode
*);
45 void llvm_codegen_visit_identifier (struct _Visitor
*, struct AstNode
*);
46 void llvm_codegen_visit_literal (struct _Visitor
*, struct AstNode
*);
47 void llvm_codegen_visit_binary_op (struct _Visitor
*, struct AstNode
*);
48 void llvm_codegen_visit_not_op (struct _Visitor
*, struct AstNode
*);
50 #endif // LLVM_CODEGEN_VISITOR_H