simplify more driver stuff and remove more unused options
authorMatthias Braun <matze@braunis.de>
Wed, 30 Mar 2011 12:12:12 +0000 (14:12 +0200)
committerMatthias Braun <matze@braunis.de>
Wed, 30 Mar 2011 12:12:12 +0000 (14:12 +0200)
TODO [deleted file]
driver/fe_common.h [deleted file]
driver/firm_cmdline.c
driver/firm_cmdline.h
driver/firm_codegen.c [deleted file]
driver/firm_opt.c
driver/firm_opt.h
driver/firm_timing.def [deleted file]

diff --git a/TODO b/TODO
deleted file mode 100644 (file)
index 0436f7c..0000000
--- a/TODO
+++ /dev/null
@@ -1,31 +0,0 @@
-Refactoring:
-- eliminate target_architecture.h and replace with stuff in lang_features.h
-
-Lexer:
-- Add preprocessor code.
-- We could save some space by holding source positions in a separate (somehow
-  compressed table) and only storing pointers to it on the AST.
-
-Parser:
-- add constant folding code (optional, ast2firm already does it)
-- Refactor code, so code to handle number values (and strings?) is an own
-  module and replacable
-- Add columns to source positions
-- SourcePositions could be stored selectively on expressions that really need
-  them.
-- check semantic for functions declared/defined in global scope and declared
-  again in a local scope
-- for errors relating to function argument, print number of argument
-- print initialisation type_path for initializer errors
-
-ast2firm:
-- output source file positions for panics.
-
-Missing Errors:
-- goto over VLA declarations
-
-Missing Warnings:
-- dead assignments (int x = 5; x = bla(); -> dead assignment at x = 5;)
-
-main/driver:
-- go through gcc manual and emulate all the gcc flags...
diff --git a/driver/fe_common.h b/driver/fe_common.h
deleted file mode 100644 (file)
index 71c0cb9..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __FE_COMMON_H__
-#define __FE_COMMON_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#define TRUE 1
-#define FALSE 0
-
-/* some needed types form teh EDG frontend */
-typedef unsigned char a_byte;
-typedef struct an_il_type *a_type_ptr;
-
-#endif /* __FE_COMMON_H__ */
index b812255..66e9ba7 100644 (file)
 
 /* optimization settings */
 struct a_firm_opt firm_opt = {
-  /* const_folding   = */ TRUE,
-  /* cse             = */ TRUE,
-  /* confirm         = */ TRUE,
-  /* muls            = */ TRUE,
-  /* divs            = */ TRUE,
-  /* mods            = */ TRUE,
-  /* alias_analysis  = */ TRUE,
-  /* strict_alias    = */ FALSE,
-  /* no_alias        = */ FALSE,
+  /* const_folding   = */ true,
+  /* cse             = */ true,
+  /* confirm         = */ true,
+  /* muls            = */ true,
+  /* divs            = */ true,
+  /* mods            = */ true,
+  /* alias_analysis  = */ true,
+  /* strict_alias    = */ false,
+  /* no_alias        = */ false,
   /* fp_model        = */ fp_model_precise,
   /* verify          = */ FIRM_VERIFICATION_ON,
-  /* check_all       = */ FALSE,
+  /* check_all       = */ false,
   /* clone_threshold = */ DEFAULT_CLONE_THRESHOLD,
   /* inline_maxsize  = */ 750,
   /* inline_threshold= */ 0,
-  /* verify_edges    = */ FALSE,
+  /* verify_edges    = */ false,
 };
 
 /* dumping options */
 struct a_firm_dump firm_dump = {
-  /* debug_print  = */ FALSE,
-  /* all_types    = */ FALSE,
-  /* no_blocks    = */ FALSE,
-  /* extbb        = */ FALSE,
-  /* ir_graph     = */ FALSE,
-  /* all_phases   = */ FALSE,
+  /* debug_print  = */ false,
+  /* all_types    = */ false,
+  /* no_blocks    = */ false,
+  /* extbb        = */ false,
+  /* ir_graph     = */ false,
+  /* all_phases   = */ false,
   /* statistic    = */ STAT_NONE,
   /* stat_pattern = */ 0,
   /* stat_dag     = */ 0,
   /* filter       = */ NULL
 };
 
-#ifdef FIRM_EXT_GRS
-struct a_firm_ext_grs firm_ext_grs = {
-  /* simd_opt       = */ FALSE,
-  /* create_pattern = */ FALSE
-};
-#endif
-
-struct a_firm_be_opt firm_be_opt = {
-  /* selection = */ BE_FIRM_BE,
-  /* node_stat = */ 0,
-};
-
 #define X(a)  a, sizeof(a)-1
 
 /** Parameter description structure */
 static const struct params {
   const char *option;      /**< name of the option */
   int        opt_len;      /**< length of the option string */
-  a_byte     *flag;        /**< address of variable to set/reset */
-  a_byte     set;          /**< iff true, variable will be set, else reset */
+  bool       *flag;        /**< address of variable to set/reset */
+  bool       set;          /**< iff true, variable will be set, else reset */
   const char *description; /**< description of this option */
 } firm_options[] = {
   /* this must be first */
@@ -109,31 +97,12 @@ static const struct params {
   { X("verify-edges-off"),       &firm_opt.verify_edges,     0, "firm: disable out edge verification" },
 
   /* dumping */
-#if defined(_DEBUG) || defined(FIRM_DEBUG)
-  { X("debug"),                  &firm_dump.debug_print,     1, "firm: enable debug output" },
-#endif
-
   { X("dump-ir"),                &firm_dump.ir_graph,        1, "firm: dump IR graph" },
   { X("dump-all-types"),         &firm_dump.all_types,       1, "firm: dump graph of all types" },
   { X("dump-no-blocks"),         &firm_dump.no_blocks,       1, "firm: dump non-blocked graph" },
   { X("dump-extbb"),             &firm_dump.extbb,           1, "firm: dump extended basic blocks" },
   { X("dump-all-phases"),        &firm_dump.all_phases,      1, "firm: dump graphs for all optimization phases" },
 
-  /* code generation */
-  { X("no-codegen"),             &firm_be_opt.selection,     BE_NONE, "cg: disable code generator" },
-
-#ifdef FIRM_EXT_GRS
-  { X("grs-simd-opt"),           &firm_ext_grs.simd_opt,       1, "firm: do simd optimization" },
-  { X("grs-create-pattern"),     &firm_ext_grs.create_pattern, 1, "firm: create patterns for simd optimization" },
-  { X("no-grs-simd-opt"),        &firm_ext_grs.simd_opt,       0, "firm: do simd optimization" },
-  { X("no-grs-create-pattern"),  &firm_ext_grs.create_pattern, 0, "firm: create patterns for simd optimization" },
-#endif
-
-  { X("be-firm"),                &firm_be_opt.selection,     BE_FIRM_BE, "backend: firm backend facility" },
-#ifdef FIRM2C_BACKEND
-  { X("be-firm2c"),              &firm_be_opt.selection,     BE_FIRM2C, "backend: firm2C" },
-#endif /* FIRM2C_BACKEND */
-
   /* misc */
   { X("stat-before-opt"),        &firm_dump.statistic,       STAT_BEFORE_OPT,  "misc: Firm statistic output before optimizations" },
   { X("stat-after-opt"),         &firm_dump.statistic,       STAT_AFTER_OPT,   "misc: Firm statistic output after optimizations" },
@@ -169,14 +138,14 @@ static void set_dump_filter(const char *filter)
 
 /** Disable all optimizations. */
 static void disable_opts(void) {
-  firm_opt.cse             = FALSE;
-  firm_opt.confirm         = FALSE;
-  firm_opt.muls            = FALSE;
-  firm_opt.divs            = FALSE;
-  firm_opt.mods            = FALSE;
-  firm_opt.alias_analysis  = FALSE;
-  firm_opt.strict_alias    = FALSE;
-  firm_opt.no_alias        = FALSE;
+  firm_opt.cse             = false;
+  firm_opt.confirm         = false;
+  firm_opt.muls            = false;
+  firm_opt.divs            = false;
+  firm_opt.mods            = false;
+  firm_opt.alias_analysis  = false;
+  firm_opt.strict_alias    = false;
+  firm_opt.no_alias        = false;
   disable_all_opts();
 }  /* disable_opts */
 
@@ -228,7 +197,7 @@ int firm_option(const char *opt)
       }
       /* statistic options do accumulate */
       if (firm_options[i].flag == &firm_dump.statistic)
-        *firm_options[i].flag = (a_byte) (*firm_options[i].flag | firm_options[i].set);
+        *firm_options[i].flag = (bool) (*firm_options[i].flag | firm_options[i].set);
       else
         *firm_options[i].flag = firm_options[i].set;
 
@@ -244,28 +213,4 @@ int firm_option(const char *opt)
     return 1;
 
   return 0;
-}  /* firm_option */
-
-/**
- * prints the firm version number
- */
-void print_firm_version(FILE *f)
-{
-       const char *revision = ir_get_version_revision();
-       const char *build    = ir_get_version_build();
-
-       fprintf(f, "Firm C-Compiler using libFirm (%u.%u",
-                       ir_get_version_major(), ir_get_version_minor());
-       if (revision[0] != 0) {
-               fputc(' ', f);
-               fputs(revision, f);
-       }
-       if (build[0] != 0) {
-               fputc(' ', f);
-               fputs(build, f);
-       }
-       fprintf(f, "}\n"
-                       "(C) 2005-2008 Michael Beck\n"
-                       "(C) 1995-2008 University of Karlsruhe\n"
-                       "Using ");
-}  /* print_firm_version */
+}
index 17b21e0..774365b 100644 (file)
@@ -2,34 +2,30 @@
  * @file firm_cmdline.h -- Additional Firm generating backend parameters
  *
  * Generates Firm fro the IL.  It works with both C++ and C programs.
- *
- * Compile with STANDALONE_CP_FIRM_BE defined and BACK_END_IS_CP_FIRM_BE
- * defined as 1 to get a main program back end.  Otherwise, a version to be
- * called in the same program as the front end is produced (if needed).
  */
 #ifndef FIRM_CMDLINE_H
 #define FIRM_CMDLINE_H
 
-#include "fe_common.h"
+#include <stdbool.h>
 
 /* optimization settings */
 struct a_firm_opt {
-  a_byte      const_folding;   /**< enable constant folding */
-  a_byte      cse;             /**< enable common-subexpression elimination */
-  a_byte      confirm;         /**< enable Confirm optimization */
-  a_byte      muls;            /**< enable architecture dependent mul optimization */
-  a_byte      divs;            /**< enable architecture dependent div optimization */
-  a_byte      mods;            /**< enable architecture dependent mod optimization */
-  a_byte      alias_analysis;  /**< enable Alias Analysis */
-  a_byte      strict_alias;    /**< enable strict Alias Analysis (using type based AA) */
-  a_byte      no_alias;        /**< no aliasing possible. */
-  a_byte      fp_model;        /**< fp model */
-  a_byte      verify;          /**< Firm verifier setting */
-  a_byte      check_all;       /**< enable checking all Firm phases */
-  int         clone_threshold; /**< The threshold value for procedure cloning. */
-  unsigned    inline_maxsize;  /**< Maximum function size for inlining. */
-  unsigned    inline_threshold;/**< Inlining benefice threshold. */
-  a_byte      verify_edges;    /**< verify edges */
+  bool     const_folding;   /**< enable constant folding */
+  bool     cse;             /**< enable common-subexpression elimination */
+  bool     confirm;         /**< enable Confirm optimization */
+  bool     muls;            /**< enable architecture dependent mul optimization */
+  bool     divs;            /**< enable architecture dependent div optimization */
+  bool     mods;            /**< enable architecture dependent mod optimization */
+  bool     alias_analysis;  /**< enable Alias Analysis */
+  bool     strict_alias;    /**< enable strict Alias Analysis (using type based AA) */
+  bool     no_alias;        /**< no aliasing possible. */
+  bool     fp_model;        /**< fp model */
+  bool     verify;          /**< Firm verifier setting */
+  bool     check_all;       /**< enable checking all Firm phases */
+  int      clone_threshold; /**< The threshold value for procedure cloning. */
+  unsigned inline_maxsize;  /**< Maximum function size for inlining. */
+  unsigned inline_threshold;/**< Inlining benefice threshold. */
+  bool     verify_edges;    /**< verify edges */
 };
 
 /** statistic options */
@@ -42,40 +38,25 @@ typedef enum a_firmstat_selection_tag {
   STAT_FINAL       = 0x00000010,
 } a_firmstat_selection;
 
-/* backend selection */
-typedef enum a_backend_selection_tag {
-  BE_NONE      = 0,       /**< no backend */
-  BE_FIRM_BE   = 1,       /**< Use Firm internal backend facility. */
-  BE_FIRM2C    = 2        /**< Use generic Firm2C backend */
-} a_backend_selection;
-
 /* dumping options */
 struct a_firm_dump {
-  a_byte debug_print;   /**< enable debug print */
-  a_byte all_types;     /**< dump the All_types graph */
-  a_byte no_blocks;     /**< dump non-blocked graph */
-  a_byte extbb;         /**< dumps extended basic blocks */
-  a_byte ir_graph;      /**< dump all graphs */
-  a_byte all_phases;    /**< dump the IR graph after all phases */
-  a_byte statistic;     /**< Firm statistic setting */
-  a_byte stat_pattern;  /**< enable Firm statistic pattern */
-  a_byte stat_dag;      /**< enable Firm DAG statistic */
-  char   *filter;       /**< the dump filter */
+  bool debug_print;   /**< enable debug print */
+  bool all_types;     /**< dump the All_types graph */
+  bool no_blocks;     /**< dump non-blocked graph */
+  bool extbb;         /**< dumps extended basic blocks */
+  bool ir_graph;      /**< dump all graphs */
+  bool all_phases;    /**< dump the IR graph after all phases */
+  bool statistic;     /**< Firm statistic setting */
+  bool stat_pattern;  /**< enable Firm statistic pattern */
+  bool stat_dag;      /**< enable Firm DAG statistic */
+  char *filter;       /**< the dump filter */
 };
 
 struct a_firm_be_opt {
-  a_byte selection;
-  a_byte node_stat;
+  bool selection;
+  bool node_stat;
 };
 
-#ifdef FIRM_EXT_GRS
-struct a_firm_ext_grs {
-  a_byte simd_opt;          /**< enable graph based SIMD optimization */
-  a_byte create_pattern;    /**< enable pattern creation for SIMD opts */
-};
-#endif
-
-
 extern struct a_firm_be_opt firm_be_opt;
 extern struct a_firm_opt firm_opt;
 extern struct a_firm_dump firm_dump;
@@ -83,11 +64,6 @@ extern struct a_firm_ext_grs firm_ext_grs;
 
 void print_option_help(const char *name, const char *description);
 
-/**
- * prints the firm version number
- */
-void print_firm_version(FILE *f);
-
 /**
  * called by the generic command line parser
  * to handle the --firm= or -f options
diff --git a/driver/firm_codegen.c b/driver/firm_codegen.c
deleted file mode 100644 (file)
index ad89a96..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * @file firm_codegen.c
- *
- * Compile when BACK_END_IS_CP_FIRM_BE is defined
- *
- * (C) 2005-2009  Michael Beck  beck@ipd.info.uni-karlsruhe.de
- *
- * $Id$
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <libfirm/dbginfo.h>
-#include <libfirm/adt/xmalloc.h>
-#include <libfirm/be.h>
-
-#ifdef FIRM2C_BACKEND
-#include "cbackend.h"
-#endif
-
-#include "firm_codegen.h"
-#include "firm_cmdline.h"
-#include "firm_opt.h"
-#include "firm_timing.h"
-
-/**
- * Substitutes '.c' for '.s'.
- */
-static char *generate_asm_file_name(const char *file_name) {
-  int len             = strlen(file_name);
-  char *asm_file_name = xmalloc(len + 5);   /* .asm + \0 */
-
-  strcpy(asm_file_name, file_name);
-  if (asm_file_name[len - 2] == '.' && asm_file_name[len - 1] == 'c')
-    asm_file_name[len - 2] = '\0';
-
-  switch (firm_be_opt.selection) {
-#ifdef FIRM2C_BACKEND
-  case BE_FIRM2C:
-    strncat(asm_file_name, ".s.c", 4);
-    break;
-#endif
-
-  case BE_FIRM_BE:
-    strncat(asm_file_name, ".s", 4);
-    break;
-  }
-
-  return asm_file_name;
-}  /* generate_asm_file_name */
-
-/**
- * Calls the specified backend.
- * Code is written to file <file_name> ('.c' is substituted for '.asm')
- */
-void do_codegen(FILE *out, const char *file_name)
-{
-       FILE *close_out = NULL;
-       if (out == NULL) {
-               char *asm_file_name = generate_asm_file_name(file_name);
-
-               if ((out = fopen(asm_file_name, "w")) == NULL) {
-                       fprintf(stderr, "Could not open output file %s\n", asm_file_name);
-                       exit(1);
-               }
-               free(asm_file_name);
-               close_out = out;
-       }
-
-       switch (firm_be_opt.selection) {
-#ifdef FIRM2C_BACKEND
-               case BE_FIRM2C: {
-                       ir_timer_t *timer = ir_timer_new();
-                       timer_register(timer, "Firm: C-generating backend");
-                       timer_start(timer);
-                       generate_code_file(out);
-                       timer_stop(timer);
-                       break;
-               }
-#endif
-
-               case BE_FIRM_BE: {
-                       ir_timer_t *timer = ir_timer_new();
-                       timer_register(timer, "Firm: backend");
-                       timer_start(timer);
-                       be_main(out, file_name);
-                       timer_stop(timer);
-                       break;
-               }
-
-               default:
-                       fprintf(stderr, "Fatal: Unknown backend %d\n", firm_be_opt.selection);
-       } /* switch (firm_be_opt.selection) */
-
-       if (close_out)
-               fclose(close_out);
-}
index 4c89958..bc715e4 100644 (file)
@@ -648,7 +648,7 @@ void gen_firm_finish(FILE *out, const char *input_filename)
 
        /* the general for dumping option must be set, or the others will not work*/
        firm_dump.ir_graph
-               = (a_byte) (firm_dump.ir_graph | firm_dump.all_phases | firm_dump.extbb);
+               = (bool) (firm_dump.ir_graph | firm_dump.all_phases | firm_dump.extbb);
 
        ir_add_dump_flags(ir_dump_flag_keepalive_edges
                        | ir_dump_flag_consts_local | ir_dump_flag_dominance);
@@ -702,8 +702,11 @@ void gen_firm_finish(FILE *out, const char *input_filename)
                stat_dump_snapshot(input_filename, "final-ir");
 
        /* run the code generator */
-       if (firm_be_opt.selection != BE_NONE)
-               do_codegen(out, input_filename);
+       ir_timer_t *timer = ir_timer_new();
+       timer_register(timer, "Firm: backend");
+       timer_start(timer);
+       be_main(out, input_filename);
+       timer_stop(timer);
 
        if (firm_dump.statistic & STAT_FINAL)
                stat_dump_snapshot(input_filename, "final");
index d3e49d9..97bbba5 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef FIRM_OPT_H
 #define FIRM_OPT_H
 
+#include <stdio.h>
 #include <libfirm/firm_types.h>
 #include <libfirm/dbginfo.h>
 
diff --git a/driver/firm_timing.def b/driver/firm_timing.def
deleted file mode 100644 (file)
index 30368ec..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- * @file firm_timing.def -- timing for the Firm compiler
- *
- * (C) 2006  Michael Beck   beck@ipd.info.uni-karlsruhe.de
- *
- * $Id: firm_timing.def 20710 2008-07-26 19:59:07Z beck $
- */
-DEFTIMEVAR(TV_CONSTRUCT, "Frontend: Graph construction")