[arm] PR target/85658 Fix operator precedence errors in parsecpu.awk

There are a number of places in parsecpu.awk where I've managed to get
the operator precedence between ! and 'in' incorrect (! binds more
tightly).  In most cases this just makes a consistency test
ineffective, but in a few cases it means we fail to correctly diagnose
errors by the user (for example, when passing an invalid cpu or
architecture name to configure.  This patch fixes all the cases I
could find, based on searching for all uses of the two operators in
the same expression.  The tweak to the API of check_fpu is to bring it
into line with the other check functions - it now returns the result
rather than printing it directly.  The caller now does the printing,
in the same way that the chkarch and chkcpu commands do.

	PR target/85658
	* config/arm/parsecpu.awk (check_cpu): Fix operator precedence.
	(check_arch): Likewise.
	(check_fpu): Return the result rather than printing it.
	(end arch): Fix operator precedence.
	(end cpu): Likewise.
	(END): Print the result from check_fpu.

From-SVN: r260032
This commit is contained in:
Richard Earnshaw 2018-05-08 10:21:34 +00:00 committed by Richard Earnshaw
parent cee99fa01b
commit 0513e3d517
2 changed files with 20 additions and 9 deletions

View file

@ -1,3 +1,13 @@
2018-05-08 Richard Earnshaw <rearnsha@arm.com>
PR target/85658
* config/arm/parsecpu.awk (check_cpu): Fix operator precedence.
(check_arch): Likewise.
(check_fpu): Return the result rather than printing it.
(end arch): Fix operator precedence.
(end cpu): Likewise.
(END): Print the result from check_fpu.
2018-05-08 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>

View file

@ -463,7 +463,7 @@ function gen_opt () {
function check_cpu (name) {
exts = split (name, extensions, "+")
if (! extensions[1] in cpu_cnames) {
if (! (extensions[1] in cpu_cnames)) {
return "error"
}
@ -477,15 +477,16 @@ function check_cpu (name) {
}
function check_fpu (name) {
if (name in fpu_cnames) {
print fpu_cnames[name]
} else print "error"
if (! (name in fpu_cnames)) {
return "error"
}
return fpu_cnames[name]
}
function check_arch (name) {
exts = split (name, extensions, "+")
if (! extensions[1] in arch_isa) {
if (! (extensions[1] in arch_isa)) {
return "error"
}
@ -600,10 +601,10 @@ BEGIN {
/^end arch / {
if (NF != 3) fatal("syntax: end arch <name>")
if (arch_name != $3) fatal("mimatched end arch")
if (! arch_name in arch_tune_for) {
if (! (arch_name in arch_tune_for)) {
fatal("arch definition lacks a \"tune for\" statement")
}
if (! arch_name in arch_isa) {
if (! (arch_name in arch_isa)) {
fatal("arch definition lacks an \"isa\" statement")
}
arch_list = arch_list " " arch_name
@ -742,7 +743,7 @@ BEGIN {
cpu_cnames[cpu_name] = cpu_name
gsub(/[-+.]/, "_", cpu_cnames[cpu_name])
}
if (! cpu_name in cpu_arch) fatal("cpu definition lacks an architecture")
if (! (cpu_name in cpu_arch)) fatal("cpu definition lacks an architecture")
cpu_list = cpu_list " " cpu_name
cpu_name = ""
parse_ok = 1
@ -776,6 +777,6 @@ END {
print check_arch(target[2])
} else if (cmd ~ /^chkfpu /) {
split (cmd, target)
check_fpu(target[2])
print check_fpu(target[2])
} else fatal("unrecognized command: "cmd)
}