From: Doug Nazar Date: Sun, 25 Aug 2019 18:50:11 +0000 (-0400) Subject: orc: Make orc_*_emit_invariants() generic X-Git-Tag: orc-0.4.33~124 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=643130c3a5620052a482925e8aa0356a5034908b;p=platform%2Fupstream%2Forc.git orc: Make orc_*_emit_invariants() generic Move mmx/sse emit invariant function to orcompiler so it can be used on other architectures. --- diff --git a/orc/orccompiler.c b/orc/orccompiler.c index f0ebb12..8d92cbe 100644 --- a/orc/orccompiler.c +++ b/orc/orccompiler.c @@ -8,6 +8,7 @@ #include #include +#include #ifdef HAVE_VALGRIND_VALGRIND_H #include @@ -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;jn_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); + } + } +} diff --git a/orc/orcinternal.h b/orc/orcinternal.h index b6387bc..91de08a 100644 --- a/orc/orcinternal.h +++ b/orc/orcinternal.h @@ -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 diff --git a/orc/orcprogram-mips.c b/orc/orcprogram-mips.c index 423e903..19002ac 100644 --- a/orc/orcprogram-mips.c +++ b/orc/orcprogram-mips.c @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -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;in_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 diff --git a/orc/orcprogram-mmx.c b/orc/orcprogram-mmx.c index d0022cd..80bd608 100644 --- a/orc/orcprogram-mmx.c +++ b/orc/orcprogram-mmx.c @@ -12,6 +12,7 @@ #include #include #include +#include #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;in_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;jn_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); - } - } -} - diff --git a/orc/orcprogram-neon.c b/orc/orcprogram-neon.c index 18d5045..05584a0 100644 --- a/orc/orcprogram-neon.c +++ b/orc/orcprogram-neon.c @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -286,30 +287,7 @@ orc_neon_load_constants_outer (OrcCompiler *compiler) } } - for(i=0;in_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 diff --git a/orc/orcprogram-sse.c b/orc/orcprogram-sse.c index 18acec0..7907f43 100644 --- a/orc/orcprogram-sse.c +++ b/orc/orcprogram-sse.c @@ -12,6 +12,7 @@ #include #include #include +#include #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;in_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;jn_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); - } - } -} -