From: Dale Weiler Date: Mon, 30 Sep 2013 09:12:28 +0000 (-0400) Subject: Handle double negation case specially. Update TODO X-Git-Tag: 0.3.5~58 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=03b56bd41f087b8310ce9f6341106f8f82c133ce;p=xonotic%2Fgmqcc.git Handle double negation case specially. Update TODO --- diff --git a/TODO b/TODO index 94163af..8652ed2 100644 --- 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 ad85e4f..e1f86a6 100644 --- 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);