From: Dale Weiler <killfieldengine@gmail.com>
Date: Sun, 6 Oct 2013 03:36:48 +0000 (-0400)
Subject: Fix some things: get all the Quake mods to compile again (I broke binary expressions... 
X-Git-Tag: 0.3.5~46
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a02e44100e6faf7dbf3b337332e26bcd1a903d8b;p=xonotic%2Fgmqcc.git

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).
---

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 "<UNK>";
     }
 }
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