[Beignet] [PATCH] GBE: output compact flag when output asm.
Zhigang Gong
zhigang.gong at linux.intel.com
Tue Jun 10 20:08:32 PDT 2014
LGTM, will push latter. thanks.
On Wed, Jun 11, 2014 at 11:14:52AM +0800, Ruiling Song wrote:
> Signed-off-by: Ruiling Song <ruiling.song at intel.com>
> ---
> backend/src/backend/gen/gen_mesa_disasm.c | 6 +++++-
> backend/src/backend/gen/gen_mesa_disasm.h | 2 +-
> backend/src/backend/gen_context.cpp | 5 ++---
> backend/src/backend/gen_program.cpp | 16 +++++++++++++---
> backend/src/backend/gen_program.hpp | 4 +++-
> 5 files changed, 24 insertions(+), 9 deletions(-)
>
> diff --git a/backend/src/backend/gen/gen_mesa_disasm.c b/backend/src/backend/gen/gen_mesa_disasm.c
> index 53dc361..c120b60 100644
> --- a/backend/src/backend/gen/gen_mesa_disasm.c
> +++ b/backend/src/backend/gen/gen_mesa_disasm.c
> @@ -1090,7 +1090,7 @@ static int qtr_ctrl(FILE *file, const union GenNativeInstruction *inst)
> return 0;
> }
>
> -int gen_disasm (FILE *file, const void *opaque_insn, uint32_t deviceID)
> +int gen_disasm (FILE *file, const void *opaque_insn, uint32_t deviceID, uint32_t compacted)
> {
> const union GenNativeInstruction *inst = (const union GenNativeInstruction *) opaque_insn;
> int err = 0;
> @@ -1287,6 +1287,10 @@ int gen_disasm (FILE *file, const void *opaque_insn, uint32_t deviceID)
> inst->header.opcode == GEN_OPCODE_SENDC)
> err |= control (file, "end of thread", end_of_thread,
> inst->bits3.generic_gen5.end_of_thread, &space);
> +
> + if(compacted) {
> + string(file, " Compacted");
> + }
> if (space)
> string (file, " ");
> string (file, "}");
> diff --git a/backend/src/backend/gen/gen_mesa_disasm.h b/backend/src/backend/gen/gen_mesa_disasm.h
> index ca2ba2d..ae007a4 100644
> --- a/backend/src/backend/gen/gen_mesa_disasm.h
> +++ b/backend/src/backend/gen/gen_mesa_disasm.h
> @@ -34,7 +34,7 @@
> extern "C" {
> #endif /* __cplusplus */
>
> -extern int gen_disasm(FILE *file, const void *opaque_insn, uint32_t deviceID);
> +extern int gen_disasm(FILE *file, const void *opaque_insn, uint32_t deviceID, uint32_t compacted);
>
> #ifdef __cplusplus
> }
> diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
> index 7133261..edb7414 100644
> --- a/backend/src/backend/gen_context.cpp
> +++ b/backend/src/backend/gen_context.cpp
> @@ -39,7 +39,6 @@
>
> namespace gbe
> {
> - extern void decompactInstruction(union GenCompactInstruction *p, union GenNativeInstruction *pOut);
> ///////////////////////////////////////////////////////////////////////////
> // GenContext implementation
> ///////////////////////////////////////////////////////////////////////////
> @@ -1890,10 +1889,10 @@ namespace gbe
> pCom = (GenCompactInstruction*)&p->store[insnID];
> if(pCom->bits1.cmpt_control == 1) {
> decompactInstruction(pCom, &insn);
> - gen_disasm(stdout, &insn, deviceID);
> + gen_disasm(stdout, &insn, deviceID, 1);
> insnID++;
> } else {
> - gen_disasm(stdout, &p->store[insnID], deviceID);
> + gen_disasm(stdout, &p->store[insnID], deviceID, 0);
> insnID = insnID + 2;
> }
> }
> diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp
> index 9fca8fa..baea83f 100644
> --- a/backend/src/backend/gen_program.cpp
> +++ b/backend/src/backend/gen_program.cpp
> @@ -72,9 +72,19 @@ namespace gbe {
> FILE *f = fopen("/dev/null", "w");
> char *buf = new char[4096];
> setbuffer(f, buf, 4096);
> -
> - for (uint32_t i = 0; i < insnNum; i++) {
> - gen_disasm(f, insns+i, deviceID);
> + GenCompactInstruction * pCom = NULL;
> + GenNativeInstruction nativeInsn;
> +
> + for (uint32_t i = 0; i < insnNum;) {
> + pCom = (GenCompactInstruction*)(insns+i);
> + if(pCom->bits1.cmpt_control == 1) {
> + decompactInstruction(pCom, &nativeInsn);
> + gen_disasm(f, &nativeInsn, deviceID, 1);
> + i++;
> + } else {
> + gen_disasm(f, insns+i, deviceID, 0);
> + i = i + 2;
> + }
> outs << buf;
> fflush(f);
> setbuffer(f, NULL, 0);
> diff --git a/backend/src/backend/gen_program.hpp b/backend/src/backend/gen_program.hpp
> index d308212..d5c9079 100644
> --- a/backend/src/backend/gen_program.hpp
> +++ b/backend/src/backend/gen_program.hpp
> @@ -27,6 +27,7 @@
>
> #include "backend/program.h"
> #include "backend/program.hpp"
> +#include "backend/gen_defs.hpp"
>
> // Gen ISA instruction
> struct GenInstruction;
> @@ -75,7 +76,8 @@ namespace gbe
> /*! Use custom allocators */
> GBE_CLASS(GenProgram);
> };
> -
> + /*! decompact GEN ASM if it is in compacted format */
> + extern void decompactInstruction(union GenCompactInstruction *p, union GenNativeInstruction *pOut);
> } /* namespace gbe */
>
> #endif /* __GBE_GEN_PROGRAM_HPP__ */
> --
> 1.7.10.4
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list