diff --git a/build.lua b/build.lua index 46d5b63d9..05a4eafcd 100644 --- a/build.lua +++ b/build.lua @@ -33,7 +33,6 @@ installable { "util/misc+pkg", "util/opt+pkg", "examples+pkg", - "mach/proto/mcg+pkg", plat_packages } } diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 282e6f185..274ef112f 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -453,7 +453,7 @@ loadtarget = function(targetname) target = targets[targetname] if not target then error(string.format("build file '%s' contains no target '%s'", - filename, targetpart)) + filepart, targetpart)) end end diff --git a/mach/proto/mcg/powerpc.c b/mach/powerpc/mcg/platform.c similarity index 100% rename from mach/proto/mcg/powerpc.c rename to mach/powerpc/mcg/platform.c diff --git a/mach/proto/mcg/table b/mach/powerpc/mcg/table similarity index 99% rename from mach/proto/mcg/table rename to mach/powerpc/mcg/table index d744dbbf7..95ba2a9fd 100644 --- a/mach/proto/mcg/table +++ b/mach/powerpc/mcg/table @@ -423,6 +423,10 @@ PATTERNS emit "subf %out, %out, %left" cost 12; + out:(int)reg = MUL4(left:(int)reg, right:(int)reg) + emit "mullw %out, %left, %right" + cost 4; + out:(int)reg = DIV4(left:(int)reg, right:(int)reg) emit "divw %out, %left, %right" cost 4; diff --git a/mach/proto/mcg/build.lua b/mach/proto/mcg/build.lua index 8fc41be95..387d14d26 100644 --- a/mach/proto/mcg/build.lua +++ b/mach/proto/mcg/build.lua @@ -1,43 +1,51 @@ include("util/mcgg/build.lua") -mcgg { - name = "mcgg_c", - srcs = { "./table" } -} - -cprogram { - name = "mcg", - srcs = { - "./*.c", - matching(filenamesof("+mcgg_c"), "%.c$"), +definerule("build_mcg", + { + arch = { type="string" } }, - deps = { - "+mcgg_c", - "./*.h", - "h+emheaders", - "modules+headers", - "modules/src/alloc+lib", - "modules/src/data+lib", - "modules/src/em_code+lib_k", - "modules/src/em_data+lib", - "modules/src/idf+lib", - "modules/src/read_em+lib_ev", - "modules/src/string+lib", - "modules/src/system+lib", - "util/mcgg+lib", - }, - vars = { - ["+cflags"] = { - "-Werror-implicit-function-declaration", + function(e) + -- Remember this is executed from the caller's directory; local + -- target names will resolve there + local headers = clibrary { + name = e.name.."/headers", + srcs = {}, + hdrs = { + "mach/proto/mcg/*.h", + "mach/"..e.arch.."/mcg/*.h", + } } - } -} --- Just for test purposes for now -installable { - name = "pkg", - map = { - ["$(PLATDEP)/mcg"] = "+mcg" - } -} + local tables = mcgg { + name = e.name.."/tables", + srcs = { "mach/"..e.arch.."/mcg/table" } + } + + return cprogram { + name = e.name, + srcs = { + "mach/proto/mcg/*.c", + "mach/"..e.arch.."/mcg/platform.c", + matching(filenamesof(tables), "%.c$") + }, + deps = { + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/data+lib", + "modules/src/em_code+lib_k", + "modules/src/em_data+lib", + "modules/src/flt_arith+lib", + "modules/src/idf+lib", + "modules/src/object+lib", + "modules/src/read_em+lib_kv", + "modules/src/string+lib", + "modules/src/system+lib", + "util/mcgg+lib", + headers, + tables, -- for .h file + } + } + end +) diff --git a/mach/proto/mcg/treebuilder.c b/mach/proto/mcg/treebuilder.c index cf25de4b9..e3d0f521d 100644 --- a/mach/proto/mcg/treebuilder.c +++ b/mach/proto/mcg/treebuilder.c @@ -441,12 +441,13 @@ static void insn_ivalue(int opcode, arith value) case op_rmi: simple_alu2(opcode, value, IR_MOD); break; case op_sli: simple_alu2(opcode, value, IR_ASL); break; case op_sri: simple_alu2(opcode, value, IR_ASR); break; - case op_slu: simple_alu2(opcode, value, IR_LSL); break; - case op_sru: simple_alu2(opcode, value, IR_LSR); break; case op_ngi: simple_alu1(opcode, value, IR_NEG); break; case op_adu: simple_alu2(opcode, value, IR_ADD); break; case op_sbu: simple_alu2(opcode, value, IR_SUB); break; + case op_mlu: simple_alu2(opcode, value, IR_MUL); break; + case op_slu: simple_alu2(opcode, value, IR_LSL); break; + case op_sru: simple_alu2(opcode, value, IR_LSR); break; case op_and: simple_alu2(opcode, value, IR_AND); break; case op_ior: simple_alu2(opcode, value, IR_OR); break; diff --git a/plat/build.lua b/plat/build.lua index dc0e87c5e..a6774b920 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -1,5 +1,6 @@ include("mach/proto/as/build.lua") include("mach/proto/ncg/build.lua") +include("mach/proto/mcg/build.lua") include("mach/proto/top/build.lua") definerule("ackfile", diff --git a/plat/linuxppc/build-tools.lua b/plat/linuxppc/build-tools.lua index 4d0f0048d..84f6e774d 100644 --- a/plat/linuxppc/build-tools.lua +++ b/plat/linuxppc/build-tools.lua @@ -5,8 +5,8 @@ build_as { arch = "powerpc", } -build_ncg { - name = "ncg", +build_mcg { + name = "mcg", arch = "powerpc", } @@ -14,7 +14,7 @@ return installable { name = "tools", map = { ["$(PLATDEP)/linuxppc/as"] = "+as", - ["$(PLATDEP)/linuxppc/ncg"] = "+ncg", + ["$(PLATDEP)/linuxppc/mcg"] = "+mcg", ["$(PLATIND)/descr/linuxppc"] = "./descr", "util/opt+pkg", } diff --git a/plat/linuxppc/descr b/plat/linuxppc/descr index b70680201..770e8834f 100644 --- a/plat/linuxppc/descr +++ b/plat/linuxppc/descr @@ -35,7 +35,7 @@ var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib/ack/{PLATFORM}/ncg + program {EM}/lib/ack/{PLATFORM}/mcg mapflag -gdb GF=-gdb args {GF?} < stdout