libFirm
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Program

ir_prog keeps information about a program: More...

Typedefs

typedef struct ir_prog ir_prog
 Program. More...
 

Enumerations

enum  ir_segment_t {
  IR_SEGMENT_FIRST, IR_SEGMENT_GLOBAL = IR_SEGMENT_FIRST, IR_SEGMENT_THREAD_LOCAL, IR_SEGMENT_CONSTRUCTORS,
  IR_SEGMENT_DESTRUCTORS, IR_SEGMENT_JCR, IR_SEGMENT_LAST = IR_SEGMENT_JCR
}
 Segment. More...
 
enum  irp_resources_t {
  IRP_RESOURCE_NONE = 0, IRP_RESOURCE_IRG_LINK = 1 << 0, IRP_RESOURCE_ENTITY_LINK = 1 << 1, IRP_RESOURCE_TYPE_VISITED = 1 << 2,
  IRP_RESOURCE_TYPE_LINK = 1 << 3
}
 Resources usable by algorithms modifying the program. More...
 

Functions

void irp_reserve_resources (ir_prog *irp, irp_resources_t resources)
 Reserve resources available for a whole program. More...
 
void irp_free_resources (ir_prog *irp, irp_resources_t resources)
 Frees resources available for a whole program. More...
 
irp_resources_t irp_resources_reserved (const ir_prog *irp)
 Returns currently reserved whole program resources. More...
 
ir_progget_irp (void)
 Returns the current irp from where everything in the current module can be accessed. More...
 
void set_irp (ir_prog *irp)
 Sets current irp. More...
 
ir_prognew_ir_prog (const char *name)
 Creates a new ir_prog (a module or compilation unit). More...
 
void free_ir_prog (void)
 Frees all memory used by irp. More...
 
void set_irp_prog_name (ident *name)
 Sets the file name / executable name or the like. More...
 
int irp_prog_name_is_set (void)
 Returns true if the user ever set a program name. More...
 
identget_irp_ident (void)
 Returns the name of the current irp. More...
 
const char * get_irp_name (void)
 Returns the name of the current irp. More...
 
ir_graphget_irp_main_irg (void)
 Returns the main routine of the compiled program. More...
 
void set_irp_main_irg (ir_graph *main_irg)
 Sets the main routine of the compiled program. More...
 
size_t get_irp_last_idx (void)
 returns the biggest not used irg index number More...
 
size_t get_irp_n_irgs (void)
 Returns the number of ir graphs in the irp. More...
 
ir_graphget_irp_irg (size_t pos)
 Returns the ir graph at position pos in the irp. More...
 
void set_irp_irg (size_t pos, ir_graph *irg)
 Sets the ir graph at position pos. More...
 
ir_typeget_segment_type (ir_segment_t segment)
 Returns the type containing the entities for a segment. More...
 
void set_segment_type (ir_segment_t segment, ir_type *new_type)
 Changes a segment segment type for the program. More...
 
ir_typeget_glob_type (void)
 Returns the "global" type of the irp. More...
 
ir_typeget_tls_type (void)
 Returns the "thread local storage" type of the irp. More...
 
ir_entityir_get_global (ident *name)
 Returns global entity with name name. More...
 
size_t get_irp_n_types (void)
 Returns the number of all types in the irp. More...
 
ir_typeget_irp_type (size_t pos)
 Returns the type at position pos in the irp. More...
 
void set_irp_type (size_t pos, ir_type *typ)
 Overwrites the type at position pos with another type. More...
 
ir_graphget_const_code_irg (void)
 Returns the graph for global constants of the current irp. More...
 
irg_callee_info_state get_irp_callee_info_state (void)
 Returns callee info state for the whole program. More...
 
void set_irp_callee_info_state (irg_callee_info_state s)
 Sets callee info state for the whole program. More...
 
ir_label_t get_irp_next_label_nr (void)
 Returns a new, unique label number. More...
 
void add_irp_asm (ident *asm_string)
 Add a new global asm include. More...
 
size_t get_irp_n_asms (void)
 Returns the number of global asm includes. More...
 
identget_irp_asm (size_t pos)
 Returns the global asm include at position pos. More...
 

Variables

ir_progirp
 A variable pointing to the current irp (program or module). More...
 

Detailed Description

ir_prog keeps information about a program:

Typedef Documentation

typedef struct ir_prog ir_prog

Program.

Definition at line 77 of file firm_types.h.

Enumeration Type Documentation

Segment.

A progrom has a number of special segments at the toplevel which modify the behaviour of the entities in them.

Enumerator
IR_SEGMENT_FIRST 
IR_SEGMENT_GLOBAL 

"normal" global data

IR_SEGMENT_THREAD_LOCAL 

thread local storage segment

IR_SEGMENT_CONSTRUCTORS 

the constructors segment.

Contains pointers to functions which are executed on module initialization (program start or when a library is dynamically loaded)

IR_SEGMENT_DESTRUCTORS 

like constructors, but functions are executed on module exit

IR_SEGMENT_JCR 

java class registry

IR_SEGMENT_LAST 

Definition at line 46 of file irprog.h.

Resources usable by algorithms modifying the program.

Enumerator
IRP_RESOURCE_NONE 

no resource

IRP_RESOURCE_IRG_LINK 

irg link field

See Also
set_irg_link(), get_irg_link()
IRP_RESOURCE_ENTITY_LINK 

entity link field

See Also
set_entity_link(), get_entity_link()
IRP_RESOURCE_TYPE_VISITED 

type visited field

See Also
type_visited(), mark_type_visited(), inc_master_type_visited()
IRP_RESOURCE_TYPE_LINK 

type link field

See Also
set_type_link(), get_type_link()

Definition at line 79 of file irprog.h.

Function Documentation

void add_irp_asm ( ident asm_string)

Add a new global asm include.

void free_ir_prog ( void  )

Frees all memory used by irp.

Types in type list and irgs in irg list must be freed by hand before.

ir_graph* get_const_code_irg ( void  )

Returns the graph for global constants of the current irp.

Returns an irgraph that only contains constant expressions for constant entities. Do not use any access function for this graph, do not generate code for this graph. This graph contains only one block. The constant expressions may not contain control flow. Walking the graph starting from any node will not reach the block or any controlflow. See also copy_const_code() in entity.h.

ir_type* get_glob_type ( void  )

Returns the "global" type of the irp.

Upon creation this is an empty class type. This is a convenience function for get_segment_type(IR_SEGMENT_GLOBAL)

ir_prog* get_irp ( void  )

Returns the current irp from where everything in the current module can be accessed.

See Also
irp
ident* get_irp_asm ( size_t  pos)

Returns the global asm include at position pos.

irg_callee_info_state get_irp_callee_info_state ( void  )

Returns callee info state for the whole program.

See Also
get_irg_callee_info_state()
ident* get_irp_ident ( void  )

Returns the name of the current irp.

ir_graph* get_irp_irg ( size_t  pos)

Returns the ir graph at position pos in the irp.

size_t get_irp_last_idx ( void  )

returns the biggest not used irg index number

ir_graph* get_irp_main_irg ( void  )

Returns the main routine of the compiled program.

size_t get_irp_n_asms ( void  )

Returns the number of global asm includes.

size_t get_irp_n_irgs ( void  )

Returns the number of ir graphs in the irp.

size_t get_irp_n_types ( void  )

Returns the number of all types in the irp.

const char* get_irp_name ( void  )

Returns the name of the current irp.

ir_label_t get_irp_next_label_nr ( void  )

Returns a new, unique label number.

ir_type* get_irp_type ( size_t  pos)

Returns the type at position pos in the irp.

ir_type* get_segment_type ( ir_segment_t  segment)

Returns the type containing the entities for a segment.

Parameters
segmentthe segment
ir_type* get_tls_type ( void  )

Returns the "thread local storage" type of the irp.

Upon creation this is an empty struct type. This is a convenience function for get_segment_type(IR_SEGMENT_THREAD_LOCAL)

ir_entity* ir_get_global ( ident name)

Returns global entity with name name.

A global entity is an entity in one of the segment types.

See Also
get_glob_type(),
get_segment_type()
void irp_free_resources ( ir_prog irp,
irp_resources_t  resources 
)

Frees resources available for a whole program.

int irp_prog_name_is_set ( void  )

Returns true if the user ever set a program name.

void irp_reserve_resources ( ir_prog irp,
irp_resources_t  resources 
)

Reserve resources available for a whole program.

This is a debug tool: All code should properly allocate the resources it uses so if two interlocked algorithms use the same resources that bug will get detected.

irp_resources_t irp_resources_reserved ( const ir_prog irp)

Returns currently reserved whole program resources.

ir_prog* new_ir_prog ( const char *  name)

Creates a new ir_prog (a module or compilation unit).

Note: This does not set irp to the newly created ir_prog

Parameters
namethe name of this irp (module)
void set_irp ( ir_prog irp)

Sets current irp.

void set_irp_callee_info_state ( irg_callee_info_state  s)

Sets callee info state for the whole program.

See Also
set_irg_callee_info_state()
void set_irp_irg ( size_t  pos,
ir_graph irg 
)

Sets the ir graph at position pos.

void set_irp_main_irg ( ir_graph main_irg)

Sets the main routine of the compiled program.

void set_irp_prog_name ( ident name)

Sets the file name / executable name or the like.

Initially the ident 'no_name_set'.

void set_irp_type ( size_t  pos,
ir_type typ 
)

Overwrites the type at position pos with another type.

void set_segment_type ( ir_segment_t  segment,
ir_type new_type 
)

Changes a segment segment type for the program.

(use with care)

Variable Documentation

ir_prog* irp

A variable pointing to the current irp (program or module).

This variable should be considered constant. Moreover, one should use get_irp() to get access the the irp.

Note
Think of the irp as the "handle" of a program.

Definition at line 74 of file irprog.h.