Merge branch '7.8'
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_tgsi_soa.c
index df2e24c2c90cbbf806f4523c2f83133f3b9079cc..d3c769e28b88ae2c9236aa57c58ed9feda79ce1a 100644 (file)
@@ -744,22 +744,11 @@ emit_declaration(
    struct lp_build_tgsi_soa_context *bld,
    const struct tgsi_full_declaration *decl)
 {
+   LLVMTypeRef vec_type = lp_build_vec_type(bld->base.type);
+
    unsigned first = decl->Range.First;
    unsigned last = decl->Range.Last;
    unsigned idx, i;
-   LLVMBasicBlockRef current_block =
-      LLVMGetInsertBlock(bld->base.builder);
-   LLVMBasicBlockRef first_block =
-      LLVMGetEntryBasicBlock(
-         LLVMGetBasicBlockParent(current_block));
-   LLVMValueRef first_inst =
-      LLVMGetFirstInstruction(first_block);
-
-   /* we want alloca's to be the first instruction
-    * in the function so we need to rewind the builder
-    * to the very beginning */
-   LLVMPositionBuilderBefore(bld->base.builder,
-                             first_inst);
 
    for (idx = first; idx <= last; ++idx) {
       switch (decl->Declaration.File) {
@@ -767,23 +756,25 @@ emit_declaration(
          if (bld->has_indirect_addressing) {
             LLVMValueRef val = LLVMConstInt(LLVMInt32Type(),
                                             last*4 + 4, 0);
-            bld->temps_array = LLVMBuildArrayAlloca(bld->base.builder,
-                                                    lp_build_vec_type(bld->base.type),
-                                                    val, "");
+            bld->temps_array = lp_build_array_alloca(bld->base.builder,
+                                                     vec_type, val, "");
          } else {
             for (i = 0; i < NUM_CHANNELS; i++)
-               bld->temps[idx][i] = lp_build_alloca(&bld->base);
+               bld->temps[idx][i] = lp_build_alloca(bld->base.builder,
+                                                    vec_type, "");
          }
          break;
 
       case TGSI_FILE_OUTPUT:
          for (i = 0; i < NUM_CHANNELS; i++)
-            bld->outputs[idx][i] = lp_build_alloca(&bld->base);
+            bld->outputs[idx][i] = lp_build_alloca(bld->base.builder,
+                                                   vec_type, "");
          break;
 
       case TGSI_FILE_ADDRESS:
          for (i = 0; i < NUM_CHANNELS; i++)
-            bld->addr[idx][i] = lp_build_alloca(&bld->base);
+            bld->addr[idx][i] = lp_build_alloca(bld->base.builder,
+                                                vec_type, "");
          break;
 
       default:
@@ -792,8 +783,6 @@ emit_declaration(
       }
    }
 
-   LLVMPositionBuilderAtEnd(bld->base.builder,
-                            current_block);
    return TRUE;
 }
 
@@ -1600,22 +1589,10 @@ emit_instruction(
       lp_exec_mask_cond_push(&bld->exec_mask, tmp0);
       break;
 
-   case TGSI_OPCODE_BGNFOR:
-      /* deprecated */
-      assert(0);
-      return FALSE;
-      break;
-
    case TGSI_OPCODE_BGNLOOP:
       lp_exec_bgnloop(&bld->exec_mask);
       break;
 
-   case TGSI_OPCODE_REP:
-      /* deprecated */
-      assert(0);
-      return FALSE;
-      break;
-
    case TGSI_OPCODE_ELSE:
       lp_exec_mask_cond_invert(&bld->exec_mask);
       break;
@@ -1624,22 +1601,10 @@ emit_instruction(
       lp_exec_mask_cond_pop(&bld->exec_mask);
       break;
 
-   case TGSI_OPCODE_ENDFOR:
-      /* deprecated */
-      assert(0);
-      return FALSE;
-      break;
-
    case TGSI_OPCODE_ENDLOOP:
       lp_exec_endloop(&bld->exec_mask);
       break;
 
-   case TGSI_OPCODE_ENDREP:
-      /* deprecated */
-      assert(0);
-      return FALSE;
-      break;
-
    case TGSI_OPCODE_PUSHA:
       /* deprecated? */
       assert(0);
@@ -1809,10 +1774,10 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
       case TGSI_TOKEN_TYPE_INSTRUCTION:
          {
             unsigned opcode = parse.FullToken.FullInstruction.Instruction.Opcode;
-            const struct tgsi_opcode_info *info = tgsi_get_opcode_info(opcode);
-            if (!emit_instruction( &bld, &parse.FullToken.FullInstruction, info ))
+            const struct tgsi_opcode_info *opcode_info = tgsi_get_opcode_info(opcode);
+            if (!emit_instruction( &bld, &parse.FullToken.FullInstruction, opcode_info ))
                _debug_printf("warning: failed to translate tgsi opcode %s to LLVM\n",
-                             info ? info->mnemonic : "<invalid>");
+                             opcode_info->mnemonic);
          }
 
          break;