fix optimized build, add benchmark mode
authorMatthias Braun <matze@braunis.de>
Fri, 8 Feb 2008 14:01:52 +0000 (14:01 +0000)
committerMatthias Braun <matze@braunis.de>
Fri, 8 Feb 2008 14:01:52 +0000 (14:01 +0000)
[r18849]

Makefile
ast.c
ast_t.h
main.c
parser.c
type.c

index e9c4c30..07db018 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -13,8 +13,10 @@ CPPFLAGS += $(FIRM_CFLAGS)
 
 CFLAGS += -Wall -W -Wstrict-prototypes -Wmissing-prototypes -Werror -std=c99 -pedantic
 CFLAGS += -O0 -g3
-ICC_CFLAGS = -O0 -g3 -std=c99 -Wall -Werror
 #CFLAGS += -O3 -march=pentium4 -fomit-frame-pointer -DNDEBUG
+#CFLAGS += -pg -O3 -fno-inline
+ICC_CFLAGS = -O0 -g3 -std=c99 -Wall -Werror
+LFLAGS += -pg
 ICC    ?= true
 GCCO1  ?= true
 
diff --git a/ast.c b/ast.c
index 4bf3258..51b6a7c 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -155,15 +155,10 @@ static unsigned get_expression_precedence(expression_kind_t kind)
                [EXPR_BINARY_ISLESSGREATER]      = PREC_PRIM,
                [EXPR_BINARY_ISUNORDERED]        = PREC_PRIM
        };
-#ifndef NDEBUG
-       if ((unsigned)kind >= (sizeof(prec)/sizeof(prec[0]))) {
-               panic("wrong expression kind");
-       }
+       assert((unsigned)kind < (sizeof(prec)/sizeof(prec[0])));
        unsigned res = prec[kind];
-       if (res == PREC_BOTTOM) {
-               panic("expression kind not defined in get_expression_precedence()");
-       }
-#endif
+
+       assert(res != PREC_BOTTOM);
        return res;
 }
 
diff --git a/ast_t.h b/ast_t.h
index 8da84ad..41e86c7 100644 (file)
--- a/ast_t.h
+++ b/ast_t.h
@@ -154,7 +154,8 @@ typedef enum {
        case EXPR_UNARY_BITFIELD_EXTRACT:
 
 struct scope_t {
-       declaration_t *declarations;  /**< List of declarations in this scope. */
+       declaration_t *declarations;      /**< List of declarations in this scope. */
+       declaration_t *last_declaration;
 };
 
 struct expression_base_t {
diff --git a/main.c b/main.c
index 64797fd..9a688b8 100644 (file)
--- a/main.c
+++ b/main.c
@@ -316,6 +316,7 @@ void lower_compound_params(void)
 }
 
 typedef enum compile_mode_t {
+       BenchmarkParser,
        ParseOnly,
        Compile,
        CompileDump,
@@ -480,6 +481,8 @@ int main(int argc, char **argv)
                                        strict_mode = true;
                                } else if(strcmp(option, "lextest") == 0) {
                                        mode = LexTest;
+                               } else if(strcmp(option, "benchmark") == 0) {
+                                       mode = BenchmarkParser;
                                } else if(strcmp(option, "print-ast") == 0) {
                                        mode = PrintAst;
                                } else if(strcmp(option, "print-implicit-cast") == 0) {
@@ -556,6 +559,7 @@ int main(int argc, char **argv)
        char  outnamebuf[4096];
        if(outname == NULL) {
                switch(mode) {
+               case BenchmarkParser:
                case PrintAst:
                case PrintFluffy:
                case LexTest:
@@ -632,6 +636,10 @@ int main(int argc, char **argv)
                fprintf(stderr, "%u warning(s)\n", warning_count);
        }
 
+       if(mode == BenchmarkParser) {
+               return 0;
+       }
+
        if(mode == PrintAst) {
                type_set_output(out);
                ast_set_output(out);
index 228c8d8..7467196 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -494,14 +494,12 @@ static void eat_paren(void)
 
 static void set_scope(scope_t *new_scope)
 {
+       if(scope != NULL) {
+               scope->last_declaration = last_declaration;
+       }
        scope = new_scope;
 
-       last_declaration = new_scope->declarations;
-       if(last_declaration != NULL) {
-               while(last_declaration->next != NULL) {
-                       last_declaration = last_declaration->next;
-               }
-       }
+       last_declaration = new_scope->last_declaration;
 }
 
 /**
diff --git a/type.c b/type.c
index 5c3da00..e7ceb05 100644 (file)
--- a/type.c
+++ b/type.c
@@ -855,6 +855,8 @@ bool pointers_compatible(const type_t *type1, const type_t *type2)
 
        assert(type1->kind == TYPE_POINTER);
        assert(type2->kind == TYPE_POINTER);
+       (void) type1;
+       (void) type2;
        /* TODO */
        return true;
 }