From: David Schleef Date: Thu, 5 Aug 2010 21:10:19 +0000 (-0700) Subject: Add OrcCode structure X-Git-Tag: orc-0.4.7~72 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=83377d0315e63e1d93bc84b6a17690c00e6e40ab;p=platform%2Fupstream%2Forc.git Add OrcCode structure --- diff --git a/orc/Makefile.am b/orc/Makefile.am index 7b6f832..4ed83e8 100644 --- a/orc/Makefile.am +++ b/orc/Makefile.am @@ -24,7 +24,8 @@ liborc_@ORC_MAJORMINOR@_la_SOURCES = \ orcopcodes.c \ orcparse.c \ orconce.c \ - orcdebug.c + orcdebug.c \ + orccode.c if ENABLE_BACKEND_SSE liborc_@ORC_MAJORMINOR@_la_SOURCES += orcsse.c orcrules-sse.c orcprogram-sse.c diff --git a/orc/orccode.c b/orc/orccode.c new file mode 100644 index 0000000..2c644ed --- /dev/null +++ b/orc/orccode.c @@ -0,0 +1,32 @@ + +#include "config.h" + +#include +#include +#include + +#include +#include + + +OrcCode * +orc_code_new (void) +{ + OrcCode *code; + code = malloc(sizeof(OrcCode)); + memset (code, 0, sizeof(OrcCode)); + return code; +} + +void +orc_code_free (OrcCode *code) +{ + if (code->insns) { + free (code->insns); + } + + free (code); +} + + + diff --git a/orc/orccompiler.c b/orc/orccompiler.c index c5a6855..e11f6d2 100644 --- a/orc/orccompiler.c +++ b/orc/orccompiler.c @@ -296,6 +296,23 @@ orc_program_compile_full (OrcProgram *program, OrcTarget *target, compiler->target->compile (compiler); if (compiler->error) goto error; + program->orccode = orc_code_new (); + program->orccode->exec = program->code_exec; + program->orccode->code = program->code; + program->orccode->code_size = compiler->codeptr - program->code; + program->orccode->is_2d = program->is_2d; + program->orccode->constant_n = program->constant_n; + program->orccode->constant_m = program->constant_m; + + program->orccode->n_insns = compiler->n_insns; + program->orccode->insns = malloc(sizeof(OrcInstruction) * compiler->n_insns); + memcpy (program->orccode->insns, compiler->insns, + sizeof(OrcInstruction) * compiler->n_insns); + + program->orccode->vars = malloc (sizeof(OrcVariable) * ORC_N_COMPILER_VARIABLES); + memcpy (program->orccode->vars, compiler->vars, + sizeof(OrcVariable) * ORC_N_COMPILER_VARIABLES); + program->asm_code = compiler->asm_code; program->code_size = compiler->codeptr - program->code; diff --git a/orc/orcprogram.h b/orc/orcprogram.h index 6a1a357..32577e9 100644 --- a/orc/orcprogram.h +++ b/orc/orcprogram.h @@ -18,6 +18,7 @@ typedef struct _OrcRuleSet OrcRuleSet; typedef struct _OrcConstant OrcConstant; typedef struct _OrcFixup OrcFixup; typedef struct _OrcTarget OrcTarget; +typedef struct _OrcCode OrcCode; typedef void (*OrcOpcodeEmulateFunc)(OrcOpcodeExecutor *ex, void *user); typedef void (*OrcOpcodeEmulateNFunc)(OrcOpcodeExecutor *ex, int n); @@ -349,6 +350,8 @@ struct _OrcProgram { int is_2d; int constant_n; int constant_m; + + OrcCode *orccode; }; /** @@ -489,6 +492,25 @@ struct _OrcExecutorAlt { #define ORC_EXECUTOR_M_INDEX(ex) ((ex)->params[ORC_VAR_A2]) #define ORC_EXECUTOR_TIME(ex) ((ex)->params[ORC_VAR_A3]) +struct _OrcCode { + /*< private >*/ + OrcCompileResult result; + char *name; + + /* for execution */ + OrcExecutorFunc exec; + unsigned char *code; + int code_size; + + /* for emulation */ + int n_insns; + OrcInstruction *insns; + OrcVariable *vars; + int is_2d; + int constant_n; + int constant_m; +}; + /** * OrcTarget: * @@ -621,6 +643,10 @@ int orc_program_get_max_accumulator_size (OrcProgram *program); void orc_get_data_cache_sizes (int *level1, int *level2, int *level3); +OrcCode * orc_code_new (void); +void orc_code_free (OrcCode *code); + + #ifdef ORC_ENABLE_UNSTABLE_API int orc_compiler_flag_check (const char *flag);