int src, int dest);
void orc_sse_emit_sysinsn_branch (OrcCompiler *p, int index, int label);
void orc_sse_emit_sysinsn_label (OrcCompiler *p, int index, int label);
+void orc_sse_emit_sysinsn_none (OrcCompiler *p, int index);
unsigned int orc_sse_get_cpu_flags (void);
void orc_x86_emit_ret (OrcCompiler *compiler)
{
if (compiler->is_64bit) {
- ORC_ASM_CODE(compiler," retq\n");
+ orc_sse_emit_sysinsn_none (compiler, ORC_X86_retq);
} else {
- ORC_ASM_CODE(compiler," ret\n");
+ orc_sse_emit_sysinsn_none (compiler, ORC_X86_ret);
}
- *compiler->codeptr++ = 0xc3;
}
void orc_x86_emit_emms (OrcCompiler *compiler)
{
- ORC_ASM_CODE(compiler," emms\n");
- *compiler->codeptr++ = 0x0f;
- *compiler->codeptr++ = 0x77;
+ orc_sse_emit_sysinsn_none (compiler, ORC_X86_emms);
}
void orc_x86_emit_rdtsc (OrcCompiler *compiler)
{
- ORC_ASM_CODE(compiler," rdtsc\n");
- *compiler->codeptr++ = 0x0f;
- *compiler->codeptr++ = 0x31;
+ orc_sse_emit_sysinsn_none (compiler, ORC_X86_rdtsc);
}
void orc_x86_emit_rep_movs (OrcCompiler *compiler, int size)
{
switch (size) {
case 1:
- ORC_ASM_CODE(compiler," rep movsb\n");
- *compiler->codeptr++ = 0xf3;
- *compiler->codeptr++ = 0xa4;
+ orc_sse_emit_sysinsn_none (compiler, ORC_X86_rep_movsb);
break;
case 2:
- ORC_ASM_CODE(compiler," rep movsw\n");
- *compiler->codeptr++ = 0x66;
- *compiler->codeptr++ = 0xf3;
- *compiler->codeptr++ = 0xa5;
+ orc_sse_emit_sysinsn_none (compiler, ORC_X86_rep_movsw);
break;
case 4:
- ORC_ASM_CODE(compiler," rep movsl\n");
- *compiler->codeptr++ = 0xf3;
- *compiler->codeptr++ = 0xa5;
+ orc_sse_emit_sysinsn_none (compiler, ORC_X86_rep_movsl);
break;
}
}
{ "jg", ORC_X86_INSN_TYPE_LABEL, 0, 0x7f },
{ "jmp", ORC_X86_INSN_TYPE_LABEL, 0, 0xeb },
{ "", ORC_X86_INSN_TYPE_LABEL, 0, 0x00 },
+ { "ret", ORC_X86_INSN_TYPE_NONE, 0, 0xc3 },
+ { "retq", ORC_X86_INSN_TYPE_NONE, 0, 0xc3 },
+ { "emms", ORC_X86_INSN_TYPE_NONE, 0, 0x0f77 },
+ { "rdtsc", ORC_X86_INSN_TYPE_NONE, 0, 0x0f31 },
+ { "rep movsb", ORC_X86_INSN_TYPE_NONE, 0, 0xf3a4 },
+ { "rep movsw", ORC_X86_INSN_TYPE_NONE, 0, 0x66f3a5 },
+ { "rep movsl", ORC_X86_INSN_TYPE_NONE, 0, 0xf3a5 },
};
}
}
+void
+orc_sse_emit_sysinsn_none (OrcCompiler *p, int index)
+{
+ const OrcSysOpcode *opcode = orc_x86_opcodes + index;
+ int size = 4;
+
+ switch (opcode->type) {
+ case ORC_X86_INSN_TYPE_NONE:
+ ORC_ASM_CODE(p," %s\n", opcode->name);
+ break;
+ default:
+ ORC_ASSERT(0);
+ break;
+ }
+
+ output_opcode (p, opcode, size, 0, 0);
+}
+
ORC_X86_INSN_TYPE_imm32_rm,
ORC_X86_INSN_TYPE_rm_r,
ORC_X86_INSN_TYPE_r_rm,
- ORC_X86_INSN_TYPE_LABEL
+ ORC_X86_INSN_TYPE_LABEL,
+ ORC_X86_INSN_TYPE_NONE
};
enum {
ORC_X86_jg,
ORC_X86_jmp,
ORC_X86_LABEL,
+ ORC_X86_ret,
+ ORC_X86_retq,
+ ORC_X86_emms,
+ ORC_X86_rdtsc,
+ ORC_X86_rep_movsb,
+ ORC_X86_rep_movsw,
+ ORC_X86_rep_movsl,
+
};