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
--- /dev/null
+
+#include "config.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <orc/orcprogram.h>
+#include <orc/orcdebug.h>
+
+
+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);
+}
+
+
+
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;
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);
int is_2d;
int constant_n;
int constant_m;
+
+ OrcCode *orccode;
};
/**
#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:
*
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);