Commit a855b8f6 authored by Sebastian Hack's avatar Sebastian Hack
Browse files

Minor corrections.

[r4590]
parent 49ad2542
...@@ -711,4 +711,5 @@ static void normalize_proj_walker(ir_node *n, void *env) ...@@ -711,4 +711,5 @@ static void normalize_proj_walker(ir_node *n, void *env)
void normalize_proj_nodes(ir_graph *irg) void normalize_proj_nodes(ir_graph *irg)
{ {
irg_walk_graph(irg, NULL, normalize_proj_walker, NULL); irg_walk_graph(irg, NULL, normalize_proj_walker, NULL);
set_irg_outs_inconsistent(irg);
} }
...@@ -900,7 +900,7 @@ int is_forking_op(const ir_node *node); ...@@ -900,7 +900,7 @@ int is_forking_op(const ir_node *node);
* register_additional_node_data() before. * register_additional_node_data() before.
* @param node The ir node to get the data from. * @param node The ir node to get the data from.
* @param type The type of the data you registered. * @param type The type of the data you registered.
* @param off The value returned by register_additional_node_data. * @param off The value returned by register_additional_node_data().
* @return A pointer of type @p type. * @return A pointer of type @p type.
*/ */
#define get_irn_data(node,type,off) \ #define get_irn_data(node,type,off) \
......
...@@ -273,11 +273,14 @@ ident *(get_op_ident)(ir_op *op){ ...@@ -273,11 +273,14 @@ ident *(get_op_ident)(ir_op *op){
const char *get_op_pin_state_name(op_pin_state s) { const char *get_op_pin_state_name(op_pin_state s) {
switch(s) { switch(s) {
case op_pin_state_floats: return "op_pin_state_floats"; #define XXX(s) case s: return #s
case op_pin_state_pinned: return "op_pin_state_pinned"; XXX(op_pin_state_floats);
case op_pin_state_exc_pinned: return "op_pin_state_exc_pinned"; XXX(op_pin_state_pinned);
case op_pin_state_mem_pinned: return "op_pin_state_mem_pinned"; XXX(op_pin_state_exc_pinned);
XXX(op_pin_state_mem_pinned);
#undef XXX
} }
return "<none>";
} }
op_pin_state (get_op_pinned)(const ir_op *op){ op_pin_state (get_op_pinned)(const ir_op *op){
......
...@@ -25,9 +25,11 @@ ...@@ -25,9 +25,11 @@
#include <stdarg.h> #include <stdarg.h>
#ifdef HAVE_STRING_H #ifdef HAVE_STRING_H
# include <string.h> #include <string.h>
#endif #endif
#include <ctype.h>
#include "ident.h" #include "ident.h"
#include "irmode_t.h" #include "irmode_t.h"
#include "irnode_t.h" #include "irnode_t.h"
...@@ -104,6 +106,90 @@ static INLINE void ir_common_printf(const appender_t *app, void *object, ...@@ -104,6 +106,90 @@ static INLINE void ir_common_printf(const appender_t *app, void *object,
va_end(args); va_end(args);
} }
#if 0
static int is_std_fmt(const char *fmt)
{
static const char *fmt_re_str =
"^[0 -+#']?[1-9]*(\\.[1-9]*)?[hlLqjzt]?[diouxXeEfFgGaAc]";
static regex_t fmt_re;
static int preapred_re = 0;
regmatch_t match[1];
int res;
if(!preapred_re) {
int res = regcomp(&fmt_re, fmt_re_str, REG_EXTENDED);
assert(res == 0 && "Could not prepare regex");
preapred_re = 1;
}
res = regexec(&fmt_re, fmt, 1, &match[0], 0);
#if 0
if(res != 0) {
char buf[256];
regerror(res, &fmt_re, buf, sizeof(buf));
printf("%s ", buf);
}
printf("res: %d, start: %d, end: %d\n",
res, match[0].rm_so, match[0].rm_eo);
#endif
return res == 0 ? match[0].rm_eo : -1;
}
#endif
struct settings {
char pad;
int width;
int left_just;
int put_plus;
int alternate;
};
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
static void dump_with_settings(const appender_t *app, void *object, size_t limit,
const struct settings *settings, const char *str)
{
if(settings->width >= 0) {
int i;
size_t n = strlen(str);
int lim = MIN(settings->width, limit);
int to_print = MIN(lim, n);
int to_pad = to_print - lim;
if(!settings->left_just)
for(i = 0; i < to_pad; ++i)
app->append_char(object, lim, settings->pad);
app->append_str(object, to_print, str);
if(!settings->left_just)
for(i = 0; i < to_pad; ++i)
app->append_char(object, lim, settings->pad);
}
else
app->append_str(object, limit, str);
}
/* Length specifiers. */
enum {
len_char,
len_short,
len_int,
len_long,
len_long_long
};
/** /**
* A small printf helper routine for ir nodes. * A small printf helper routine for ir nodes.
* @param app An appender (this determines where the stuff is dumped * @param app An appender (this determines where the stuff is dumped
...@@ -116,7 +202,8 @@ static INLINE void ir_common_printf(const appender_t *app, void *object, ...@@ -116,7 +202,8 @@ static INLINE void ir_common_printf(const appender_t *app, void *object,
static void ir_common_vprintf(const appender_t *app, void *object, static void ir_common_vprintf(const appender_t *app, void *object,
size_t limit, const char *fmt, va_list args) size_t limit, const char *fmt, va_list args)
{ {
char buf[256]; const char *str;
char buf[4096];
int i, n; int i, n;
#define DUMP_STR(s) app->append_str(object, limit, s) #define DUMP_STR(s) app->append_str(object, limit, s)
...@@ -126,35 +213,130 @@ static void ir_common_vprintf(const appender_t *app, void *object, ...@@ -126,35 +213,130 @@ static void ir_common_vprintf(const appender_t *app, void *object,
char ch = fmt[i]; char ch = fmt[i];
if(ch == '%') { if(ch == '%') {
char next_ch = fmt[++i]; int len;
const char *len_str = "";
struct settings settings;
settings.alternate = 0;
settings.pad = ' ';
settings.width = -1;
settings.left_just = 0;
settings.put_plus = 0;
ch = fmt[++i];
/* Clear the temporary buffer */ /* Clear the temporary buffer */
buf[0] = '\0'; buf[0] = '\0';
switch(next_ch) { /* Set the string to print to the buffer by default. */
case '%': str = buf;
DUMP_CH('%');
while(strchr("#0-+", ch)) {
switch(ch) {
case '#':
settings.alternate = 1;
break;
case '0':
settings.pad = '0';
break;
case '-':
settings.left_just = 1;
break;
case '+':
settings.put_plus = 1;
break;
}
ch = fmt[++i];
}
/* Read the field width */
{
char *endptr;
int increase;
settings.width = (int) strtol(&fmt[i], &endptr, 10);
increase = (char *) endptr - &fmt[i];
ch = fmt[i += increase];
if(increase == 0)
settings.width = -1;
}
/* Ignore the precision */
if(ch == '.')
while(isdigit(ch = fmt[++i]));
/* read the length modifier. */
switch(ch) {
case 'h':
len_str = "h";
len = len_short;
if((ch = fmt[++i]) == 'h') {
len_str = "hh";
len = len_char;
}
break; break;
case 's':
DUMP_STR(va_arg(args, const char *)); case 'l':
len_str = "l";
len = len_long;
if((ch = fmt[++i]) == 'l') {
len_str = "ll";
len = len_long_long;
}
break; break;
case 'I': default:
DUMP_STR(get_id_str(va_arg(args, ident *))); len = len_int;
break; }
/* Do the conversion specifier. */
switch(ch) {
case 'e': /* The percent itself */
DUMP_STR(get_entity_name(va_arg(args, entity *))); case '%':
break; buf[0] = '%';
buf[1] = '\0';
break;
case 'E': case 'c':
DUMP_STR(get_entity_ld_name(va_arg(args, entity *))); buf[0] = va_arg(args, int);
break; buf[1] = '\0';
break;
case 's':
str = va_arg(args, const char *);
break;
case 'p': case 'p':
snprintf(buf, sizeof(buf), "%p", va_arg(args, void *)); snprintf(buf, sizeof(buf), "%p", va_arg(args, void *));
break; break;
case 'd':
case 'x':
case 'X':
case 'o':
{
char fmt_str[16];
snprintf(fmt_str, sizeof(fmt_str), "%%%s%c", len_str, ch);
vsnprintf(buf, sizeof(buf), fmt_str, args);
}
break;
case 'I':
str = get_id_str(va_arg(args, ident *));
break;
case 'e':
str = get_entity_name(va_arg(args, entity *));
break;
case 'E':
str = get_entity_ld_name(va_arg(args, entity *));
break;
case 't': case 't':
tarval_snprintf(buf, sizeof(buf), va_arg(args, tarval *)); tarval_snprintf(buf, sizeof(buf), va_arg(args, tarval *));
break; break;
...@@ -167,8 +349,8 @@ static void ir_common_vprintf(const appender_t *app, void *object, ...@@ -167,8 +349,8 @@ static void ir_common_vprintf(const appender_t *app, void *object,
} }
break; break;
case 'o': case 'O':
DUMP_STR(get_irn_opname(va_arg(args, ir_node *))); str = get_irn_opname(va_arg(args, ir_node *));
break; break;
case 'N': case 'N':
...@@ -176,7 +358,7 @@ static void ir_common_vprintf(const appender_t *app, void *object, ...@@ -176,7 +358,7 @@ static void ir_common_vprintf(const appender_t *app, void *object,
break; break;
case 'm': case 'm':
DUMP_STR(get_mode_name(va_arg(args, ir_mode *))); str = get_mode_name(va_arg(args, ir_mode *));
break; break;
case 'b': case 'b':
...@@ -184,7 +366,7 @@ static void ir_common_vprintf(const appender_t *app, void *object, ...@@ -184,7 +366,7 @@ static void ir_common_vprintf(const appender_t *app, void *object,
get_irn_node_nr(get_nodes_block(va_arg(args, ir_node *)))); get_irn_node_nr(get_nodes_block(va_arg(args, ir_node *))));
break; break;
case '+': case '*':
{ {
iterator_t *it = va_arg(args, iterator_t *); iterator_t *it = va_arg(args, iterator_t *);
void *collection = va_arg(args, void *); void *collection = va_arg(args, void *);
...@@ -218,9 +400,7 @@ static void ir_common_vprintf(const appender_t *app, void *object, ...@@ -218,9 +400,7 @@ static void ir_common_vprintf(const appender_t *app, void *object,
break; break;
} }
/* Dump the temporary buffer, if something is in it. */ dump_with_settings(app, object, limit, &settings, str);
if(buf[0] != '\0')
DUMP_STR(buf);
} }
else else
......
...@@ -188,7 +188,7 @@ rflct_sig_t *rflct_signature_allocate(int defs, int uses); ...@@ -188,7 +188,7 @@ rflct_sig_t *rflct_signature_allocate(int defs, int uses);
* @param name The name of the argument. * @param name The name of the argument.
* @param mc The mode class of the argument. * @param mc The mode class of the argument.
* @param is_variadic true, if the argument is variadic. * @param is_variadic true, if the argument is variadic.
* @param mode_equals This variable has following meaning. If the * @param mode_equals This variable has following meaning: If the
* argument is variadic, a 1 indicates that all operands binding to this * argument is variadic, a 1 indicates that all operands binding to this
* argument must have the same mode. A 0 indicates, that their mode must * argument must have the same mode. A 0 indicates, that their mode must
* be of the specified mode class but can differ. If the argument is non * be of the specified mode class but can differ. If the argument is non
......
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