mips: handle various update types for vars
authorGuillaume Emont <guijemont@igalia.com>
Wed, 5 Dec 2012 18:21:17 +0000 (19:21 +0100)
committerGuillaume Emont <guijemont@igalia.com>
Fri, 28 Dec 2012 14:17:46 +0000 (15:17 +0100)
orc/orcprogram-mips.c
orc/orcrules-mips.c

index f5d8cb9..88d5245 100644 (file)
@@ -297,14 +297,24 @@ orc_mips_emit_loop (OrcCompiler *compiler)
   }
 
   for (j=0; j<ORC_N_COMPILER_VARIABLES; j++) {
-    if (compiler->vars[j].name == NULL) continue;
-    if (compiler->vars[j].vartype == ORC_VAR_TYPE_SRC ||
-        compiler->vars[j].vartype == ORC_VAR_TYPE_DEST) {
-      if (compiler->vars[j].ptr_register) {
+    OrcVariable *var = compiler->vars + j;
+
+    if (var->name == NULL) continue;
+    if (var->vartype == ORC_VAR_TYPE_SRC ||
+        var->vartype == ORC_VAR_TYPE_DEST) {
+      int offset;
+      if (var->update_type == 0) {
+        offset = 0;
+      } else if (var->update_type == 1) {
+        offset = (var->size << compiler->loop_shift) >> 1;
+      } else {
+        offset = var->size << compiler->loop_shift;
+      }
+      if (offset !=0 && var->ptr_register) {
         orc_mips_emit_addiu (compiler,
-            compiler->vars[j].ptr_register,
-            compiler->vars[j].ptr_register,
-            compiler->vars[j].size << compiler->loop_shift);
+                             var->ptr_register,
+                             var->ptr_register,
+                             offset);
       }
     }
   }
index 105b851..295a0a7 100644 (file)
@@ -48,7 +48,7 @@ mips_rule_load (OrcCompiler *compiler, void *user, OrcInstruction *insn)
   default:
     ORC_PROGRAM_ERROR(compiler, "Don't know how to handle that shift");
   }
-
+  compiler->vars[insn->src_args[0]].update_type = 2;
 }
 
 void
@@ -87,6 +87,7 @@ mips_rule_store (OrcCompiler *compiler, void *user, OrcInstruction *insn)
   default:
     ORC_PROGRAM_ERROR(compiler, "Don't know how to handle that shift");
   }
+  compiler->vars[insn->dest_args[0]].update_type = 2;
 }