LoongArch: Fix awk / sed usage for compatibility
Tested with nawk, mawk, and gawk. gcc/ChangeLog: * config/loongarch/genopts/gen-evolution.awk: remove usage of "asort". * config/loongarch/genopts/genstr.sh: replace sed with awk.
This commit is contained in:
parent
ca4e6e6317
commit
6ed8c17c2b
2 changed files with 40 additions and 29 deletions
|
@ -101,10 +101,18 @@ function gen_cpucfg_useful_idx()
|
|||
idx_list[j++] = i+0
|
||||
delete idx_bucket
|
||||
|
||||
asort (idx_list)
|
||||
for (i = 1; i < j; i++) {
|
||||
t = i
|
||||
for (k = i + 1; k < j; k++)
|
||||
t = idx_list[k] < idx_list[t] ? k : t
|
||||
|
||||
k = idx_list[t]
|
||||
idx_list[t] = idx_list[i]
|
||||
idx_list[i] = k
|
||||
}
|
||||
|
||||
print "static constexpr int cpucfg_useful_idx[] = {"
|
||||
for (i in idx_list)
|
||||
for (i = 1; i < j; i++)
|
||||
printf(" %d,\n", idx_list[i])
|
||||
print "};"
|
||||
|
||||
|
|
|
@ -51,18 +51,18 @@ along with GCC; see the file COPYING3. If not see
|
|||
#define LOONGARCH_STR_H
|
||||
EOF
|
||||
|
||||
sed -e '/^$/n' -e 's@#.*$@@' -e '/^$/d' \
|
||||
-e 's@^\([^ \t]\+\)[ \t]*\([^ \t]*\)@#define \1 "\2"@' \
|
||||
loongarch-strings
|
||||
awk '/^#.*$/ { next } /^$/ { print; next }
|
||||
{ printf ("#define %s \"%s\"\n", $1, $2) }' \
|
||||
loongarch-strings
|
||||
|
||||
echo
|
||||
|
||||
# Generate the strings from isa-evolution.in.
|
||||
awk '{
|
||||
a=$3
|
||||
gsub(/-/, "_", a)
|
||||
print("#define OPTSTR_"toupper(a)"\t\""$3"\"")
|
||||
}' isa-evolution.in
|
||||
# Generate the strings from isa-evolution.in.
|
||||
awk '{
|
||||
a=$3
|
||||
gsub(/-/, "_", a)
|
||||
print("#define OPTSTR_"toupper(a)"\t\""$3"\"")
|
||||
}' isa-evolution.in
|
||||
|
||||
echo
|
||||
echo "#endif /* LOONGARCH_STR_H */"
|
||||
|
@ -73,18 +73,8 @@ EOF
|
|||
# according to the key-value pairs defined in loongarch-strings.
|
||||
|
||||
gen_options() {
|
||||
|
||||
sed -e '/^$/n' -e 's@#.*$@@' -e '/^$/d' \
|
||||
-e 's@^\([^ \t]\+\)[ \t]*\([^ \t]*\)@\1="\2"@' \
|
||||
loongarch-strings | { \
|
||||
|
||||
# read the definitions
|
||||
while read -r line; do
|
||||
eval "$line"
|
||||
done
|
||||
|
||||
# print a header
|
||||
cat << EOF
|
||||
# print a header
|
||||
cat << EOF
|
||||
; Generated by "genstr" from the template "loongarch.opt.in"
|
||||
; and definitions from "loongarch-strings" and "isa-evolution.in".
|
||||
;
|
||||
|
@ -95,12 +85,25 @@ gen_options() {
|
|||
;
|
||||
EOF
|
||||
|
||||
# make the substitutions
|
||||
sed -e 's@"@\\"@g' -e 's/@@\([^@]\+\)@@/${\1}/g' loongarch.opt.in | \
|
||||
while read -r line; do
|
||||
eval "echo \"$line\""
|
||||
done
|
||||
}
|
||||
# Generate loongarch.opt.
|
||||
awk 'BEGIN {
|
||||
delete strtab
|
||||
while (getline < "loongarch-strings" > 0) {
|
||||
if ($0 ~ /^#.*$/ || $0 ~ /^$/) continue
|
||||
strtab[$1] = $2
|
||||
}
|
||||
}
|
||||
{
|
||||
n = split($0, tmp, "@@")
|
||||
for (i = 2; i <= n; i += 2)
|
||||
tmp[i] = strtab[tmp[i]]
|
||||
|
||||
for (i = 1; i <= n; i++)
|
||||
printf("%s", tmp[i])
|
||||
printf ("\n")
|
||||
|
||||
}' loongarch.opt.in
|
||||
|
||||
|
||||
# Generate the strings from isa-evolution.in.
|
||||
awk '{
|
||||
|
|
Loading…
Add table
Reference in a new issue