diff options
author | David Schleef <ds@schleef.org> | 2010-08-10 03:31:58 +0400 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2010-08-10 03:31:58 +0400 |
commit | a3c383a17d3b0d710a75c159eb52105c903ffa08 (patch) | |
tree | 1e01826fc1f80605cf86baf700ecf483244aa4d7 | |
parent | 6d736f44189e5a9870bea4e3b5107c271005785f (diff) |
Refactor instruction flags
-rw-r--r-- | orc/orccompiler.c | 10 | ||||
-rw-r--r-- | orc/orcprogram-arm.c | 4 | ||||
-rw-r--r-- | orc/orcprogram-c.c | 14 | ||||
-rw-r--r-- | orc/orcprogram-mmx.c | 4 | ||||
-rw-r--r-- | orc/orcprogram-neon.c | 4 | ||||
-rw-r--r-- | orc/orcprogram-sse.c | 4 | ||||
-rw-r--r-- | orc/orcprogram.h | 8 |
7 files changed, 25 insertions, 23 deletions
diff --git a/orc/orccompiler.c b/orc/orccompiler.c index a4e41c9..a5ffef4 100644 --- a/orc/orccompiler.c +++ b/orc/orccompiler.c @@ -479,9 +479,9 @@ orc_compiler_rewrite_insns (OrcCompiler *compiler) OrcInstruction *cinsn; cinsn = compiler->insns + compiler->n_insns; - compiler->insn_flags[compiler->n_insns] |= ORC_INSN_FLAG_ADDED; compiler->n_insns++; + cinsn->flags |= ORC_INSN_FLAG_ADDED; cinsn->opcode = get_load_opcode_for_size (var->size); cinsn->dest_args[0] = orc_compiler_new_temporary (compiler, var->size); cinsn->src_args[0] = insn.src_args[i]; @@ -491,9 +491,9 @@ orc_compiler_rewrite_insns (OrcCompiler *compiler) OrcInstruction *cinsn; cinsn = compiler->insns + compiler->n_insns; - compiler->insn_flags[compiler->n_insns] |= ORC_INSN_FLAG_ADDED; compiler->n_insns++; + cinsn->flags |= ORC_INSN_FLAG_ADDED; cinsn->opcode = get_loadp_opcode_for_size (var->size); cinsn->dest_args[0] = orc_compiler_new_temporary (compiler, var->size); cinsn->src_args[0] = insn.src_args[i]; @@ -517,9 +517,9 @@ orc_compiler_rewrite_insns (OrcCompiler *compiler) OrcInstruction *cinsn; cinsn = compiler->insns + compiler->n_insns; - compiler->insn_flags[compiler->n_insns] |= ORC_INSN_FLAG_ADDED; compiler->n_insns++; + cinsn->flags |= ORC_INSN_FLAG_ADDED; cinsn->opcode = get_store_opcode_for_size (var->size); cinsn->src_args[0] = orc_compiler_new_temporary (compiler, var->size); cinsn->dest_args[0] = xinsn->dest_args[i]; @@ -714,7 +714,7 @@ orc_compiler_global_reg_alloc (OrcCompiler *compiler) var->first_use = -1; var->last_use = -1; var->alloc = orc_compiler_allocate_register (compiler, TRUE); - compiler->insn_flags[i] |= ORC_INSN_FLAG_INVARIANT; + insn->flags |= ORC_INSN_FLAG_INVARIANT; } if (opcode->flags & ORC_STATIC_OPCODE_ITERATOR) { @@ -746,7 +746,7 @@ orc_compiler_rewrite_vars2 (OrcCompiler *compiler) * - src1 must be last_use * - only one dest */ - if (compiler->insn_flags[j] & ORC_INSN_FLAG_INVARIANT) continue; + if (compiler->insns[j].flags & ORC_INSN_FLAG_INVARIANT) continue; if (!(compiler->insns[j].opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) && compiler->insns[j].opcode->dest_size[1] == 0) { diff --git a/orc/orcprogram-arm.c b/orc/orcprogram-arm.c index 3f5054a..2c92caf 100644 --- a/orc/orcprogram-arm.c +++ b/orc/orcprogram-arm.c @@ -179,7 +179,7 @@ orc_arm_load_constants_outer (OrcCompiler *compiler) OrcStaticOpcode *opcode = insn->opcode; OrcRule *rule; - if (!(compiler->insn_flags[i] & ORC_INSN_FLAG_INVARIANT)) continue; + if (!(insn->flags & ORC_INSN_FLAG_INVARIANT)) continue; ORC_ASM_CODE(compiler,"# %d: %s\n", i, insn->opcode->name); @@ -368,7 +368,7 @@ orc_arm_emit_loop (OrcCompiler *compiler) insn = compiler->insns + j; opcode = insn->opcode; - if (compiler->insn_flags[j] & ORC_INSN_FLAG_INVARIANT) continue; + if (insn->flags & ORC_INSN_FLAG_INVARIANT) continue; orc_compiler_append_code(compiler,"# %d: %s", j, insn->opcode->name); diff --git a/orc/orcprogram-c.c b/orc/orcprogram-c.c index 09e550a..6d91242 100644 --- a/orc/orcprogram-c.c +++ b/orc/orcprogram-c.c @@ -677,11 +677,12 @@ c_rule_ ## name (OrcCompiler *p, void *user, OrcInstruction *insn) \ static void c_rule_loadX (OrcCompiler *p, void *user, OrcInstruction *insn) { - if (p->insn_flags[insn-p->insns] & ORC_INSN_FLAG_ADDED) { - ORC_ASM_CODE(p," var%d = ptr%d[i];\n", insn->dest_args[0], + if (p->target_flags & ORC_TARGET_C_OPCODE && + !(insn->flags & ORC_INSN_FLAG_ADDED)) { + ORC_ASM_CODE(p," var%d = ptr%d[offset + i];\n", insn->dest_args[0], insn->src_args[0]); } else { - ORC_ASM_CODE(p," var%d = ptr%d[offset + i];\n", insn->dest_args[0], + ORC_ASM_CODE(p," var%d = ptr%d[i];\n", insn->dest_args[0], insn->src_args[0]); } } @@ -711,11 +712,12 @@ c_rule_loadupib (OrcCompiler *p, void *user, OrcInstruction *insn) static void c_rule_storeX (OrcCompiler *p, void *user, OrcInstruction *insn) { - if (p->insn_flags[insn-p->insns] & ORC_INSN_FLAG_ADDED) { - ORC_ASM_CODE(p," ptr%d[i] = var%d;\n", insn->dest_args[0], + if (p->target_flags & ORC_TARGET_C_OPCODE && + !(insn->flags & ORC_INSN_FLAG_ADDED)) { + ORC_ASM_CODE(p," ptr%d[offset + i] = var%d;\n", insn->dest_args[0], insn->src_args[0]); } else { - ORC_ASM_CODE(p," ptr%d[offset + i] = var%d;\n", insn->dest_args[0], + ORC_ASM_CODE(p," ptr%d[i] = var%d;\n", insn->dest_args[0], insn->src_args[0]); } } diff --git a/orc/orcprogram-mmx.c b/orc/orcprogram-mmx.c index 40a9d64..b3fc6ea 100644 --- a/orc/orcprogram-mmx.c +++ b/orc/orcprogram-mmx.c @@ -739,7 +739,7 @@ orc_mmx_emit_loop (OrcCompiler *compiler, int offset, int update) insn = compiler->insns + j; opcode = insn->opcode; - if (compiler->insn_flags[j] & ORC_INSN_FLAG_INVARIANT) continue; + if (insn->flags & ORC_INSN_FLAG_INVARIANT) continue; ORC_ASM_CODE(compiler,"# %d: %s\n", j, insn->opcode->name); @@ -790,7 +790,7 @@ orc_mmx_emit_invariants (OrcCompiler *compiler) insn = compiler->insns + j; opcode = insn->opcode; - if (!(compiler->insn_flags[j] & ORC_INSN_FLAG_INVARIANT)) continue; + if (!(insn->flags & ORC_INSN_FLAG_INVARIANT)) continue; ORC_ASM_CODE(compiler,"# %d: %s\n", j, insn->opcode->name); diff --git a/orc/orcprogram-neon.c b/orc/orcprogram-neon.c index 5c9a74b..3da106d 100644 --- a/orc/orcprogram-neon.c +++ b/orc/orcprogram-neon.c @@ -257,7 +257,7 @@ orc_neon_load_constants_outer (OrcCompiler *compiler) OrcStaticOpcode *opcode = insn->opcode; OrcRule *rule; - if (!(compiler->insn_flags[i] & ORC_INSN_FLAG_INVARIANT)) continue; + if (!(insn->flags & ORC_INSN_FLAG_INVARIANT)) continue; ORC_ASM_CODE(compiler,"# %d: %s\n", i, insn->opcode->name); @@ -699,7 +699,7 @@ orc_neon_emit_loop (OrcCompiler *compiler, int unroll_index) insn = compiler->insns + j; opcode = insn->opcode; - if (compiler->insn_flags[j] & ORC_INSN_FLAG_INVARIANT) continue; + if (insn->flags & ORC_INSN_FLAG_INVARIANT) continue; orc_compiler_append_code(compiler,"# %d: %s", j, insn->opcode->name); diff --git a/orc/orcprogram-sse.c b/orc/orcprogram-sse.c index d7925d3..40b82d5 100644 --- a/orc/orcprogram-sse.c +++ b/orc/orcprogram-sse.c @@ -784,7 +784,7 @@ orc_sse_emit_loop (OrcCompiler *compiler, int offset, int update) insn = compiler->insns + j; opcode = insn->opcode; - if (compiler->insn_flags[j] & ORC_INSN_FLAG_INVARIANT) continue; + if (insn->flags & ORC_INSN_FLAG_INVARIANT) continue; ORC_ASM_CODE(compiler,"# %d: %s\n", j, insn->opcode->name); @@ -835,7 +835,7 @@ orc_sse_emit_invariants (OrcCompiler *compiler) insn = compiler->insns + j; opcode = insn->opcode; - if (!(compiler->insn_flags[j] & ORC_INSN_FLAG_INVARIANT)) continue; + if (!(insn->flags & ORC_INSN_FLAG_INVARIANT)) continue; ORC_ASM_CODE(compiler,"# %d: %s\n", j, insn->opcode->name); diff --git a/orc/orcprogram.h b/orc/orcprogram.h index b251998..bb7a18c 100644 --- a/orc/orcprogram.h +++ b/orc/orcprogram.h @@ -300,6 +300,10 @@ struct _OrcInstruction { #define ORC_INSTRUCTION_FLAG_X2 (1<<0) #define ORC_INSTRUCTION_FLAG_X4 (1<<1) +#define ORC_INSN_FLAG_INVARIANT (1<<2) +#define ORC_INSN_FLAG_ADDED (1<<3) + + /** * OrcConstant: * @@ -381,7 +385,6 @@ struct _OrcCompiler { OrcInstruction insns[ORC_N_INSNS]; int n_insns; - int insn_flags[ORC_N_INSNS]; OrcVariable vars[ORC_N_COMPILER_VARIABLES]; int n_temp_vars; @@ -430,9 +433,6 @@ struct _OrcCompiler { int offset; }; -#define ORC_INSN_FLAG_INVARIANT (1<<0) -#define ORC_INSN_FLAG_ADDED (1<<1) - #define ORC_SRC_ARG(p,i,n) ((p)->vars[(i)->src_args[(n)]].alloc) #define ORC_DEST_ARG(p,i,n) ((p)->vars[(i)->dest_args[(n)]].alloc) #define ORC_SRC_TYPE(p,i,n) ((p)->vars[(i)->src_args[(n)]].vartype) |