]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Handle double negation case specially. Update TODO
authorDale Weiler <killfieldengine@gmail.com>
Mon, 30 Sep 2013 09:12:28 +0000 (05:12 -0400)
committerDale Weiler <killfieldengine@gmail.com>
Mon, 30 Sep 2013 09:12:28 +0000 (05:12 -0400)
TODO
ast.c

diff --git a/TODO b/TODO
index 94163afefcf65b50881f672f3e5735a7e42b128f..8652ed228b22b6dbe660b14f53fb12a1fb661ad7 100644 (file)
--- a/TODO
+++ b/TODO
@@ -29,21 +29,10 @@ Optimizations:
             Which can be replaced with calls to a shared subroutine. To
             reduce duplicated code. (Size optimization)
 
-    The following are optimizations that can be implemented anywhere, ideally
-    these are functional language optimizations.
-
-        Removing Recursion:
-            Tail recursive algorithms can be converted to iteration, which
-            does not have to have call overhead.
-
-
 Language Features:
     The following are language features that we'd like to see implemented in the
     future.
 
-    Enumerations:
-        Like C
-
     AST Macros:
         Macros with sanity.  Not textual substiution.
 
@@ -153,5 +142,3 @@ Testsuite:
 Assembler:
     Possibly support for a future assembler for QCASM.  But we're not
     entirely sure if it makes sense.
-
-
diff --git a/ast.c b/ast.c
index ad85e4fec6bc4d38ab3a360c0254eb8f48070b82..e1f86a65e9b5558d1d4a71989b79e60ab85c973d 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -518,8 +518,15 @@ ast_unary* ast_unary_new(lex_ctx_t ctx, int op,
     self->op      = op;
     self->operand = expr;
 
+
     if (ast_istype(expr, ast_unary) && OPTS_OPTIMIZATION(OPTIM_PEEPHOLE)) {
         ast_unary *prev = (ast_unary*)((ast_unary*)expr)->operand;
+        ast_unary *cur  = (ast_unary*)expr;
+
+        /* Handle for double negation */
+        if (cur->op == op && (op >= VINSTR_NEG_F && op <= VINSTR_NEG_V))
+            prev = cur;
+
         if (ast_istype(prev, ast_unary)) {
             ast_expression_delete((ast_expression*)self);
             mem_d(self);