summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Schleef <ds@ginger.bigkitten.com>2008-05-15 14:44:30 -0700
committerDavid Schleef <ds@ginger.bigkitten.com>2008-05-15 14:44:30 -0700
commitc003f17b82ed66f7879a83519d19ac81207c07ce (patch)
treec79ec735301bd2e41a644584d89414ecc115d841
parent2a97ef7026f7e89c4f986b220961861bdc11d39a (diff)
[orc] global replace of oj_ (etc) with orc_
-rw-r--r--examples/orc/jit.c44
-rw-r--r--orc/orcexecutor.c30
-rw-r--r--orc/orcopcodes.c36
-rw-r--r--orc/orcprogram-linux.c2
-rw-r--r--orc/orcprogram-x86.c178
-rw-r--r--orc/orcprogram.c78
-rw-r--r--orc/orcprogram.h172
-rw-r--r--orc/orcrule.c24
-rw-r--r--orc/orctype.c12
9 files changed, 288 insertions, 288 deletions
diff --git a/examples/orc/jit.c b/examples/orc/jit.c
index 70214c4..4e9b1fc 100644
--- a/examples/orc/jit.c
+++ b/examples/orc/jit.c
@@ -14,43 +14,43 @@ int16_t src1[N];
int16_t src2[N];
int16_t dest[N];
-void test(OJExecutor *ex);
+void test(OrcExecutor *ex);
int
main (int argc, char *argv[])
{
- OJProgram *p;
- OJExecutor *ex;
+ OrcProgram *p;
+ OrcExecutor *ex;
int s1, s2, d1, offset, shift;
int t1;
- oj_opcode_init ();
+ orc_opcode_init ();
- p = oj_program_new ();
+ p = orc_program_new ();
- d1 = oj_program_add_destination (p, "s16", "d1");
- s1 = oj_program_add_source (p, "s16", "s1");
- s2 = oj_program_add_source (p, "s16", "s2");
- t1 = oj_program_add_temporary (p, "s16", "t1");
- offset = oj_program_add_constant (p, "s16", 1, "offset");
- shift = oj_program_add_constant (p, "s16", 1, "shift");
+ d1 = orc_program_add_destination (p, "s16", "d1");
+ s1 = orc_program_add_source (p, "s16", "s1");
+ s2 = orc_program_add_source (p, "s16", "s2");
+ t1 = orc_program_add_temporary (p, "s16", "t1");
+ offset = orc_program_add_constant (p, "s16", 1, "offset");
+ shift = orc_program_add_constant (p, "s16", 1, "shift");
- oj_program_append (p, "add_s16", t1, s1, s2);
- oj_program_append (p, "add_s16", t1, t1, offset);
- oj_program_append (p, "rshift_s16", d1, t1, shift);
+ orc_program_append (p, "add_s16", t1, s1, s2);
+ orc_program_append (p, "add_s16", t1, t1, offset);
+ orc_program_append (p, "rshift_s16", d1, t1, shift);
- ex = oj_executor_new (p);
+ ex = orc_executor_new (p);
- oj_executor_set_n (ex, N);
- oj_executor_set_array (ex, s1, src1);
- oj_executor_set_array (ex, s2, src2);
- oj_executor_set_array (ex, d1, dest);
+ orc_executor_set_n (ex, N);
+ orc_executor_set_array (ex, s1, src1);
+ orc_executor_set_array (ex, s2, src2);
+ orc_executor_set_array (ex, d1, dest);
- oj_program_compile_x86 (p);
+ orc_program_compile_x86 (p);
if (0) {
int i;
- void (*func) (OJExecutor *);
+ void (*func) (OrcExecutor *);
for(i=0;i<N;i++){
src1[i] = rand()&0xf;
@@ -59,7 +59,7 @@ main (int argc, char *argv[])
func = p->code_exec;
func (ex);
- //oj_executor_emulate (ex);
+ //orc_executor_emulate (ex);
for(i=0;i<N;i++){
printf("# %4d %4d %4d %4d\n", src1[i], src2[i], dest[i],
diff --git a/orc/orcexecutor.c b/orc/orcexecutor.c
index 8072bf4..f8af0ce 100644
--- a/orc/orcexecutor.c
+++ b/orc/orcexecutor.c
@@ -9,54 +9,54 @@
#include <orc/orcprogram.h>
-OJExecutor *
-oj_executor_new (OJProgram *program)
+OrcExecutor *
+orc_executor_new (OrcProgram *program)
{
- OJExecutor *ex;
+ OrcExecutor *ex;
- ex = g_malloc0(sizeof(OJExecutor));
+ ex = g_malloc0(sizeof(OrcExecutor));
ex->program = program;
- memcpy (ex->vars, program->vars, 10*sizeof(OJVariable));
+ memcpy (ex->vars, program->vars, 10*sizeof(OrcVariable));
return ex;
}
void
-oj_executor_free (OJExecutor *ex)
+orc_executor_free (OrcExecutor *ex)
{
g_free (ex);
}
void
-oj_executor_run (OJExecutor *ex)
+orc_executor_run (OrcExecutor *ex)
{
}
void
-oj_executor_set_array (OJExecutor *ex, int var, void *ptr)
+orc_executor_set_array (OrcExecutor *ex, int var, void *ptr)
{
ex->arrays[var] = ptr;
}
void
-oj_executor_set_n (OJExecutor *ex, int n)
+orc_executor_set_n (OrcExecutor *ex, int n)
{
ex->n = n;
}
void
-oj_executor_emulate (OJExecutor *ex)
+orc_executor_emulate (OrcExecutor *ex)
{
int i;
int j;
int k;
- OJProgram *program = ex->program;
- OJInstruction *insn;
- OJOpcode *opcode;
+ OrcProgram *program = ex->program;
+ OrcInstruction *insn;
+ OrcOpcode *opcode;
printf("n %d\n", ex->n);
printf("n_insns %d\n", program->n_insns);
@@ -75,7 +75,7 @@ oj_executor_emulate (OJExecutor *ex)
printf("setting up arg %d as var %d vartype %d\n",
k, insn->args[k], ex->args[k]->vartype);
- if (ex->args[k]->vartype == OJ_VAR_TYPE_SRC) {
+ if (ex->args[k]->vartype == ORC_VAR_TYPE_SRC) {
void *ptr = ex->arrays[insn->args[k]] + 2*i;
printf("load %p\n", ptr);
@@ -88,7 +88,7 @@ oj_executor_emulate (OJExecutor *ex)
ex->args[1]->s16, ex->args[2]->s16);
for(k=0;k<opcode->n_src + opcode->n_dest;k++){
- if (ex->args[k]->vartype == OJ_VAR_TYPE_DEST) {
+ if (ex->args[k]->vartype == ORC_VAR_TYPE_DEST) {
void *ptr = ex->arrays[insn->args[k]] + 2*i;
printf("store %p\n", ptr);
diff --git a/orc/orcopcodes.c b/orc/orcopcodes.c
index 6e3427d..b9ee821 100644
--- a/orc/orcopcodes.c
+++ b/orc/orcopcodes.c
@@ -9,21 +9,21 @@
#include <orc/orcprogram.h>
-static OJOpcode *opcode_list;
+static OrcOpcode *opcode_list;
static int n_opcodes;
static int n_opcodes_alloc;
void
-oj_opcode_register (const char *name, int n_dest, int n_src,
- OJOpcodeEmulateFunc emulate, void *user)
+orc_opcode_register (const char *name, int n_dest, int n_src,
+ OrcOpcodeEmulateFunc emulate, void *user)
{
- OJOpcode *opcode;
+ OrcOpcode *opcode;
if (n_opcodes == n_opcodes_alloc) {
n_opcodes_alloc += 100;
- opcode_list = realloc(opcode_list, sizeof(OJOpcode) * n_opcodes_alloc);
+ opcode_list = realloc(opcode_list, sizeof(OrcOpcode) * n_opcodes_alloc);
}
opcode = opcode_list + n_opcodes;
@@ -37,8 +37,8 @@ oj_opcode_register (const char *name, int n_dest, int n_src,
n_opcodes++;
}
-OJOpcode *
-oj_opcode_find_by_name (const char *name)
+OrcOpcode *
+orc_opcode_find_by_name (const char *name)
{
int i;
@@ -52,43 +52,43 @@ oj_opcode_find_by_name (const char *name)
}
static void
-add_s16 (OJExecutor *ex, void *user)
+add_s16 (OrcExecutor *ex, void *user)
{
ex->args[0]->s16 = (int16_t)(ex->args[1]->s16 + ex->args[2]->s16);
}
static void
-sub_s16 (OJExecutor *ex, void *user)
+sub_s16 (OrcExecutor *ex, void *user)
{
ex->args[0]->s16 = (int16_t)(ex->args[1]->s16 - ex->args[2]->s16);
}
static void
-mul_s16 (OJExecutor *ex, void *user)
+mul_s16 (OrcExecutor *ex, void *user)
{
ex->args[0]->s16 = (int16_t)(ex->args[1]->s16 * ex->args[2]->s16);
}
static void
-lshift_s16 (OJExecutor *ex, void *user)
+lshift_s16 (OrcExecutor *ex, void *user)
{
ex->args[0]->s16 = (int16_t)(ex->args[1]->s16 << ex->args[2]->s16);
}
static void
-rshift_s16 (OJExecutor *ex, void *user)
+rshift_s16 (OrcExecutor *ex, void *user)
{
ex->args[0]->s16 = (int16_t)(ex->args[1]->s16 >> ex->args[2]->s16);
}
void
-oj_opcode_init (void)
+orc_opcode_init (void)
{
- oj_opcode_register("add_s16", 1, 2, add_s16, NULL);
- oj_opcode_register("sub_s16", 1, 2, sub_s16, NULL);
- oj_opcode_register("mul_s16", 1, 2, mul_s16, NULL);
- oj_opcode_register("lshift_s16", 1, 2, lshift_s16, NULL);
- oj_opcode_register("rshift_s16", 1, 2, rshift_s16, NULL);
+ orc_opcode_register("add_s16", 1, 2, add_s16, NULL);
+ orc_opcode_register("sub_s16", 1, 2, sub_s16, NULL);
+ orc_opcode_register("mul_s16", 1, 2, mul_s16, NULL);
+ orc_opcode_register("lshift_s16", 1, 2, lshift_s16, NULL);
+ orc_opcode_register("rshift_s16", 1, 2, rshift_s16, NULL);
}
diff --git a/orc/orcprogram-linux.c b/orc/orcprogram-linux.c
index 793e479..3109ceb 100644
--- a/orc/orcprogram-linux.c
+++ b/orc/orcprogram-linux.c
@@ -16,7 +16,7 @@
void
-oj_program_allocate_codemem (OJProgram *program)
+orc_program_allocate_codemem (OrcProgram *program)
{
char *filename;
int fd;
diff --git a/orc/orcprogram-x86.c b/orc/orcprogram-x86.c
index bf8cfcc..4faa7c8 100644
--- a/orc/orcprogram-x86.c
+++ b/orc/orcprogram-x86.c
@@ -14,26 +14,26 @@
#define SIZE 65536
-void x86_emit_push (OJProgram *program, int size, int reg);
-void x86_emit_pop (OJProgram *program, int size, int reg);
-void x86_emit_mov_memoffset_reg (OJProgram *program, int size, int offset, int reg1, int reg2);
-void x86_emit_mov_reg_memoffset (OJProgram *program, int size, int reg1, int offset, int reg2);
-void x86_emit_mov_imm_reg (OJProgram *program, int size, int value, int reg1);
-void x86_emit_mov_reg_reg (OJProgram *program, int size, int reg1, int reg2);
-void x86_emit_test_reg_reg (OJProgram *program, int size, int reg1, int reg2);
-void x86_emit_dec_memoffset (OJProgram *program, int size, int offset, int reg);
-void x86_emit_add_imm_memoffset (OJProgram *program, int size, int value, int offset, int reg);
-void x86_emit_ret (OJProgram *program);
-void x86_emit_je (OJProgram *program, int label);
-void x86_emit_jne (OJProgram *program, int label);
-void x86_emit_label (OJProgram *program, int label);
-
-void x86_emit_modrm_memoffset (OJProgram *program, int reg1, int offset, int reg2);
-void x86_emit_modrm_reg (OJProgram *program, int reg1, int reg2);
-void x86_test (OJProgram *program);
+void x86_emit_push (OrcProgram *program, int size, int reg);
+void x86_emit_pop (OrcProgram *program, int size, int reg);
+void x86_emit_mov_memoffset_reg (OrcProgram *program, int size, int offset, int reg1, int reg2);
+void x86_emit_mov_reg_memoffset (OrcProgram *program, int size, int reg1, int offset, int reg2);
+void x86_emit_mov_imm_reg (OrcProgram *program, int size, int value, int reg1);
+void x86_emit_mov_reg_reg (OrcProgram *program, int size, int reg1, int reg2);
+void x86_emit_test_reg_reg (OrcProgram *program, int size, int reg1, int reg2);
+void x86_emit_dec_memoffset (OrcProgram *program, int size, int offset, int reg);
+void x86_emit_add_imm_memoffset (OrcProgram *program, int size, int value, int offset, int reg);
+void x86_emit_ret (OrcProgram *program);
+void x86_emit_je (OrcProgram *program, int label);
+void x86_emit_jne (OrcProgram *program, int label);
+void x86_emit_label (OrcProgram *program, int label);
+
+void x86_emit_modrm_memoffset (OrcProgram *program, int reg1, int offset, int reg2);
+void x86_emit_modrm_reg (OrcProgram *program, int reg1, int reg2);
+void x86_test (OrcProgram *program);
enum {
- X86_EAX = OJ_GP_REG_BASE,
+ X86_EAX = ORC_GP_REG_BASE,
X86_ECX,
X86_EDX,
X86_EBX,
@@ -49,7 +49,7 @@ x86_get_regname(int i)
static const char *x86_regs[] = { "eax", "ecx", "edx", "ebx",
"esp", "ebp", "esi", "edi" };
- if (i>=OJ_GP_REG_BASE && i<OJ_GP_REG_BASE + 8) return x86_regs[i - OJ_GP_REG_BASE];
+ if (i>=ORC_GP_REG_BASE && i<ORC_GP_REG_BASE + 8) return x86_regs[i - ORC_GP_REG_BASE];
switch (i) {
case 0:
return "UNALLOCATED";
@@ -63,7 +63,7 @@ x86_get_regname(int i)
static int
x86_get_regnum(int i)
{
- return i - OJ_GP_REG_BASE;
+ return i - ORC_GP_REG_BASE;
}
static const char *
@@ -72,7 +72,7 @@ x86_get_regname_16(int i)
static const char *x86_regs[] = { "ax", "cx", "dx", "bx",
"sp", "bp", "si", "di" };
- if (i>=OJ_GP_REG_BASE && i<OJ_GP_REG_BASE + 8) return x86_regs[i - OJ_GP_REG_BASE];
+ if (i>=ORC_GP_REG_BASE && i<ORC_GP_REG_BASE + 8) return x86_regs[i - ORC_GP_REG_BASE];
switch (i) {
case 0:
return "UNALLOCATED";
@@ -84,12 +84,12 @@ x86_get_regname_16(int i)
}
-void oj_program_rewrite_vars (OJProgram *program);
-void oj_program_allocate_regs (OJProgram *program);
-void oj_program_dump (OJProgram *program);
+void orc_program_rewrite_vars (OrcProgram *program);
+void orc_program_allocate_regs (OrcProgram *program);
+void orc_program_dump (OrcProgram *program);
void
-x86_emit_prologue (OJProgram *program)
+x86_emit_prologue (OrcProgram *program)
{
g_print(".global test\n");
g_print("test:\n");
@@ -101,7 +101,7 @@ x86_emit_prologue (OJProgram *program)
}
void
-x86_emit_epilogue (OJProgram *program)
+x86_emit_epilogue (OrcProgram *program)
{
x86_emit_pop (program, 4, X86_EBX);
x86_emit_pop (program, 4, X86_ESI);
@@ -111,7 +111,7 @@ x86_emit_epilogue (OJProgram *program)
}
void
-x86_do_fixups (OJProgram *program)
+x86_do_fixups (OrcProgram *program)
{
int i;
for(i=0;i<program->n_fixups;i++){
@@ -125,30 +125,30 @@ x86_do_fixups (OJProgram *program)
}
void
-oj_program_compile_x86 (OJProgram *program)
+orc_program_compile_x86 (OrcProgram *program)
{
int j;
int k;
- OJInstruction *insn;
- OJOpcode *opcode;
- OJVariable *args[10];
- OJRuleList *list;
- OJRule *rule;
+ OrcInstruction *insn;
+ OrcOpcode *opcode;
+ OrcVariable *args[10];
+ OrcRuleList *list;
+ OrcRule *rule;
- oj_program_allocate_codemem (program);
+ orc_program_allocate_codemem (program);
- list = oj_rule_list_new();
- oj_program_x86_register_rules (list);
+ list = orc_rule_list_new();
+ orc_program_x86_register_rules (list);
- oj_program_rewrite_vars (program);
+ orc_program_rewrite_vars (program);
x86_emit_prologue (program);
- x86_emit_mov_memoffset_reg (program, 4, (int)G_STRUCT_OFFSET(OJExecutor,n),
+ x86_emit_mov_memoffset_reg (program, 4, (int)G_STRUCT_OFFSET(OrcExecutor,n),
X86_EBP, X86_ECX);
x86_emit_mov_reg_memoffset (program, 4, X86_ECX,
- (int)G_STRUCT_OFFSET(OJExecutor,counter), X86_EBP);
+ (int)G_STRUCT_OFFSET(OrcExecutor,counter), X86_EBP);
x86_emit_test_reg_reg (program, 4, X86_ECX, X86_ECX);
@@ -168,16 +168,16 @@ oj_program_compile_x86 (OJProgram *program)
for(k=opcode->n_dest;k<opcode->n_src + opcode->n_dest;k++){
switch (args[k]->vartype) {
- case OJ_VAR_TYPE_SRC:
+ case ORC_VAR_TYPE_SRC:
x86_emit_mov_memoffset_reg (program, 4,
- (int)G_STRUCT_OFFSET(OJExecutor, arrays[k]),
+ (int)G_STRUCT_OFFSET(OrcExecutor, arrays[k]),
X86_EBP, X86_ECX);
x86_emit_mov_memoffset_reg (program, 2, 0, X86_ECX, args[k]->alloc);
break;
- case OJ_VAR_TYPE_CONST:
+ case ORC_VAR_TYPE_CONST:
x86_emit_mov_imm_reg (program, 2, args[k]->s16, args[k]->alloc);
break;
- case OJ_VAR_TYPE_TEMP:
+ case ORC_VAR_TYPE_TEMP:
#if 0
g_print(" movw temp, %%%s\n",
x86_get_regname(args[k]->alloc));
@@ -188,9 +188,9 @@ oj_program_compile_x86 (OJProgram *program)
}
}
- rule = oj_rule_list_get (list, opcode);
+ rule = orc_rule_list_get (list, opcode);
if (rule) {
- if (!(rule->flags & OJ_RULE_3REG) && insn->args[0] != insn->args[1]) {
+ if (!(rule->flags & ORC_RULE_3REG) && insn->args[0] != insn->args[1]) {
x86_emit_mov_reg_reg (program, 2, args[1]->alloc, args[0]->alloc);
}
rule->emit (program, rule->emit_user, insn);
@@ -200,13 +200,13 @@ oj_program_compile_x86 (OJProgram *program)
for(k=0;k<opcode->n_dest;k++){
switch (args[k]->vartype) {
- case OJ_VAR_TYPE_DEST:
+ case ORC_VAR_TYPE_DEST:
x86_emit_mov_memoffset_reg (program, 4,
- (int)G_STRUCT_OFFSET(OJExecutor, arrays[k]),
+ (int)G_STRUCT_OFFSET(OrcExecutor, arrays[k]),
X86_EBP, X86_ECX);
x86_emit_mov_reg_memoffset (program, 2, args[k]->alloc, 0, X86_ECX);
break;
- case OJ_VAR_TYPE_TEMP:
+ case ORC_VAR_TYPE_TEMP:
#if 0
g_print(" movw %%%s, temp\n",
x86_get_regname(args[k]->alloc));
@@ -219,15 +219,15 @@ oj_program_compile_x86 (OJProgram *program)
}
for(k=0;k<program->n_vars;k++){
- if (program->vars[k].vartype == OJ_VAR_TYPE_SRC ||
- program->vars[k].vartype == OJ_VAR_TYPE_DEST) {
+ if (program->vars[k].vartype == ORC_VAR_TYPE_SRC ||
+ program->vars[k].vartype == ORC_VAR_TYPE_DEST) {
x86_emit_add_imm_memoffset (program, 4, 2,
- (int)G_STRUCT_OFFSET(OJExecutor, arrays[k]),
+ (int)G_STRUCT_OFFSET(OrcExecutor, arrays[k]),
X86_EBP);
}
}
- x86_emit_dec_memoffset (program, 4, (int)G_STRUCT_OFFSET(OJExecutor,counter),
+ x86_emit_dec_memoffset (program, 4, (int)G_STRUCT_OFFSET(OrcExecutor,counter),
X86_EBP);
x86_emit_jne (program, 0);
x86_emit_label (program, 1);
@@ -239,14 +239,14 @@ oj_program_compile_x86 (OJProgram *program)
x86_do_fixups (program);
- oj_program_dump_code (program);
+ orc_program_dump_code (program);
}
/* rules */
static void
-x86_rule_add_s16 (OJProgram *p, void *user, OJInstruction *insn)
+x86_rule_add_s16 (OrcProgram *p, void *user, OrcInstruction *insn)
{
g_print(" addw %%%s, %%%s\n",
x86_get_regname_16(p->vars[insn->args[2]].alloc),
@@ -260,7 +260,7 @@ x86_rule_add_s16 (OJProgram *p, void *user, OJInstruction *insn)
}
static void
-x86_rule_sub_s16 (OJProgram *p, void *user, OJInstruction *insn)
+x86_rule_sub_s16 (OrcProgram *p, void *user, OrcInstruction *insn)
{
g_print(" subw %%%s, %%%s\n",
x86_get_regname_16(p->vars[insn->args[2]].alloc),
@@ -273,7 +273,7 @@ x86_rule_sub_s16 (OJProgram *p, void *user, OJInstruction *insn)
}
static void
-x86_rule_mul_s16 (OJProgram *p, void *user, OJInstruction *insn)
+x86_rule_mul_s16 (OrcProgram *p, void *user, OrcInstruction *insn)
{
g_print(" imulw %%%s, %%%s\n",
x86_get_regname_16(p->vars[insn->args[2]].alloc),
@@ -287,7 +287,7 @@ x86_rule_mul_s16 (OJProgram *p, void *user, OJInstruction *insn)
}
static void
-x86_rule_lshift_s16 (OJProgram *p, void *user, OJInstruction *insn)
+x86_rule_lshift_s16 (OrcProgram *p, void *user, OrcInstruction *insn)
{
x86_emit_mov_reg_reg(p, 4, p->vars[insn->args[2]].alloc, X86_ECX);
@@ -300,7 +300,7 @@ x86_rule_lshift_s16 (OJProgram *p, void *user, OJInstruction *insn)
}
static void
-x86_rule_rshift_s16 (OJProgram *p, void *user, OJInstruction *insn)
+x86_rule_rshift_s16 (OrcProgram *p, void *user, OrcInstruction *insn)
{
x86_emit_mov_reg_reg(p, 4, p->vars[insn->args[2]].alloc, X86_ECX);
@@ -314,25 +314,25 @@ x86_rule_rshift_s16 (OJProgram *p, void *user, OJInstruction *insn)
void
-oj_program_x86_register_rules (OJRuleList *list)
+orc_program_x86_register_rules (OrcRuleList *list)
{
- oj_rule_list_register (list, "add_s16", x86_rule_add_s16, NULL,
- OJ_RULE_REG_REG);
- oj_rule_list_register (list, "sub_s16", x86_rule_sub_s16, NULL,
- OJ_RULE_REG_REG);
- oj_rule_list_register (list, "mul_s16", x86_rule_mul_s16, NULL,
- OJ_RULE_REG_REG);
- oj_rule_list_register (list, "lshift_s16", x86_rule_lshift_s16, NULL,
- OJ_RULE_REG_REG);
- oj_rule_list_register (list, "rshift_s16", x86_rule_rshift_s16, NULL,
- OJ_RULE_REG_REG);
+ orc_rule_list_register (list, "add_s16", x86_rule_add_s16, NULL,
+ ORC_RULE_REG_REG);
+ orc_rule_list_register (list, "sub_s16", x86_rule_sub_s16, NULL,
+ ORC_RULE_REG_REG);
+ orc_rule_list_register (list, "mul_s16", x86_rule_mul_s16, NULL,
+ ORC_RULE_REG_REG);
+ orc_rule_list_register (list, "lshift_s16", x86_rule_lshift_s16, NULL,
+ ORC_RULE_REG_REG);
+ orc_rule_list_register (list, "rshift_s16", x86_rule_rshift_s16, NULL,
+ ORC_RULE_REG_REG);
}
/* code generation */
void
-x86_emit_push (OJProgram *program, int size, int reg)
+x86_emit_push (OrcProgram *program, int size, int reg)
{
if (size == 1) {
@@ -348,7 +348,7 @@ x86_emit_push (OJProgram *program, int size, int reg)
}
void
-x86_emit_pop (OJProgram *program, int size, int reg)
+x86_emit_pop (OrcProgram *program, int size, int reg)
{
if (size == 1) {
@@ -367,7 +367,7 @@ x86_emit_pop (OJProgram *program, int size, int reg)
#define X86_SIB(ss, ind, reg) ((((ss)&3)<<6)|(((ind)&7)<<3)|((reg)&7))
void
-x86_emit_modrm_memoffset (OJProgram *program, int reg1, int offset, int reg2)
+x86_emit_modrm_memoffset (OrcProgram *program, int reg1, int offset, int reg2)
{
if (offset == 0 && reg2 != X86_EBP) {
if (reg2 == X86_ESP) {
@@ -395,13 +395,13 @@ x86_emit_modrm_memoffset (OJProgram *program, int reg1, int offset, int reg2)
}
void
-x86_emit_modrm_reg (OJProgram *program, int reg1, int reg2)
+x86_emit_modrm_reg (OrcProgram *program, int reg1, int reg2)
{
*program->codeptr++ = X86_MODRM(3, reg1, reg2);
}
void
-x86_emit_mov_memoffset_reg (OJProgram *program, int size, int offset,
+x86_emit_mov_memoffset_reg (OrcProgram *program, int size, int offset,
int reg1, int reg2)
{
if (size == 2) {
@@ -418,7 +418,7 @@ x86_emit_mov_memoffset_reg (OJProgram *program, int size, int offset,
}
void
-x86_emit_mov_reg_memoffset (OJProgram *program, int size, int reg1, int offset,
+x86_emit_mov_reg_memoffset (OrcProgram *program, int size, int reg1, int offset,
int reg2)
{
if (size == 2) {
@@ -435,7 +435,7 @@ x86_emit_mov_reg_memoffset (OJProgram *program, int size, int reg1, int offset,
}
void
-x86_emit_mov_imm_reg (OJProgram *program, int size, int value, int reg1)
+x86_emit_mov_imm_reg (OrcProgram *program, int size, int value, int reg1)
{
if (size == 2) {
g_print(" movw $%d, %%%s\n", value, x86_get_regname_16(reg1));
@@ -454,7 +454,7 @@ x86_emit_mov_imm_reg (OJProgram *program, int size, int value, int reg1)
}
-void x86_emit_mov_reg_reg (OJProgram *program, int size, int reg1, int reg2)
+void x86_emit_mov_reg_reg (OrcProgram *program, int size, int reg1, int reg2)
{
if (size == 2) {
g_print(" movw %%%s, %%%s\n", x86_get_regname_16(reg1),
@@ -471,7 +471,7 @@ void x86_emit_mov_reg_reg (OJProgram *program, int size, int reg1, int reg2)
void
-x86_emit_test_reg_reg (OJProgram *program, int size, int reg1, int reg2)
+x86_emit_test_reg_reg (OrcProgram *program, int size, int reg1, int reg2)
{
if (size == 2) {
g_print(" testw %%%s, %%%s\n", x86_get_regname_16(reg1),
@@ -487,7 +487,7 @@ x86_emit_test_reg_reg (OJProgram *program, int size, int reg1, int reg2)
}
void
-x86_emit_add_imm_memoffset (OJProgram *program, int size, int value,
+x86_emit_add_imm_memoffset (OrcProgram *program, int size, int value,
int offset, int reg)
{
if (size == 2) {
@@ -516,7 +516,7 @@ x86_emit_add_imm_memoffset (OJProgram *program, int size, int value,
}
void
-x86_emit_dec_memoffset (OJProgram *program, int size,
+x86_emit_dec_memoffset (OrcProgram *program, int size,
int offset, int reg)
{
if (size == 2) {
@@ -530,14 +530,14 @@ x86_emit_dec_memoffset (OJProgram *program, int size,
x86_emit_modrm_memoffset (program, 1, offset, reg);
}
-void x86_emit_ret (OJProgram *program)
+void x86_emit_ret (OrcProgram *program)
{
g_print(" ret\n");
*program->codeptr++ = 0xc3;
}
void
-x86_add_fixup (OJProgram *program, unsigned char *ptr, int label)
+x86_add_fixup (OrcProgram *program, unsigned char *ptr, int label)
{
program->fixups[program->n_fixups].ptr = ptr;
program->fixups[program->n_fixups].label = label;
@@ -546,12 +546,12 @@ x86_add_fixup (OJProgram *program, unsigned char *ptr, int label)
}
void
-x86_add_label (OJProgram *program, unsigned char *ptr, int label)
+x86_add_label (OrcProgram *program, unsigned char *ptr, int label)
{
program->labels[label] = ptr;
}
-void x86_emit_je (OJProgram *program, int label)
+void x86_emit_je (OrcProgram *program, int label)
{
g_print(" je .L%d\n", label);
@@ -560,7 +560,7 @@ void x86_emit_je (OJProgram *program, int label)
*program->codeptr++ = -1;
}
-void x86_emit_jne (OJProgram *program, int label)
+void x86_emit_jne (OrcProgram *program, int label)
{
g_print(" jne .L%d\n", label);
*program->codeptr++ = 0x75;
@@ -568,7 +568,7 @@ void x86_emit_jne (OJProgram *program, int label)
*program->codeptr++ = -1;
}
-void x86_emit_label (OJProgram *program, int label)
+void x86_emit_label (OrcProgram *program, int label)
{
g_print(".L%d:\n", label);
@@ -576,7 +576,7 @@ void x86_emit_label (OJProgram *program, int label)
}
void
-x86_test (OJProgram *program)
+x86_test (OrcProgram *program)
{
int size;
int i;
@@ -585,7 +585,7 @@ x86_test (OJProgram *program)
for(size=2;size<=4;size+=2) {
for(i=0;i<8;i++){
- reg = OJ_GP_REG_BASE + i;
+ reg = ORC_GP_REG_BASE + i;
x86_emit_push (program, size, reg);
x86_emit_pop (program, size, reg);
x86_emit_mov_imm_reg (program, size, 0, reg);
@@ -601,7 +601,7 @@ x86_test (OJProgram *program)
x86_emit_add_imm_memoffset (program, size, 256, 1, reg);
x86_emit_add_imm_memoffset (program, size, 256, 256, reg);
for(j=0;j<8;j++){
- int reg2 = OJ_GP_REG_BASE + j;
+ int reg2 = ORC_GP_REG_BASE + j;
x86_emit_mov_reg_reg (program, size, reg, reg2);
x86_emit_mov_memoffset_reg (program, size, 0, reg, reg2);
x86_emit_mov_memoffset_reg (program, size, 1, reg, reg2);
diff --git a/orc/orcprogram.c b/orc/orcprogram.c
index e47493b..f2e83d3 100644
--- a/orc/orcprogram.c
+++ b/orc/orcprogram.c
@@ -9,21 +9,21 @@
#include <orc/orcprogram.h>
-OJProgram *
-oj_program_new (void)
+OrcProgram *
+orc_program_new (void)
{
- OJProgram *p;
- p = g_malloc0(sizeof(OJProgram));
+ OrcProgram *p;
+ p = g_malloc0(sizeof(OrcProgram));
return p;
}
int
-oj_program_add_temporary (OJProgram *program, const char *type, const char *name)
+orc_program_add_temporary (OrcProgram *program, const char *type, const char *name)
{
int i = program->n_vars;
- program->vars[i].vartype = OJ_VAR_TYPE_TEMP;
- program->vars[i].type = oj_type_get(type);
+ program->vars[i].vartype = ORC_VAR_TYPE_TEMP;
+ program->vars[i].type = orc_type_get(type);
program->vars[i].name = strdup(name);
program->n_vars++;
@@ -31,11 +31,11 @@ oj_program_add_temporary (OJProgram *program, const char *type, const char *name
}
int
-oj_program_dup_temporary (OJProgram *program, int var, int j)
+orc_program_dup_temporary (OrcProgram *program, int var, int j)
{
int i = program->n_vars;
- program->vars[i].vartype = OJ_VAR_TYPE_TEMP;
+ program->vars[i].vartype = ORC_VAR_TYPE_TEMP;
program->vars[i].type = program->vars[var].type;
program->vars[i].name = g_strdup_printf("%s.dup%d",
program->vars[var].name, j);
@@ -45,12 +45,12 @@ oj_program_dup_temporary (OJProgram *program, int var, int j)
}
int
-oj_program_add_source (OJProgram *program, const char *type, const char *name)
+orc_program_add_source (OrcProgram *program, const char *type, const char *name)
{
int i = program->n_vars;
- program->vars[i].vartype = OJ_VAR_TYPE_SRC;
- program->vars[i].type = oj_type_get(type);
+ program->vars[i].vartype = ORC_VAR_TYPE_SRC;
+ program->vars[i].type = orc_type_get(type);
program->vars[i].name = strdup(name);
program->n_vars++;
@@ -58,12 +58,12 @@ oj_program_add_source (OJProgram *program, const char *type, const char *name)
}
int
-oj_program_add_destination (OJProgram *program, const char *type, const char *name)
+orc_program_add_destination (OrcProgram *program, const char *type, const char *name)
{
int i = program->n_vars;
- program->vars[i].vartype = OJ_VAR_TYPE_DEST;
- program->vars[i].type = oj_type_get(type);
+ program->vars[i].vartype = ORC_VAR_TYPE_DEST;
+ program->vars[i].type = orc_type_get(type);
program->vars[i].name = strdup(name);
program->n_vars++;
@@ -71,12 +71,12 @@ oj_program_add_destination (OJProgram *program, const char *type, const char *na
}
int
-oj_program_add_constant (OJProgram *program, const char *type, int value, const char *name)
+orc_program_add_constant (OrcProgram *program, const char *type, int value, const char *name)
{
int i = program->n_vars;
- program->vars[i].vartype = OJ_VAR_TYPE_CONST;
- program->vars[i].type = oj_type_get(type);
+ program->vars[i].vartype = ORC_VAR_TYPE_CONST;
+ program->vars[i].type = orc_type_get(type);
program->vars[i].s16 = value;
program->vars[i].name = strdup(name);
program->n_vars++;
@@ -85,21 +85,21 @@ oj_program_add_constant (OJProgram *program, const char *type, int value, const
}
int
-oj_program_add_parameter (OJProgram *program, OJType *type, int value, const char *name)
+orc_program_add_parameter (OrcProgram *program, OrcType *type, int value, const char *name)
{
return 0;
}
void
-oj_program_append (OJProgram *program, const char *name, int arg0,
+orc_program_append (OrcProgram *program, const char *name, int arg0,
int arg1, int arg2)
{
- OJInstruction *insn;
+ OrcInstruction *insn;
insn = program->insns + program->n_insns;
- insn->opcode = oj_opcode_find_by_name (name);
+ insn->opcode = orc_opcode_find_by_name (name);
if (!insn->opcode) {
printf("unknown opcode: %s\n", name);
}
@@ -112,13 +112,13 @@ oj_program_append (OJProgram *program, const char *name, int arg0,
void
-oj_program_rewrite_vars (OJProgram *program)
+orc_program_rewrite_vars (OrcProgram *program)
{
int i;
int j;
int k;
- OJInstruction *insn;
- OJOpcode *opcode;
+ OrcInstruction *insn;
+ OrcOpcode *opcode;
int var;
int actual_var;
int alloc[8] = { 0, 1, 0, 0, 1, 1, 0, 0 };
@@ -130,7 +130,7 @@ oj_program_rewrite_vars (OJProgram *program)
/* set up args */
for(k=opcode->n_dest;k<opcode->n_src + opcode->n_dest;k++){
var = insn->args[k];
- if (program->vars[var].vartype == OJ_VAR_TYPE_DEST) {
+ if (program->vars[var].vartype == ORC_VAR_TYPE_DEST) {
g_print("ERROR: using dest var as source\n");
}
@@ -141,7 +141,7 @@ oj_program_rewrite_vars (OJProgram *program)
}
if (!program->vars[var].used) {
- if (program->vars[var].vartype == OJ_VAR_TYPE_TEMP) {
+ if (program->vars[var].vartype == ORC_VAR_TYPE_TEMP) {
g_print("ERROR: using uninitialized temp var\n");
}
program->vars[var].used = TRUE;
@@ -153,13 +153,13 @@ oj_program_rewrite_vars (OJProgram *program)
for(k=0;k<opcode->n_dest;k++){
var = insn->args[k];
- if (program->vars[var].vartype == OJ_VAR_TYPE_SRC) {
+ if (program->vars[var].vartype == ORC_VAR_TYPE_SRC) {
g_print("ERROR: using src var as dest\n");
}
- if (program->vars[var].vartype == OJ_VAR_TYPE_CONST) {
+ if (program->vars[var].vartype == ORC_VAR_TYPE_CONST) {
g_print("ERROR: using const var as dest\n");
}
- if (program->vars[var].vartype == OJ_VAR_TYPE_PARAM) {
+ if (program->vars[var].vartype == ORC_VAR_TYPE_PARAM) {
g_print("ERROR: using param var as dest\n");
}
@@ -173,11 +173,11 @@ oj_program_rewrite_vars (OJProgram *program)
program->vars[actual_var].used = TRUE;
program->vars[actual_var].first_use = j;
} else {
- if (program->vars[var].vartype == OJ_VAR_TYPE_DEST) {
+ if (program->vars[var].vartype == ORC_VAR_TYPE_DEST) {
g_print("ERROR: writing dest more than once\n");
}
- if (program->vars[var].vartype == OJ_VAR_TYPE_TEMP) {
- actual_var = oj_program_dup_temporary (program, var, j);
+ if (program->vars[var].vartype == ORC_VAR_TYPE_TEMP) {
+ actual_var = orc_program_dup_temporary (program, var, j);
program->vars[var].replaced = TRUE;
program->vars[var].replacement = actual_var;
insn->args[k] = actual_var;
@@ -194,7 +194,7 @@ oj_program_rewrite_vars (OJProgram *program)
if (program->vars[i].first_use == j) {
for(k=0;k<8;k++){
if (!alloc[k]) {
- program->vars[i].alloc = k + OJ_GP_REG_BASE;
+ program->vars[i].alloc = k + ORC_GP_REG_BASE;
alloc[k] = 1;
break;
}
@@ -206,7 +206,7 @@ oj_program_rewrite_vars (OJProgram *program)
}
for(i=0;i<program->n_vars;i++){
if (program->vars[i].last_use == j) {
- alloc[program->vars[i].alloc - OJ_GP_REG_BASE] = 0;
+ alloc[program->vars[i].alloc - ORC_GP_REG_BASE] = 0;
}
}
}
@@ -224,7 +224,7 @@ oj_program_rewrite_vars (OJProgram *program)
}
void
-oj_program_dump_code (OJProgram *program)
+orc_program_dump_code (OrcProgram *program)
{
FILE *file;
@@ -235,12 +235,12 @@ oj_program_dump_code (OJProgram *program)
}
void
-oj_program_dump (OJProgram *program)
+orc_program_dump (OrcProgram *program)
{
int i;
int j;
- OJOpcode *opcode;
- OJInstruction *insn;
+ OrcOpcode *opcode;
+ OrcInstruction *insn;
for(i=0;i<program->n_insns;i++){
insn = program->insns + i;
diff --git a/orc/orcprogram.h b/orc/orcprogram.h
index c755b3e..58f84a7 100644
--- a/orc/orcprogram.h
+++ b/orc/orcprogram.h
@@ -1,41 +1,41 @@
-#ifndef _OJ_PROGRAM_H_
-#define _OJ_PROGRAM_H_
+#ifndef _ORC_PROGRAM_H_
+#define _ORC_PROGRAM_H_
#include <glib.h>
-typedef struct _OJType OJType;
-typedef struct _OJExecutor OJExecutor;
-typedef struct _OJVariable OJVariable;
-typedef struct _OJOpcode OJOpcode;
-typedef struct _OJArgument OJArgument;
-typedef struct _OJInstruction OJInstruction;
-typedef struct _OJProgram OJProgram;
-typedef struct _OJRule OJRule;
-typedef struct _OJRuleList OJRuleList;
-typedef struct _OJFixup OJFixup;
-
-typedef void (*OJOpcodeEmulateFunc)(OJExecutor *ex, void *user);
-typedef void (*OJRuleEmitFunc)(OJProgram *p, void *user, OJInstruction *insn);
-
-struct _OJType {
+typedef struct _OrcType OrcType;
+typedef struct _OrcExecutor OrcExecutor;
+typedef struct _OrcVariable OrcVariable;
+typedef struct _OrcOpcode OrcOpcode;
+typedef struct _OrcArgument OrcArgument;
+typedef struct _OrcInstruction OrcInstruction;
+typedef struct _OrcProgram OrcProgram;
+typedef struct _OrcRule OrcRule;
+typedef struct _OrcRuleList OrcRuleList;
+typedef struct _OrcFixup OrcFixup;
+
+typedef void (*OrcOpcodeEmulateFunc)(OrcExecutor *ex, void *user);
+typedef void (*OrcRuleEmitFunc)(OrcProgram *p, void *user, OrcInstruction *insn);
+
+struct _OrcType {
char *name;
int size;
};
typedef enum {
- OJ_VAR_TYPE_TEMP,
- OJ_VAR_TYPE_SRC,
- OJ_VAR_TYPE_DEST,
- OJ_VAR_TYPE_CONST,
- OJ_VAR_TYPE_PARAM
-} OJVarType;
-
-struct _OJVariable {
+ ORC_VAR_TYPE_TEMP,
+ ORC_VAR_TYPE_SRC,
+ ORC_VAR_TYPE_DEST,
+ ORC_VAR_TYPE_CONST,
+ ORC_VAR_TYPE_PARAM
+} OrcVarType;
+
+struct _OrcVariable {
char *name;
- OJType *type;
- OJVarType vartype;
+ OrcType *type;
+ OrcVarType vartype;
int used;
int first_use;
@@ -49,136 +49,136 @@ struct _OJVariable {
};
-struct _OJOpcode {
+struct _OrcOpcode {
char *name;
int n_src;
int n_dest;
- OJType *arg_types[10];
+ OrcType *arg_types[10];
- OJOpcodeEmulateFunc emulate;
+ OrcOpcodeEmulateFunc emulate;
void *emulate_user;
};
-struct _OJArgument {
- OJVariable *var;
+struct _OrcArgument {
+ OrcVariable *var;
int is_indirect;
int is_indexed;
- OJVariable *index_var;
+ OrcVariable *index_var;
int index_scale;
int type; // remove
int index; // remove
int offset;
};
-struct _OJInstruction {
- OJOpcode *opcode;
+struct _OrcInstruction {
+ OrcOpcode *opcode;
int args[3];
- OJRule *rule;
+ OrcRule *rule;
};
-struct _OJFixup {
+struct _OrcFixup {
unsigned char *ptr;
int type;
int label;
};
-struct _OJProgram {
- OJInstruction insns[100];
+struct _OrcProgram {
+ OrcInstruction insns[100];
int n_insns;
- OJVariable vars[100];
+ OrcVariable vars[100];
int n_vars;
- OJInstruction *insn;
+ OrcInstruction *insn;
unsigned char *code;
void *code_exec;
unsigned char *codeptr;
int code_size;
- OJFixup fixups[100];
+ OrcFixup fixups[100];
int n_fixups;
unsigned char *labels[100];
int error;
};
-struct _OJExecutor {
- OJProgram *program;
+struct _OrcExecutor {
+ OrcProgram *program;
int n;
int counter;
void *arrays[10];
- OJVariable vars[10];
- OJVariable *args[4];
+ OrcVariable vars[10];
+ OrcVariable *args[4];
};
enum {
- OJ_RULE_3REG = (1<<0),
- OJ_RULE_REG_REG = (1<<1),
- OJ_RULE_MEM_REG = (1<<2),
- OJ_RULE_REG_MEM = (1<<3),
- OJ_RULE_REG_IMM = (1<<4),
- OJ_RULE_MEM_IMM = (1<<5),
- OJ_RULE_REG_CL = (1<<6)
+ ORC_RULE_3REG = (1<<0),
+ ORC_RULE_REG_REG = (1<<1),
+ ORC_RULE_MEM_REG = (1<<2),
+ ORC_RULE_REG_MEM = (1<<3),
+ ORC_RULE_REG_IMM = (1<<4),
+ ORC_RULE_MEM_IMM = (1<<5),
+ ORC_RULE_REG_CL = (1<<6)
};
-struct _OJRule {
- OJOpcode *opcode;
+struct _OrcRule {
+ OrcOpcode *opcode;
unsigned int flags;
- OJRuleEmitFunc emit;
+ OrcRuleEmitFunc emit;
void *emit_user;
};
-struct _OJRuleList {
+struct _OrcRuleList {
int n_alloc;
int n_rules;
- OJRule *rules;
+ OrcRule *rules;
};
-#define OJ_GP_REG_BASE 8
+#define ORC_GP_REG_BASE 8
-OJProgram * oj_program_new (void);
-OJOpcode * oj_opcode_find_by_name (const char *name);
-void oj_opcode_init (void);
+OrcProgram * orc_program_new (void);
+OrcOpcode * orc_opcode_find_by_name (const char *name);
+void orc_opcode_init (void);
-void oj_program_append (OJProgram *p, const char *opcode, int arg0, int arg1, int arg2);
+void orc_program_append (OrcProgram *p, const char *opcode, int arg0, int arg1, int arg2);
-void oj_program_compile_x86 (OJProgram *p);
-void oj_program_free (OJProgram *program);
+void orc_program_compile_x86 (OrcProgram *p);
+void orc_program_free (OrcProgram *program);
-int oj_program_add_temporary (OJProgram *program, const char *type, const char *name);
-int oj_program_dup_temporary (OJProgram *program, int i, int j);
-int oj_program_add_source (OJProgram *program, const char *type, const char *name);
-int oj_program_add_destination (OJProgram *program, const char *type, const char *name);
-int oj_program_add_constant (OJProgram *program, const char *type, int value, const char *name);
-void oj_program_append (OJProgram *program, const char *opcode, int arg0,
+int orc_program_add_temporary (OrcProgram *program, const char *type, const char *name);
+int orc_program_dup_temporary (OrcProgram *program, int i, int j);
+int orc_program_add_source (OrcProgram *program, const char *type, const char *name);
+int orc_program_add_destination (OrcProgram *program, const char *type, const char *name);
+int orc_program_add_constant (OrcProgram *program, const char *type, int value, const char *name);
+void orc_program_append (OrcProgram *program, const char *opcode, int arg0,
int arg1, int arg2);
-OJType * oj_type_get (const char *name);
-void oj_type_register (const char *name, int size);
+OrcType * orc_type_get (const char *name);
+void orc_type_register (const char *name, int size);
-OJExecutor * oj_executor_new (OJProgram *program);
-void oj_executor_free (OJExecutor *ex);
-void oj_executor_set_array (OJExecutor *ex, int var, void *ptr);
-void oj_executor_set_n (OJExecutor *ex, int n);
-void oj_executor_emulate (OJExecutor *ex);
+OrcExecutor * orc_executor_new (OrcProgram *program);
+void orc_executor_free (OrcExecutor *ex);
+void orc_executor_set_array (OrcExecutor *ex, int var, void *ptr);
+void orc_executor_set_n (OrcExecutor *ex, int n);
+void orc_executor_emulate (OrcExecutor *ex);
-OJRuleList *oj_rule_list_new(void);
-void oj_rule_list_free (OJRuleList *rule_list);
-void oj_rule_list_register (OJRuleList *rule_list, const char *op_name,
- OJRuleEmitFunc emit, void *emit_user, unsigned int flags);
-OJRule * oj_rule_list_get (OJRuleList *rule_list, OJOpcode *opcode);
-void oj_program_x86_register_rules (OJRuleList *rule_list);
-void oj_program_allocate_codemem (OJProgram *program);
-void oj_program_dump_code (OJProgram *program);
+OrcRuleList *orc_rule_list_new(void);
+void orc_rule_list_free (OrcRuleList *rule_list);
+void orc_rule_list_register (OrcRuleList *rule_list, const char *op_name,
+ OrcRuleEmitFunc emit, void *emit_user, unsigned int flags);
+OrcRule * orc_rule_list_get (OrcRuleList *rule_list, OrcOpcode *opcode);
+void orc_program_x86_register_rules (OrcRuleList *rule_list);
+void orc_program_allocate_codemem (OrcProgram *program);
+void orc_program_dump_code (OrcProgram *program);
#endif
diff --git a/orc/orcrule.c b/orc/orcrule.c
index b2a11f4..7170b9e 100644
--- a/orc/orcrule.c
+++ b/orc/orcrule.c
@@ -9,37 +9,37 @@
#include <orc/orcprogram.h>
-OJRuleList *
-oj_rule_list_new (void)
+OrcRuleList *
+orc_rule_list_new (void)
{
- OJRuleList *rule_list;
+ OrcRuleList *rule_list;
- rule_list = malloc (sizeof(OJRuleList));
- memset (rule_list, 0, sizeof(OJRuleList));
+ rule_list = malloc (sizeof(OrcRuleList));
+ memset (rule_list, 0, sizeof(OrcRuleList));
return rule_list;
}
void
-oj_rule_list_free (OJRuleList *rule_list)
+orc_rule_list_free (OrcRuleList *rule_list)
{
free (rule_list->rules);
free (rule_list);
}
void
-oj_rule_list_register (OJRuleList *rule_list, const char *opcode_name,
- OJRuleEmitFunc emit, void *emit_user, unsigned int flags)
+orc_rule_list_register (OrcRuleList *rule_list, const char *opcode_name,
+ OrcRuleEmitFunc emit, void *emit_user, unsigned int flags)
{
int i;
if (rule_list->n_rules == rule_list->n_alloc) {
rule_list->n_alloc += 100;
- rule_list->rules = realloc (rule_list, sizeof(OJRule) * rule_list->n_alloc);
+ rule_list->rules = realloc (rule_list, sizeof(OrcRule) * rule_list->n_alloc);
}
i = rule_list->n_rules;
- rule_list->rules[i].opcode = oj_opcode_find_by_name (opcode_name);
+ rule_list->rules[i].opcode = orc_opcode_find_by_name (opcode_name);
rule_list->rules[i].emit = emit;
rule_list->rules[i].emit_user = emit_user;
rule_list->rules[i].flags = flags;
@@ -47,8 +47,8 @@ oj_rule_list_register (OJRuleList *rule_list, const char *opcode_name,
rule_list->n_rules++;
}
-OJRule *
-oj_rule_list_get (OJRuleList *rule_list, OJOpcode *opcode)
+OrcRule *
+orc_rule_list_get (OrcRuleList *rule_list, OrcOpcode *opcode)
{
int i;
for (i=0;i<rule_list->n_rules;i++){
diff --git a/orc/orctype.c b/orc/orctype.c
index 42150eb..ea770c9 100644
--- a/orc/orctype.c
+++ b/orc/orctype.c
@@ -8,12 +8,12 @@
#include <orc/orcprogram.h>
-OJType *types;
+OrcType *types;
static int n_types;
static int n_alloc_types;
-OJType *
-oj_type_get (const char *name)
+OrcType *
+orc_type_get (const char *name)
{
int i;
for(i=0;i<n_types;i++){
@@ -25,13 +25,13 @@ oj_type_get (const char *name)
}
void
-oj_type_register (const char *name, int size)
+orc_type_register (const char *name, int size)
{
- OJType *type;
+ OrcType *type;
if (n_types == n_alloc_types) {
n_alloc_types += 100;
- types = realloc (types, sizeof(OJType) * n_alloc_types);
+ types = realloc (types, sizeof(OrcType) * n_alloc_types);
}
type = types + n_types;