libFirm 1.20
libfirm/irop.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1995-2011 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 
00026 #ifndef FIRM_IR_IROP_H
00027 #define FIRM_IR_IROP_H
00028 
00029 #include <stdio.h>
00030 #include "firm_types.h"
00031 #include "ident.h"
00032 #include "begin.h"
00033 #include "opcodes.h"
00034 
00047 typedef enum {
00048     oparity_invalid = 0,
00049     oparity_unary,              
00050     oparity_binary,             
00051     oparity_trinary,            
00052     oparity_zero,               
00053     oparity_variable,           
00055     oparity_dynamic,            
00058     oparity_any                 
00059 } op_arity;
00060 
00061 
00063 typedef enum {
00064     irop_flag_none         = 0, 
00065     irop_flag_labeled      = 1U << 0, 
00066     irop_flag_commutative  = 1U << 1, 
00067     irop_flag_cfopcode     = 1U << 2, 
00068     irop_flag_fragile      = 1U << 3, 
00071     irop_flag_forking      = 1U << 4, 
00072     irop_flag_highlevel    = 1U << 5, 
00074     irop_flag_constlike    = 1U << 6, 
00076     irop_flag_always_opt   = 1U << 7, 
00077     irop_flag_keep         = 1U << 8, 
00078     irop_flag_start_block  = 1U << 9, 
00079     irop_flag_uses_memory  = 1U << 10, 
00080     irop_flag_dump_noblock = 1U << 11, 
00081     irop_flag_dump_noinput = 1U << 12, 
00082     irop_flag_cse_neutral  = 1U << 13, 
00086     irop_flag_unknown_jump = 1U << 14,
00087 } irop_flags;
00088 
00090 FIRM_API ident *get_op_ident(const ir_op *op);
00091 
00093 FIRM_API const char *get_op_name(const ir_op *op);
00094 
00096 FIRM_API unsigned get_op_code(const ir_op *op);
00097 
00099 FIRM_API const char *get_op_pin_state_name(op_pin_state s);
00100 
00102 FIRM_API op_pin_state get_op_pinned(const ir_op *op);
00103 
00106 FIRM_API void set_op_pinned(ir_op *op, op_pin_state pinned);
00107 
00109 FIRM_API unsigned get_next_ir_opcode(void);
00110 
00112 FIRM_API unsigned get_next_ir_opcodes(unsigned num);
00113 
00117 typedef void (*op_func)(void);
00118 
00120 #define NULL_FUNC       ((generic_func)(NULL))
00121 
00125 FIRM_API op_func get_generic_function_ptr(const ir_op *op);
00126 
00130 FIRM_API void set_generic_function_ptr(ir_op *op, op_func func);
00131 
00135 FIRM_API irop_flags get_op_flags(const ir_op *op);
00136 
00141 typedef unsigned (*hash_func)(const ir_node *self);
00142 
00148 typedef ir_tarval *(*computed_value_func)(const ir_node *self);
00149 
00158 typedef ir_node *(*equivalent_node_func)(ir_node *self);
00159 
00168 typedef ir_node *(*transform_node_func)(ir_node *self);
00169 
00175 typedef int (*node_cmp_attr_func)(const ir_node *a, const ir_node *b);
00176 
00184 typedef int (*reassociate_func)(ir_node **n);
00185 
00190 typedef void (*copy_attr_func)(ir_graph *irg, const ir_node *old_node, ir_node *new_node);
00191 
00197 typedef ir_type *(*get_type_attr_func)(const ir_node *self);
00198 
00204 typedef ir_entity *(*get_entity_attr_func)(const ir_node *self);
00205 
00213 typedef int (*verify_node_func)(const ir_node *node);
00214 
00222 typedef int (*verify_proj_node_func)(const ir_node *proj);
00223 
00227 typedef enum {
00228     dump_node_opcode_txt,   
00229     dump_node_mode_txt,     
00230     dump_node_nodeattr_txt, 
00231     dump_node_info_txt      
00232 } dump_reason_t;
00233 
00239 typedef void (*dump_node_func)(FILE *out, const ir_node *self, dump_reason_t reason);
00240 
00244 typedef struct {
00245     hash_func             hash;                 
00246     computed_value_func   computed_value;       
00247     computed_value_func   computed_value_Proj;  
00248     equivalent_node_func  equivalent_node;      
00249     equivalent_node_func  equivalent_node_Proj; 
00250     transform_node_func   transform_node;       
00251     equivalent_node_func  transform_node_Proj;  
00252     node_cmp_attr_func    node_cmp_attr;        
00253     reassociate_func      reassociate;          
00254     copy_attr_func        copy_attr;            
00255     get_type_attr_func    get_type_attr;        
00256     get_entity_attr_func  get_entity_attr;      
00257     verify_node_func      verify_node;          
00258     verify_proj_node_func verify_proj_node;     
00259     dump_node_func        dump_node;            
00260     op_func               generic;              
00261     const arch_irn_ops_t *be_ops;               
00262 } ir_op_ops;
00263 
00282 FIRM_API ir_op *new_ir_op(unsigned code, const char *name, op_pin_state p,
00283                           unsigned flags, op_arity opar, int op_index,
00284                           size_t attr_size, const ir_op_ops *ops);
00285 
00287 FIRM_API unsigned ir_get_n_opcodes(void);
00288 
00295 FIRM_API ir_op *ir_get_opcode(unsigned code);
00296 
00298 FIRM_API void ir_clear_opcodes_generic_func(void);
00299 
00303 FIRM_API void ir_op_set_memory_index(ir_op *op, int memory_index);
00304 
00309 FIRM_API void ir_op_set_fragile_indices(ir_op *op, int pn_x_regular,
00310                                         int pn_x_except);
00311 
00313 FIRM_API const ir_op_ops *get_op_ops(const ir_op *op);
00314 
00317 #include "end.h"
00318 
00319 #endif