Commit 9d80d3ee authored by Christoph Mallon's avatar Christoph Mallon
Browse files

be: Cleanup.

This also condenses double spaces at the end of verbose asm comments, which have no debug location.
parent eab08761
......@@ -18,13 +18,14 @@
#include "ident.h"
#include "tv.h"
#include "dbginfo.h"
#include "util.h"
FILE *emit_file;
struct obstack emit_obst;
void be_emit_init(FILE *file)
{
emit_file = file;
emit_file = file;
obstack_init(&emit_obst);
}
......@@ -41,7 +42,6 @@ void be_emit_irvprintf(const char *fmt, va_list args)
void be_emit_irprintf(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
be_emit_irvprintf(fmt, ap);
va_end(ap);
......@@ -49,9 +49,8 @@ void be_emit_irprintf(const char *fmt, ...)
void be_emit_write_line(void)
{
size_t len = obstack_object_size(&emit_obst);
char *line = (char*)obstack_finish(&emit_obst);
size_t const len = obstack_object_size(&emit_obst);
char *const line = (char*)obstack_finish(&emit_obst);
fwrite(line, 1, len, emit_file);
obstack_free(&emit_obst, line);
}
......@@ -59,39 +58,26 @@ void be_emit_write_line(void)
void be_emit_pad_comment(void)
{
size_t len = obstack_object_size(&emit_obst);
if (len > 30)
len = 30;
len = MIN(len, 30);
/* 34 spaces */
be_emit_string_len(" ", 34 - len);
}
void be_emit_finish_line_gas(const ir_node *node)
{
dbg_info *dbg;
src_loc_t loc;
if (node == NULL || !be_options.verbose_asm) {
if (node && be_options.verbose_asm) {
be_emit_pad_comment();
dbg_info *const dbg = get_irn_dbg_info(node);
src_loc_t const loc = ir_retrieve_dbg_info(dbg);
char const *const fmt =
!loc.file ? "/* %+F */\n" :
loc.line == 0 ? "/* %+F %s */\n" :
loc.column == 0 ? "/* %+F %s:%u */\n" :
/* */ "/* %+F %s:%u:%u */\n";
be_emit_irprintf(fmt, node, loc.file, loc.line, loc.column);
} else {
be_emit_char('\n');
be_emit_write_line();
return;
}
be_emit_pad_comment();
be_emit_cstring("/* ");
be_emit_irprintf("%+F ", node);
dbg = get_irn_dbg_info(node);
loc = ir_retrieve_dbg_info(dbg);
if (loc.file) {
be_emit_string(loc.file);
if (loc.line != 0) {
be_emit_irprintf(":%u", loc.line);
if (loc.column != 0) {
be_emit_irprintf(":%u", loc.column);
}
}
}
be_emit_cstring(" */\n");
be_emit_write_line();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment