summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2019-03-03 09:13:48 +0100
committerChristoph Mallon <christoph.mallon@gmx.de>2019-03-04 20:53:43 +0100
commitc8cf8d509fd41d301541a5e24ad6f19672a7e9af (patch)
treea6364b5334c59bd9d4400130a6bd56bfd8f22e08
parentc47bf936ead28b59953e34fe45b7005e5d778ea7 (diff)
be: Factor out code to emit an unconditional jump in each backend.
-rw-r--r--ir/be/amd64/amd64_emitter.c9
-rw-r--r--ir/be/arm/arm_emitter.c9
-rw-r--r--ir/be/ia32/ia32_emitter.c9
-rw-r--r--ir/be/mips/mips_emitter.c15
-rw-r--r--ir/be/riscv/riscv_emitter.c9
-rw-r--r--ir/be/sparc/sparc_emitter.c17
6 files changed, 48 insertions, 20 deletions
diff --git a/ir/be/amd64/amd64_emitter.c b/ir/be/amd64/amd64_emitter.c
index 73bf229..c7c3307 100644
--- a/ir/be/amd64/amd64_emitter.c
+++ b/ir/be/amd64/amd64_emitter.c
@@ -587,6 +587,11 @@ static void emit_amd64_asm_operand(ir_node const *const node, char const modifie
panic("invalid asm operand kind");
}
+static void emit_jmp(ir_node const *const node, ir_node const *const target)
+{
+ BE_EMIT_JMP(amd64, node, "jmp", target) {}
+}
+
static void emit_amd64_asm(const ir_node *node)
{
be_emit_asm(node, emit_amd64_asm_operand);
@@ -597,7 +602,7 @@ static void emit_amd64_asm(const ir_node *node)
*/
static void emit_amd64_jmp(const ir_node *node)
{
- BE_EMIT_JMP(amd64, node, "jmp", node) {}
+ emit_jmp(node, node);
}
static void emit_jumptable_target(ir_entity const *const table,
@@ -663,7 +668,7 @@ static void emit_amd64_jcc(const ir_node *irn)
/* emit the true proj */
amd64_emitf(irn, "j%PX %L", (int)cc, projs.t);
- BE_EMIT_JMP(amd64, irn, "jmp", projs.f) {}
+ emit_jmp(irn, projs.f);
}
static void emit_amd64_mov_gp(const ir_node *node)
diff --git a/ir/be/arm/arm_emitter.c b/ir/be/arm/arm_emitter.c
index d090f77..6b44246 100644
--- a/ir/be/arm/arm_emitter.c
+++ b/ir/be/arm/arm_emitter.c
@@ -350,6 +350,11 @@ static void emit_arm_fConst(const ir_node *irn)
arm_emitf(irn, "ldf%m %D0, %C", mode, entry);
}
+static void emit_jmp(ir_node const *const node, ir_node const *const target)
+{
+ BE_EMIT_JMP(arm, node, "b", target) {}
+}
+
/**
* Emit a Compare with conditional branch.
*/
@@ -393,7 +398,7 @@ static void emit_arm_Bcc(const ir_node *irn)
/* emit the true proj */
arm_emitf(irn, "b%s %L", suffix, projs.t);
- BE_EMIT_JMP(arm, irn, "b", projs.f) {}
+ emit_jmp(irn, projs.f);
}
static void emit_jumptable_target(ir_entity const *const table,
@@ -542,7 +547,7 @@ static void emit_be_MemPerm(const ir_node *node)
static void emit_arm_B(const ir_node *node)
{
- BE_EMIT_JMP(arm, node, "b", node) {}
+ emit_jmp(node, node);
}
/**
diff --git a/ir/be/ia32/ia32_emitter.c b/ir/be/ia32/ia32_emitter.c
index 038f2f4..035b67a 100644
--- a/ir/be/ia32/ia32_emitter.c
+++ b/ir/be/ia32/ia32_emitter.c
@@ -596,6 +596,11 @@ static void ia32_emit_exc_label(const ir_node *node)
be_emit_irprintf("%lu", get_ia32_exc_label_id(node));
}
+static void emit_jmp(ir_node const *const node, ir_node const *const target)
+{
+ BE_EMIT_JMP(ia32, node, "jmp", target) {}
+}
+
/**
* Emits the jump sequence for a conditional jump (cmp + jmp_true + jmp_false)
*/
@@ -652,7 +657,7 @@ static void emit_ia32_Jcc(const ir_node *node)
be_emit_write_line();
}
- BE_EMIT_JMP(ia32, node, "jmp", projs.f) {}
+ emit_jmp(node, projs.f);
}
/**
@@ -716,7 +721,7 @@ static void emit_ia32_SwitchJmp(const ir_node *node)
*/
static void emit_ia32_Jmp(const ir_node *node)
{
- BE_EMIT_JMP(ia32, node, "jmp", node) {}
+ emit_jmp(node, node);
}
static void emit_ia32_asm_register(const arch_register_t *reg, char modifier,
diff --git a/ir/be/mips/mips_emitter.c b/ir/be/mips/mips_emitter.c
index b590953..9ae0e16 100644
--- a/ir/be/mips/mips_emitter.c
+++ b/ir/be/mips/mips_emitter.c
@@ -134,6 +134,13 @@ static void emit_mips_asm_operand(ir_node const *const node, char const modifier
panic("invalid asm operand kind");
}
+static void emit_jmp(ir_node const *const node, ir_node const *const target)
+{
+ BE_EMIT_JMP(mips, node, "b", target) {
+ mips_emitf(NULL, "nop");
+ }
+}
+
static void emit_be_ASM(const ir_node *node)
{
be_emit_asm(node, &emit_mips_asm_operand);
@@ -176,9 +183,7 @@ static void emit_be_Perm(ir_node const *const node)
static void emit_mips_b(ir_node const *const node)
{
- BE_EMIT_JMP(mips, node, "b", node) {
- mips_emitf(NULL, "nop");
- }
+ emit_jmp(node, node);
}
static void emit_mips_bcc(ir_node const *const node)
@@ -190,9 +195,7 @@ static void emit_mips_bcc(ir_node const *const node)
mips_emitf(node, fmt, mips_negate_cond(cond), projs.f);
} else {
mips_emitf(node, fmt, cond, projs.t);
- BE_EMIT_JMP(mips, node, "b", projs.f) {
- mips_emitf(NULL, "nop");
- }
+ emit_jmp(node, projs.f);
}
}
diff --git a/ir/be/riscv/riscv_emitter.c b/ir/be/riscv/riscv_emitter.c
index ce1a046..3d6fb14 100644
--- a/ir/be/riscv/riscv_emitter.c
+++ b/ir/be/riscv/riscv_emitter.c
@@ -94,6 +94,11 @@ unknown:
}
}
+static void emit_jmp(ir_node const *const node, ir_node const *const target)
+{
+ BE_EMIT_JMP(riscv, node, "j", target) {}
+}
+
static void emit_riscv_asm_operand(ir_node const *const node, char const modifier, unsigned const pos)
{
be_asm_attr_t const *const attr = get_be_asm_attr_const(node);
@@ -200,13 +205,13 @@ static void emit_riscv_bcc(ir_node const *const node)
riscv_emitf(node, fmt, riscv_negate_cond(cond), projs.f);
} else {
riscv_emitf(node, fmt, cond, projs.t);
- BE_EMIT_JMP(riscv, node, "j", projs.f) {}
+ emit_jmp(node, projs.f);
}
}
static void emit_riscv_j(ir_node const *const node)
{
- BE_EMIT_JMP(riscv, node, "j", node) {}
+ emit_jmp(node, node);
}
static void emit_jumptable_target(ir_entity const *const table, ir_node const *const proj_x)
diff --git a/ir/be/sparc/sparc_emitter.c b/ir/be/sparc/sparc_emitter.c
index 2a26548..0845469 100644
--- a/ir/be/sparc/sparc_emitter.c
+++ b/ir/be/sparc/sparc_emitter.c
@@ -664,6 +664,16 @@ static void emit_sparc_asm_operand(ir_node const *const node, char const modifie
panic("invalid asm operand kind");
}
+static void emit_jmp(ir_node const *const node, ir_node const *const target)
+{
+ BE_EMIT_JMP(sparc, node, "ba", target) {
+ /* TODO: fill this slot as well */
+ emitting_delay_slot = true;
+ sparc_emitf(NULL, "nop");
+ emitting_delay_slot = false;
+ }
+}
+
static void emit_sparc_ASM(const ir_node *node)
{
be_emit_asm(node, emit_sparc_asm_operand);
@@ -1082,12 +1092,7 @@ static void emit_sparc_branch(const ir_node *node, get_cc_func get_cc)
sparc_emitf(node, "%s%A %L", get_cc(relation), projs.t);
fill_delay_slot(node);
- BE_EMIT_JMP(sparc, node, "ba", projs.f) {
- /* TODO: fill this slot as well */
- emitting_delay_slot = true;
- sparc_emitf(NULL, "nop");
- emitting_delay_slot = false;
- }
+ emit_jmp(node, projs.f);
}
static void emit_sparc_Bicc(const ir_node *node)