From a02e44100e6faf7dbf3b337332e26bcd1a903d8b Mon Sep 17 00:00:00 2001 From: Dale Weiler Date: Sat, 5 Oct 2013 23:36:48 -0400 Subject: [PATCH] Fix some things: get all the Quake mods to compile again (I broke binary expressions .. oops) Fix the check-proj script, using $? for status was invalid because of pipes. The ir now properly considers negation virtual instruction to be operations (as it should). --- ast.c | 10 ++++------ ir.c | 4 +++- misc/check-proj.sh | 7 +++++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/ast.c b/ast.c index 4c14203..362a06f 100644 --- a/ast.c +++ b/ast.c @@ -450,10 +450,6 @@ ast_binary* ast_binary_new(lex_ctx_t ctx, int op, ast_propagate_effects(self, left); ast_propagate_effects(self, right); - /* - * Try to fold away superfluous binary operations, such as: - * A * 1, a + 0, etc. - */ if (OPTS_OPTIMIZATION(OPTIM_PEEPHOLE) && (fold = (ast_binary*)fold_superfluous(left, right, op))) { ast_binary_delete(self); return fold; @@ -467,10 +463,12 @@ ast_binary* ast_binary_new(lex_ctx_t ctx, int op, else self->expression.vtype = TYPE_FLOAT; } - else if (op == INSTR_BITAND || op == INSTR_BITOR || op == INSTR_MUL_F) + else if (op == INSTR_BITAND || op == INSTR_BITOR) self->expression.vtype = TYPE_FLOAT; - else if (op >= INSTR_MUL_V && op <= INSTR_MUL_VF) + else if (op == INSTR_MUL_VF || op == INSTR_MUL_FV) self->expression.vtype = TYPE_VECTOR; + else if (op == INSTR_MUL_V) + self->expression.vtype = TYPE_FLOAT; else self->expression.vtype = left->vtype; diff --git a/ir.c b/ir.c index f33e48c..f0274e1 100644 --- a/ir.c +++ b/ir.c @@ -613,7 +613,7 @@ static bool instr_is_operation(uint16_t op) (op >= INSTR_NOT_F && op <= INSTR_NOT_FNC) || (op >= INSTR_AND && op <= INSTR_BITOR) || (op >= INSTR_CALL0 && op <= INSTR_CALL8) || - (op >= VINSTR_BITAND_V && op <= VINSTR_CROSS) ); + (op >= VINSTR_BITAND_V && op <= VINSTR_NEG_V) ); } static bool ir_function_pass_peephole(ir_function *self) @@ -3999,6 +3999,8 @@ static const char *qc_opname(int op) case VINSTR_BITOR_VF: return "BITOR_VF"; case VINSTR_BITXOR_VF: return "BITXOR_VF"; case VINSTR_CROSS: return "CROSS"; + case VINSTR_NEG_F: return "NEG_F"; + case VINSTR_NEG_V: return "NEG_V"; default: return ""; } } diff --git a/misc/check-proj.sh b/misc/check-proj.sh index 36b3774..90242e9 100755 --- a/misc/check-proj.sh +++ b/misc/check-proj.sh @@ -116,7 +116,8 @@ do echo -n " compiling $dir... " old="$PWD" cd "$dir" - "$gmqcc_bin" $(cat ../../../options | grep "$line:" | awk '{print substr($0, index($0, $2))}') > /dev/null 2>&1 + cmd="$(cat ../../../options | grep "$line:" | awk '{print substr($0, index($0, $2))}')" + "$gmqcc_bin" $cmd > /dev/null 2>&1 if [ $? -ne 0 ]; then echo "error" else @@ -126,7 +127,9 @@ do done # nope only one project else - "$gmqcc_bin" $(cat ../../options | grep "$line:" | awk '{print substr($0, index($0, $2))}') > /dev/null 2>&1 + echo "$gmqcc_bin" $(cat ../../options | grep "$line:" | awk '{print substr($0, index($0, $2))}') + cmd="$(cat ../../options | grep "$line:" | awk '{print substr($0, index($0, $2))}')" + "$gmqcc_bin" $cmd > /dev/null 2>&1 if [ $? -ne 0 ]; then echo "error" else -- 2.39.2