2016-09-24 16:31:35 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
in=$1
|
|
|
|
header=$2
|
|
|
|
source=$3
|
|
|
|
|
|
|
|
awk -f - $in >$header << "EOF"
|
|
|
|
BEGIN {
|
|
|
|
print "enum ir_opcode {"
|
|
|
|
}
|
|
|
|
|
|
|
|
/^ *[^# ]+/ {
|
|
|
|
print "\tIR_" $2 ","
|
|
|
|
}
|
|
|
|
|
|
|
|
END {
|
|
|
|
print "\tIR__COUNT"
|
|
|
|
print "};"
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
awk -f - $in >$source << "EOF"
|
|
|
|
BEGIN {
|
|
|
|
print "#include \"ircodes.h\""
|
2016-09-26 20:12:46 +00:00
|
|
|
print "const struct ir_data ir_data[IR__COUNT] = {"
|
2016-09-24 16:31:35 +00:00
|
|
|
}
|
|
|
|
|
2016-09-26 20:12:46 +00:00
|
|
|
function char_to_flags(c) {
|
|
|
|
if (c == "S") return "IRF_SIZED"
|
|
|
|
return "0"
|
2016-09-24 16:31:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/^ *[^# ]+/ {
|
2016-09-26 20:12:46 +00:00
|
|
|
printf("\t{ \"%s\", ", $2)
|
2016-09-29 17:58:02 +00:00
|
|
|
printf("%s", char_to_flags(substr($1, 1, 1)))
|
2016-09-26 20:12:46 +00:00
|
|
|
printf(" },\n")
|
2016-09-24 16:31:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
END {
|
|
|
|
print "};"
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|