beifg: Factorise code to count interference components.
[libfirm] / ir / be / be_t.h
index 14a632b..8f60ce7 100644 (file)
@@ -1,30 +1,33 @@
-/**
- * Internal backend global data structures.
- * @author Sebastian Hack
- * @date 8.12.2004
+/*
+ * This file is part of libFirm.
+ * Copyright (C) 2012 University of Karlsruhe.
  */
 
-#ifndef _BE_T_H
-#define _BE_T_H
+/**
+ * @file
+ * @brief   Internal backend global data structures.
+ * @author  Sebastian Hack
+ */
+#ifndef FIRM_BE_BE_T_H
+#define FIRM_BE_BE_T_H
 
-#include "firm_types.h"
-#include "obst.h"
-#include "debug.h"
+#include "be.h"
+#include "be_types.h"
 #include "bitset.h"
+#include "firm_types.h"
+#include "pmap.h"
+#include "timing.h"
 
-#include "be.h"
-#include "bearch.h"
-#include "beirgmod.h"
-#include "be_dbgout.h"
-
-#define DUMP_NONE       0
-#define DUMP_INITIAL    (1 << 0)
-#define DUMP_ABI        (1 << 1)
-#define DUMP_SCHED      (1 << 2)
-#define DUMP_PREPARED   (1 << 3)
-#define DUMP_RA         (1 << 4)
-#define DUMP_FINAL      (1 << 5)
-#define DUMP_BE         (1 << 6)
+enum {
+       DUMP_NONE     = 0,
+       DUMP_INITIAL  = 1 << 0,
+       DUMP_ABI      = 1 << 1,
+       DUMP_SCHED    = 1 << 2,
+       DUMP_PREPARED = 1 << 3,
+       DUMP_RA       = 1 << 4,
+       DUMP_FINAL    = 1 << 5,
+       DUMP_BE       = 1 << 6
+};
 
 enum {
        BE_TIME_OFF,
@@ -32,52 +35,102 @@ enum {
 };
 
 enum {
-       BE_VRFY_OFF,
-       BE_VRFY_WARN,
-       BE_VRFY_ASSERT
+       BE_VERIFY_OFF,
+       BE_VERIFY_WARN,
+       BE_VERIFY_ASSERT
 };
 
 /** Backend options */
-struct _be_options_t {
-       unsigned dump_flags;          /**< backend dumping flags */
-       int  timing;              /**< time the backend phases */
-       int  opt_profile;         /**< instrument code for profiling */
-       int  omit_fp;             /**< try to omit the frame pointer */
-       int  stabs_debug_support; /**< enable stabs debugging support */
-       int  vrfy_option;         /**< backend verify option */
-       char ilp_server[128];     /**< the ilp server name */
-       char ilp_solver[128];     /**< the ilp solver name */
-       char stat_file_name[256]; /**< name of the file where the statistics are put to */
+struct be_options_t {
+       unsigned dump_flags;       /**< backend dumping flags */
+       int  timing;               /**< time the backend phases */
+       int  opt_profile_generate; /**< instrument code for profiling */
+       int  opt_profile_use;      /**< use existing profile data */
+       int  omit_fp;              /**< try to omit the frame pointer */
+       int  pic;                  /**< create position independent code */
+       int  verify_option;        /**< backend verify option */
+       char ilp_server[128];      /**< the ilp server name */
+       char ilp_solver[128];      /**< the ilp solver name */
+       int  statev;               /**< enable stat event dumping */
+       char filtev[128];          /**< filter mask for stat events */
+       int  verbose_asm;          /**< dump verbose assembler */
 };
+extern be_options_t be_options;
 
-struct _be_main_env_t {
-       struct obstack obst;
-       struct _be_node_factory_t *node_factory;
-       struct _arch_env_t *arch_env;
-       struct _be_options_t *options;
-       struct _arch_code_generator_t *cg;
-       struct _arch_irn_handler_t *phi_handler;
-       dbg_handle *db_handle;
-       DEBUG_ONLY(firm_dbg_module_t *dbg;)
+struct be_main_env_t {
+       arch_env_t   *arch_env;
+       const char   *cup_name;             /**< name of the compilation unit */
+       pmap         *ent_trampoline_map;   /**< A map containing PIC trampolines for methods. */
+       ir_type      *pic_trampolines_type; /**< Class type containing all trampolines */
+       pmap         *ent_pic_symbol_map;
+       ir_type      *pic_symbols_type;
 };
 
-struct _be_irg_t {
-       ir_graph                      *irg;
-       struct _be_main_env_t         *main_env;
-       struct _be_abi_irg_t          *abi;
-       struct _arch_code_generator_t *cg;
-       ir_exec_freq                  *execfreqs;
-};
+extern asm_constraint_flags_t asm_constraint_flags[256];
+
+void be_init_default_asm_constraint_flags(void);
+
+void be_put_allocatable_regs(const ir_graph *irg,
+                             const arch_register_class_t *cls, bitset_t *bs);
+
+void be_set_allocatable_regs(const ir_graph *irg,
+                             const arch_register_class_t *cls,
+                             unsigned *raw_bitset);
+
+unsigned be_get_n_allocatable_regs(const ir_graph *irg,
+                                   const arch_register_class_t *cls);
 
 /**
-* Put the registers to be ignored in this IRG into a bitset.
-* @param birg The backend IRG data structure.
-* @param cls  The register class.
-* @param bs   The bitset (may be NULL).
-* @return The number of registers to be ignored.
-*/
-int be_put_ignore_regs(const struct _be_irg_t *birg, const struct _arch_register_class_t *cls, bitset_t *bs);
+ * Initialize the backend. Must be run first in init_firm();
+ */
+void firm_be_init(void);
+void firm_be_finish(void);
+
+extern int be_timing;
+
+typedef enum {
+       T_FIRST,
+       T_ABI = T_FIRST,
+       T_CODEGEN,
+       T_RA_PREPARATION,
+       T_SCHED,
+       T_CONSTR,
+       T_FINISH,
+       T_EMIT,
+       T_VERIFY,
+       T_OTHER,
+       T_HEIGHTS,
+       T_LIVE,
+       T_EXECFREQ,
+       T_SSA_CONSTR,
+       T_RA_EPILOG,
+       T_RA_CONSTR,
+       T_RA_SPILL,
+       T_RA_SPILL_APPLY,
+       T_RA_COLOR,
+       T_RA_IFG,
+       T_RA_COPYMIN,
+       T_RA_SSA,
+       T_RA_OTHER,
+       T_LAST = T_RA_OTHER
+} be_timer_id_t;
+ENUM_COUNTABLE(be_timer_id_t)
+extern ir_timer_t *be_timers[T_LAST+1];
 
+static inline void be_timer_push(be_timer_id_t id)
+{
+       assert(id <= T_LAST);
+       if (!be_timing)
+               return;
+       ir_timer_push(be_timers[id]);
+}
 
+static inline void be_timer_pop(be_timer_id_t id)
+{
+       assert(id <= T_LAST);
+       if (!be_timing)
+               return;
+       ir_timer_pop(be_timers[id]);
+}
 
-#endif /* _BE_T_H */
+#endif