summaryrefslogtreecommitdiffhomepage
path: root/ir/be/beasm.c
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2016-11-06 12:23:49 +0100
committerChristoph Mallon <christoph.mallon@gmx.de>2016-11-28 17:37:22 +0100
commite0a4d0193285b483b96139e7830138ccc3e0284b (patch)
tree43f89939ea9e5168d83bca1f423c7692994a94e8 /ir/be/beasm.c
parente2e3d5283fe90089e76f9fff730f2dd43b02e6ed (diff)
be: Improve error handling when parsing asm constraints.
Diffstat (limited to 'ir/be/beasm.c')
-rw-r--r--ir/be/beasm.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/ir/be/beasm.c b/ir/be/beasm.c
index 01ea200..d61de0f 100644
--- a/ir/be/beasm.c
+++ b/ir/be/beasm.c
@@ -99,13 +99,13 @@ void be_parse_asm_constraints_internal(be_asm_constraint_t *const constraint, id
default:
if (is_digit(*i)) {
- if (is_output)
- panic("can only specify same constraint on input");
-
int p;
- sscanf(i, "%d%n", &same_as, &p);
- if (same_as >= 0)
+ if (sscanf(i, "%d%n", &same_as, &p) == 0) {
+ be_errorf(NULL, "error while reading matching constraint in \"%s\"", constraint_text);
+ i += 1;
+ } else {
i += p;
+ }
} else {
be_asm_constraint_t new_constraint;
memset(&new_constraint, 0, sizeof(new_constraint));
@@ -118,14 +118,14 @@ void be_parse_asm_constraints_internal(be_asm_constraint_t *const constraint, id
arch_register_class_t const *const new_cls = new_constraint.cls;
if (new_cls) {
if (cls && cls != new_cls)
- panic("multiple register classes not supported");
+ be_warningf(NULL, "multiple register classes not supported in \"%s\"", constraint_text);
cls = new_cls;
}
char const new_imm = new_constraint.immediate_type;
if (new_imm != '\0') {
if (immediate_type != '\0' && immediate_type != new_imm)
- panic("multiple immediate types not supported");
+ be_warningf(NULL, "multiple immediate types not supported in \"%s\"", constraint_text);
immediate_type = new_imm;
}
}
@@ -134,10 +134,19 @@ void be_parse_asm_constraints_internal(be_asm_constraint_t *const constraint, id
}
if (same_as >= 0) {
- if (cls)
- panic("same as and register constraint not supported");
- if (immediate_type != '\0')
- panic("same as and immediate constraint not supported");
+ if (is_output) {
+ be_warningf(NULL, "output constraint \"%s\" has matching constraint; ignoring it", constraint_text);
+ same_as = -1;
+ } else {
+ if (cls) {
+ be_warningf(NULL, "matching and register constraint not supported in constraint \"%s\"; ignoring register constraint", constraint_text);
+ cls = NULL;
+ }
+ if (immediate_type != '\0') {
+ be_warningf(NULL, "matching and immediate constraint not supported in constraint \"%s\"; ignoring immediate constraint", constraint_text);
+ immediate_type = '\0';
+ }
+ }
}
if (!cls && same_as < 0 && !memory_possible)