diff --git a/modules/src/read_em/argtype b/modules/src/read_em/argtype deleted file mode 100755 index 8d77b9bb3..000000000 --- a/modules/src/read_em/argtype +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -: argtype lists all em mnemonics that have an argument type equal to -: one of the letters specified in the argument -case x$# in - x2) - ;; - x*) echo "Usage: $0 argtypes " 1>&2 - exit 1 - ;; -esac -$ED -s $2 << A -1,/^\$/d -1,/^\$/d -1,/^\$/g/^\(...\) [$1].*/s//\\1/gp -A diff --git a/modules/src/read_em/build.lua b/modules/src/read_em/build.lua index 0d570416b..8acbd6d07 100644 --- a/modules/src/read_em/build.lua +++ b/modules/src/read_em/build.lua @@ -1,28 +1,26 @@ normalrule { name = "c_mnem_narg_h", ins = { - "./m_C_mnem_na", - "util/cmisc+ed", + "./make_C_mnem_narg_h.lua", + "h/em_table_lib.lua", "h/em_table", - "./argtype" }, outleaves = "C_mnem_narg.h", commands = { - "%{ins} > %{outs}" + "$LUA %{ins[1]} < %{ins[3]} > %{outs}" } } normalrule { name = "c_mnem_h", ins = { - "./m_C_mnem", - "util/cmisc+ed", + "./make_C_mnem_h.lua", + "h/em_table_lib.lua", "h/em_table", - "./argtype" }, outleaves = "C_mnem.h", commands = { - "%{ins} > %{outs}" + "$LUA %{ins[1]} < %{ins[3]} > %{outs}" } } diff --git a/modules/src/read_em/m_C_mnem b/modules/src/read_em/m_C_mnem deleted file mode 100755 index 28588792d..000000000 --- a/modules/src/read_em/m_C_mnem +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/sh - -export ED=$1 -EM_TABLE=$2 -ARGTYPE=$3 -echo "switch(p->em_opcode) {" -for i in - cdflnorswz p b -do - list=`$ARGTYPE $i $EM_TABLE` - case $i in - -) args='()' - echo " /* no arguments */" - ;; - cdflnorswz) - args='(p->em_cst)' - echo " /* one integer constant argument */" - ;; - p) - args='(p->em_pnam)' - echo " /* a procedure name argument */" - ;; - b) - -: Grumbl, an instruction label as argument is encoded in a sp_cst2 - - args='((label) (p->em_cst))' - echo " /* An instruction label argument */" - ;; - esac - for i in $list - do - cat << EOF - case op_$i: - C_$i$args; - break; -EOF - done -done -list=$($ARGTYPE g $EM_TABLE | tr -d '\r') -cat << 'EOF' - default: -/* a "g" argument */ - if (p->em_argtype == nof_ptyp) { - switch(p->em_opcode) { - default: - EM_error = "Illegal mnemonic"; - break; -EOF -for i in $list -do - cat << EOF - case op_$i: - C_${i}_dlb(p->em_dlb, p->em_off); - break; -EOF -done -cat << 'EOF' - } - } - else if (p->em_argtype == sof_ptyp) { - switch(p->em_opcode) { - default: - EM_error = "Illegal mnemonic"; - break; -EOF -for i in $list -do - cat << EOF - case op_$i: - C_${i}_dnam(p->em_dnam, p->em_off); - break; -EOF -done -cat << 'EOF' - } - } - else /*argtype == cst_ptyp */ { - switch(p->em_opcode) { - default: - EM_error = "Illegal mnemonic"; - break; -EOF -for i in $list -do - cat << EOF - case op_$i: - C_$i(p->em_cst); - break; -EOF -done -cat << 'EOF' - } - } -} -EOF diff --git a/modules/src/read_em/m_C_mnem_na b/modules/src/read_em/m_C_mnem_na deleted file mode 100755 index 1d4935cc1..000000000 --- a/modules/src/read_em/m_C_mnem_na +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -export ED=$1 -EM_TABLE=$2 -ARGTYPE=$3 -list=$($ARGTYPE w $EM_TABLE | tr -d '\r') -echo "switch(p->em_opcode) {" -for i in $list -do - cat << EOF - case op_$i: - C_${i}_narg(); - break; -EOF -done -cat << EOF - default: EM_error = "Illegal mnemonic"; -} -EOF diff --git a/modules/src/read_em/make_C_mnem_h.lua b/modules/src/read_em/make_C_mnem_h.lua new file mode 100644 index 000000000..1953efbc3 --- /dev/null +++ b/modules/src/read_em/make_C_mnem_h.lua @@ -0,0 +1,80 @@ +require "h.em_table_lib" + +local specs, pseudos, mnems = load_table() + +local function makecase(flags, args) + for _, mnem in ipairs(mnems) do + if mnem.flags1:find(flags) then + print(string.format('\tcase op_%s:\n\t\tC_%s%s;\n\t\tbreak;', + mnem.name, mnem.name, args)) + end + end +end + +print("switch(p->em_opcode) {") + +print("\t/* no arguments */") +makecase("^-", "()") + +print("\t/* one integer constant argument */") +makecase("^[cdflnorswz]", "(p->em_cst)") + +print("\t/* a procedure name argument */") +makecase("^p", "(p->em_pnam)") + +print("\t/* An instruction label argument */") +makecase("^b", "((label) (p->em_cst))") + +print([[ + default: + /* a "g" argument */ + if (p->em_argtype == nof_ptyp) { + switch(p->em_opcode) { + default: + EM_error = "Illegal mnemonic"; + break; +]]) +for _, mnem in ipairs(mnems) do + if mnem.flags1:find("^g") then + print(string.format('\t\t\t\tcase op_%s:', mnem.name)) + print(string.format('\t\t\t\t\tC_%s_dlb(p->em_dlb, p->em_off);\n\t\t\t\t\tbreak;', + mnem.name)) + end +end +print([[ + } + } + else if (p->em_argtype == sof_ptyp) { + switch(p->em_opcode) { + default: + EM_error = "Illegal mnemonic"; + break; +]]) +for _, mnem in ipairs(mnems) do + if mnem.flags1:find("^g") then + print(string.format('\t\t\t\tcase op_%s:', mnem.name)) + print(string.format('\t\t\t\t\tC_%s_dnam(p->em_dnam, p->em_off);\n\t\t\t\t\tbreak;', + mnem.name)) + end +end +print([[ + } + } + else /*argtype == cst_ptyp */ { + switch(p->em_opcode) { + default: + EM_error = "Illegal mnemonic"; + break; +]]) +for _, mnem in ipairs(mnems) do + if mnem.flags1:find("^g") then + print(string.format('\t\t\t\tcase op_%s:', mnem.name)) + print(string.format('\t\t\t\t\tC_%s(p->em_cst);\n\t\t\t\t\tbreak;', + mnem.name)) + end +end +print([[ + } + } +} +]]) diff --git a/modules/src/read_em/make_C_mnem_narg_h.lua b/modules/src/read_em/make_C_mnem_narg_h.lua new file mode 100644 index 000000000..91ba7aaa4 --- /dev/null +++ b/modules/src/read_em/make_C_mnem_narg_h.lua @@ -0,0 +1,16 @@ +require "h.em_table_lib" + +local specs, pseudos, mnems = load_table() + +print("switch(p->em_opcode) {") +for _, mnem in ipairs(mnems) do + if mnem.flags1:find("^w") then + print(string.format('\tcase op_%s:', mnem.name)) + print(string.format('\t\tC_%s_narg();\n\t\tbreak;', + mnem.name)) + end +end +print([[ + default: EM_error = "Illegal mnemonic"; +} +]])