summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2019-03-03 16:55:19 +0100
committerChristoph Mallon <christoph.mallon@gmx.de>2019-03-04 20:55:18 +0100
commitaeb9a50904e8864cef8e7f783f5bda705a792c37 (patch)
treebf627443164c57170e9d97b411969d73589aa30c
parent60d49bf6351f543e33f122c6d60567486a054051 (diff)
beasm: Add helper function to check for occurrence of modifiers.
-rw-r--r--ir/be/amd64/amd64_emitter.c2
-rw-r--r--ir/be/arm/arm_emitter.c2
-rw-r--r--ir/be/beasm.h5
-rw-r--r--ir/be/ia32/ia32_emitter.c2
4 files changed, 8 insertions, 3 deletions
diff --git a/ir/be/amd64/amd64_emitter.c b/ir/be/amd64/amd64_emitter.c
index c7c3307..203a50b 100644
--- a/ir/be/amd64/amd64_emitter.c
+++ b/ir/be/amd64/amd64_emitter.c
@@ -579,7 +579,7 @@ static void emit_amd64_asm_operand(ir_node const *const node, char const modifie
}
case BE_ASM_OPERAND_IMMEDIATE:
- if (modifier != 'c' && modifier != 'P' && modifier != 'p')
+ if (!be_has_modifier("Pcp", modifier))
be_emit_char('$');
x86_emit_imm32(&op->u.imm32);
return;
diff --git a/ir/be/arm/arm_emitter.c b/ir/be/arm/arm_emitter.c
index 6b44246..822708d 100644
--- a/ir/be/arm/arm_emitter.c
+++ b/ir/be/arm/arm_emitter.c
@@ -440,7 +440,7 @@ static void emit_arm_asm_operand(ir_node const *const node, char const modifier,
return;
case BE_ASM_OPERAND_IMMEDIATE:
- if (modifier != 'B' && modifier != 'c')
+ if (!be_has_modifier("Bc", modifier))
be_emit_char('#');
if (op->ent) {
if (modifier == 'B')
diff --git a/ir/be/beasm.h b/ir/be/beasm.h
index b0c7bce..2af6154 100644
--- a/ir/be/beasm.h
+++ b/ir/be/beasm.h
@@ -123,4 +123,9 @@ struct be_register_name_t {
arch_register_t const *be_parse_register_name(char const *clobber);
+static inline bool be_has_modifier(char const* const candidates, char const modifier)
+{
+ return modifier != '\0' && strchr(candidates, modifier);
+}
+
#endif
diff --git a/ir/be/ia32/ia32_emitter.c b/ir/be/ia32/ia32_emitter.c
index 035b67a..9eafdb7 100644
--- a/ir/be/ia32/ia32_emitter.c
+++ b/ir/be/ia32/ia32_emitter.c
@@ -792,7 +792,7 @@ static void emit_ia32_asm_operand(ir_node const *const node, char const modifier
}
case BE_ASM_OPERAND_IMMEDIATE:
- if (modifier != 'c' && modifier != 'P' && modifier != 'p')
+ if (!be_has_modifier("Pcp", modifier))
be_emit_char('$');
x86_emit_imm32(&op->u.imm32);
return;