* @brief Entry point to the representation of a whole program.
* @author Goetz Lindenmaier
* @date 2000
- * @version $Id$
* @brief
* Intermediate Representation (IR) of a program.
*
- * This file defines a construct that keeps all information about a
- * program:
+ */
+#ifndef FIRM_IR_IRPROG_H
+#define FIRM_IR_IRPROG_H
+
+#include <stddef.h>
+#include "firm_types.h"
+#include "irgraph.h"
+#include "begin.h"
+
+/**
+ * @defgroup ir_prog Program
+ *
+ * ir_prog keeps information about a program:
* - A reference point to the method to be executed on program start.
* - A list of all procedures.
* - A list of all types.
* program. It is not the base class of
* all classes in a class hierarchy (as, e.g., "object" in java).
* - A degenerated graph that contains constant expressions.
- * - interprocedural outs state.
- * - a flag indicating validity of the interprocedural representation.
* - the output file name
+ *
+ * @{
*/
-#ifndef FIRM_IR_IRPROG_H
-#define FIRM_IR_IRPROG_H
-
-#include "firm_types.h"
-#include "irgraph.h"
-#include "begin.h"
typedef enum ir_segment_t {
IR_SEGMENT_FIRST,
IR_SEGMENT_LAST = IR_SEGMENT_DESTRUCTORS
} ir_segment_t;
+ENUM_COUNTABLE(ir_segment_t)
/**
* 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.
+ * @note Think of the irp as the "handle" of a program.
*/
FIRM_API ir_prog *irp;
+typedef 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,
+} irp_resources_t;
+ENUM_BITSET(irp_resources_t)
+
#ifndef NDEBUG
-FIRM_API void irp_reserve_resources(ir_prog *irp, ir_resources_t resources);
-FIRM_API void irp_free_resources(ir_prog *irp, ir_resources_t resources);
-FIRM_API ir_resources_t irp_resources_reserved(const ir_prog *irp);
+FIRM_API void irp_reserve_resources(ir_prog *irp, irp_resources_t resources);
+FIRM_API void irp_free_resources(ir_prog *irp, irp_resources_t resources);
+FIRM_API irp_resources_t irp_resources_reserved(const ir_prog *irp);
#else
-#define irp_reserve_resources(irp, resources)
-#define irp_free_resources(irp, resources)
-#define irp_resources_reserved(irp) 0
+#define irp_reserve_resources(irp, resources) (void)0
+#define irp_free_resources(irp, resources) (void)0
+#define irp_resources_reserved(irp) 0
#endif
/**
FIRM_API ir_prog *get_irp(void);
/**
- * Creates a new ir_prog (a module or compilation unit),
- * returns it and sets irp with it.
+ * Set current irp
+ */
+FIRM_API void set_irp(ir_prog *irp);
+
+/**
+ * Creates a new ir_prog (a module or compilation unit).
+ * Note: This does not set irp to the newly created ir_prog
*
* @param name the name of this irp (module)
*/
FIRM_API void remove_irp_irg(ir_graph *irg);
/** returns the biggest not used irg index number */
-FIRM_API int get_irp_last_idx(void);
+FIRM_API size_t get_irp_last_idx(void);
/** Returns the number of ir graphs in the irp. */
-FIRM_API int get_irp_n_irgs(void);
+FIRM_API size_t get_irp_n_irgs(void);
/** Returns the ir graph at position pos in the irp. */
-FIRM_API ir_graph *get_irp_irg(int pos);
+FIRM_API ir_graph *get_irp_irg(size_t pos);
/** Sets the ir graph at position pos. */
-FIRM_API void set_irp_irg(int pos, ir_graph *irg);
-
-/** Gets the number of graphs _and_ pseudo graphs. */
-FIRM_API int get_irp_n_allirgs(void);
-
-/** Returns the ir graph at position pos of all graphs (including
- pseudo graphs). Visits first graphs, then pseudo graphs. */
-FIRM_API ir_graph *get_irp_allirg(int pos);
+FIRM_API void set_irp_irg(size_t pos, ir_graph *irg);
/**
* Returns the type containing the entities for a segment.
*/
FIRM_API ir_type *get_tls_type(void);
-/** Adds type to the list of types in irp. */
-FIRM_API void add_irp_type(ir_type *typ);
-
-/** Removes type from the list of types, deallocates it and
- shrinks the list by one. */
-FIRM_API void remove_irp_type(ir_type *typ);
-
/**
* Returns the number of all types in the irp.
* @deprecated
*/
-FIRM_API int get_irp_n_types(void);
+FIRM_API size_t get_irp_n_types(void);
/**
* Returns the type at position pos in the irp.
* @deprecated
*/
-FIRM_API ir_type *get_irp_type(int pos);
+FIRM_API ir_type *get_irp_type(size_t pos);
/**
* Overwrites the type at position pos with another type.
* @deprecated
*/
-FIRM_API void set_irp_type(int pos, ir_type *typ);
+FIRM_API void set_irp_type(size_t pos, ir_type *typ);
/** Returns the number of all modes in the irp. */
-FIRM_API int get_irp_n_modes(void);
+FIRM_API size_t get_irp_n_modes(void);
/** Returns the mode at position pos in the irp. */
-FIRM_API ir_mode *get_irp_mode(int pos);
+FIRM_API ir_mode *get_irp_mode(size_t pos);
/** Adds opcode to the list of opcodes in irp. */
FIRM_API void add_irp_opcode(ir_op *opcode);
FIRM_API void remove_irp_opcode(ir_op *opcode);
/** Returns the number of all opcodes in the irp. */
-FIRM_API int get_irp_n_opcodes(void);
+FIRM_API size_t get_irp_n_opcodes(void);
/** Returns the opcode at position pos in the irp. */
-FIRM_API ir_op *get_irp_opcode(int pos);
+FIRM_API ir_op *get_irp_opcode(size_t pos);
/** Sets the generic function pointer of all opcodes to NULL */
FIRM_API void clear_irp_opcodes_generic_func(void);
FIRM_API irg_phase_state get_irp_phase_state(void);
FIRM_API void set_irp_phase_state(irg_phase_state s);
-FIRM_API irg_outs_state get_irp_ip_outs_state(void);
-FIRM_API void set_irp_ip_outs_inconsistent(void);
-
/**
* Creates an ir_prog pass for set_irp_phase_state().
*
FIRM_API void add_irp_asm(ident *asm_string);
/** Return the number of global asm includes. */
-FIRM_API int get_irp_n_asms(void);
+FIRM_API size_t get_irp_n_asms(void);
/** Return the global asm include at position pos. */
-FIRM_API ident *get_irp_asm(int pos);
+FIRM_API ident *get_irp_asm(size_t pos);
+
+/** Return whether optimization dump vcg graphs */
+FIRM_API int get_irp_optimization_dumps(void);
+
+/** Enable vcg dumping of optimization */
+FIRM_API void enable_irp_optimization_dumps(void);
+
+/** @} */
#include "end.h"