Commit 643130c3 authored by Doug Nazar's avatar Doug Nazar Committed by Sebastian Dröge

orc: Make orc_*_emit_invariants() generic

Move mmx/sse emit invariant function to orcompiler so it can
be used on other architectures.
parent ff9190b1
......@@ -8,6 +8,7 @@
#include <orc/orcprogram.h>
#include <orc/orcdebug.h>
#include <orc/orcinternal.h>
#ifdef HAVE_VALGRIND_VALGRIND_H
#include <valgrind/valgrind.h>
......@@ -1226,3 +1227,36 @@ orc_compiler_error (OrcCompiler *compiler, const char *fmt, ...)
va_end (var_args);
}
void
orc_compiler_emit_invariants (OrcCompiler *compiler)
{
int j;
OrcInstruction *insn;
OrcStaticOpcode *opcode;
OrcRule *rule;
for(j=0;j<compiler->n_insns;j++){
insn = compiler->insns + j;
opcode = insn->opcode;
if (!(insn->flags & ORC_INSN_FLAG_INVARIANT)) continue;
ORC_ASM_CODE(compiler,"# %d: %s\n", j, opcode->name);
compiler->insn_shift = compiler->loop_shift;
if (insn->flags & ORC_INSTRUCTION_FLAG_X2) {
compiler->insn_shift += 1;
}
if (insn->flags & ORC_INSTRUCTION_FLAG_X4) {
compiler->insn_shift += 2;
}
rule = insn->rule;
if (rule && rule->emit) {
rule->emit (compiler, rule->emit_user, insn);
} else {
orc_compiler_error (compiler, "no code generation rule for %s",
opcode->name);
}
}
}
......@@ -34,6 +34,7 @@ extern int _orc_cpu_model;
extern int _orc_cpu_stepping;
extern const char *_orc_cpu_name;
void orc_compiler_emit_invariants (OrcCompiler *compiler);
#endif
ORC_END_DECLS
......
......@@ -31,6 +31,7 @@
#include <orc/orcmips.h>
#include <orc/orcdebug.h>
#include <orc/orcinternal.h>
#include <stdlib.h>
#include <string.h>
......@@ -294,31 +295,7 @@ orc_mips_load_constants_inner (OrcCompiler *compiler)
orc_mips_emit_move (compiler, var->ptr_offset, ORC_MIPS_ZERO);
}
for(i=0;i<compiler->n_insns;i++){
OrcInstruction *insn = compiler->insns + i;
OrcStaticOpcode *opcode = insn->opcode;
OrcRule *rule;
if (!(insn->flags & ORC_INSN_FLAG_INVARIANT)) continue;
ORC_ASM_CODE(compiler,"# %d: %s\n", i, insn->opcode->name);
compiler->insn_shift = compiler->loop_shift;
if (insn->flags & ORC_INSTRUCTION_FLAG_X2) {
compiler->insn_shift += 1;
}
if (insn->flags & ORC_INSTRUCTION_FLAG_X4) {
compiler->insn_shift += 2;
}
rule = insn->rule;
if (rule && rule->emit) {
rule->emit (compiler, rule->emit_user, insn);
} else {
ORC_COMPILER_ERROR(compiler,"No rule for: %s", opcode->name);
}
}
orc_compiler_emit_invariants (compiler);
}
#define CACHE_LINE_SIZE 32
......
......@@ -12,6 +12,7 @@
#include <orc/orcmmx.h>
#include <orc/orcutils.h>
#include <orc/orcdebug.h>
#include <orc/orcinternal.h>
#define MMX 1
#define SIZE 65536
......@@ -24,7 +25,6 @@ static void orc_compiler_mmx_init (OrcCompiler *compiler);
static unsigned int orc_compiler_mmx_get_default_flags (void);
static void orc_compiler_mmx_assemble (OrcCompiler *compiler);
extern void orc_compiler_mmx_register_rules (OrcTarget *target);
static void orc_mmx_emit_invariants (OrcCompiler *compiler);
void mmx_load_constant (OrcCompiler *compiler, int reg, int size, int value);
void mmx_load_constant_long (OrcCompiler *compiler, int reg,
......@@ -484,7 +484,7 @@ mmx_load_constants_outer (OrcCompiler *compiler)
}
}
orc_mmx_emit_invariants (compiler);
orc_compiler_emit_invariants (compiler);
/* FIXME move to a better place */
for(i=0;i<compiler->n_constants;i++){
......@@ -1078,38 +1078,3 @@ orc_mmx_emit_loop (OrcCompiler *compiler, int offset, int update)
}
}
}
static void
orc_mmx_emit_invariants (OrcCompiler *compiler)
{
int j;
OrcInstruction *insn;
OrcStaticOpcode *opcode;
OrcRule *rule;
for(j=0;j<compiler->n_insns;j++){
insn = compiler->insns + j;
opcode = insn->opcode;
if (!(insn->flags & ORC_INSN_FLAG_INVARIANT)) continue;
ORC_ASM_CODE(compiler,"# %d: %s\n", j, insn->opcode->name);
compiler->insn_shift = compiler->loop_shift;
if (insn->flags & ORC_INSTRUCTION_FLAG_X2) {
compiler->insn_shift += 1;
}
if (insn->flags & ORC_INSTRUCTION_FLAG_X4) {
compiler->insn_shift += 2;
}
rule = insn->rule;
if (rule && rule->emit) {
rule->emit (compiler, rule->emit_user, insn);
} else {
orc_compiler_error (compiler, "no code generation rule for %s",
opcode->name);
}
}
}
......@@ -11,6 +11,7 @@
#include <orc/orcarm.h>
#include <orc/orcutils.h>
#include <orc/orcdebug.h>
#include <orc/orcinternal.h>
#include <orc/orcneon.h>
......@@ -286,30 +287,7 @@ orc_neon_load_constants_outer (OrcCompiler *compiler)
}
}
for(i=0;i<compiler->n_insns;i++){
OrcInstruction *insn = compiler->insns + i;
OrcStaticOpcode *opcode = insn->opcode;
OrcRule *rule;
if (!(insn->flags & ORC_INSN_FLAG_INVARIANT)) continue;
ORC_ASM_CODE(compiler,"# %d: %s\n", i, insn->opcode->name);
compiler->insn_shift = compiler->loop_shift;
if (insn->flags & ORC_INSTRUCTION_FLAG_X2) {
compiler->insn_shift += 1;
}
if (insn->flags & ORC_INSTRUCTION_FLAG_X4) {
compiler->insn_shift += 2;
}
rule = insn->rule;
if (rule && rule->emit) {
rule->emit (compiler, rule->emit_user, insn);
} else {
ORC_COMPILER_ERROR(compiler,"No rule for: %s", opcode->name);
}
}
orc_compiler_emit_invariants (compiler);
}
static void
......
......@@ -12,6 +12,7 @@
#include <orc/orcsse.h>
#include <orc/orcutils.h>
#include <orc/orcdebug.h>
#include <orc/orcinternal.h>
#undef MMX
#define SIZE 65536
......@@ -24,7 +25,6 @@ void orc_compiler_sse_register_rules (OrcTarget *target);
static void orc_compiler_sse_init (OrcCompiler *compiler);
static unsigned int orc_compiler_sse_get_default_flags (void);
static void orc_compiler_sse_assemble (OrcCompiler *compiler);
static void orc_sse_emit_invariants (OrcCompiler *compiler);
void sse_load_constant (OrcCompiler *compiler, int reg, int size, int value);
void sse_load_constant_long (OrcCompiler *compiler, int reg,
......@@ -484,7 +484,7 @@ sse_load_constants_outer (OrcCompiler *compiler)
}
}
orc_sse_emit_invariants (compiler);
orc_compiler_emit_invariants (compiler);
/* FIXME move to a better place */
for(i=0;i<compiler->n_constants;i++){
......@@ -1126,38 +1126,3 @@ orc_sse_emit_loop (OrcCompiler *compiler, int offset, int update)
}
}
}
static void
orc_sse_emit_invariants (OrcCompiler *compiler)
{
int j;
OrcInstruction *insn;
OrcStaticOpcode *opcode;
OrcRule *rule;
for(j=0;j<compiler->n_insns;j++){
insn = compiler->insns + j;
opcode = insn->opcode;
if (!(insn->flags & ORC_INSN_FLAG_INVARIANT)) continue;
ORC_ASM_CODE(compiler,"# %d: %s\n", j, insn->opcode->name);
compiler->insn_shift = compiler->loop_shift;
if (insn->flags & ORC_INSTRUCTION_FLAG_X2) {
compiler->insn_shift += 1;
}
if (insn->flags & ORC_INSTRUCTION_FLAG_X4) {
compiler->insn_shift += 2;
}
rule = insn->rule;
if (rule && rule->emit) {
rule->emit (compiler, rule->emit_user, insn);
} else {
orc_compiler_error (compiler, "no code generation rule for %s",
opcode->name);
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment