libFirm
Switch node

Change control flow. More...

Typedefs

typedef struct ir_switch_table ir_switch_table
 A switch table mapping integer numbers to proj-numbers of a Switch-node.

Enumerations

enum  n_Switch { n_Switch_selector, n_Switch_max = n_Switch_selector }
 Input numbers for Switch node. More...
enum  pn_Switch { pn_Switch_default, pn_Switch_max = pn_Switch_default }
 Projection numbers for result of Switch node (use for Proj nodes) More...

Functions

ir_switch_tableir_new_switch_table (ir_graph *irg, size_t n_entries)
 Creates a new switch_table datastructure with n_entries entries.
size_t ir_switch_table_get_n_entries (const ir_switch_table *table)
 Returns number of entries available in switch table table.
void ir_switch_table_set (ir_switch_table *table, size_t entry, ir_tarval *min, ir_tarval *max, long pn)
 Sets entry number entry in the switch table table.
ir_tarvalir_switch_table_get_max (const ir_switch_table *table, size_t entry)
 Returns maximum tarval value of switch table entry entry.
ir_tarvalir_switch_table_get_min (const ir_switch_table *table, size_t entry)
 Returns minimum tarval value of switch table entry entry.
long ir_switch_table_get_pn (const ir_switch_table *table, size_t entry)
 Returns proj number taken if switch table entry entry matches.
ir_switch_tableir_switch_table_duplicate (ir_graph *irg, const ir_switch_table *table)
 Duplicates switch table table on obstack of irg.
ir_nodenew_rd_Switch (dbg_info *dbgi, ir_node *block, ir_node *irn_selector, unsigned n_outs, ir_switch_table *table)
 Construct a Switch node.
ir_nodenew_r_Switch (ir_node *block, ir_node *irn_selector, unsigned n_outs, ir_switch_table *table)
 Construct a Switch node.
ir_nodenew_d_Switch (dbg_info *dbgi, ir_node *irn_selector, unsigned n_outs, ir_switch_table *table)
 Construct a Switch node.
ir_nodenew_Switch (ir_node *irn_selector, unsigned n_outs, ir_switch_table *table)
 Construct a Switch node.
int is_Switch (const ir_node *node)
 Test if node is a Switch.
ir_nodeget_Switch_selector (const ir_node *node)
 Returns selector input of a Switch node.
void set_Switch_selector (ir_node *node, ir_node *selector)
 Sets selector input of a Switch node.
unsigned get_Switch_n_outs (const ir_node *node)
 Returns n_outs attribute of a Switch node.
void set_Switch_n_outs (ir_node *node, unsigned n_outs)
 Sets n_outs attribute of a Switch node.
ir_switch_tableget_Switch_table (const ir_node *node)
 Returns table attribute of a Switch node.
void set_Switch_table (ir_node *node, ir_switch_table *table)
 Sets table attribute of a Switch node.
ir_opget_op_Switch (void)
 Returns opcode for Switch nodes.

Variables

ir_opop_Switch
 Switch opcode.

Detailed Description

Change control flow.

The destination is choosen based on an integer input value which is looked up in a table.

Backends can implement this efficiently using a jump table.

Typedef Documentation

A switch table mapping integer numbers to proj-numbers of a Switch-node.

Entries map a continuous range of integer numbers to a proj-number. There must never be two different entries matching the same integer number.

Definition at line 128 of file firm_types.h.

Enumeration Type Documentation

enum n_Switch

Input numbers for Switch node.

Definition at line 3686 of file nodeops.h.

enum pn_Switch

Projection numbers for result of Switch node (use for Proj nodes)

Enumerator:
pn_Switch_default 

control flow if no other case matches

Definition at line 3695 of file nodeops.h.

Function Documentation

ir_op* get_op_Switch ( void  )

Returns opcode for Switch nodes.

unsigned get_Switch_n_outs ( const ir_node node)

Returns n_outs attribute of a Switch node.

ir_node* get_Switch_selector ( const ir_node node)

Returns selector input of a Switch node.

ir_switch_table* get_Switch_table ( const ir_node node)

Returns table attribute of a Switch node.

ir_switch_table* ir_new_switch_table ( ir_graph irg,
size_t  n_entries 
)

Creates a new switch_table datastructure with n_entries entries.

The datastructure is allocated on the obstack of irg.

ir_switch_table* ir_switch_table_duplicate ( ir_graph irg,
const ir_switch_table table 
)

Duplicates switch table table on obstack of irg.

ir_tarval* ir_switch_table_get_max ( const ir_switch_table table,
size_t  entry 
)

Returns maximum tarval value of switch table entry entry.

ir_tarval* ir_switch_table_get_min ( const ir_switch_table table,
size_t  entry 
)

Returns minimum tarval value of switch table entry entry.

size_t ir_switch_table_get_n_entries ( const ir_switch_table table)

Returns number of entries available in switch table table.

long ir_switch_table_get_pn ( const ir_switch_table table,
size_t  entry 
)

Returns proj number taken if switch table entry entry matches.

void ir_switch_table_set ( ir_switch_table table,
size_t  entry,
ir_tarval min,
ir_tarval max,
long  pn 
)

Sets entry number entry in the switch table table.

Parameters
tablethe switch table
entryentry number to set
minThe minimum tarval that matches this entry
maxThe maximum tarval that matches this entry
pnProj number taken on match
int is_Switch ( const ir_node node)

Test if node is a Switch.

Returns
1 if the node is a Switch node, 0 otherwise
ir_node* new_d_Switch ( dbg_info dbgi,
ir_node irn_selector,
unsigned  n_outs,
ir_switch_table table 
)

Construct a Switch node.

Parameters
dbgiA pointer to debug information.
irn_selectorinput selector
n_outsnumber of outputs (including pn_Switch_default)
tabletable describing mapping from input values to Proj numbers
ir_node* new_r_Switch ( ir_node block,
ir_node irn_selector,
unsigned  n_outs,
ir_switch_table table 
)

Construct a Switch node.

Parameters
blockThe IR block the node belongs to.
irn_selectorinput selector
n_outsnumber of outputs (including pn_Switch_default)
tabletable describing mapping from input values to Proj numbers
ir_node* new_rd_Switch ( dbg_info dbgi,
ir_node block,
ir_node irn_selector,
unsigned  n_outs,
ir_switch_table table 
)

Construct a Switch node.

Parameters
dbgiA pointer to debug information.
blockThe IR block the node belongs to.
irn_selectorinput selector
n_outsnumber of outputs (including pn_Switch_default)
tabletable describing mapping from input values to Proj numbers
ir_node* new_Switch ( ir_node irn_selector,
unsigned  n_outs,
ir_switch_table table 
)

Construct a Switch node.

Parameters
irn_selectorinput selector
n_outsnumber of outputs (including pn_Switch_default)
tabletable describing mapping from input values to Proj numbers
void set_Switch_n_outs ( ir_node node,
unsigned  n_outs 
)

Sets n_outs attribute of a Switch node.

void set_Switch_selector ( ir_node node,
ir_node selector 
)

Sets selector input of a Switch node.

void set_Switch_table ( ir_node node,
ir_switch_table table 
)

Sets table attribute of a Switch node.

Variable Documentation

ir_op* op_Switch

Switch opcode.

Definition at line 348 of file opcodes.h.