i965: Move up fs_inst::regs_written to backend_instruction.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_blorp_blit_eu.h
index bb01df316ac17dd428fdbaf0aba702ad457c60f2..8953ce834873c5fcfb148db05e48676f4cf492cb 100644 (file)
 #define BRW_BLORP_BLIT_EU_H
 
 #include "brw_context.h"
-#include "brw_eu.h"
+#include "brw_fs.h"
 
 class brw_blorp_eu_emitter
 {
 protected:
-   explicit brw_blorp_eu_emitter(struct brw_context *brw);
+   explicit brw_blorp_eu_emitter(struct brw_context *brw, bool debug_flag);
    ~brw_blorp_eu_emitter();
 
-   const unsigned *get_program(unsigned *program_size, FILE *dump_file);
+   const unsigned *get_program(unsigned *program_size);
 
    void emit_kill_if_outside_rect(const struct brw_reg &x,
                                   const struct brw_reg &y,
@@ -59,13 +59,15 @@ protected:
 
    inline void emit_cond_mov(const struct brw_reg &x,
                              const struct brw_reg &y,
-                             int op,
+                             enum brw_conditional_mod op,
                              const struct brw_reg &dst,
                              const struct brw_reg &src)
    {
-      brw_CMP(&func, vec16(brw_null_reg()), op, x, y);
-      brw_MOV(&func, dst, src);
-      brw_set_predicate_control(&func, BRW_PREDICATE_NONE);
+      emit_cmp(op, x, y);
+
+      fs_inst *mv = new (mem_ctx) fs_inst(BRW_OPCODE_MOV, 16, dst, src);
+      mv->predicate = BRW_PREDICATE_NORMAL;
+      insts.push_tail(mv);
    }
 
    inline void emit_if_eq_mov(const struct brw_reg &x, unsigned y,
@@ -74,57 +76,111 @@ protected:
       emit_cond_mov(x, brw_imm_d(y), BRW_CONDITIONAL_EQ, dst, brw_imm_d(src));
    }
 
+   inline void emit_lrp(const struct brw_reg &dst,
+                        const struct brw_reg &src1,
+                        const struct brw_reg &src2,
+                        const struct brw_reg &src3)
+   {
+      insts.push_tail(
+         new (mem_ctx) fs_inst(BRW_OPCODE_LRP, 16, dst, src1, src2, src3));
+   }
+
    inline void emit_mov(const struct brw_reg& dst, const struct brw_reg& src)
    {
-      brw_MOV(&func, dst, src);
+      insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_MOV, 16, dst, src));
    }
 
    inline void emit_mov_8(const struct brw_reg& dst, const struct brw_reg& src)
    {
-      brw_set_compression_control(&func, BRW_COMPRESSION_NONE);
-      emit_mov(dst, src);
-      brw_set_compression_control(&func, BRW_COMPRESSION_COMPRESSED);
+      insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_MOV, 8, dst, src));
    }
 
    inline void emit_and(const struct brw_reg& dst,
                         const struct brw_reg& src1,
                         const struct brw_reg& src2)
    {
-      brw_AND(&func, dst, src1, src2);
+      insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_AND, 16, dst, src1, src2));
    }
 
    inline void emit_add(const struct brw_reg& dst,
                         const struct brw_reg& src1,
                         const struct brw_reg& src2)
    {
-      brw_ADD(&func, dst, src1, src2);
+      insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_ADD, 16, dst, src1, src2));
    }
 
    inline void emit_add_8(const struct brw_reg& dst,
                           const struct brw_reg& src1,
                           const struct brw_reg& src2)
    {
-      brw_set_compression_control(&func, BRW_COMPRESSION_NONE);
-      emit_add(dst, src1, src2);
-      brw_set_compression_control(&func, BRW_COMPRESSION_COMPRESSED);
+      insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_ADD, 8, dst, src1, src2));
+   }
+
+   inline void emit_mul(const struct brw_reg& dst,
+                        const struct brw_reg& src1,
+                        const struct brw_reg& src2)
+   {
+      insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_MUL, 16, dst, src1, src2));
    }
 
    inline void emit_shr(const struct brw_reg& dst,
                         const struct brw_reg& src1,
                         const struct brw_reg& src2)
    {
-      brw_SHR(&func, dst, src1, src2);
+      insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_SHR, 16, dst, src1, src2));
    }
 
    inline void emit_shl(const struct brw_reg& dst,
                         const struct brw_reg& src1,
                         const struct brw_reg& src2)
    {
-      brw_SHL(&func, dst, src1, src2);
+      insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_SHL, 16, dst, src1, src2));
+   }
+
+   inline void emit_or(const struct brw_reg& dst,
+                       const struct brw_reg& src1,
+                       const struct brw_reg& src2)
+   {
+      insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_OR, 16, dst, src1, src2));
+   }
+
+   inline void emit_frc(const struct brw_reg& dst,
+                        const struct brw_reg& src)
+   {
+      insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_FRC, 16, dst, src));
+   }
+
+   inline void emit_rndd(const struct brw_reg& dst,
+                         const struct brw_reg& src)
+   {
+      insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_RNDD, 16, dst, src));
+   }
+
+   inline void emit_cmp_if(enum brw_conditional_mod op,
+                           const struct brw_reg &x,
+                           const struct brw_reg &y)
+   {
+      emit_cmp(op, x, y);
+      insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_IF, 16));
    }
 
+   inline void emit_else(void)
+   {
+      insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_ELSE, 16));
+   }
+
+   inline void emit_endif(void)
+   {
+      insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_ENDIF, 16));
+   }
+
+private:
+   fs_inst *emit_cmp(enum brw_conditional_mod op, const struct brw_reg &x,
+                     const struct brw_reg &y);
+
    void *mem_ctx;
-   struct brw_compile func;
+   exec_list insts;
+   fs_generator generator;
 };
 
 #endif /* BRW_BLORP_BLIT_EU_H */