return 0;
}
+const char *varnames[] = {
+ "d1", "d2", "d3", "d4",
+ "s1", "s2", "s3", "s4",
+ "s5", "s6", "s7", "s8",
+ "a1", "a2", "a3", "d4",
+ "c1", "c2", "c3", "c4",
+ "c5", "c6", "c7", "c8",
+ "p1", "p2", "p3", "p4",
+ "p5", "p6", "p7", "p8",
+ "t1", "t2", "t3", "t4",
+ "t5", "t6", "t7", "t8",
+ "t9", "t10", "t11", "t12",
+ "t13", "t14", "t15", "t16"
+};
+
void
orc_compiler_c_assemble (OrcCompiler *compiler)
{
i);
break;
case ORC_VAR_TYPE_PARAM:
- ORC_ASM_CODE(compiler," const %s var%d = ex->params[%d];\n",
- c_get_type_name (var->size), i, i);
+ if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) {
+ ORC_ASM_CODE(compiler," const %s var%d = ex->params[%d];\n",
+ c_get_type_name (var->size), i, i);
+ } else {
+ ORC_ASM_CODE(compiler," const %s var%d = %s;\n",
+ c_get_type_name (var->size), i, varnames[i]);
+ }
break;
default:
ORC_COMPILER_ERROR(compiler, "bad vartype");
ORC_ASM_CODE(compiler,"\n");
if (compiler->program->is_2d) {
if (compiler->program->constant_m == 0) {
- ORC_ASM_CODE(compiler," for (j = 0; j < ex->params[ORC_VAR_A1]; j++) {\n");
+ if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) {
+ ORC_ASM_CODE(compiler," for (j = 0; j < ex->params[ORC_VAR_A1]; j++) {\n");
+ } else {
+ ORC_ASM_CODE(compiler," for (j = 0; j < m; j++) {\n");
+ }
} else {
ORC_ASM_CODE(compiler," for (j = 0; j < %d; j++) {\n",
compiler->program->constant_m);
if (var->name == NULL) continue;
switch (var->vartype) {
case ORC_VAR_TYPE_SRC:
- ORC_ASM_CODE(compiler," var%d = ORC_PTR_OFFSET(ex->arrays[%d], ex->params[%d] * j);\n",
- i, i, i);
+ if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) {
+ ORC_ASM_CODE(compiler," var%d = ORC_PTR_OFFSET(ex->arrays[%d], ex->params[%d] * j);\n",
+ i, i, i);
+ } else {
+ ORC_ASM_CODE(compiler," var%d = ORC_PTR_OFFSET(%s, %s_stride * j);\n",
+ i, varnames[i], varnames[i]);
+ }
break;
case ORC_VAR_TYPE_DEST:
- ORC_ASM_CODE(compiler," var%d = ORC_PTR_OFFSET(ex->arrays[%d], ex->params[%d] * j);\n",
- i, i, i);
+ if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) {
+ ORC_ASM_CODE(compiler," var%d = ORC_PTR_OFFSET(ex->arrays[%d], ex->params[%d] * j);\n",
+ i, i, i);
+ } else {
+ ORC_ASM_CODE(compiler," var%d = ORC_PTR_OFFSET(%s, %s_stride * j);\n",
+ i, varnames[i], varnames[i]);
+ }
break;
default:
break;
if (var->name == NULL) continue;
switch (var->vartype) {
case ORC_VAR_TYPE_SRC:
- ORC_ASM_CODE(compiler," var%d = ex->arrays[%d];\n", i, i);
+ if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) {
+ ORC_ASM_CODE(compiler," var%d = ex->arrays[%d];\n", i, i);
+ } else {
+ ORC_ASM_CODE(compiler," var%d = (void *)%s;\n", i, varnames[i]);
+ }
break;
case ORC_VAR_TYPE_DEST:
- ORC_ASM_CODE(compiler," var%d = ex->arrays[%d];\n", i, i);
+ if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) {
+ ORC_ASM_CODE(compiler," var%d = ex->arrays[%d];\n", i, i);
+ } else {
+ ORC_ASM_CODE(compiler," var%d = (void *)%s;\n", i, varnames[i]);
+ }
break;
default:
break;
ORC_ASM_CODE(compiler,"\n");
if (compiler->program->constant_n == 0) {
- ORC_ASM_CODE(compiler,"%*s for (i = 0; i < ex->n; i++) {\n", prefix, "");
+ if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) {
+ ORC_ASM_CODE(compiler,"%*s for (i = 0; i < ex->n; i++) {\n", prefix, "");
+ } else {
+ ORC_ASM_CODE(compiler,"%*s for (i = 0; i < n; i++) {\n", prefix, "");
+ }
} else {
ORC_ASM_CODE(compiler,"%*s for (i = 0; i < %d; i++) {\n",
prefix, "",
void output_code_header (OrcProgram *p, FILE *output);
void output_code_test (OrcProgram *p, FILE *output);
void output_code_backup (OrcProgram *p, FILE *output);
+void output_code_no_orc (OrcProgram *p, FILE *output);
static void print_defines (FILE *output);
static void print_exec_header (FILE *output);
static void
print_exec_header (FILE *output)
{
+#if 0
fprintf(output,
"typedef struct _OrcExecutor OrcExecutor;\n"
"typedef struct _OrcProgram OrcProgram;\n"
" ORC_VAR_T14,\n"
" ORC_VAR_T15\n"
"};\n");
+#endif
}
static void
}
void
+output_code_no_orc (OrcProgram *p, FILE *output)
+{
+
+ fprintf(output, "void\n");
+ output_prototype (p, output);
+ fprintf(output, "{\n");
+ {
+ OrcCompileResult result;
+
+ result = orc_program_compile_full (p, orc_target_get_by_name("c"),
+ ORC_TARGET_C_BARE | ORC_TARGET_C_NOEXEC);
+ if (ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) {
+ fprintf(output, "%s\n", orc_program_get_asm_code (p));
+ }
+ }
+ fprintf(output, "}\n");
+ fprintf(output, "\n");
+
+}
+
+void
output_code (OrcProgram *p, FILE *output)
{
OrcVariable *var;
fprintf(output, "\n");
fprintf(output, "/* %s */\n", p->name);
+ fprintf(output, "#ifdef DISABLE_ORC\n");
+ output_code_no_orc (p, output);
+ fprintf(output, "#else\n");
output_code_backup (p, output);
fprintf(output, "void\n");
output_prototype (p, output);
fprintf(output, "\n");
fprintf(output, "{\n");
fprintf(output, " OrcExecutor _ex, *ex = &_ex;\n");
- fprintf(output, "#ifndef DISABLE_ORC\n");
fprintf(output, " static int p_inited = 0;\n");
fprintf(output, " static OrcProgram *p = 0;\n");
fprintf(output, "\n");
fprintf(output, " orc_once_mutex_unlock ();\n");
fprintf(output, " }\n");
fprintf(output, " ex->program = p;\n");
- fprintf(output, "#endif\n");
fprintf(output, "\n");
if (p->constant_n) {
fprintf(output, " ex->n = %d;\n", p->constant_n);
}
}
fprintf(output, "\n");
- fprintf(output, "#ifndef DISABLE_ORC\n");
fprintf(output, " orc_executor_run (ex);\n");
- fprintf(output, "#else\n");
- fprintf(output, " _backup_%s (ex);\n", p->name);
- fprintf(output, "#endif\n");
for(i=0;i<4;i++){
var = &p->vars[ORC_VAR_A1 + i];
if (var->size) {
}
}
fprintf(output, "}\n");
+ fprintf(output, "#endif\n");
+ fprintf(output, "\n");
}