Bolt mcg into the PowerPC backend. It doesn't build yet, but it is generating

*some* code.
This commit is contained in:
David Given 2016-10-17 00:06:06 +02:00
parent d539389e81
commit 5f0164db62
9 changed files with 58 additions and 45 deletions

View file

@ -33,7 +33,6 @@ installable {
"util/misc+pkg", "util/misc+pkg",
"util/opt+pkg", "util/opt+pkg",
"examples+pkg", "examples+pkg",
"mach/proto/mcg+pkg",
plat_packages plat_packages
} }
} }

View file

@ -453,7 +453,7 @@ loadtarget = function(targetname)
target = targets[targetname] target = targets[targetname]
if not target then if not target then
error(string.format("build file '%s' contains no target '%s'", error(string.format("build file '%s' contains no target '%s'",
filename, targetpart)) filepart, targetpart))
end end
end end

View file

@ -423,6 +423,10 @@ PATTERNS
emit "subf %out, %out, %left" emit "subf %out, %out, %left"
cost 12; 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) out:(int)reg = DIV4(left:(int)reg, right:(int)reg)
emit "divw %out, %left, %right" emit "divw %out, %left, %right"
cost 4; cost 4;

View file

@ -1,43 +1,51 @@
include("util/mcgg/build.lua") include("util/mcgg/build.lua")
mcgg { definerule("build_mcg",
name = "mcgg_c", {
srcs = { "./table" } arch = { type="string" }
}
cprogram {
name = "mcg",
srcs = {
"./*.c",
matching(filenamesof("+mcgg_c"), "%.c$"),
}, },
deps = { function(e)
"+mcgg_c", -- Remember this is executed from the caller's directory; local
"./*.h", -- target names will resolve there
"h+emheaders", local headers = clibrary {
"modules+headers", name = e.name.."/headers",
"modules/src/alloc+lib", srcs = {},
"modules/src/data+lib", hdrs = {
"modules/src/em_code+lib_k", "mach/proto/mcg/*.h",
"modules/src/em_data+lib", "mach/"..e.arch.."/mcg/*.h",
"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",
} }
}
}
-- Just for test purposes for now local tables = mcgg {
installable { name = e.name.."/tables",
name = "pkg", srcs = { "mach/"..e.arch.."/mcg/table" }
map = { }
["$(PLATDEP)/mcg"] = "+mcg"
} 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
)

View file

@ -441,12 +441,13 @@ static void insn_ivalue(int opcode, arith value)
case op_rmi: simple_alu2(opcode, value, IR_MOD); break; case op_rmi: simple_alu2(opcode, value, IR_MOD); break;
case op_sli: simple_alu2(opcode, value, IR_ASL); break; case op_sli: simple_alu2(opcode, value, IR_ASL); break;
case op_sri: simple_alu2(opcode, value, IR_ASR); 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_ngi: simple_alu1(opcode, value, IR_NEG); break;
case op_adu: simple_alu2(opcode, value, IR_ADD); break; case op_adu: simple_alu2(opcode, value, IR_ADD); break;
case op_sbu: simple_alu2(opcode, value, IR_SUB); 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_and: simple_alu2(opcode, value, IR_AND); break;
case op_ior: simple_alu2(opcode, value, IR_OR); break; case op_ior: simple_alu2(opcode, value, IR_OR); break;

View file

@ -1,5 +1,6 @@
include("mach/proto/as/build.lua") include("mach/proto/as/build.lua")
include("mach/proto/ncg/build.lua") include("mach/proto/ncg/build.lua")
include("mach/proto/mcg/build.lua")
include("mach/proto/top/build.lua") include("mach/proto/top/build.lua")
definerule("ackfile", definerule("ackfile",

View file

@ -5,8 +5,8 @@ build_as {
arch = "powerpc", arch = "powerpc",
} }
build_ncg { build_mcg {
name = "ncg", name = "mcg",
arch = "powerpc", arch = "powerpc",
} }
@ -14,7 +14,7 @@ return installable {
name = "tools", name = "tools",
map = { map = {
["$(PLATDEP)/linuxppc/as"] = "+as", ["$(PLATDEP)/linuxppc/as"] = "+as",
["$(PLATDEP)/linuxppc/ncg"] = "+ncg", ["$(PLATDEP)/linuxppc/mcg"] = "+mcg",
["$(PLATIND)/descr/linuxppc"] = "./descr", ["$(PLATIND)/descr/linuxppc"] = "./descr",
"util/opt+pkg", "util/opt+pkg",
} }

View file

@ -35,7 +35,7 @@ var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi
name be name be
from .m.g from .m.g
to .s to .s
program {EM}/lib/ack/{PLATFORM}/ncg program {EM}/lib/ack/{PLATFORM}/mcg
mapflag -gdb GF=-gdb mapflag -gdb GF=-gdb
args {GF?} < args {GF?} <
stdout stdout