libFirm 1.20
libfirm/irnode.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
00003  *
00004  * This file is part of libFirm.
00005  *
00006  * This file may be distributed and/or modified under the terms of the
00007  * GNU General Public License version 2 as published by the Free Software
00008  * Foundation and appearing in the file LICENSE.GPL included in the
00009  * packaging of this file.
00010  *
00011  * Licensees holding valid libFirm Professional Edition licenses may use
00012  * this file in accordance with the libFirm Commercial License.
00013  * Agreement provided with the Software.
00014  *
00015  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017  * PURPOSE.
00018  */
00019 
00025 #ifndef FIRM_IR_IRNODE_H
00026 #define FIRM_IR_IRNODE_H
00027 
00028 #include <stddef.h>
00029 
00030 #include "firm_common.h"
00031 #include "typerep.h"
00032 #include "irop.h"
00033 #include "irmode.h"
00034 #include "begin.h"
00035 #include "nodeops.h"
00036 
00067 FIRM_API int is_ir_node(const void *thing);
00068 
00074 FIRM_API int get_irn_arity(const ir_node *node);
00075 
00080 FIRM_API ir_node *get_irn_n(const ir_node *node, int n);
00081 
00089 FIRM_API void set_irn_in(ir_node *node, int arity, ir_node *in[]);
00090 
00101 FIRM_API int add_irn_dep(ir_node *node, ir_node *dep);
00102 
00110 FIRM_API void add_irn_deps(ir_node *tgt, ir_node *src);
00111 
00117 FIRM_API int get_irn_deps(const ir_node *node);
00118 
00125 FIRM_API ir_node *get_irn_dep(const ir_node *node, int pos);
00126 
00133 FIRM_API void set_irn_dep(ir_node *node, int pos, ir_node *dep);
00134 
00136 FIRM_API void set_irn_n(ir_node *node, int n, ir_node *in);
00142 FIRM_API int add_irn_n(ir_node *node, ir_node *in);
00144 FIRM_API void set_irn_mode(ir_node *node, ir_mode *mode);
00146 FIRM_API ir_mode *get_irn_mode(const ir_node *node);
00148 FIRM_API ir_op *get_irn_op(const ir_node *node);
00150 FIRM_API void set_irn_op(ir_node *node, ir_op *op);
00152 FIRM_API unsigned get_irn_opcode(const ir_node *node);
00154 FIRM_API const char *get_irn_opname(const ir_node *node);
00156 FIRM_API ident *get_irn_opident(const ir_node *node);
00158 FIRM_API int get_irn_pred_pos(ir_node *node, ir_node *arg);
00160 FIRM_API ir_visited_t get_irn_visited(const ir_node *node);
00162 FIRM_API void set_irn_visited(ir_node *node, ir_visited_t visited);
00164 FIRM_API void mark_irn_visited(ir_node *node);
00166 FIRM_API int irn_visited(const ir_node *node);
00169 FIRM_API int irn_visited_else_mark(ir_node *node);
00170 
00175 FIRM_API void set_irn_link(ir_node *node, void *link);
00176 
00178 FIRM_API void *get_irn_link(const ir_node *node);
00179 
00181 FIRM_API ir_graph *get_irn_irg(const ir_node *node);
00182 
00186 FIRM_API long get_irn_node_nr(const ir_node *node);
00187 
00195 FIRM_API op_pin_state get_irn_pinned(const ir_node *node);
00196 
00198 FIRM_API void set_irn_pinned(ir_node *node, op_pin_state state);
00199 
00206 FIRM_API op_pin_state is_irn_pinned_in_irg(const ir_node *node);
00207 
00222 FIRM_API ir_node *new_ir_node(dbg_info *db, ir_graph *irg, ir_node *block,
00223                               ir_op *op, ir_mode *mode,
00224                               int arity, ir_node *const *in);
00225 
00242 FIRM_API ir_node *get_nodes_block(const ir_node *node);
00243 
00245 FIRM_API void set_nodes_block(ir_node *node, ir_node *block);
00246 
00248 FIRM_API int get_Block_n_cfgpreds(const ir_node *block);
00250 FIRM_API ir_node *get_Block_cfgpred(const ir_node *block, int pos);
00252 FIRM_API void set_Block_cfgpred(ir_node *block, int pos, ir_node *pred);
00253 
00267 FIRM_API int get_Block_cfgpred_pos(const ir_node *block, const ir_node *pred);
00268 
00280 FIRM_API ir_node *get_Block_cfgpred_block(const ir_node *node, int pos);
00281 
00283 FIRM_API int get_Block_matured(const ir_node *block);
00285 FIRM_API void set_Block_matured(ir_node *block, int matured);
00286 
00289 FIRM_API ir_visited_t get_Block_block_visited(const ir_node *block);
00291 FIRM_API void set_Block_block_visited(ir_node *block, ir_visited_t visit);
00292 
00294 FIRM_API void mark_Block_block_visited(ir_node *node);
00296 FIRM_API int Block_block_visited(const ir_node *node);
00297 
00299 FIRM_API ir_extblk *get_Block_extbb(const ir_node *block);
00301 FIRM_API void set_Block_extbb(ir_node *block, ir_extblk *extblk);
00303 FIRM_API ir_graph *get_Block_irg(const ir_node *block);
00305 FIRM_API ir_entity *create_Block_entity(ir_node *block);
00307 FIRM_API ir_node *get_Block_phis(const ir_node *block);
00309 FIRM_API void set_Block_phis(ir_node *block, ir_node *phi);
00311 FIRM_API void add_Block_phi(ir_node *block, ir_node *phi);
00313 FIRM_API unsigned get_Block_mark(const ir_node *block);
00315 FIRM_API void set_Block_mark(ir_node *block, unsigned mark);
00316 
00323 FIRM_API ir_type *is_frame_pointer(const ir_node *n);
00324 
00330 FIRM_API int get_End_n_keepalives(const ir_node *end);
00332 FIRM_API ir_node *get_End_keepalive(const ir_node *end, int pos);
00334 FIRM_API void add_End_keepalive(ir_node *end, ir_node *ka);
00336 FIRM_API void set_End_keepalive(ir_node *end, int pos, ir_node *ka);
00337 
00343 FIRM_API void set_End_keepalives(ir_node *end, int n, ir_node *in[]);
00344 
00346 FIRM_API void remove_End_keepalive(ir_node *end, ir_node *irn);
00347 
00349 FIRM_API void remove_End_Bads_and_doublets(ir_node *end);
00350 
00355 FIRM_API void free_End(ir_node *end);
00356 
00364 FIRM_API ir_node **get_Return_res_arr(ir_node *node);
00366 FIRM_API size_t get_Return_n_ress(const ir_node *node);
00368 FIRM_API ir_node *get_Return_res(const ir_node *node, int pos);
00370 FIRM_API void set_Return_res(ir_node *node, int pos, ir_node *res);
00371 
00379 FIRM_API int is_Const_null(const ir_node *node);
00380 
00382 FIRM_API int is_Const_one(const ir_node *node);
00383 
00385 FIRM_API int is_Const_all_one(const ir_node *node);
00386 
00393 FIRM_API int is_strictConv(const ir_node *node);
00394 
00403 FIRM_API int is_SymConst_addr_ent(const ir_node *node);
00404 
00406 #define SYMCONST_HAS_TYPE(kind) ((kind) <= symconst_type_align)
00407 
00409 #define SYMCONST_HAS_ENT(kind) ((kind) == symconst_addr_ent || (kind) == symconst_ofs_ent)
00410 
00412 #define SYMCONST_HAS_ENUM(kind) ((kind) == symconst_enum_const)
00413 
00415 FIRM_API symconst_kind get_SymConst_kind(const ir_node *node);
00417 FIRM_API void set_SymConst_kind(ir_node *node, symconst_kind num);
00418 
00422 FIRM_API ir_type *get_SymConst_type(const ir_node *node);
00424 FIRM_API void set_SymConst_type(ir_node *node, ir_type *tp);
00425 
00429 FIRM_API ir_entity *get_SymConst_entity(const ir_node *node);
00431 FIRM_API void set_SymConst_entity(ir_node *node, ir_entity *ent);
00432 
00436 FIRM_API ir_enum_const *get_SymConst_enum(const ir_node *node);
00438 FIRM_API void set_SymConst_enum(ir_node *node, ir_enum_const *ec);
00439 
00441 FIRM_API union symconst_symbol get_SymConst_symbol(const ir_node *node);
00443 FIRM_API void set_SymConst_symbol(ir_node *node, union symconst_symbol sym);
00444 
00452 FIRM_API ir_node **get_Sel_index_arr(ir_node *node);
00454 FIRM_API int get_Sel_n_indexs(const ir_node *node);
00456 FIRM_API ir_node *get_Sel_index(const ir_node *node, int pos);
00458 FIRM_API void set_Sel_index(ir_node *node, int pos, ir_node *index);
00459 
00467 FIRM_API ir_node **get_Call_param_arr(ir_node *node);
00469 FIRM_API size_t get_Call_n_params(const ir_node *node);
00471 FIRM_API ir_node *get_Call_param(const ir_node *node, int pos);
00473 FIRM_API void set_Call_param(ir_node *node, int pos, ir_node *param);
00474 
00492 FIRM_API int Call_has_callees(const ir_node *node);
00494 FIRM_API size_t get_Call_n_callees(const ir_node *node);
00496 FIRM_API ir_entity *get_Call_callee(const ir_node *node, size_t pos);
00497 
00501 FIRM_API void set_Call_callee_arr(ir_node *node, size_t n, ir_entity **arr);
00503 FIRM_API void remove_Call_callee_arr(ir_node *node);
00504 
00512 FIRM_API ir_node **get_Builtin_param_arr(ir_node *node);
00514 FIRM_API int get_Builtin_n_params(const ir_node *node);
00516 FIRM_API ir_node *get_Builtin_param(const ir_node *node, int pos);
00518 FIRM_API void set_Builtin_param(ir_node *node, int pos, ir_node *param);
00519 
00523 FIRM_API const char *get_builtin_kind_name(ir_builtin_kind kind);
00524 
00528 FIRM_API int is_unop(const ir_node *node);
00530 FIRM_API ir_node *get_unop_op(const ir_node *node);
00532 FIRM_API void set_unop_op(ir_node *node, ir_node *op);
00533 
00537 FIRM_API int is_binop(const ir_node *node);
00539 FIRM_API ir_node *get_binop_left(const ir_node *node);
00541 FIRM_API void set_binop_left(ir_node *node, ir_node *left);
00543 FIRM_API ir_node *get_binop_right(const ir_node *node);
00545 FIRM_API void set_binop_right(ir_node *node, ir_node *right);
00546 
00550 FIRM_API int is_x_except_Proj(const ir_node *node);
00551 
00555 FIRM_API int is_x_regular_Proj(const ir_node *node);
00556 
00561 FIRM_API void ir_set_throws_exception(ir_node *node, int throws_exception);
00562 
00564 FIRM_API int ir_throws_exception(const ir_node *node);
00565 
00567 FIRM_API const char *get_relation_string(ir_relation relation);
00568 
00570 FIRM_API ir_relation get_negated_relation(ir_relation relation);
00571 
00573 FIRM_API ir_relation get_inversed_relation(ir_relation relation);
00574 
00587 FIRM_API int is_Cast_upcast(ir_node *node);
00588 
00596 FIRM_API int is_Cast_downcast(ir_node *node);
00597 
00609 FIRM_API int is_Phi0(const ir_node *n);
00613 FIRM_API ir_node **get_Phi_preds_arr(ir_node *node);
00617 FIRM_API int get_Phi_n_preds(const ir_node *node);
00623 FIRM_API ir_node *get_Phi_pred(const ir_node *node, int pos);
00627 FIRM_API void set_Phi_pred(ir_node *node, int pos, ir_node *pred);
00631 FIRM_API ir_node *get_Phi_next(const ir_node *phi);
00635 FIRM_API void set_Phi_next(ir_node *phi, ir_node *next);
00636 
00644 FIRM_API int is_memop(const ir_node *node);
00648 FIRM_API ir_node *get_memop_mem(const ir_node *node);
00652 FIRM_API void set_memop_mem(ir_node *node, ir_node *mem);
00653 
00659 FIRM_API ir_node **get_Sync_preds_arr(ir_node *node);
00661 FIRM_API int get_Sync_n_preds(const ir_node *node);
00663 FIRM_API ir_node *get_Sync_pred(const ir_node *node, int pos);
00665 FIRM_API void set_Sync_pred(ir_node *node, int pos, ir_node *pred);
00667 FIRM_API void add_Sync_pred(ir_node *node, ir_node *pred);
00669 FIRM_API void del_Sync_n(ir_node *n, int i);
00670 
00678 FIRM_API int is_arg_Proj(const ir_node *node);
00679 
00685 FIRM_API ir_node **get_Tuple_preds_arr(ir_node *node);
00687 FIRM_API int get_Tuple_n_preds(const ir_node *node);
00689 FIRM_API ir_node  *get_Tuple_pred(const ir_node *node, int pos);
00691 FIRM_API void set_Tuple_pred(ir_node *node, int pos, ir_node *pred);
00692 
00700 FIRM_API size_t get_ASM_n_input_constraints(const ir_node *node);
00702 FIRM_API size_t get_ASM_n_output_constraints(const ir_node *node);
00704 FIRM_API size_t get_ASM_n_clobbers(const ir_node *node);
00705 
00709 FIRM_API ir_node *skip_Proj(ir_node *node);
00711 FIRM_API const ir_node *skip_Proj_const(const ir_node *node);
00713 FIRM_API ir_node *skip_Id(ir_node *node);
00715 FIRM_API ir_node *skip_Tuple(ir_node *node);
00717 FIRM_API ir_node *skip_Cast(ir_node *node);
00719 FIRM_API const ir_node *skip_Cast_const(const ir_node *node);
00721 FIRM_API ir_node *skip_Pin(ir_node *node);
00723 FIRM_API ir_node *skip_Confirm(ir_node *node);
00725 FIRM_API ir_node *skip_HighLevel_ops(ir_node *node);
00727 FIRM_API int is_cfop(const ir_node *node);
00730 FIRM_API int is_unknown_jump(const ir_node *node);
00731 
00737 FIRM_API int is_fragile_op(const ir_node *node);
00738 
00741 FIRM_API int is_irn_forking(const ir_node *node);
00742 
00756 FIRM_API void copy_node_attr(ir_graph *irg, const ir_node *old_node, ir_node *new_node);
00757 
00760 FIRM_API ir_type *get_irn_type_attr(ir_node *n);
00761 
00763 FIRM_API ir_entity *get_irn_entity_attr(ir_node *n);
00764 
00766 FIRM_API int is_irn_constlike(const ir_node *node);
00767 
00772 FIRM_API int is_irn_keep(const ir_node *node);
00773 
00777 FIRM_API int is_irn_start_block_placed(const ir_node *node);
00778 
00782 FIRM_API int is_irn_cse_neutral(const ir_node *node);
00783 
00785 FIRM_API const char *get_cond_jmp_predicate_name(cond_jmp_predicate pred);
00786 
00796 #define get_irn_data(node,type,off) \
00797   (assert(off > 0 && "Invalid node data offset"), (type *) ((char *) (node) - (off)))
00798 
00805 #define get_irn_data_base(data,off) \
00806   (assert(off > 0 && "Invalid node data offset"), (ir_node *) ((char *) (data) + (off)))
00807 
00815 FIRM_API unsigned firm_register_additional_node_data(unsigned size);
00816 
00821 FIRM_API void *get_irn_generic_attr(ir_node *node);
00826 FIRM_API const void *get_irn_generic_attr_const(const ir_node *node);
00827 
00833 FIRM_API unsigned get_irn_idx(const ir_node *node);
00834 
00841 FIRM_API void set_irn_dbg_info(ir_node *n, dbg_info *db);
00842 
00848 FIRM_API dbg_info *get_irn_dbg_info(const ir_node *n);
00849 
00855 FIRM_API unsigned firm_default_hash(const ir_node *node);
00856 
00860 FIRM_API const char *gdb_node_helper(void *firm_object);
00861 
00871 FIRM_API ir_switch_table *ir_new_switch_table(ir_graph *irg, size_t n_entries);
00872 
00876 FIRM_API size_t ir_switch_table_get_n_entries(const ir_switch_table *table);
00877 
00886 FIRM_API void ir_switch_table_set(ir_switch_table *table, size_t entry,
00887                                   ir_tarval *min, ir_tarval *max, long pn);
00888 
00890 FIRM_API ir_tarval *ir_switch_table_get_max(const ir_switch_table *table,
00891                                             size_t entry);
00892 
00894 FIRM_API ir_tarval *ir_switch_table_get_min(const ir_switch_table *table,
00895                                             size_t entry);
00896 
00898 FIRM_API long ir_switch_table_get_pn(const ir_switch_table *table, size_t entry);
00899 
00901 FIRM_API ir_switch_table *ir_switch_table_duplicate(ir_graph *irg, const ir_switch_table *table);
00906 #include "end.h"
00907 
00908 #endif