Build (but don't use) libfp for cpm.
This library is for software floating point. The i80 back end has never implemented floating point, and might not be ready for libfp. This commit only builds libfp without using it. I edit first/build.lua and plat/build.lua to allow `ack -c.s`, then use FP.script to edit the assembly code. I edit FP.script so it writes the edited assembly code to stdout, not to the input file.
This commit is contained in:
parent
aabf0bdd69
commit
b9b3428e01
|
@ -40,6 +40,7 @@ definerule("cfile",
|
|||
{
|
||||
srcs = { type="targets" },
|
||||
deps = { type="targets", default={} },
|
||||
suffix = { type="string", default=".o" },
|
||||
commands = {
|
||||
type="strings",
|
||||
default={
|
||||
|
@ -56,7 +57,7 @@ definerule("cfile",
|
|||
end
|
||||
hdrpaths = uniquify(hdrpaths)
|
||||
|
||||
local outleaf = basename(e.name)..".o"
|
||||
local outleaf = basename(e.name)..e.suffix
|
||||
|
||||
return normalrule {
|
||||
name = e.name,
|
||||
|
|
|
@ -37,5 +37,5 @@ g/_b64_add/s//.b64_add/g
|
|||
g/_b64_sft/s//.b64_sft/g
|
||||
g/_b64_rsft/s//.b64_rsft/g
|
||||
g/_b64_lsft/s//.b64_lsft/g
|
||||
w
|
||||
1,$p
|
||||
q
|
||||
|
|
53
mach/proto/fp/build.lua
Normal file
53
mach/proto/fp/build.lua
Normal file
|
@ -0,0 +1,53 @@
|
|||
include("plat/build.lua")
|
||||
|
||||
-- For now, all floats are little-endian.
|
||||
local byte_order = "mach/i86/libfp/byte_order.h"
|
||||
|
||||
-- For now, only cpm uses software floating-point.
|
||||
for _, plat in ipairs({"cpm"}) do
|
||||
local edits = {}
|
||||
for _, src in fpairs("./*.c", "./*.e") do
|
||||
|
||||
-- Compile each src file into assembly code.
|
||||
local n = basename(src):gsub("%.%w*$", "")
|
||||
local assembly = ackfile {
|
||||
name = "s_"..plat.."/"..n,
|
||||
srcs = { src },
|
||||
deps = {
|
||||
"./*.h",
|
||||
byte_order,
|
||||
},
|
||||
suffix = ".s",
|
||||
vars = {
|
||||
ackcflags = "-I"..dirname(byte_order),
|
||||
plat = plat
|
||||
}
|
||||
}
|
||||
|
||||
-- Run FP.script to edit the assembly code.
|
||||
edits[#edits+1] = normalrule {
|
||||
name = "ed_"..plat.."/"..n,
|
||||
ins = {
|
||||
"./FP.script",
|
||||
assembly,
|
||||
},
|
||||
outleaves = { n..".s" },
|
||||
commands = {
|
||||
"ed -s %{ins[2]} <%{ins[1]} >%{outs}"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
acklibrary {
|
||||
name = "lib_"..plat,
|
||||
srcs = { edits },
|
||||
vars = { plat = plat }
|
||||
}
|
||||
|
||||
installable {
|
||||
name = "pkg_"..plat,
|
||||
map = {
|
||||
["$(PLATIND)/"..plat.."/libfp.a"] = "+lib_"..plat,
|
||||
}
|
||||
}
|
||||
end
|
|
@ -8,8 +8,10 @@ definerule("ackfile",
|
|||
{
|
||||
srcs = { type="targets" },
|
||||
deps = { type="targets", default={} },
|
||||
suffix = { type="string", default=".o" },
|
||||
},
|
||||
function (e)
|
||||
local c = (e.suffix == ".o" and "-c" or "-c"..e.suffix)
|
||||
local plat = e.vars.plat
|
||||
|
||||
return cfile {
|
||||
|
@ -28,8 +30,9 @@ definerule("ackfile",
|
|||
"util/misc+pkg",
|
||||
e.deps
|
||||
},
|
||||
suffix = e.suffix,
|
||||
commands = {
|
||||
"ACKDIR=$(INSDIR) $(INSDIR)/bin/ack -m%{plat} -c -o %{outs} %{ins} %{hdrpaths} %{ackcflags}"
|
||||
"ACKDIR=$(INSDIR) $(INSDIR)/bin/ack -m%{plat} "..c.." -o %{outs} %{ins} %{hdrpaths} %{ackcflags}"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -100,18 +103,25 @@ definerule("build_plat_libs",
|
|||
plat = { type="string" },
|
||||
},
|
||||
function(e)
|
||||
local installmap = {
|
||||
"lang/b/lib+pkg_"..e.plat,
|
||||
"lang/basic/lib+pkg_"..e.plat,
|
||||
"lang/cem/libcc.ansi+pkg_"..e.plat,
|
||||
"lang/m2/libm2+pkg_"..e.plat,
|
||||
"lang/pc/libpc+pkg_"..e.plat,
|
||||
"lang/b/lib+pkg_"..e.plat,
|
||||
["$(PLATIND)/"..e.plat.."/libem.a"] = "mach/"..e.arch.."/libem+lib_"..e.plat,
|
||||
["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat,
|
||||
}
|
||||
|
||||
-- For now, only cpm uses software floating-point.
|
||||
if e.plat == "cpm" then
|
||||
installmap[#installmap+1] = "mach/proto/fp+pkg_"..e.plat
|
||||
end
|
||||
|
||||
return installable {
|
||||
name = e.name,
|
||||
map = {
|
||||
"lang/b/lib+pkg_"..e.plat,
|
||||
"lang/basic/lib+pkg_"..e.plat,
|
||||
"lang/cem/libcc.ansi+pkg_"..e.plat,
|
||||
"lang/m2/libm2+pkg_"..e.plat,
|
||||
"lang/pc/libpc+pkg_"..e.plat,
|
||||
"lang/b/lib+pkg_"..e.plat,
|
||||
["$(PLATIND)/"..e.plat.."/libem.a"] = "mach/"..e.arch.."/libem+lib_"..e.plat,
|
||||
["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat,
|
||||
}
|
||||
map = installmap,
|
||||
}
|
||||
end
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue