diff --git a/modules/src/em_code/build.lua b/modules/src/em_code/build.lua index b65ce83ca..37392d425 100644 --- a/modules/src/em_code/build.lua +++ b/modules/src/em_code/build.lua @@ -1,15 +1,15 @@ normalrule { name = "em_code_ek_h", ins = { - "./make.em.gen", - "util/cmisc+ed", + "./make_codeek_h.lua", + "h/em_table_lib.lua", + "h/em_table", "./em.nogen", - "h/em_table" }, outleaves = { "em_codeEK.h" }, commands = { - "%{ins[1]} %{ins[2]} %{ins[4]} > %{outs}", - "cat %{ins[3]} >> %{outs}" + "$LUA %{ins[1]} < %{ins[3]} > %{outs}", + "cat %{ins[4]} >> %{outs}" } } diff --git a/modules/src/em_code/make.em.gen b/modules/src/em_code/make.em.gen deleted file mode 100755 index d37d45638..000000000 --- a/modules/src/em_code/make.em.gen +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -echo "/* this part is generated from $2 at: " `date` "*/" -$1 -s $2 <<'EOI' -1,/^$/d -1,/^$/d -1,$s/^\(...\) \(.\).*/\1:\2/ -g/:d/s/^\(...\):\(.\).*/#define C_\1(c) CC_opcst(op_\1, c)/ -g/:[cslnfzor]/s/^\(...\):\(.\).*/#define C_\1(c) CC_opcst(op_\1, c)/ -g/:w/s/^\(...\).*/#define C_\1(w) CC_opcst(op_\1, w)\ -#define C_\1_narg() CC_opnarg(op_\1)/ -g/:g/s/^\(...\).*/#define C_\1(g) CC_opcst(op_\1, g)\ -#define C_\1_dnam(g, o) CC_opdnam(op_\1, g, o)\ -#define C_\1_dlb(g, o) CC_opdlb(op_\1, g, o)/ -g/:p/s/^\(...\).*/#define C_\1(p) CC_oppnam(op_\1, p)/ -g/:b/s/^\(...\).*/#define C_\1(b) CC_opilb(op_\1, b)/ -g/:-/s/^\(...\).*/#define C_\1() CC_op(op_\1)/ -1,$p -EOI diff --git a/modules/src/em_code/make.sh b/modules/src/em_code/make.sh deleted file mode 100755 index 9ee7d44eb..000000000 --- a/modules/src/em_code/make.sh +++ /dev/null @@ -1,20 +0,0 @@ -list= -target=$1 -shift -for i -do - echo "+$cc $cflags $i" - if $cc $cflags $i - then - list="$list `basename $i .c`.$suf" - else - exit 1 - fi -done -echo "+$ar r libem$target.$libsuf $list" -if $ar r libem$target.$libsuf $list -then - : -else - exit 1 -fi diff --git a/modules/src/em_code/make_codeek_h.lua b/modules/src/em_code/make_codeek_h.lua new file mode 100644 index 000000000..2ebf46761 --- /dev/null +++ b/modules/src/em_code/make_codeek_h.lua @@ -0,0 +1,25 @@ +require "h.em_table_lib" + +local specs, pseudos, mnems = load_table() + +for _, mnem in ipairs(mnems) do + if mnem.flags1:find("^[cslndfzor]") then + print(string.format("#define C_%s(c) CC_opcst(op_%s, c)", mnem.name, mnem.name)) + elseif mnem.flags1:find("^w") then + print(string.format("#define C_%s(w) CC_opcst(op_%s, w)", mnem.name, mnem.name)) + print(string.format("#define C_%s_narg() CC_opnarg(op_%s)", mnem.name, mnem.name)) + elseif mnem.flags1:find("^g") then + print(string.format("#define C_%s(g) CC_opcst(op_%s, g)", mnem.name, mnem.name)) + print(string.format("#define C_%s_dnam(g, o) CC_opdnam(op_%s, g, o)", mnem.name, mnem.name)) + print(string.format("#define C_%s_dlb(g, o) CC_opdlb(op_%s, g, o)", mnem.name, mnem.name)) + elseif mnem.flags1:find("^p") then + print(string.format("#define C_%s(p) CC_oppnam(op_%s, p)", mnem.name, mnem.name)) + elseif mnem.flags1:find("^b") then + print(string.format("#define C_%s(b) CC_opilb(op_%s, b)", mnem.name, mnem.name)) + elseif mnem.flags1:find("^-") then + print(string.format("#define C_%s() CC_op(op_%s)", mnem.name, mnem.name)) + else + error("unsupport em_table flag") + end +end + diff --git a/modules/src/em_code/makeem.sed b/modules/src/em_code/makeem.sed deleted file mode 100644 index 8db5d8cc9..000000000 --- a/modules/src/em_code/makeem.sed +++ /dev/null @@ -1,18 +0,0 @@ -1i\ -/* this part is generated from em_table */ -# Remove pseudo instructions -/^\(...\) \([0-9]\).*/d -# Remove opcode constant categories/count -/^\(....\) \([0-9]\).*/d -/^\(.....\) \([0-9]\).*/d -# Below are the actual replacement of opcodes. -s/^\(...\) \(d\).*/#define C_\1(c) CC_opcst(op_\1, c)/ -s/^\(...\) \([cslnfzor]\).*/#define C_\1(c) CC_opcst(op_\1, c)/ -s/^\(...\) \(w\).*/#define C_\1(w) CC_opcst(op_\1, w)\ -#define C_\1_narg() CC_opnarg(op_\1)/ -s/^\(...\) \(g\).*/#define C_\1(g) CC_opcst(op_\1, g)\ -#define C_\1_dnam(g, o) CC_opdnam(op_\1, g, o)\ -#define C_\1_dlb(g, o) CC_opdlb(op_\1, g, o)/ -s/^\(...\) \(p\).*/#define C_\1(p) CC_oppnam(op_\1, p)/ -s/^\(...\) \(b\).*/#define C_\1(b) CC_opilb(op_\1, b)/ -s/^\(...\) \(-\).*/#define C_\1() CC_op(op_\1)/