orcsse.c \
orcmmx.c \
x86.c \
- arm.c
+ orcarm.c
if HAVE_I386
liborc_@ORC_MAJORMINOR@_la_SOURCES += orccpu-x86.c
orcsse.h \
orcmmx.h \
orcx86.h \
- arm.h
+ orcarm.h
nodist_pkginclude_HEADERS = orc-stdint.h
+++ /dev/null
-
-#ifndef _ORC_ARM_H_
-#define _ORC_ARM_H_
-
-#include <orc/orcprogram.h>
-
-#define ARM_R0 (ORC_GP_REG_BASE+0)
-
-#define ARM_A1 (ORC_GP_REG_BASE+0)
-#define ARM_A2 (ORC_GP_REG_BASE+1)
-#define ARM_A3 (ORC_GP_REG_BASE+2)
-#define ARM_A4 (ORC_GP_REG_BASE+3)
-#define ARM_V1 (ORC_GP_REG_BASE+4)
-#define ARM_V2 (ORC_GP_REG_BASE+5)
-#define ARM_V3 (ORC_GP_REG_BASE+6)
-#define ARM_V4 (ORC_GP_REG_BASE+7)
-#define ARM_V5 (ORC_GP_REG_BASE+8)
-#define ARM_V6 (ORC_GP_REG_BASE+9)
-#define ARM_V7 (ORC_GP_REG_BASE+10)
-#define ARM_V8 (ORC_GP_REG_BASE+11)
-#define ARM_IP (ORC_GP_REG_BASE+12)
-#define ARM_SP (ORC_GP_REG_BASE+13)
-#define ARM_LR (ORC_GP_REG_BASE+14)
-#define ARM_PC (ORC_GP_REG_BASE+15)
-
-#define ARM_SB (ORC_GP_REG_BASE+9)
-
-enum {
- ARM_DP_AND = 0,
- ARM_DP_EOR,
- ARM_DP_SUB,
- ARM_DP_RSB,
- ARM_DP_ADD,
- ARM_DP_ADC,
- ARM_DP_SBC,
- ARM_DP_RSC,
- ARM_DP_TST,
- ARM_DP_TEQ,
- ARM_DP_CMP,
- ARM_DP_CMN,
- ARM_DP_ORR,
- ARM_DP_MOV,
- ARM_DP_BIC,
- ARM_DP_MVN
-};
-
-enum {
- ARM_COND_EQ = 0,
- ARM_COND_NE,
- ARM_COND_CS,
- ARM_COND_CC,
- ARM_COND_MI,
- ARM_COND_PL,
- ARM_COND_VS,
- ARM_COND_VC,
- ARM_COND_HI,
- ARM_COND_LS,
- ARM_COND_GE,
- ARM_COND_LT,
- ARM_COND_GT,
- ARM_COND_LE,
- ARM_COND_AL,
-};
-
-void arm_emit (OrcCompiler *compiler, uint32_t insn);
-void arm_emit_bx_lr (OrcCompiler *compiler);
-const char * arm_reg_name (int reg);
-void arm_emit_loadimm (OrcCompiler *compiler, int dest, int imm);
-
-void arm_emit_add (OrcCompiler *compiler, int dest, int src1, int src2);
-void arm_emit_sub (OrcCompiler *compiler, int dest, int src1, int src2);
-void arm_emit_add_imm (OrcCompiler *compiler, int dest, int src1, int value);
-void arm_emit_sub_imm (OrcCompiler *compiler, int dest, int src1, int value);
-void arm_emit_cmp_imm (OrcCompiler *compiler, int src1, int value);
-
-void arm_emit_label (OrcCompiler *compiler, int label);
-void arm_emit_push (OrcCompiler *compiler, int regs);
-void arm_emit_pop (OrcCompiler *compiler, int regs);
-void arm_emit_mov (OrcCompiler *compiler, int dest, int src);
-void arm_emit_branch (OrcCompiler *compiler, int cond, int label);
-
-void arm_emit_dp_reg (OrcCompiler *compiler, int cond, int opcode, int dest,
- int src1, int src2);
-
-void arm_loadw (OrcCompiler *compiler, int dest, int src1, int offset);
-void arm_storew (OrcCompiler *compiler, int dest, int offset, int src1);
-
-void arm_emit_load_reg (OrcCompiler *compiler, int dest, int src1, int offset);
-
-void arm_do_fixups (OrcCompiler *compiler);
-
-
-#endif
-
#include <sys/types.h>
#include <orc/orcprogram.h>
-#include <orc/arm.h>
+#include <orc/orcarm.h>
#include <orc/orcutils.h>
const char *
-arm_reg_name (int reg)
+orc_arm_reg_name (int reg)
{
#if 0
static const char *gp_regs[] = {
}
void
-arm_emit (OrcCompiler *compiler, uint32_t insn)
+orc_arm_emit (OrcCompiler *compiler, uint32_t insn)
{
ORC_WRITE_UINT32_LE (compiler->codeptr, insn);
compiler->codeptr+=4;
}
void
-arm_emit_bx_lr (OrcCompiler *compiler)
+orc_arm_emit_bx_lr (OrcCompiler *compiler)
{
ORC_ASM_CODE(compiler," bx lr\n");
- arm_emit (compiler, 0xe12fff1e);
+ orc_arm_emit (compiler, 0xe12fff1e);
}
void
-arm_emit_push (OrcCompiler *compiler, int regs)
+orc_arm_emit_push (OrcCompiler *compiler, int regs)
{
int i;
int x = 0;
}
ORC_ASM_CODE(compiler,"}\n");
- arm_emit (compiler, 0xe92d0000 | regs);
+ orc_arm_emit (compiler, 0xe92d0000 | regs);
}
void
-arm_emit_pop (OrcCompiler *compiler, int regs)
+orc_arm_emit_pop (OrcCompiler *compiler, int regs)
{
int i;
int x = 0;
}
ORC_ASM_CODE(compiler,"}\n");
- arm_emit (compiler, 0xe8bd0000 | regs);
+ orc_arm_emit (compiler, 0xe8bd0000 | regs);
}
void
-arm_emit_mov (OrcCompiler *compiler, int dest, int src)
+orc_arm_emit_mov (OrcCompiler *compiler, int dest, int src)
{
uint32_t code;
code |= (src&0xf) << 0;
code |= (dest&0xf) << 12;
- ORC_ASM_CODE(compiler," mov %s, %s\n", arm_reg_name (dest), arm_reg_name (src));
+ ORC_ASM_CODE(compiler," mov %s, %s\n", orc_arm_reg_name (dest), orc_arm_reg_name (src));
- arm_emit (compiler, code);
+ orc_arm_emit (compiler, code);
}
void
-arm_emit_label (OrcCompiler *compiler, int label)
+orc_arm_emit_label (OrcCompiler *compiler, int label)
{
ORC_ASM_CODE(compiler,".L%d:\n", label);
}
void
-arm_add_fixup (OrcCompiler *compiler, int label, int type)
+orc_arm_add_fixup (OrcCompiler *compiler, int label, int type)
{
compiler->fixups[compiler->n_fixups].ptr = compiler->codeptr;
compiler->fixups[compiler->n_fixups].label = label;
}
void
-arm_do_fixups (OrcCompiler *compiler)
+orc_arm_do_fixups (OrcCompiler *compiler)
{
int i;
for(i=0;i<compiler->n_fixups;i++){
}
void
-arm_emit_branch (OrcCompiler *compiler, int cond, int label)
+orc_arm_emit_branch (OrcCompiler *compiler, int cond, int label)
{
static const char *cond_names[] = {
"eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc",
code = 0x0afffffe;
code |= (cond&0xf) << 28;
- arm_add_fixup (compiler, label, 0);
- arm_emit (compiler, code);
+ orc_arm_add_fixup (compiler, label, 0);
+ orc_arm_emit (compiler, code);
ORC_ASM_CODE(compiler," b%s .L%d\n", cond_names[cond], label);
}
void
-arm_emit_loadimm (OrcCompiler *compiler, int dest, int imm)
+orc_arm_emit_loadimm (OrcCompiler *compiler, int dest, int imm)
{
uint32_t code;
int shift2;
code |= (((16-shift2)&0xf) << 8);
code |= (imm&0xff);
- ORC_ASM_CODE(compiler," mov %s, #0x%08x\n", arm_reg_name (dest), imm << (shift2*2));
- arm_emit (compiler, code);
+ ORC_ASM_CODE(compiler," mov %s, #0x%08x\n", orc_arm_reg_name (dest), imm << (shift2*2));
+ orc_arm_emit (compiler, code);
}
void
-arm_emit_add (OrcCompiler *compiler, int dest, int src1, int src2)
+orc_arm_emit_add (OrcCompiler *compiler, int dest, int src1, int src2)
{
uint32_t code;
code |= (src2&0xf) << 0;
ORC_ASM_CODE(compiler," add %s, %s, %s\n",
- arm_reg_name (dest),
- arm_reg_name (src1),
- arm_reg_name (src2));
- arm_emit (compiler, code);
+ orc_arm_reg_name (dest),
+ orc_arm_reg_name (src1),
+ orc_arm_reg_name (src2));
+ orc_arm_emit (compiler, code);
}
void
-arm_emit_sub (OrcCompiler *compiler, int dest, int src1, int src2)
+orc_arm_emit_sub (OrcCompiler *compiler, int dest, int src1, int src2)
{
uint32_t code;
code |= (src2&0xf) << 0;
ORC_ASM_CODE(compiler," sub %s, %s, %s\n",
- arm_reg_name (dest),
- arm_reg_name (src1),
- arm_reg_name (src2));
- arm_emit (compiler, code);
+ orc_arm_reg_name (dest),
+ orc_arm_reg_name (src1),
+ orc_arm_reg_name (src2));
+ orc_arm_emit (compiler, code);
}
void
-arm_emit_add_imm (OrcCompiler *compiler, int dest, int src1, int value)
+orc_arm_emit_add_imm (OrcCompiler *compiler, int dest, int src1, int value)
{
uint32_t code;
code |= (value) << 0;
ORC_ASM_CODE(compiler," add %s, %s, #%d\n",
- arm_reg_name (dest),
- arm_reg_name (src1),
+ orc_arm_reg_name (dest),
+ orc_arm_reg_name (src1),
value);
- arm_emit (compiler, code);
+ orc_arm_emit (compiler, code);
}
void
-arm_emit_sub_imm (OrcCompiler *compiler, int dest, int src1, int value)
+orc_arm_emit_sub_imm (OrcCompiler *compiler, int dest, int src1, int value)
{
uint32_t code;
code |= (value) << 0;
ORC_ASM_CODE(compiler," subs %s, %s, #%d\n",
- arm_reg_name (dest),
- arm_reg_name (src1),
+ orc_arm_reg_name (dest),
+ orc_arm_reg_name (src1),
value);
- arm_emit (compiler, code);
+ orc_arm_emit (compiler, code);
}
void
-arm_emit_cmp_imm (OrcCompiler *compiler, int src1, int value)
+orc_arm_emit_cmp_imm (OrcCompiler *compiler, int src1, int value)
{
uint32_t code;
code |= (value) << 0;
ORC_ASM_CODE(compiler," cmp %s, #%d\n",
- arm_reg_name (src1),
+ orc_arm_reg_name (src1),
value);
- arm_emit (compiler, code);
+ orc_arm_emit (compiler, code);
}
void
-arm_emit_load_reg (OrcCompiler *compiler, int dest, int src1, int offset)
+orc_arm_emit_load_reg (OrcCompiler *compiler, int dest, int src1, int offset)
{
uint32_t code;
code |= offset&0xfff;
ORC_ASM_CODE(compiler," ldr %s, [%s, #%d]\n",
- arm_reg_name (dest),
- arm_reg_name (src1), offset);
- arm_emit (compiler, code);
+ orc_arm_reg_name (dest),
+ orc_arm_reg_name (src1), offset);
+ orc_arm_emit (compiler, code);
}
void
-arm_emit_dp_reg (OrcCompiler *compiler, int cond, int opcode, int dest,
+orc_arm_emit_dp_reg (OrcCompiler *compiler, int cond, int opcode, int dest,
int src1, int src2)
{
static const char *dp_insn_names[] = {
ORC_ASM_CODE(compiler," %s%s %s, %s\n",
dp_insn_names[opcode],
update ? "s" : "",
- arm_reg_name (src1),
- arm_reg_name (src2));
+ orc_arm_reg_name (src1),
+ orc_arm_reg_name (src2));
} else {
ORC_ASM_CODE(compiler," %s%s %s, %s, %s\n",
dp_insn_names[opcode],
update ? "s" : "",
- arm_reg_name (dest),
- arm_reg_name (src1),
- arm_reg_name (src2));
+ orc_arm_reg_name (dest),
+ orc_arm_reg_name (src1),
+ orc_arm_reg_name (src2));
}
- arm_emit (compiler, code);
+ orc_arm_emit (compiler, code);
}
--- /dev/null
+
+#ifndef _ORC_ARM_H_
+#define _ORC_ARM_H_
+
+#include <orc/orcprogram.h>
+
+#define ORC_ARM_R0 (ORC_GP_REG_BASE+0)
+
+#define ORC_ARM_A1 (ORC_GP_REG_BASE+0)
+#define ORC_ARM_A2 (ORC_GP_REG_BASE+1)
+#define ORC_ARM_A3 (ORC_GP_REG_BASE+2)
+#define ORC_ARM_A4 (ORC_GP_REG_BASE+3)
+#define ORC_ARM_V1 (ORC_GP_REG_BASE+4)
+#define ORC_ARM_V2 (ORC_GP_REG_BASE+5)
+#define ORC_ARM_V3 (ORC_GP_REG_BASE+6)
+#define ORC_ARM_V4 (ORC_GP_REG_BASE+7)
+#define ORC_ARM_V5 (ORC_GP_REG_BASE+8)
+#define ORC_ARM_V6 (ORC_GP_REG_BASE+9)
+#define ORC_ARM_V7 (ORC_GP_REG_BASE+10)
+#define ORC_ARM_V8 (ORC_GP_REG_BASE+11)
+#define ORC_ARM_IP (ORC_GP_REG_BASE+12)
+#define ORC_ARM_SP (ORC_GP_REG_BASE+13)
+#define ORC_ARM_LR (ORC_GP_REG_BASE+14)
+#define ORC_ARM_PC (ORC_GP_REG_BASE+15)
+
+#define ORC_ARM_SB (ORC_GP_REG_BASE+9)
+
+enum {
+ ORC_ARM_DP_AND = 0,
+ ORC_ARM_DP_EOR,
+ ORC_ARM_DP_SUB,
+ ORC_ARM_DP_RSB,
+ ORC_ARM_DP_ADD,
+ ORC_ARM_DP_ADC,
+ ORC_ARM_DP_SBC,
+ ORC_ARM_DP_RSC,
+ ORC_ARM_DP_TST,
+ ORC_ARM_DP_TEQ,
+ ORC_ARM_DP_CMP,
+ ORC_ARM_DP_CMN,
+ ORC_ARM_DP_ORR,
+ ORC_ARM_DP_MOV,
+ ORC_ARM_DP_BIC,
+ ORC_ARM_DP_MVN
+};
+
+enum {
+ ORC_ARM_COND_EQ = 0,
+ ORC_ARM_COND_NE,
+ ORC_ARM_COND_CS,
+ ORC_ARM_COND_CC,
+ ORC_ARM_COND_MI,
+ ORC_ARM_COND_PL,
+ ORC_ARM_COND_VS,
+ ORC_ARM_COND_VC,
+ ORC_ARM_COND_HI,
+ ORC_ARM_COND_LS,
+ ORC_ARM_COND_GE,
+ ORC_ARM_COND_LT,
+ ORC_ARM_COND_GT,
+ ORC_ARM_COND_LE,
+ ORC_ARM_COND_AL,
+};
+
+void orc_arm_emit (OrcCompiler *compiler, uint32_t insn);
+void orc_arm_emit_bx_lr (OrcCompiler *compiler);
+const char * orc_arm_reg_name (int reg);
+void orc_arm_emit_loadimm (OrcCompiler *compiler, int dest, int imm);
+
+void orc_arm_emit_add (OrcCompiler *compiler, int dest, int src1, int src2);
+void orc_arm_emit_sub (OrcCompiler *compiler, int dest, int src1, int src2);
+void orc_arm_emit_add_imm (OrcCompiler *compiler, int dest, int src1, int value);
+void orc_arm_emit_sub_imm (OrcCompiler *compiler, int dest, int src1, int value);
+void orc_arm_emit_cmp_imm (OrcCompiler *compiler, int src1, int value);
+
+void orc_arm_emit_label (OrcCompiler *compiler, int label);
+void orc_arm_emit_push (OrcCompiler *compiler, int regs);
+void orc_arm_emit_pop (OrcCompiler *compiler, int regs);
+void orc_arm_emit_mov (OrcCompiler *compiler, int dest, int src);
+void orc_arm_emit_branch (OrcCompiler *compiler, int cond, int label);
+
+void orc_arm_emit_dp_reg (OrcCompiler *compiler, int cond, int opcode, int dest,
+ int src1, int src2);
+
+void orc_arm_loadw (OrcCompiler *compiler, int dest, int src1, int offset);
+void orc_arm_storew (OrcCompiler *compiler, int dest, int offset, int src1);
+
+void orc_arm_emit_load_reg (OrcCompiler *compiler, int dest, int src1, int offset);
+
+void orc_arm_do_fixups (OrcCompiler *compiler);
+
+
+#endif
+
#include <sys/types.h>
#include <orc/orcprogram.h>
-#include <orc/arm.h>
+#include <orc/orcarm.h>
#include <orc/orcutils.h>
#include <orc/orcdebug.h>
#define SIZE 65536
-int arm_exec_ptr = ARM_R0;
+int orc_arm_exec_ptr = ORC_ARM_R0;
-void arm_emit_loop (OrcCompiler *compiler);
+void orc_arm_emit_loop (OrcCompiler *compiler);
-void orc_compiler_arm_register_rules (OrcTarget *target);
+void orc_compiler_orc_arm_register_rules (OrcTarget *target);
-void orc_compiler_arm_init (OrcCompiler *compiler);
-unsigned int orc_compiler_arm_get_default_flags (void);
-void orc_compiler_arm_assemble (OrcCompiler *compiler);
+void orc_compiler_orc_arm_init (OrcCompiler *compiler);
+unsigned int orc_compiler_orc_arm_get_default_flags (void);
+void orc_compiler_orc_arm_assemble (OrcCompiler *compiler);
void orc_compiler_rewrite_vars (OrcCompiler *compiler);
void orc_compiler_dump (OrcCompiler *compiler);
void
-arm_emit_prologue (OrcCompiler *compiler)
+orc_arm_emit_prologue (OrcCompiler *compiler)
{
unsigned int regs = 0;
int i;
regs |= (1<<i);
}
}
- if (regs) arm_emit_push (compiler, regs);
+ if (regs) orc_arm_emit_push (compiler, regs);
}
void
-arm_dump_insns (OrcCompiler *compiler)
+orc_arm_dump_insns (OrcCompiler *compiler)
{
- arm_emit_label (compiler, 0);
+ orc_arm_emit_label (compiler, 0);
- arm_emit_add (compiler, ARM_A2, ARM_A3, ARM_A4);
- arm_emit_sub (compiler, ARM_A2, ARM_A3, ARM_A4);
- arm_emit_push (compiler, 0x06);
- arm_emit_mov (compiler, ARM_A2, ARM_A3);
+ orc_arm_emit_add (compiler, ORC_ARM_A2, ORC_ARM_A3, ORC_ARM_A4);
+ orc_arm_emit_sub (compiler, ORC_ARM_A2, ORC_ARM_A3, ORC_ARM_A4);
+ orc_arm_emit_push (compiler, 0x06);
+ orc_arm_emit_mov (compiler, ORC_ARM_A2, ORC_ARM_A3);
- arm_emit_branch (compiler, ARM_COND_LE, 0);
- arm_emit_branch (compiler, ARM_COND_AL, 0);
+ orc_arm_emit_branch (compiler, ORC_ARM_COND_LE, 0);
+ orc_arm_emit_branch (compiler, ORC_ARM_COND_AL, 0);
- arm_emit_loadimm (compiler, ARM_A3, 0xa500);
- arm_loadw (compiler, ARM_A3, ARM_A4, 0xa5);
- arm_emit_load_reg (compiler, ARM_A3, ARM_A4, 0x5a5);
+ orc_arm_emit_loadimm (compiler, ORC_ARM_A3, 0xa500);
+ orc_arm_loadw (compiler, ORC_ARM_A3, ORC_ARM_A4, 0xa5);
+ orc_arm_emit_load_reg (compiler, ORC_ARM_A3, ORC_ARM_A4, 0x5a5);
}
void
-arm_emit_epilogue (OrcCompiler *compiler)
+orc_arm_emit_epilogue (OrcCompiler *compiler)
{
int i;
unsigned int regs = 0;
regs |= (1<<i);
}
}
- if (regs) arm_emit_pop (compiler, regs);
- arm_emit_bx_lr (compiler);
+ if (regs) orc_arm_emit_pop (compiler, regs);
+ orc_arm_emit_bx_lr (compiler);
- //arm_dump_insns (compiler);
+ //orc_arm_dump_insns (compiler);
}
-static OrcTarget arm_target = {
+static OrcTarget orc_arm_target = {
"arm",
#ifdef HAVE_ARM
TRUE,
FALSE,
#endif
ORC_GP_REG_BASE,
- orc_compiler_arm_get_default_flags,
- orc_compiler_arm_init,
- orc_compiler_arm_assemble
+ orc_compiler_orc_arm_get_default_flags,
+ orc_compiler_orc_arm_init,
+ orc_compiler_orc_arm_assemble
};
void
orc_arm_init (void)
{
- orc_target_register (&arm_target);
+ orc_target_register (&orc_arm_target);
- orc_compiler_arm_register_rules (&arm_target);
+ orc_compiler_orc_arm_register_rules (&orc_arm_target);
}
unsigned int
-orc_compiler_arm_get_default_flags (void)
+orc_compiler_orc_arm_get_default_flags (void)
{
return 0;
}
void
-orc_compiler_arm_init (OrcCompiler *compiler)
+orc_compiler_orc_arm_init (OrcCompiler *compiler)
{
int i;
for(i=ORC_GP_REG_BASE;i<ORC_GP_REG_BASE+9;i++){
compiler->valid_regs[i] = 1;
}
- compiler->valid_regs[ARM_R0] = 0;
- //compiler->valid_regs[ARM_SB] = 0;
- compiler->valid_regs[ARM_IP] = 0;
- compiler->valid_regs[ARM_SP] = 0;
- compiler->valid_regs[ARM_LR] = 0;
- compiler->valid_regs[ARM_PC] = 0;
+ compiler->valid_regs[ORC_ARM_R0] = 0;
+ //compiler->valid_regs[ORC_ARM_SB] = 0;
+ compiler->valid_regs[ORC_ARM_IP] = 0;
+ compiler->valid_regs[ORC_ARM_SP] = 0;
+ compiler->valid_regs[ORC_ARM_LR] = 0;
+ compiler->valid_regs[ORC_ARM_PC] = 0;
for(i=4;i<11;i++) {
compiler->save_regs[ORC_GP_REG_BASE+i] = 1;
}
}
void
-arm_load_constants (OrcCompiler *compiler)
+orc_arm_load_constants (OrcCompiler *compiler)
{
int i;
for(i=0;i<ORC_N_VARIABLES;i++){
if (compiler->vars[i].name == NULL) continue;
switch (compiler->vars[i].vartype) {
case ORC_VAR_TYPE_CONST:
- //arm_emit_loadiw (compiler, compiler->vars[i].alloc,
+ //orc_arm_emit_loadiw (compiler, compiler->vars[i].alloc,
// (int)compiler->vars[i].value);
break;
case ORC_VAR_TYPE_PARAM:
- //arm_emit_loadw (compiler, compiler->vars[i].alloc,
- // (int)ORC_STRUCT_OFFSET(OrcExecutor, params[i]), arm_exec_ptr);
+ //orc_arm_emit_loadw (compiler, compiler->vars[i].alloc,
+ // (int)ORC_STRUCT_OFFSET(OrcExecutor, params[i]), orc_arm_exec_ptr);
break;
case ORC_VAR_TYPE_SRC:
case ORC_VAR_TYPE_DEST:
- arm_emit_load_reg (compiler,
+ orc_arm_emit_load_reg (compiler,
compiler->vars[i].ptr_register,
- arm_exec_ptr, ORC_STRUCT_OFFSET(OrcExecutor, arrays[i]));
+ orc_arm_exec_ptr, ORC_STRUCT_OFFSET(OrcExecutor, arrays[i]));
break;
default:
break;
}
void
-arm_emit_load_src (OrcCompiler *compiler, OrcVariable *var)
+orc_arm_emit_load_src (OrcCompiler *compiler, OrcVariable *var)
{
int ptr_reg;
if (var->ptr_register == 0) {
int i;
i = var - compiler->vars;
- //arm_emit_mov_memoffset_reg (compiler, arm_ptr_size,
+ //orc_arm_emit_mov_memoffset_reg (compiler, orc_arm_ptr_size,
// (int)ORC_STRUCT_OFFSET(OrcExecutor, arrays[i]),
- // arm_exec_ptr, X86_ECX);
- ptr_reg = ARM_PC;
+ // orc_arm_exec_ptr, X86_ECX);
+ ptr_reg = ORC_ARM_PC;
} else {
ptr_reg = var->ptr_register;
}
switch (var->size << compiler->loop_shift) {
//case 1:
- //arm_emit_mov_memoffset_reg (compiler, 1, 0, ptr_reg, X86_ECX);
- //arm_emit_mov_reg_arm (compiler, X86_ECX, var->alloc);
+ //orc_arm_emit_mov_memoffset_reg (compiler, 1, 0, ptr_reg, X86_ECX);
+ //orc_arm_emit_mov_reg_arm (compiler, X86_ECX, var->alloc);
break;
case 2:
- arm_loadw (compiler, var->alloc, ptr_reg, 0);
- //arm_emit_mov_memoffset_reg (compiler, 2, 0, ptr_reg, X86_ECX);
- //arm_emit_mov_reg_arm (compiler, X86_ECX, var->alloc);
+ orc_arm_loadw (compiler, var->alloc, ptr_reg, 0);
+ //orc_arm_emit_mov_memoffset_reg (compiler, 2, 0, ptr_reg, X86_ECX);
+ //orc_arm_emit_mov_reg_arm (compiler, X86_ECX, var->alloc);
break;
//case 4:
- //arm_emit_mov_memoffset_arm (compiler, 4, 0, ptr_reg, var->alloc);
+ //orc_arm_emit_mov_memoffset_arm (compiler, 4, 0, ptr_reg, var->alloc);
break;
//case 8:
- //arm_emit_mov_memoffset_arm (compiler, 8, 0, ptr_reg, var->alloc);
+ //orc_arm_emit_mov_memoffset_arm (compiler, 8, 0, ptr_reg, var->alloc);
break;
//case 16:
- //arm_emit_mov_memoffset_arm (compiler, 16, 0, ptr_reg, var->alloc);
+ //orc_arm_emit_mov_memoffset_arm (compiler, 16, 0, ptr_reg, var->alloc);
break;
default:
ORC_COMPILER_ERROR(compiler, "bad size %d\n", var->size << compiler->loop_shift);
}
void
-arm_emit_store_dest (OrcCompiler *compiler, OrcVariable *var)
+orc_arm_emit_store_dest (OrcCompiler *compiler, OrcVariable *var)
{
int ptr_reg;
if (var->ptr_register == 0) {
- //arm_emit_mov_memoffset_reg (compiler, arm_ptr_size,
- // var->ptr_offset, arm_exec_ptr, X86_ECX);
- ptr_reg = ARM_PC;
+ //orc_arm_emit_mov_memoffset_reg (compiler, orc_arm_ptr_size,
+ // var->ptr_offset, orc_arm_exec_ptr, X86_ECX);
+ ptr_reg = ORC_ARM_PC;
} else {
ptr_reg = var->ptr_register;
}
switch (var->size << compiler->loop_shift) {
case 1:
- //arm_emit_mov_arm_reg (compiler, var->alloc, X86_ECX);
- //arm_emit_mov_reg_memoffset (compiler, 1, X86_ECX, 0, ptr_reg);
+ //orc_arm_emit_mov_orc_arm_reg (compiler, var->alloc, X86_ECX);
+ //orc_arm_emit_mov_reg_memoffset (compiler, 1, X86_ECX, 0, ptr_reg);
break;
case 2:
- arm_storew (compiler, ptr_reg, 0, var->alloc);
- //arm_emit_mov_arm_reg (compiler, var->alloc, X86_ECX);
- //arm_emit_mov_reg_memoffset (compiler, 2, X86_ECX, 0, ptr_reg);
+ orc_arm_storew (compiler, ptr_reg, 0, var->alloc);
+ //orc_arm_emit_mov_orc_arm_reg (compiler, var->alloc, X86_ECX);
+ //orc_arm_emit_mov_reg_memoffset (compiler, 2, X86_ECX, 0, ptr_reg);
break;
case 4:
- //arm_emit_mov_arm_memoffset (compiler, 4, var->alloc, 0, ptr_reg,
+ //orc_arm_emit_mov_orc_arm_memoffset (compiler, 4, var->alloc, 0, ptr_reg,
// var->is_aligned, var->is_uncached);
break;
case 8:
- //arm_emit_mov_arm_memoffset (compiler, 8, var->alloc, 0, ptr_reg,
+ //orc_arm_emit_mov_orc_arm_memoffset (compiler, 8, var->alloc, 0, ptr_reg,
// var->is_aligned, var->is_uncached);
break;
case 16:
- //arm_emit_mov_arm_memoffset (compiler, 16, var->alloc, 0, ptr_reg,
+ //orc_arm_emit_mov_orc_arm_memoffset (compiler, 16, var->alloc, 0, ptr_reg,
// var->is_aligned, var->is_uncached);
break;
default:
}
void
-orc_compiler_arm_assemble (OrcCompiler *compiler)
+orc_compiler_orc_arm_assemble (OrcCompiler *compiler)
{
int dest_var = orc_compiler_get_dest (compiler);
compiler->vars[dest_var].is_aligned = FALSE;
- arm_emit_prologue (compiler);
+ orc_arm_emit_prologue (compiler);
- arm_emit_load_reg (compiler, ARM_IP, arm_exec_ptr,
+ orc_arm_emit_load_reg (compiler, ORC_ARM_IP, orc_arm_exec_ptr,
(int)ORC_STRUCT_OFFSET(OrcExecutor,n));
- arm_load_constants (compiler);
+ orc_arm_load_constants (compiler);
- arm_emit_label (compiler, 1);
+ orc_arm_emit_label (compiler, 1);
- arm_emit_cmp_imm (compiler, ARM_IP, 0);
- arm_emit_branch (compiler, ARM_COND_EQ, 3);
+ orc_arm_emit_cmp_imm (compiler, ORC_ARM_IP, 0);
+ orc_arm_emit_branch (compiler, ORC_ARM_COND_EQ, 3);
- arm_emit_label (compiler, 2);
- arm_emit_loop (compiler);
- arm_emit_sub_imm (compiler, ARM_IP, ARM_IP, 1);
- arm_emit_cmp_imm (compiler, ARM_IP, 0);
- arm_emit_branch (compiler, ARM_COND_NE, 2);
- arm_emit_label (compiler, 3);
+ orc_arm_emit_label (compiler, 2);
+ orc_arm_emit_loop (compiler);
+ orc_arm_emit_sub_imm (compiler, ORC_ARM_IP, ORC_ARM_IP, 1);
+ orc_arm_emit_cmp_imm (compiler, ORC_ARM_IP, 0);
+ orc_arm_emit_branch (compiler, ORC_ARM_COND_NE, 2);
+ orc_arm_emit_label (compiler, 3);
- arm_emit_epilogue (compiler);
+ orc_arm_emit_epilogue (compiler);
- arm_do_fixups (compiler);
+ orc_arm_do_fixups (compiler);
}
void
-arm_emit_loop (OrcCompiler *compiler)
+orc_arm_emit_loop (OrcCompiler *compiler)
{
int j;
int k;
switch (compiler->vars[insn->src_args[k]].vartype) {
case ORC_VAR_TYPE_SRC:
- arm_emit_load_src (compiler, &compiler->vars[insn->src_args[k]]);
+ orc_arm_emit_load_src (compiler, &compiler->vars[insn->src_args[k]]);
break;
case ORC_VAR_TYPE_CONST:
break;
if (rule && rule->emit) {
if (compiler->vars[insn->dest_args[0]].alloc !=
compiler->vars[insn->src_args[0]].alloc) {
- arm_emit_mov (compiler, compiler->vars[insn->src_args[0]].alloc,
+ orc_arm_emit_mov (compiler, compiler->vars[insn->src_args[0]].alloc,
compiler->vars[insn->dest_args[0]].alloc);
}
rule->emit (compiler, rule->emit_user, insn);
switch (compiler->vars[insn->dest_args[k]].vartype) {
case ORC_VAR_TYPE_DEST:
- arm_emit_store_dest (compiler, &compiler->vars[insn->dest_args[k]]);
+ orc_arm_emit_store_dest (compiler, &compiler->vars[insn->dest_args[k]]);
break;
case ORC_VAR_TYPE_TEMP:
break;
if (compiler->vars[k].vartype == ORC_VAR_TYPE_SRC ||
compiler->vars[k].vartype == ORC_VAR_TYPE_DEST) {
if (compiler->vars[k].ptr_register) {
- arm_emit_add_imm (compiler,
+ orc_arm_emit_add_imm (compiler,
compiler->vars[k].ptr_register,
compiler->vars[k].ptr_register,
compiler->vars[k].size << compiler->loop_shift);
} else {
- //arm_emit_add_imm_memoffset (compiler, arm_ptr_size,
+ //orc_arm_emit_add_imm_memoffset (compiler, orc_arm_ptr_size,
// compiler->vars[k].size << compiler->loop_shift,
// (int)ORC_STRUCT_OFFSET(OrcExecutor, arrays[k]),
- // arm_exec_ptr);
+ // orc_arm_exec_ptr);
}
}
}
#include <sys/types.h>
#include <orc/orcprogram.h>
-#include <orc/arm.h>
+#include <orc/orcarm.h>
void
-arm_loadw (OrcCompiler *compiler, int dest, int src1, int offset)
+orc_arm_loadw (OrcCompiler *compiler, int dest, int src1, int offset)
{
uint32_t code;
code |= offset&0x0f;
ORC_ASM_CODE(compiler," ldrh %s, [%s, #%d]\n",
- arm_reg_name (dest),
- arm_reg_name (src1), offset);
- arm_emit (compiler, code);
+ orc_arm_reg_name (dest),
+ orc_arm_reg_name (src1), offset);
+ orc_arm_emit (compiler, code);
}
void
-arm_storew (OrcCompiler *compiler, int dest, int offset, int src1)
+orc_arm_storew (OrcCompiler *compiler, int dest, int offset, int src1)
{
uint32_t code;
code |= offset&0x0f;
ORC_ASM_CODE(compiler," strh %s, [%s, #%d]\n",
- arm_reg_name (src1),
- arm_reg_name (dest), offset);
- arm_emit (compiler, code);
+ orc_arm_reg_name (src1),
+ orc_arm_reg_name (dest), offset);
+ orc_arm_emit (compiler, code);
}
static void
-arm_rule_addw (OrcCompiler *p, void *user, OrcInstruction *insn)
+orc_arm_rule_addw (OrcCompiler *p, void *user, OrcInstruction *insn)
{
uint32_t code;
code |= (p->vars[insn->src_args[1]].alloc&0xf) << 0;
ORC_ASM_CODE(p," add %s, %s, %s\n",
- arm_reg_name (p->vars[insn->dest_args[0]].alloc),
- arm_reg_name (p->vars[insn->src_args[0]].alloc),
- arm_reg_name (p->vars[insn->src_args[1]].alloc));
- arm_emit (p, code);
+ orc_arm_reg_name (p->vars[insn->dest_args[0]].alloc),
+ orc_arm_reg_name (p->vars[insn->src_args[0]].alloc),
+ orc_arm_reg_name (p->vars[insn->src_args[1]].alloc));
+ orc_arm_emit (p, code);
}
static void
-arm_rule_subw (OrcCompiler *p, void *user, OrcInstruction *insn)
+orc_arm_rule_subw (OrcCompiler *p, void *user, OrcInstruction *insn)
{
uint32_t code;
code |= (p->vars[insn->src_args[1]].alloc&0xf) << 0;
ORC_ASM_CODE(p," sub %s, %s, %s\n",
- arm_reg_name (p->vars[insn->dest_args[0]].alloc),
- arm_reg_name (p->vars[insn->src_args[0]].alloc),
- arm_reg_name (p->vars[insn->src_args[1]].alloc));
- arm_emit (p, code);
+ orc_arm_reg_name (p->vars[insn->dest_args[0]].alloc),
+ orc_arm_reg_name (p->vars[insn->src_args[0]].alloc),
+ orc_arm_reg_name (p->vars[insn->src_args[1]].alloc));
+ orc_arm_emit (p, code);
}
static void
-arm_rule_mullw (OrcCompiler *p, void *user, OrcInstruction *insn)
+orc_arm_rule_mullw (OrcCompiler *p, void *user, OrcInstruction *insn)
{
uint32_t code;
code |= (p->vars[insn->src_args[1]].alloc&0xf) << 8;
ORC_ASM_CODE(p," mul %s, %s, %s\n",
- arm_reg_name (p->vars[insn->dest_args[0]].alloc),
- arm_reg_name (p->vars[insn->src_args[0]].alloc),
- arm_reg_name (p->vars[insn->src_args[1]].alloc));
- arm_emit (p, code);
+ orc_arm_reg_name (p->vars[insn->dest_args[0]].alloc),
+ orc_arm_reg_name (p->vars[insn->src_args[0]].alloc),
+ orc_arm_reg_name (p->vars[insn->src_args[1]].alloc));
+ orc_arm_emit (p, code);
}
static void
-arm_rule_shrsw (OrcCompiler *p, void *user, OrcInstruction *insn)
+orc_arm_rule_shrsw (OrcCompiler *p, void *user, OrcInstruction *insn)
{
uint32_t code;
code |= (p->vars[insn->src_args[1]].alloc&0xf) << 8;
ORC_ASM_CODE(p," asr %s, %s, %s\n",
- arm_reg_name (p->vars[insn->dest_args[0]].alloc),
- arm_reg_name (p->vars[insn->src_args[0]].alloc),
- arm_reg_name (p->vars[insn->src_args[1]].alloc));
- arm_emit (p, code);
+ orc_arm_reg_name (p->vars[insn->dest_args[0]].alloc),
+ orc_arm_reg_name (p->vars[insn->src_args[0]].alloc),
+ orc_arm_reg_name (p->vars[insn->src_args[1]].alloc));
+ orc_arm_emit (p, code);
}
#if 0
void
-arm_emit_loadiw (OrcCompiler *p, int reg, int value)
+orc_arm_emit_loadiw (OrcCompiler *p, int reg, int value)
{
if (value == 0) {
ORC_ASM_CODE(compiler," pxor %%%s, %%%s\n", x86_get_regname_sse(reg),
}
void
-arm_emit_loadw (OrcCompiler *p, int reg, int offset, int reg1)
+orc_arm_emit_loadw (OrcCompiler *p, int reg, int offset, int reg1)
{
ORC_ASM_CODE(compiler," movd %d(%%%s), %%%s\n", offset, x86_get_regname_ptr(reg1),
x86_get_regname_sse(reg));
}
static void
-arm_rule_copyx (OrcCompiler *p, void *user, OrcInstruction *insn)
+orc_arm_rule_copyx (OrcCompiler *p, void *user, OrcInstruction *insn)
{
ORC_ASM_CODE(compiler," movdqa %%%s, %%%s\n",
x86_get_regname_sse(p->vars[insn->src_args[0]].alloc),
}
static void
-arm_emit_66_rex_0f (OrcCompiler *p, OrcInstruction *insn, int code,
+orc_arm_emit_66_rex_0f (OrcCompiler *p, OrcInstruction *insn, int code,
const char *insn_name)
{
ORC_ASM_CODE(compiler," %s %%%s, %%%s\n", insn_name,
#if 0
static void
-arm_rule_addw (OrcCompiler *p, void *user, OrcInstruction *insn)
+orc_arm_rule_addw (OrcCompiler *p, void *user, OrcInstruction *insn)
{
- arm_emit_66_rex_0f (p, insn, 0xfd, "paddw");
+ orc_arm_emit_66_rex_0f (p, insn, 0xfd, "paddw");
}
static void
-arm_rule_subw (OrcCompiler *p, void *user, OrcInstruction *insn)
+orc_arm_rule_subw (OrcCompiler *p, void *user, OrcInstruction *insn)
{
- arm_emit_66_rex_0f (p, insn, 0xf9, "psubw");
+ orc_arm_emit_66_rex_0f (p, insn, 0xf9, "psubw");
}
static void
-arm_rule_mullw (OrcCompiler *p, void *user, OrcInstruction *insn)
+orc_arm_rule_mullw (OrcCompiler *p, void *user, OrcInstruction *insn)
{
- arm_emit_66_rex_0f (p, insn, 0xd5, "pmullw");
+ orc_arm_emit_66_rex_0f (p, insn, 0xd5, "pmullw");
}
#endif
#define UNARY(opcode,insn_name,code) \
static void \
-arm_rule_ ## opcode (OrcCompiler *p, void *user, OrcInstruction *insn) \
+orc_arm_rule_ ## opcode (OrcCompiler *p, void *user, OrcInstruction *insn) \
{ \
- arm_emit_66_rex_0f (p, insn, code, insn_name); \
+ orc_arm_emit_66_rex_0f (p, insn, code, insn_name); \
}
#define BINARY(opcode,insn_name,code) \
static void \
-arm_rule_ ## opcode (OrcCompiler *p, void *user, OrcInstruction *insn) \
+orc_arm_rule_ ## opcode (OrcCompiler *p, void *user, OrcInstruction *insn) \
{ \
- arm_emit_66_rex_0f (p, insn, code, insn_name); \
+ orc_arm_emit_66_rex_0f (p, insn, code, insn_name); \
}
static void
-arm_rule_shlw (OrcCompiler *p, void *user, OrcInstruction *insn)
+orc_arm_rule_shlw (OrcCompiler *p, void *user, OrcInstruction *insn)
{
if (p->vars[insn->src_args[1]].vartype == ORC_VAR_TYPE_CONST) {
ORC_ASM_CODE(compiler," psllw $%d, %%%s\n",
}
static void
-arm_rule_shrsw (OrcCompiler *p, void *user, OrcInstruction *insn)
+orc_arm_rule_shrsw (OrcCompiler *p, void *user, OrcInstruction *insn)
{
if (p->vars[insn->src_args[1]].vartype == ORC_VAR_TYPE_CONST) {
ORC_ASM_CODE(compiler," psraw $%d, %%%s\n",
}
static void
-arm_rule_convsbw (OrcCompiler *p, void *user, OrcInstruction *insn)
+orc_arm_rule_convsbw (OrcCompiler *p, void *user, OrcInstruction *insn)
{
ORC_ASM_CODE(compiler," punpcklbw %%%s, %%%s\n",
x86_get_regname_sse(p->vars[insn->src_args[0]].alloc),
}
static void
-arm_rule_convubw (OrcCompiler *p, void *user, OrcInstruction *insn)
+orc_arm_rule_convubw (OrcCompiler *p, void *user, OrcInstruction *insn)
{
/* FIXME should do this by unpacking with a zero reg */
}
static void
-arm_rule_convsuswb (OrcCompiler *p, void *user, OrcInstruction *insn)
+orc_arm_rule_convsuswb (OrcCompiler *p, void *user, OrcInstruction *insn)
{
ORC_ASM_CODE(compiler," packuswb %%%s, %%%s\n",
x86_get_regname_sse(p->vars[insn->src_args[0]].alloc),
#endif
void
-orc_compiler_arm_register_rules (OrcTarget *target)
+orc_compiler_orc_arm_register_rules (OrcTarget *target)
{
OrcRuleSet *rule_set;
#if 0
#define REG(x) \
- orc_rule_register (rule_set, #x , arm_rule_ ## x, NULL)
+ orc_rule_register (rule_set, #x , orc_arm_rule_ ## x, NULL)
REG(absb);
REG(addb);
//REG(subusl);
REG(xorl);
- orc_rule_register (rule_set, "copyb", arm_rule_copyx, NULL);
- orc_rule_register (rule_set, "copyw", arm_rule_copyx, NULL);
- orc_rule_register (rule_set, "copyl", arm_rule_copyx, NULL);
+ orc_rule_register (rule_set, "copyb", orc_arm_rule_copyx, NULL);
+ orc_rule_register (rule_set, "copyw", orc_arm_rule_copyx, NULL);
+ orc_rule_register (rule_set, "copyl", orc_arm_rule_copyx, NULL);
- orc_rule_register (rule_set, "shlw", arm_rule_shlw, NULL);
- orc_rule_register (rule_set, "shrsw", arm_rule_shrsw, NULL);
+ orc_rule_register (rule_set, "shlw", orc_arm_rule_shlw, NULL);
+ orc_rule_register (rule_set, "shrsw", orc_arm_rule_shrsw, NULL);
- orc_rule_register (rule_set, "convsbw", arm_rule_convsbw, NULL);
- orc_rule_register (rule_set, "convubw", arm_rule_convubw, NULL);
- orc_rule_register (rule_set, "convsuswb", arm_rule_convsuswb, NULL);
+ orc_rule_register (rule_set, "convsbw", orc_arm_rule_convsbw, NULL);
+ orc_rule_register (rule_set, "convubw", orc_arm_rule_convubw, NULL);
+ orc_rule_register (rule_set, "convsuswb", orc_arm_rule_convsuswb, NULL);
#endif
- orc_rule_register (rule_set, "addw", arm_rule_addw, NULL);
- orc_rule_register (rule_set, "subw", arm_rule_subw, NULL);
- orc_rule_register (rule_set, "mullw", arm_rule_mullw, NULL);
- orc_rule_register (rule_set, "shrsw", arm_rule_shrsw, NULL);
+ orc_rule_register (rule_set, "addw", orc_arm_rule_addw, NULL);
+ orc_rule_register (rule_set, "subw", orc_arm_rule_subw, NULL);
+ orc_rule_register (rule_set, "mullw", orc_arm_rule_mullw, NULL);
+ orc_rule_register (rule_set, "shrsw", orc_arm_rule_shrsw, NULL);
}