Remove .ret from libem and inline the code.

This removes a wrong-way dependency of libsys on libem.  The C
functions in libsys called .ret, but libsys is after libem in the
linker arguments, so the linker didn't find .ret unless something else
had called .ret.  Almost everything called .ret, but I got a linker
error when I wrote an assembly program using the EM runtime, because
my assembly program didn't call .ret.

Add a dummy comment to build.lua, so git checkout touches that file,
the build system reconfigures itself, and the *.s glob sees that ret.s
has gone.
This commit is contained in:
George Koehler 2017-02-16 21:18:39 -05:00
parent e6df553ebf
commit 736c45453c
3 changed files with 20 additions and 25 deletions

View file

@ -6,7 +6,7 @@ for _, plat in ipairs(vars.plats) do
acklibrary { acklibrary {
name = "lib_"..plat, name = "lib_"..plat,
srcs = { srcs = {
"./*.s", -- los4.s, sts4.s "./*.s", -- rm ret.s
}, },
vars = { plat = plat }, vars = { plat = plat },
deps = { deps = {

View file

@ -1,12 +0,0 @@
.sect .text
! Standard boilerplate for returning from functions.
.define .ret
.ret:
lwz r0, 4(fp)
mtspr lr, r0
lwz r0, 0(fp) ! our stack frame becomes invalid as soon as...
addi sp, fp, 8 ! ...we change sp
mr fp, r0
blr

View file

@ -228,6 +228,7 @@ INSTRUCTIONS
bcctrl CONST:ro, CONST:ro, CONST:ro. bcctrl CONST:ro, CONST:ro, CONST:ro.
bctrl. bctrl.
bclr CONST:ro, CONST:ro, CONST:ro. bclr CONST:ro, CONST:ro, CONST:ro.
blr.
bl LABEL:ro. bl LABEL:ro.
cmp CR:ro, CONST:ro, GPR:ro, GPR:ro kills :cc. cmp CR:ro, CONST:ro, GPR:ro, GPR:ro kills :cc.
cmpw GPR:ro, GPR:ro kills :cc. cmpw GPR:ro, GPR:ro kills :cc.
@ -1839,23 +1840,29 @@ PATTERNS
pat ret $1==0 /* Return from procedure */ pat ret $1==0 /* Return from procedure */
gen gen
/* Restore saved registers. */
return return
b {LABEL, ".ret"} /* Epilog: restore lr and fp. */
lwz r0, {IND_RC_W, fp, 4}
mtspr lr, r0
lwz r0, {IND_RC_W, fp, 0}
/* Free our stack frame. */
addi sp, fp, {CONST, 8}
mr fp, r0
blr.
pat ret $1==INT32 /* Return from procedure, word */ pat ret $1==4 /* Return from procedure, word */
with REG with REG
gen gen move %1, r3
move %1, r3 leaving ret 0
return
b {LABEL, ".ret"}
pat ret $1==INT64 /* Return from procedure, double-word */ pat ret $1==8 /* Return from proc, double-word */
with REG REG with REG REG
gen gen
move %1, r3 move %1, r3
move %2, r4 move %2, r4
return leaving
b {LABEL, ".ret"} ret 0
pat blm /* Block move constant length */ pat blm /* Block move constant length */
leaving leaving