add AINSTR_END to the end of functions so the debug-printing knows when to end...

This commit is contained in:
Wolfgang Bumiller 2012-07-04 13:29:26 +02:00
parent 7245b675b2
commit 29091971d2
2 changed files with 23 additions and 9 deletions

9
ir.c
View file

@ -2310,6 +2310,7 @@ tailcall:
static bool gen_function_code(ir_function *self) static bool gen_function_code(ir_function *self)
{ {
ir_block *block; ir_block *block;
prog_section_statement stmt;
/* Starting from entry point, we generate blocks "as they come" /* Starting from entry point, we generate blocks "as they come"
* for now. Dead blocks will not be translated obviously. * for now. Dead blocks will not be translated obviously.
@ -2327,6 +2328,14 @@ static bool gen_function_code(ir_function *self)
printf("failed to generate blocks for '%s'\n", self->name); printf("failed to generate blocks for '%s'\n", self->name);
return false; return false;
} }
/* otherwise code_write crashes since it debug-prints functions until AINSTR_END */
stmt.opcode = AINSTR_END;
stmt.o1.u1 = 0;
stmt.o2.u1 = 0;
stmt.o3.u1 = 0;
if (code_statements_add(stmt) < 0)
return false;
return true; return true;
} }

View file

@ -29,6 +29,8 @@ int main()
DEFVAR(f5); DEFVAR(f5);
DEFVAR(print); DEFVAR(print);
/* opts_debug = true; */
#if 0 #if 0
BUILTIN(print, TYPE_VOID, -1); BUILTIN(print, TYPE_VOID, -1);
PARAM(TYPE_STRING, text); PARAM(TYPE_STRING, text);
@ -43,6 +45,9 @@ MKCONSTFLOAT(f0, 0.0);
MKCONSTFLOAT(f1, 1.0); MKCONSTFLOAT(f1, 1.0);
MKCONSTFLOAT(f5, 5.0); MKCONSTFLOAT(f5, 5.0);
FUNCTION(foo, TYPE_VOID);
ENDFUNCTION(foo);
FUNCTION(main, TYPE_VOID); FUNCTION(main, TYPE_VOID);
VAR(TYPE_FLOAT, vi); VAR(TYPE_FLOAT, vi);