summaryrefslogtreecommitdiffhomepage
path: root/ir/be/beemitter.c
diff options
context:
space:
mode:
authorChristoph Mallon <mallon@cs.uni-saarland.de>2014-10-21 19:20:45 +0200
committerChristoph Mallon <mallon@cs.uni-saarland.de>2014-10-22 18:48:22 +0200
commit9d80d3ee78923aed2c305a9fd0dab1c8bcc7b731 (patch)
treec8de46c878f3e071dedb04863ecf919fa9a9b617 /ir/be/beemitter.c
parenteab08761524d26704002fdd0284304fccdc68c4d (diff)
be: Cleanup.
This also condenses double spaces at the end of verbose asm comments, which have no debug location.
Diffstat (limited to 'ir/be/beemitter.c')
-rw-r--r--ir/be/beemitter.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/ir/be/beemitter.c b/ir/be/beemitter.c
index 7ae5869..3a797f1 100644
--- a/ir/be/beemitter.c
+++ b/ir/be/beemitter.c
@@ -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();
}