]> git.mdlowis.com Git - proto/obnc.git/commitdiff
added base type definitions for llvm ir
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 8 Feb 2022 21:33:20 +0000 (16:33 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 8 Feb 2022 21:33:20 +0000 (16:33 -0500)
cerise/backend/ssa/codegen.c
cerise/backend/test/codegen.c
cerise/inc/cerise.h
cerise/src/grammar.c

index 140d9ec9a28453640fb5a3e00121bbb4493f41c9..fc09ae9f377e80d7b034bfd59a39f5f13ae7e65c 100644 (file)
@@ -40,6 +40,14 @@ void emit_type(Type* type)
     }
 }
 
+void codegen_init(Parser* p)
+{
+    printf("@Bool = type i1\n");
+    printf("@Int = type i64\n");
+    printf("@Real = type double\n");
+    printf("@Void = type void\n");
+}
+
 void codegen_symbol(Parser* p, Symbol* sym)
 {
     (void)p;
index 79056130504ae3a79a3380567ee2d522f5ef789e..373be444a91dc115ed671f6e14e638ddd77972b5 100644 (file)
@@ -26,6 +26,11 @@ Type StringType = {
     .size = -1
 };
 
+void codegen_init(Parser* p)
+{
+    (void)p;
+}
+
 void codegen_symbol(Parser* p, Symbol* sym)
 {
     (void)p;
index f2ccfbeb398e78da1412eb08c26566dfb3ee5702..0e9d625994986e188b933463d423a829b864fabf 100644 (file)
@@ -287,5 +287,6 @@ void ssa_print_asm(Parser* p, SsaBlock* block);
  *****************************************************************************/
 extern Type VoidType, BoolType, IntType, RealType, StringType;
 
+void codegen_init(Parser* p);
 void codegen_symbol(Parser* p, Symbol* sym);
 void codegen_block(Parser* p, SsaBlock* block);
index 17ad0fabe28372e0d36650c6e76b748fed7b5f7e..8b015b0fb12a060e78bdab0a0e9836b23027e27e 100644 (file)
@@ -720,6 +720,8 @@ void compile(char* fname)
     p->types[p->ntypes++] = &RealType;
     symbol_new(p, 0, "String", SYM_TYPE, 0)->type = &StringType;
     p->types[p->ntypes++] = &StringType;
+
+    codegen_init(p);
     module(p);
 }