/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
- *
* This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
+ * Copyright (C) 2012 University of Karlsruhe.
*/
/**
* @file
* @brief Support for libcore IR object output.
* @author Sebastian Hack
- * @version $Id$
*/
#include "config.h"
#include "irloop_t.h"
#include "tv_t.h"
#include "dbginfo_t.h"
+#include "util.h"
/**
* identify a firm object type
{
int res = 2;
bitset_t *b = (bitset_t*)arg->v_ptr;
- size_t p;
char buf[32];
const char *prefix = "";
void *X = (void*)arg->v_ptr;
firm_kind *obj = (firm_kind*)X;
- int i, n;
ir_node *block;
char add[64];
char buf[256];
char tv_buf[256];
- ir_entity *ent;
buf[0] = '\0';
add[0] = '\0';
case k_entity: {
ir_entity *entity = (ir_entity*)X;
snprintf(buf, sizeof(buf), "%s%s", A("ent"),
- isupper(occ->conversion) ? get_entity_ld_name_ex(entity): get_entity_name(entity));
+ isupper((unsigned char)occ->conversion) ? get_entity_ld_name_ex(entity): get_entity_name(entity));
snprintf(add, sizeof(add), "[%ld]", get_entity_nr(entity));
break;
}
snprintf(buf, sizeof(buf), "%s%s %s[%s]", A("irn"), get_irn_opname(node),
get_mode_name(get_irn_mode(node)), get_entity_name(get_SymConst_entity(node)));
} else if (is_Sel(node)) {
+ ir_entity *entity = get_Sel_entity(node);
+ const char *entity_name = "(null)";
+ if (entity != NULL)
+ entity_name = get_entity_name(entity);
snprintf(buf, sizeof(buf), "%s%s %s[%s]", A("irn"), get_irn_opname(node),
- get_mode_name(get_irn_mode(node)), get_entity_name(get_Sel_entity(node)));
+ get_mode_name(get_irn_mode(node)), entity_name);
+ } else if (is_Cmp(node)) {
+ ir_relation relation = get_Cmp_relation(node);
+ snprintf(buf, sizeof(buf), "%s%s %s", A("irn"), get_irn_opname(node), get_relation_string(relation));
} else {
snprintf(buf, sizeof(buf), "%s%s %s", A("irn"), get_irn_opname(node),
get_mode_name(get_irn_mode(node)));
snprintf(buf, sizeof(buf), "%s%s", A("op"), get_op_name(op));
break;
}
- case k_ir_compound_graph_path: {
- compound_graph_path *path = (compound_graph_path*)X;
- n = get_compound_graph_path_length(path);
-
- for (i = 0; i < n; ++i) {
- ent = get_compound_graph_path_node(path, i);
-
- strncat(buf, ".", sizeof(buf)-1);
- strncat(buf, get_entity_name(ent), sizeof(buf)-1);
- if (is_Array_type(get_entity_owner(ent))) {
- snprintf(add, sizeof(add), "[%ld]",
- get_compound_graph_path_array_index(path, i));
- strncat(buf, add, sizeof(buf)-1);
- }
- }
- add[0] = '\0';
- break;
- }
- case k_ir_extblk: {
- ir_extblk *extblk = (ir_extblk*)X;
- snprintf(buf, sizeof(buf), "ExtBlock");
- snprintf(add, sizeof(add), "[%ld]", get_irn_node_nr(get_extbb_leader(extblk)));
- break;
- }
default:
snprintf(buf, sizeof(buf), "UNKWN");
}
if (occ->flag_plus)
- strncat(buf, add, sizeof(buf)-1);
+ strncat(buf, add, sizeof(buf)-strlen(buf)-1);
return lc_arg_append(app, occ, buf, strlen(buf));
#undef A
static int firm_emit_pnc(lc_appendable_t *app,
const lc_arg_occ_t *occ, const lc_arg_value_t *arg)
{
- int value = arg->v_int;
- const char *p = get_pnc_string(value);
+ ir_relation value = (ir_relation)arg->v_int;
+ const char *p = get_relation_string(value);
return lc_arg_append(app, occ, p, strlen(p));
}
{"firm:irn_nr", 'N'},
{"firm:mode", 'm'},
{"firm:block", 'B'},
- {"firm:cg_path", 'P'},
};
size_t i;
lc_arg_add_std(env);
lc_arg_register(env, "firm", 'F', &firm_handler);
- for (i = 0; i < sizeof(args)/sizeof(args[0]); ++i)
+ for (i = 0; i != ARRAY_SIZE(args); ++i)
lc_arg_register(env, args[i].name, args[i].letter, &firm_handler);
lc_arg_register(env, "firm:ident", 'I', &ident_handler);