+2017-09-22 Richard Earnshaw <richard.earnshaw@arm.com>
+
+ * config/arm/parsecpu.awk (fatal): Note that we've encountered an
+ error. Only quit immediately if parsing is complete.
+ (BEGIN): Initialize fatal_err and parse_done.
+ (begin fpu, end fpu): Check number of arguments.
+ (begin arch, end arch): Likewise.
+ (begin cpu, end cpu): Likewise.
+ (cname, tune for, tune flags, architecture, fpu, option): Likewise.
+ (optalias): Likewise.
+
2017-09-22 Richard Earnshaw <richard.earnshaw@arm.com>
* config.gcc (arm*-*-*): Don't add arm-isa.h to tm_p_file.
function fatal (m) {
print "error ("lineno"): " m > "/dev/stderr"
- exit 1
+ fatal_err = 1
+ if (parse_done) exit 1
}
function toplevel () {
arch_name = ""
fpu_name = ""
lineno = 0
+ fatal_err = 0
+ parse_done = 0
if (cmd == "") fatal("Usage parsecpu.awk -v cmd=<xyz>")
}
+# New line. Reset parse status and increment line count for error messages
// {
lineno++
parse_ok = 0
}
+# Comments must be on a line on their own.
/^#/ {
parse_ok = 1
}
}
/^begin fpu / {
+ if (NF != 3) fatal("syntax: begin fpu <name>")
toplevel()
fpu_name = $3
parse_ok = 1
}
/^end fpu / {
+ if (NF != 3) fatal("syntax: end fpu <name>")
if (fpu_name != $3) fatal("mimatched end fpu")
if (! (fpu_name in fpu_isa)) {
fatal("fpu definition \"" fpu_name "\" lacks an \"isa\" statement")
}
/^begin arch / {
+ if (NF != 3) fatal("syntax: begin arch <name>")
toplevel()
arch_name = $3
parse_ok = 1
}
/^[ ]*base / {
+ if (NF != 2) fatal("syntax: base <architecture-base-name>")
if (arch_name == "") fatal("\"base\" statement outside of arch block")
arch_base[arch_name] = $2
parse_ok = 1
}
/^[ ]*profile / {
+ if (NF != 2) fatal("syntax: profile <profile-name>")
if (arch_name == "") fatal("\"profile\" statement outside of arch block")
arch_prof[arch_name] = $2
parse_ok = 1
}
/^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) {
fatal("arch definition lacks a \"tune for\" statement")
}
/^begin cpu / {
+ if (NF != 3) fatal("syntax: begin cpu <name>")
toplevel()
cpu_name = $3
parse_ok = 1
}
/^[ ]*cname / {
+ if (NF != 2) fatal("syntax: cname <identifier>")
if (cpu_name == "") fatal("\"cname\" outside of cpu block")
cpu_cnames[cpu_name] = $2
parse_ok = 1
}
/^[ ]*tune for / {
+ if (NF != 3) fatal("syntax: tune for <cpu-name>")
if (cpu_name != "") {
cpu_tune_for[cpu_name] = $3
} else if (arch_name != "") {
}
/^[ ]*tune flags / {
+ if (NF < 3) fatal("syntax: tune flags <flag> [<flag>]*")
flags=""
flag_count = NF
for (n = 3; n <= flag_count; n++) {
}
/^[ ]*architecture / {
+ if (NF != 2) fatal("syntax: architecture <arch-name>")
if (cpu_name == "") fatal("\"architecture\" outside of cpu block")
cpu_arch[cpu_name] = $2
parse_ok = 1
}
/^[ ]*fpu / {
+ if (NF != 2) fatal("syntax: fpu <fpu-name>")
if (cpu_name == "") fatal("\"fpu\" outside of cpu block")
cpu_fpu[cpu_name] = $2
parse_ok = 1
}
/^[ ]*isa / {
+ if (NF < 2) fatal("syntax: isa <feature-or-fgroup> [<feature-or-fgroup>]*")
flags=""
flag_count = NF
for (n = 2; n <= flag_count; n++) {
}
/^[ ]*option / {
+ if (NF < 4) fatal("syntax: option <name> add|remove <feature-or-fgroup>+")
name=$2
if ($3 == "add") {
remove = "false"
}
/^[ ]*optalias / {
+ if (NF != 3) fatal("syntax: optalias <name> <option-name>")
name=$2
alias=$3
if (cpu_name != "") {
}
/^[ ]*costs / {
+ if (NF != 2) fatal("syntax: costs <identifier>")
if (cpu_name == "") fatal("\"costs\" outside of cpu block")
cpu_cost[cpu_name] = $2
parse_ok = 1
}
/^end cpu / {
+ if (NF != 3) fatal("syntax: end cpu <name>")
if (cpu_name != $3) fatal("mimatched end cpu")
if (! (cpu_name in cpu_cnames)) {
cpu_cnames[cpu_name] = cpu_name
}
END {
+ parse_done = 1
+ if (fatal_err) exit 1
toplevel()
if (cmd == "data") {
gen_data()