[Mesa-dev] [PATCH 3/4] i965: let if_stack just store the instruction index

2011-11-29 Thread Yuanhan Liu
Let if_stack just store the instruction pointer(an index). This is
somehow more flexible than store the instruction memory address.

This patch is mainly for the next patch.

Signed-off-by: Yuanhan Liu yuanhan@linux.intel.com
---
 src/mesa/drivers/dri/i965/brw_eu.c  |3 +--
 src/mesa/drivers/dri/i965/brw_eu.h  |4 +++-
 src/mesa/drivers/dri/i965/brw_eu_emit.c |   16 
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu.c 
b/src/mesa/drivers/dri/i965/brw_eu.c
index b5a858b..d6e5c09 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.c
+++ b/src/mesa/drivers/dri/i965/brw_eu.c
@@ -191,8 +191,7 @@ brw_init_compile(struct brw_context *brw, struct 
brw_compile *p, void *mem_ctx)
/* Set up control flow stack */
p-if_stack_depth = 0;
p-if_stack_array_size = 16;
-   p-if_stack =
-  rzalloc_array(mem_ctx, struct brw_instruction *, p-if_stack_array_size);
+   p-if_stack = rzalloc_array(mem_ctx, GLuint, p-if_stack_array_size);
 }
 
 
diff --git a/src/mesa/drivers/dri/i965/brw_eu.h 
b/src/mesa/drivers/dri/i965/brw_eu.h
index 8a446eb..9bc8a76 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -123,8 +123,10 @@ struct brw_compile {
/* Control flow stacks:
 * - if_stack contains IF and ELSE instructions which must be patched
 *   (and popped) once the matching ENDIF instruction is encountered.
+*
+*   Just store the instruction pointer(an index).
 */
-   struct brw_instruction **if_stack;
+   GLuint *if_stack;
int if_stack_depth;
int if_stack_array_size;
 
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 60350ca..b9feb7d 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -896,14 +896,14 @@ struct brw_instruction *brw_JMPI(struct brw_compile *p,
 }
 
 static void
-push_if_stack(struct brw_compile *p, struct brw_instruction *inst)
+push_if_stack(struct brw_compile *p, GLuint inst)
 {
p-if_stack[p-if_stack_depth] = inst;
 
p-if_stack_depth++;
if (p-if_stack_array_size = p-if_stack_depth) {
   p-if_stack_array_size *= 2;
-  p-if_stack = reralloc(p-mem_ctx, p-if_stack, struct brw_instruction *,
+  p-if_stack = reralloc(p-mem_ctx, p-if_stack, GLuint,
 p-if_stack_array_size);
}
 }
@@ -957,7 +957,7 @@ brw_IF(struct brw_compile *p, GLuint execute_size)
 
p-current-header.predicate_control = BRW_PREDICATE_NONE;
 
-   push_if_stack(p, insn);
+   push_if_stack(p, p-nr_insn - 1);
return insn;
 }
 
@@ -989,7 +989,7 @@ gen6_IF(struct brw_compile *p, uint32_t conditional,
if (!p-single_program_flow)
   insn-header.thread_control = BRW_THREAD_SWITCH;
 
-   push_if_stack(p, insn);
+   push_if_stack(p, p-nr_insn - 1);
return insn;
 }
 
@@ -1139,7 +1139,7 @@ brw_ELSE(struct brw_compile *p)
if (!p-single_program_flow)
   insn-header.thread_control = BRW_THREAD_SWITCH;
 
-   push_if_stack(p, insn);
+   push_if_stack(p, p-nr_insn - 1);
 }
 
 void
@@ -1152,11 +1152,11 @@ brw_ENDIF(struct brw_compile *p)
 
/* Pop the IF and (optional) ELSE instructions from the stack */
p-if_stack_depth--;
-   if (p-if_stack[p-if_stack_depth]-header.opcode == BRW_OPCODE_ELSE) {
-  else_inst = p-if_stack[p-if_stack_depth];
+   if (p-store[p-if_stack[p-if_stack_depth]].header.opcode == 
BRW_OPCODE_ELSE) {
+  else_inst = p-store[p-if_stack[p-if_stack_depth]];
   p-if_stack_depth--;
}
-   if_inst = p-if_stack[p-if_stack_depth];
+   if_inst = p-store[p-if_stack[p-if_stack_depth]];
 
if (p-single_program_flow) {
   /* ENDIF is useless; don't bother emitting it. */
-- 
1.7.4.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/4] i965: let if_stack just store the instruction index

2011-11-29 Thread Eric Anholt
On Tue, 29 Nov 2011 16:08:38 +0800, Yuanhan Liu yuanhan@linux.intel.com 
wrote:
 Let if_stack just store the instruction pointer(an index). This is
 somehow more flexible than store the instruction memory address.

I'd be more specific: This lets us realloc the instruction store.

 diff --git a/src/mesa/drivers/dri/i965/brw_eu.c 
 b/src/mesa/drivers/dri/i965/brw_eu.c
 index b5a858b..d6e5c09 100644
 --- a/src/mesa/drivers/dri/i965/brw_eu.c
 +++ b/src/mesa/drivers/dri/i965/brw_eu.c
 @@ -191,8 +191,7 @@ brw_init_compile(struct brw_context *brw, struct 
 brw_compile *p, void *mem_ctx)
 /* Set up control flow stack */
 p-if_stack_depth = 0;
 p-if_stack_array_size = 16;
 -   p-if_stack =
 -  rzalloc_array(mem_ctx, struct brw_instruction *, 
 p-if_stack_array_size);
 +   p-if_stack = rzalloc_array(mem_ctx, GLuint, p-if_stack_array_size);
  }

Please use plain types instead of the awful GL-decorated types, unless
it's something directly exposed in the GL API.

(if you want sized types, the standard ones in inttypes.h are good)


pgpbotDhI4ruN.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/4] i965: let if_stack just store the instruction index

2011-11-29 Thread Yuanhan Liu
On Tue, Nov 29, 2011 at 10:35:42AM -0800, Eric Anholt wrote:
 On Tue, 29 Nov 2011 16:08:38 +0800, Yuanhan Liu yuanhan@linux.intel.com 
 wrote:
  Let if_stack just store the instruction pointer(an index). This is
  somehow more flexible than store the instruction memory address.
 
 I'd be more specific: This lets us realloc the instruction store.
 
  diff --git a/src/mesa/drivers/dri/i965/brw_eu.c 
  b/src/mesa/drivers/dri/i965/brw_eu.c
  index b5a858b..d6e5c09 100644
  --- a/src/mesa/drivers/dri/i965/brw_eu.c
  +++ b/src/mesa/drivers/dri/i965/brw_eu.c
  @@ -191,8 +191,7 @@ brw_init_compile(struct brw_context *brw, struct 
  brw_compile *p, void *mem_ctx)
  /* Set up control flow stack */
  p-if_stack_depth = 0;
  p-if_stack_array_size = 16;
  -   p-if_stack =
  -  rzalloc_array(mem_ctx, struct brw_instruction *, 
  p-if_stack_array_size);
  +   p-if_stack = rzalloc_array(mem_ctx, GLuint, p-if_stack_array_size);
   }
 
 Please use plain types instead of the awful GL-decorated types, unless
 it's something directly exposed in the GL API.

Agreed. But I somehow followed the type usage of 'GLuint nr_insn'
defined in brw_compile. Since the if_stack is used to store instruction
index, and the index is defined in a GLuint type. That's why I
origianlly used GLuint.

So, I should also change the type of nr_insn to something like int, too?
(BTW, I guess int would be enough, but for good semantics, a positive
index, should I use uint32_t?)

Thanks,
Yuanhan Liu

 
 (if you want sized types, the standard ones in inttypes.h are good)


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev