summaryrefslogtreecommitdiffhomepage
path: root/ir/be/beemitter.h
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2016-10-19 14:41:56 +0200
committerChristoph Mallon <christoph.mallon@gmx.de>2016-10-19 15:25:59 +0200
commit6a01dd0a907fd6fb5be2fd4737fd3fee163731a0 (patch)
tree910de76c3c69777683ed8964b18597d389c79677 /ir/be/beemitter.h
parent24c5a97fd02ccc5f1fb8f43f640d3bd2fe0ccc68 (diff)
be: Factor out (almost) common code in ${ARCH}_emitf() into the macro BE_EMITF().
This save quite a bit of code duplication. Also the code drifted apart in the different backends, which this macro prevents now.
Diffstat (limited to 'ir/be/beemitter.h')
-rw-r--r--ir/be/beemitter.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/ir/be/beemitter.h b/ir/be/beemitter.h
index d5f7ce0..56ab3db 100644
--- a/ir/be/beemitter.h
+++ b/ir/be/beemitter.h
@@ -96,4 +96,25 @@ static inline size_t be_emit_get_column(void)
return obstack_object_size(&emit_obst);
}
+#define BE_EMITF(node, fmt, ap, in_delay_slot) \
+ va_list ap; \
+ va_start(ap, fmt); \
+ be_emit_char('\t'); \
+ if (in_delay_slot) \
+ be_emit_char(' '); \
+ for (size_t n;;) \
+ if (n = strcspn(fmt, "\n%"), be_emit_string_len(fmt, n), fmt += n, *fmt == '\0') { \
+ be_emit_finish_line_gas(node); \
+ va_end(ap); \
+ break; \
+ } else if (*fmt == '\n') { \
+ ++fmt; \
+ be_emit_char('\n'); \
+ be_emit_write_line(); \
+ be_emit_char('\t'); \
+ } else if (*++fmt == '%') { \
+ ++fmt; \
+ be_emit_char('%'); \
+ } else
+
#endif