From dcf7d2a15920303ff74df298f3fb1cf29289c118 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Sat, 4 Jul 2020 15:06:14 +0200 Subject: add support for arch specific asm constraints When evaluating asm operands it must be known if they correspond to a memory operand or not in order to process/ignore the 'noderef' attribute. This is done for operands specified with the common constraints but not for the machine specific constraints. So, add support for processing machine specific constraints. Signed-off-by: Luc Van Oostenryck --- evaluate.c | 5 ++++- target.h | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/evaluate.c b/evaluate.c index 3b9aec3c..f515ce6f 100644 --- a/evaluate.c +++ b/evaluate.c @@ -3642,7 +3642,10 @@ static void parse_asm_constraint(struct asm_operand *op) return; default: - // FIXME: arch-specific (and multi-letter) constraints + if (arch_target->asm_constraint) + str = arch_target->asm_constraint(op, c, str); + + // FIXME: multi-letter constraints break; } } diff --git a/target.h b/target.h index 8640026c..3ef0d520 100644 --- a/target.h +++ b/target.h @@ -53,7 +53,7 @@ extern int pointer_alignment; extern int bits_in_enum; extern int enum_alignment; - +struct asm_operand; struct builtin_fn; struct target { @@ -77,6 +77,7 @@ struct target { void (*init)(const struct target *self); void (*predefine)(const struct target *self); + const char *(*asm_constraint)(struct asm_operand *op, int c, const char *str); }; extern const struct target target_default; -- cgit 1.2.3-korg From 60aa5705d990c92f8afdbc9bb401ad202a68b9e8 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Sat, 4 Jul 2020 15:05:37 +0200 Subject: add memory asm constraint for PPC The 'Z' asm constraint is used for doing IO accessors on PPC but isn't part of the 'common constraints'. It's responsible for more than half of all warnings (with defconfig + allyesconfig). Fix this by handling this constraint in a specific method for PPC. Signed-off-by: Luc Van Oostenryck --- target-ppc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/target-ppc.c b/target-ppc.c index b138635b..c0d6068f 100644 --- a/target-ppc.c +++ b/target-ppc.c @@ -1,6 +1,7 @@ #include "symbol.h" #include "target.h" #include "machine.h" +#include "expression.h" static void predefine_ppc(const struct target *self) @@ -15,6 +16,16 @@ static void predefine_ppc(const struct target *self) predefine("_BIG_ENDIAN", 1, "1"); } +static const char *asm_constraint_ppc(struct asm_operand *op, int c, const char *str) +{ + switch (c) { + case 'Z': + op->is_memory = true; + break; + } + return str; +} + static void predefine_ppc32(const struct target *self) { @@ -32,6 +43,7 @@ const struct target target_ppc32 = { .target_64bit = &target_ppc64, .predefine = predefine_ppc32, + .asm_constraint = asm_constraint_ppc, }; @@ -55,4 +67,5 @@ const struct target target_ppc64 = { .target_32bit = &target_ppc32, .predefine = predefine_ppc64, + .asm_constraint = asm_constraint_ppc, }; -- cgit 1.2.3-korg From b84b4b4b63aa13dd3257827ec0b0b777a1fbe159 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Sat, 4 Jul 2020 15:05:37 +0200 Subject: add memory asm constraint for S390 The 'Q', 'R', 'S' & 'T'' asm constraint are used for for memory operands on S390 but only 'Q' belong to the 'common constraints'. Fix this by handling the 3 others with an arch-specific method. Signed-off-by: Luc Van Oostenryck --- target-s390.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/target-s390.c b/target-s390.c index 8fe7d936..9dbc810e 100644 --- a/target-s390.c +++ b/target-s390.c @@ -1,6 +1,7 @@ #include "symbol.h" #include "target.h" #include "machine.h" +#include "expression.h" static void predefine_s390(const struct target *self) @@ -8,6 +9,16 @@ static void predefine_s390(const struct target *self) predefine("__s390__", 1, "1"); } +static const char *asm_constraint_s390(struct asm_operand *op, int c, const char *str) +{ + switch (c) { + case 'R': case 'S': case 'T': + op->is_memory = true; + break; + } + return str; +} + const struct target target_s390 = { .mach = MACH_S390, .bitness = ARCH_LP32, @@ -21,6 +32,7 @@ const struct target target_s390 = { .target_64bit = &target_s390x, .predefine = predefine_s390, + .asm_constraint = asm_constraint_s390, }; @@ -45,4 +57,5 @@ const struct target target_s390x = { .target_32bit = &target_s390, .predefine = predefine_s390x, + .asm_constraint = asm_constraint_s390, }; -- cgit 1.2.3-korg