summaryrefslogtreecommitdiffhomepage
path: root/ir/be
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2019-03-04 08:07:59 +0100
committerChristoph Mallon <christoph.mallon@gmx.de>2019-04-05 20:44:50 +0200
commit4aacad60e2ba5c17db38e3e106a4947a21ac2983 (patch)
tree1d4b47177422cf0b36b6c0782431b75c0dfe2f88 /ir/be
parent80146aaacf50c17449e07b8aac0000e5267aed59 (diff)
beasm: Add BE_ASM_OPERAND_LABEL and tell the backends how to emit it.
Diffstat (limited to 'ir/be')
-rw-r--r--ir/be/amd64/amd64_emitter.c5
-rw-r--r--ir/be/arm/arm_emitter.c5
-rw-r--r--ir/be/beasm.c1
-rw-r--r--ir/be/beasm.h1
-rw-r--r--ir/be/beemithlp.c6
-rw-r--r--ir/be/beemithlp.h2
-rw-r--r--ir/be/ia32/ia32_emitter.c5
-rw-r--r--ir/be/mips/mips_emitter.c4
-rw-r--r--ir/be/riscv/riscv_emitter.c4
-rw-r--r--ir/be/sparc/sparc_emitter.c4
10 files changed, 37 insertions, 0 deletions
diff --git a/ir/be/amd64/amd64_emitter.c b/ir/be/amd64/amd64_emitter.c
index 20ea772..e3e3613 100644
--- a/ir/be/amd64/amd64_emitter.c
+++ b/ir/be/amd64/amd64_emitter.c
@@ -571,6 +571,11 @@ static void emit_amd64_asm_operand(ir_node const *const node, char const modifie
be_emit_char('$');
x86_emit_imm32(&op->u.imm32);
return;
+
+ case BE_ASM_OPERAND_LABEL:
+ be_emit_char('$');
+ be_emit_cfop_target_pos(node, op->op.pos);
+ return;
}
panic("invalid asm operand kind");
}
diff --git a/ir/be/arm/arm_emitter.c b/ir/be/arm/arm_emitter.c
index 822708d..b8a2ea4 100644
--- a/ir/be/arm/arm_emitter.c
+++ b/ir/be/arm/arm_emitter.c
@@ -456,6 +456,11 @@ static void emit_arm_asm_operand(ir_node const *const node, char const modifier,
}
return;
+ case BE_ASM_OPERAND_LABEL:
+ be_emit_char('#');
+ be_emit_cfop_target_pos(node, op->op.pos);
+ return;
+
case BE_ASM_OPERAND_MEMORY:
be_emit_char('[');
arm_emit_register(arch_get_irn_register_in(node, op->op.pos));
diff --git a/ir/be/beasm.c b/ir/be/beasm.c
index 150f238..c1f28b3 100644
--- a/ir/be/beasm.c
+++ b/ir/be/beasm.c
@@ -421,6 +421,7 @@ static char const *be_get_constraint_name(be_asm_operand_kind_t const kind)
case BE_ASM_OPERAND_OUTPUT_VALUE: return "output register";
case BE_ASM_OPERAND_IMMEDIATE: return "immediate";
case BE_ASM_OPERAND_MEMORY: return "memory";
+ case BE_ASM_OPERAND_LABEL: return "label";
}
panic("invalid constraint kind");
}
diff --git a/ir/be/beasm.h b/ir/be/beasm.h
index 33af771..7a4e515 100644
--- a/ir/be/beasm.h
+++ b/ir/be/beasm.h
@@ -26,6 +26,7 @@ typedef enum be_asm_operand_kind_t {
BE_ASM_OPERAND_OUTPUT_VALUE,
BE_ASM_OPERAND_IMMEDIATE,
BE_ASM_OPERAND_MEMORY,
+ BE_ASM_OPERAND_LABEL,
} be_asm_operand_kind_t;
typedef struct be_asm_operand_t {
diff --git a/ir/be/beemithlp.c b/ir/be/beemithlp.c
index a24ce71..bfd823f 100644
--- a/ir/be/beemithlp.c
+++ b/ir/be/beemithlp.c
@@ -104,6 +104,12 @@ void be_emit_cfop_target(ir_node const *const jmp)
be_gas_emit_block_name(target);
}
+void be_emit_cfop_target_pos(ir_node const *const jmp, unsigned const pos)
+{
+ ir_node *const proj = get_Proj_for_pn(jmp, pos);
+ be_emit_cfop_target(proj);
+}
+
bool be_is_fallthrough(ir_node const *const jmp)
{
ir_node *const block = get_nodes_block(jmp);
diff --git a/ir/be/beemithlp.h b/ir/be/beemithlp.h
index d84f912..ced007b 100644
--- a/ir/be/beemithlp.h
+++ b/ir/be/beemithlp.h
@@ -83,6 +83,8 @@ be_cond_branch_projs_t be_get_cond_branch_projs(ir_node const *node);
*/
void be_emit_cfop_target(ir_node const *jmp);
+void be_emit_cfop_target_pos(ir_node const *jmp, unsigned pos);
+
bool be_is_fallthrough(ir_node const *jmp);
/**
diff --git a/ir/be/ia32/ia32_emitter.c b/ir/be/ia32/ia32_emitter.c
index 8cc6acc..ee96481 100644
--- a/ir/be/ia32/ia32_emitter.c
+++ b/ir/be/ia32/ia32_emitter.c
@@ -787,6 +787,11 @@ static void emit_ia32_asm_operand(ir_node const *const node, char const modifier
be_emit_char('$');
x86_emit_imm32(&op->u.imm32);
return;
+
+ case BE_ASM_OPERAND_LABEL:
+ be_emit_char('$');
+ be_emit_cfop_target_pos(node, op->op.pos);
+ return;
}
panic("invalid asm operand kind");
}
diff --git a/ir/be/mips/mips_emitter.c b/ir/be/mips/mips_emitter.c
index ac56fe9..792127d 100644
--- a/ir/be/mips/mips_emitter.c
+++ b/ir/be/mips/mips_emitter.c
@@ -126,6 +126,10 @@ static void emit_mips_asm_operand(ir_node const *const node, char const modifier
emit_immediate_val(NULL, op->ent, op->val);
return;
+ case BE_ASM_OPERAND_LABEL:
+ be_emit_cfop_target_pos(node, op->op.pos);
+ return;
+
case BE_ASM_OPERAND_MEMORY:
be_emit_char('(');
emit_register(arch_get_irn_register_in(node, op->op.pos));
diff --git a/ir/be/riscv/riscv_emitter.c b/ir/be/riscv/riscv_emitter.c
index 6df475c..2c36fae 100644
--- a/ir/be/riscv/riscv_emitter.c
+++ b/ir/be/riscv/riscv_emitter.c
@@ -149,6 +149,10 @@ static void emit_riscv_asm_operand(ir_node const *const node, char const modifie
return;
}
+ case BE_ASM_OPERAND_LABEL:
+ be_emit_cfop_target_pos(node, op->op.pos);
+ return;
+
case BE_ASM_OPERAND_MEMORY:
be_emit_char('(');
emit_register(arch_get_irn_register_in(node, op->op.pos));
diff --git a/ir/be/sparc/sparc_emitter.c b/ir/be/sparc/sparc_emitter.c
index e51ccad..b06bd3e 100644
--- a/ir/be/sparc/sparc_emitter.c
+++ b/ir/be/sparc/sparc_emitter.c
@@ -648,6 +648,10 @@ static void emit_sparc_asm_operand(ir_node const *const node, char const modifie
sparc_emit_register(arch_get_irn_register_in(node, op->op.pos));
return;
+ case BE_ASM_OPERAND_LABEL:
+ be_emit_cfop_target_pos(node, op->op.pos);
+ return;
+
case BE_ASM_OPERAND_OUTPUT_VALUE:
sparc_emit_register(arch_get_irn_register_out(node, op->op.pos));
return;