[Mesa-dev] [PATCH 4/5] i965: prepare work for dynamic instruction store size on JMPI

Yuanhan Liu yuanhan.liu at linux.intel.com
Mon Dec 5 02:24:54 PST 2011


If dynamic instruction store size is enabled, while after the brw_JMPI()
and before the brw_land_fwd_jump() function, the eu instruction store
base address(p->store) may change. Thus, the safe way to reference the
jmp instruction is by index instead of by the instruction address.

Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
---
 src/mesa/drivers/dri/i965/brw_eu.h      |    8 +++++---
 src/mesa/drivers/dri/i965/brw_eu_emit.c |   17 ++++++++---------
 src/mesa/drivers/dri/i965/brw_sf_emit.c |    2 +-
 src/mesa/drivers/dri/i965/brw_wm_emit.c |    2 +-
 4 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h
index 19b919f..18dd9c7 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -849,7 +849,6 @@ ALU2(SHL)
 ALU2(RSR)
 ALU2(RSL)
 ALU2(ASR)
-ALU2(JMPI)
 ALU2(ADD)
 ALU2(MUL)
 ALU1(FRC)
@@ -1018,8 +1017,11 @@ struct brw_instruction *brw_CONT(struct brw_compile *p, int pop_count);
 struct brw_instruction *gen6_CONT(struct brw_compile *p);
 /* Forward jumps:
  */
-void brw_land_fwd_jump(struct brw_compile *p, 
-		       struct brw_instruction *jmp_insn);
+int brw_JMPI(struct brw_compile *p,
+             struct brw_reg dest,
+             struct brw_reg src0,
+             struct brw_reg src1);
+void brw_land_fwd_jump(struct brw_compile *p, int jmp_insn_idx);
 
 
 
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 2acfacf..29dd623 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -879,10 +879,10 @@ void brw_NOP(struct brw_compile *p)
  * Comparisons, if/else/endif
  */
 
-struct brw_instruction *brw_JMPI(struct brw_compile *p, 
-                                 struct brw_reg dest,
-                                 struct brw_reg src0,
-                                 struct brw_reg src1)
+int brw_JMPI(struct brw_compile *p,
+             struct brw_reg dest,
+             struct brw_reg src0,
+             struct brw_reg src1)
 {
    struct brw_instruction *insn = brw_alu2(p, BRW_OPCODE_JMPI, dest, src0, src1);
 
@@ -892,7 +892,7 @@ struct brw_instruction *brw_JMPI(struct brw_compile *p,
 
    p->current->header.predicate_control = BRW_PREDICATE_NONE;
 
-   return insn;
+   return brw_insn_index(p, insn);
 }
 
 static void
@@ -1360,11 +1360,10 @@ struct brw_instruction *brw_WHILE(struct brw_compile *p, int do_insn_idx)
 
 /* FORWARD JUMPS:
  */
-void brw_land_fwd_jump(struct brw_compile *p, 
-		       struct brw_instruction *jmp_insn)
+void brw_land_fwd_jump(struct brw_compile *p, int jmp_insn_idx)
 {
    struct intel_context *intel = &p->brw->intel;
-   struct brw_instruction *landing = &p->store[p->nr_insn];
+   struct brw_instruction *jmp_insn = &p->store[jmp_insn_idx];
    GLuint jmpi = 1;
 
    if (intel->gen >= 5)
@@ -1373,7 +1372,7 @@ void brw_land_fwd_jump(struct brw_compile *p,
    assert(jmp_insn->header.opcode == BRW_OPCODE_JMPI);
    assert(jmp_insn->bits1.da1.src1_reg_file == BRW_IMMEDIATE_VALUE);
 
-   jmp_insn->bits3.ud = jmpi * ((landing - jmp_insn) - 1);
+   jmp_insn->bits3.ud = jmpi * ((p->nr_insn - jmp_insn_idx) - 1);
 }
 
 
diff --git a/src/mesa/drivers/dri/i965/brw_sf_emit.c b/src/mesa/drivers/dri/i965/brw_sf_emit.c
index fe3341c..ba890d4 100644
--- a/src/mesa/drivers/dri/i965/brw_sf_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_sf_emit.c
@@ -717,7 +717,7 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c )
    struct brw_reg payload_prim = brw_uw1_reg(BRW_GENERAL_REGISTER_FILE, 1, 0);
    struct brw_reg payload_attr = get_element_ud(brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, 1, 0), 0); 
    struct brw_reg primmask;
-   struct brw_instruction *jmp;
+   int jmp;
    struct brw_reg v1_null_ud = vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_UD));
    
    GLuint saveflag;
diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c
index b5a4a4f..ad49244 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c
@@ -1528,7 +1528,7 @@ void emit_fb_write(struct brw_wm_compile *c,
    else {
       struct brw_reg v1_null_ud = vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_UD));
       struct brw_reg ip = brw_ip_reg();
-      struct brw_instruction *jmp;
+      int jmp;
       
       brw_set_compression_control(p, BRW_COMPRESSION_NONE);
       brw_set_conditionalmod(p, BRW_CONDITIONAL_Z);
-- 
1.7.4.4



More information about the mesa-dev mailing list