compiler->target = target;
compiler->target_flags = flags;
- if (program->backup_func && _orc_compiler_flag_backup) {
- ORC_COMPILER_ERROR(compiler, "Compilation disabled");
- compiler->result = ORC_COMPILE_RESULT_UNKNOWN_COMPILE;
- goto error;
- }
-
{
ORC_LOG("variables");
for(i=0;i<ORC_N_VARIABLES;i++){
program->orccode->is_2d = program->is_2d;
program->orccode->constant_n = program->constant_n;
program->orccode->constant_m = program->constant_m;
+ program->orccode->exec = program->code_exec;
program->orccode->n_insns = compiler->n_insns;
program->orccode->insns = malloc(sizeof(OrcInstruction) * compiler->n_insns);
program->orccode->vars[i].value = compiler->vars[i].value;
}
+ if (program->backup_func && _orc_compiler_flag_backup) {
+ ORC_COMPILER_ERROR(compiler, "Compilation disabled");
+ compiler->result = ORC_COMPILE_RESULT_UNKNOWN_COMPILE;
+ goto error;
+ }
+
if (_orc_compiler_flag_emulate || target == NULL) {
program->code_exec = (void *)orc_executor_emulate;
+ program->orccode->exec = (void *)orc_executor_emulate;
compiler->result = ORC_COMPILE_RESULT_UNKNOWN_COMPILE;
goto error;
}
{
void (*func) (OrcExecutor *);
- func = ex->program->code_exec;
+ if (ex->program) {
+ func = ex->program->code_exec;
+ } else {
+ OrcCode *code = (OrcCode *)ex->arrays[ORC_VAR_A2];
+ func = code->exec;
+ }
if (func) {
func (ex);
//ORC_ERROR("counters %d %d %d", ex->counter1, ex->counter2, ex->counter3);
{
void (*func) (OrcExecutor *);
- func = ex->program->backup_func;
+ if (ex->program) {
+ func = ex->program->backup_func;
+ } else {
+ OrcCode *code = (OrcCode *)ex->arrays[ORC_VAR_A2];
+ func = code->exec;
+ }
if (func) {
func (ex);
//ORC_ERROR("counters %d %d %d", ex->counter1, ex->counter2, ex->counter3);
int j;
int k;
int m, m_index;
- OrcCode *code = ex->program->orccode;
+ OrcCode *code;
OrcInstruction *insn;
OrcStaticOpcode *opcode;
OrcOpcodeExecutor *opcode_ex;
void *tmpspace[ORC_N_COMPILER_VARIABLES] = { 0 };
+ if (ex->program) {
+ code = ex->program->orccode;
+ } else {
+ code = (OrcCode *)ex->arrays[ORC_VAR_A2];
+ }
+
ex->accumulators[0] = 0;
ex->accumulators[1] = 0;
ex->accumulators[2] = 0;
OrcProgram **programs;
int use_inline = FALSE;
+int use_code = FALSE;
const char *init_function = NULL;
exit (1);
}
}
+ if (compat >= ORC_VERSION(0,4,11,1)) {
+ use_code = TRUE;
+ }
if (output_file == NULL) {
switch (mode) {
int i;
if (init_function) {
+ const char *storage;
if (is_inline) {
- fprintf(output, "extern OrcProgram *_orc_program_%s;\n", p->name);
+ storage = "extern ";
} else {
if (use_inline) {
- fprintf(output, "OrcProgram *_orc_program_%s;\n", p->name);
+ storage = "";
} else {
- fprintf(output, "static OrcProgram *_orc_program_%s;\n", p->name);
+ storage = "static ";
}
}
+ if (use_code) {
+ fprintf(output, "%sOrcCode *_orc_code_%s;\n", storage, p->name);
+ } else {
+ fprintf(output, "%sOrcProgram *_orc_program_%s;\n", storage, p->name);
+ }
}
if (is_inline) {
fprintf(output, "static inline void\n");
fprintf(output, "{\n");
fprintf(output, " OrcExecutor _ex, *ex = &_ex;\n");
if (init_function) {
- fprintf(output, " OrcProgram *p = _orc_program_%s;\n", p->name);
+ if (use_code) {
+ fprintf(output, " OrcCode *c = _orc_code_%s;\n", p->name);
+ } else {
+ if (use_code) {
+ fprintf(output, " OrcCode *c = _orc_code_%s;\n", p->name);
+ } else {
+ fprintf(output, " OrcProgram *p = _orc_program_%s;\n", p->name);
+ }
+ }
} else {
fprintf(output, " static int p_inited = 0;\n");
- fprintf(output, " static OrcProgram *p = 0;\n");
+ if (use_code) {
+ fprintf(output, " static OrcCode *c = 0;\n");
+ } else {
+ fprintf(output, " static OrcProgram *p = 0;\n");
+ }
}
fprintf(output, " void (*func) (OrcExecutor *);\n");
fprintf(output, "\n");
fprintf(output, " orc_once_mutex_lock ();\n");
fprintf(output, " if (!p_inited) {\n");
fprintf(output, " OrcCompileResult result;\n");
+ if (use_code) {
+ fprintf(output, " OrcProgram *p;\n");
+ }
fprintf(output, "\n");
output_program_generation (p, output, is_inline);
fprintf(output, "\n");
fprintf(output, " result = orc_program_compile (p);\n");
+ if (use_code) {
+ fprintf(output, " c = orc_program_take_code (p);\n");
+ fprintf(output, " orc_program_free (p);\n");
+ }
fprintf(output, " }\n");
fprintf(output, " p_inited = TRUE;\n");
fprintf(output, " orc_once_mutex_unlock ();\n");
fprintf(output, " }\n");
}
- fprintf(output, " ex->program = p;\n");
+ if (use_code) {
+ fprintf(output, " ex->arrays[ORC_VAR_A2] = c;\n");
+ fprintf(output, " ex->program = 0;\n");
+ } else {
+ fprintf(output, " ex->program = p;\n");
+ }
fprintf(output, "\n");
if (p->constant_n) {
fprintf(output, " ex->n = %d;\n", p->constant_n);
}
}
fprintf(output, "\n");
- fprintf(output, " func = p->code_exec;\n");
+ if (use_code) {
+ fprintf(output, " func = c->exec;\n");
+ } else {
+ fprintf(output, " func = p->code_exec;\n");
+ }
fprintf(output, " func (ex);\n");
for(i=0;i<4;i++){
var = &p->vars[ORC_VAR_A1 + i];
fprintf(output, "\n");
fprintf(output, " result = orc_program_compile (p);\n");
fprintf(output, "\n");
- fprintf(output, " _orc_program_%s = p;\n", programs[i]->name);
+ if (use_code) {
+ fprintf(output, " _orc_code_%s = orc_program_take_code (p);\n",
+ programs[i]->name);
+ fprintf(output, " orc_program_free (p);\n");
+ } else {
+ fprintf(output, " _orc_program_%s = p;\n", programs[i]->name);
+ }
fprintf(output, " }\n");
}
fprintf(output, "#endif\n");