+
+/* Returns true if the operation is a forking control flow operation. */
+int (is_irn_forking)(const ir_node *node) {
+ return _is_irn_forking(node);
+}
+
+ir_type *(get_irn_type)(ir_node *node) {
+ return _get_irn_type(node);
+}
+
+/* Returns non-zero for constant-like nodes. */
+int (is_irn_constlike)(const ir_node *node) {
+ return _is_irn_constlike(node);
+}
+
+/* Gets the string representation of the jump prediction .*/
+const char *get_cond_jmp_predicate_name(cond_jmp_predicate pred)
+{
+ switch (pred) {
+ default:
+ case COND_JMP_PRED_NONE: return "no prediction";
+ case COND_JMP_PRED_TRUE: return "true taken";
+ case COND_JMP_PRED_FALSE: return "false taken";
+ }
+}
+
+/* Returns the conditional jump prediction of a Cond node. */
+cond_jmp_predicate (get_Cond_jmp_pred)(ir_node *cond) {
+ return _get_Cond_jmp_pred(cond);
+}
+
+/* Sets a new conditional jump prediction. */
+void (set_Cond_jmp_pred)(ir_node *cond, cond_jmp_predicate pred) {
+ _set_Cond_jmp_pred(cond, pred);
+}
+
+/** the get_type/get_type_attr operation must be always implemented */
+static ir_type *get_Null_type(ir_node *n) {
+ return NULL;
+}
+
+/* Sets the get_type operation for an ir_op_ops. */
+ir_op_ops *firm_set_default_get_type(opcode code, ir_op_ops *ops)
+{
+ switch (code) {
+ case iro_Const: ops->get_type = get_Const_type; break;
+ case iro_SymConst: ops->get_type = get_SymConst_value_type; break;
+ case iro_Cast: ops->get_type = get_Cast_type; break;
+ case iro_Proj: ops->get_type = get_Proj_type; break;
+ default:
+ /* not allowed to be NULL */
+ if (! ops->get_type)
+ ops->get_type = get_Null_type;
+ break;
+ }
+ return ops;
+}
+
+/** Return the attribute type of a SymConst node if exists */
+static ir_type *get_SymConst_attr_type(ir_node *self) {
+ symconst_kind kind = get_SymConst_kind(self);
+ if (kind == symconst_type_tag || kind == symconst_size)
+ return get_SymConst_type(self);
+ return NULL;
+}
+
+/** Return the attribute entity of a SymConst node if exists */
+static entity *get_SymConst_attr_entity(ir_node *self) {
+ symconst_kind kind = get_SymConst_kind(self);
+ if (kind == symconst_addr_ent)
+ return get_SymConst_entity(self);
+ return NULL;
+}
+
+/* Sets the get_type operation for an ir_op_ops. */
+ir_op_ops *firm_set_default_get_type_attr(opcode code, ir_op_ops *ops)
+{
+ switch (code) {
+ case iro_SymConst: ops->get_type_attr = get_SymConst_attr_type; break;
+ case iro_Call: ops->get_type_attr = get_Call_type; break;
+ case iro_Alloc: ops->get_type_attr = get_Alloc_type; break;
+ case iro_Free: ops->get_type_attr = get_Free_type; break;
+ case iro_Cast: ops->get_type_attr = get_Cast_type; break;
+ default:
+ /* not allowed to be NULL */
+ if (! ops->get_type_attr)
+ ops->get_type_attr = get_Null_type;
+ break;
+ }
+ return ops;
+}
+
+/** the get_entity_attr operation must be always implemented */
+static entity *get_Null_ent(ir_node *n) {
+ return NULL;
+}
+
+/* Sets the get_type operation for an ir_op_ops. */
+ir_op_ops *firm_set_default_get_entity_attr(opcode code, ir_op_ops *ops)
+{
+ switch (code) {
+ case iro_SymConst: ops->get_entity_attr = get_SymConst_attr_entity; break;
+ case iro_Sel: ops->get_entity_attr = get_Sel_entity; break;
+ default:
+ /* not allowed to be NULL */
+ if (! ops->get_entity_attr)
+ ops->get_entity_attr = get_Null_ent;
+ break;
+ }
+ return ops;
+}
+
+#ifdef DEBUG_libfirm
+void dump_irn (ir_node *n) {
+ int i, arity = get_irn_arity(n);
+ printf("%s%s: %ld (%p)\n", get_irn_opname(n), get_mode_name(get_irn_mode(n)), get_irn_node_nr(n), (void *)n);
+ if (!is_Block(n)) {
+ ir_node *pred = get_irn_n(n, -1);
+ printf(" block: %s%s: %ld (%p)\n", get_irn_opname(pred), get_mode_name(get_irn_mode(pred)),
+ get_irn_node_nr(pred), (void *)pred);
+ }
+ printf(" preds: \n");
+ for (i = 0; i < arity; ++i) {
+ ir_node *pred = get_irn_n(n, i);
+ printf(" %d: %s%s: %ld (%p)\n", i, get_irn_opname(pred), get_mode_name(get_irn_mode(pred)),
+ get_irn_node_nr(pred), (void *)pred);
+ }
+}
+
+#else /* DEBUG_libfirm */
+void dump_irn (ir_node *n) {}
+#endif /* DEBUG_libfirm */