2 * A little printf understanding some firm types.
3 * @author Sebastian Hack
13 * Something that can append strings and chars to something.
15 typedef struct _appender_t {
16 void (*append_char)(void *object, size_t n, char ch);
17 void (*append_str)(void *object, size_t n, const char *str);
21 * A callback function type to add something to an appender.
22 * @param app The appender.
23 * @param object The object for the appender.
24 * @param limit The limit for the appender.
25 * @param arg The thing to append.
27 typedef void (ir_printf_cb_t)(const appender_t *app, void *object, size_t limit, const void *arg);
30 * A string formatting routine for ir nodes.
31 * This function rudimentarily implements a kind of printf(3) for ir
32 * nodes. Following conversion specifiers. No length, special or field
33 * width specifiers are accepted.
36 * - %n A full description of a node.
37 * - %o The opcode name of an ir node.
38 * - %m The mode name of an ir mode.
39 * - %N The node number of an ir node.
40 * - %b The block node number of the nodes block.
43 * Each of these can be prepended by a '+' which means, that the given
44 * pointer is a collection of items specified by the format. In this
45 * case you also have to pass an iterator interface to ir_printf
46 * suitable for the instance of the collection. So, imagine you have a
47 * <tt>pset</tt> of ir_nodes and want to dump it, you write:
51 * ir_printf("Some nodes: %+n\n", it_pset, nodes);
53 * The <tt>it_pset</tt> is an iterator interface (of type
54 * <tt>iterator_t</tt> that allows the dumper to traverse the set.
56 * As special case when working with collections, you can also give a
57 * callback function which will be invoked on each element in the
58 * collection. It gets the appender (the thing where the textual
59 * representation of the element is written to) and its parameters
60 * passed by the dumping function. Suppose you have your own datatype
61 * <tt>xyz_t</tt> and want to dump a pset of it, you have:
63 * void xyz_dump(const appender_t *app, void *object, size_t limit,
66 * const xyz_t *xyz = arg;
67 * app->append_str(object, limit, xyz->name);
72 * ir_printf("A set of xyz\'s: %+C\n", it_pset, xyzs, xyz_dump);
75 * @param fmt The format string.
77 void ir_printf(const char *fmt, ...);
82 void ir_fprintf(FILE *f, const char *fmt, ...);
87 void ir_snprintf(char *buf, size_t n, const char *fmt, ...);
91 #define ir_debugf ir_printf
92 #define ir_fdebugf ir_fprintf
96 static INLINE void ir_debugf(const char *fmt, ...)
100 static INLINE void ir_fdebugf(FILE *, const char *fmt, ...)