feat(asm): give riscv64 the END and GETCALLERPC the toolchain accepts
Assisted-by: GLM 5.3 Flash
This commit is contained in:
1 parent
0211d6672d
commit
76f8ba6403
3 files changed
+195
-6
No files matched your search
+11
-4
@@ -34,6 +34,11 @@ import (
|
||||
type riscvFrameInfo struct {
|
||||
autosize int // the real SP adjustment (locals + saved LR)
|
||||
|
||||
// leaf mirrors the toolchain's cursym.Leaf: the body makes no call, so
|
||||
// the link register still holds the caller's address. GETCALLERPC reads
|
||||
// it there; a framed body reads the prologue's save at 0(SP) instead.
|
||||
leaf bool
|
||||
|
||||
// Stack-split guard state: the toolchain emits the check for every
|
||||
// non-NOSPLIT function whose autosize is nonzero (a zero autosize is
|
||||
// "effectively NOSPLIT"); unlike amd64 and arm64 there is no leaf
|
||||
@@ -44,12 +49,12 @@ type riscvFrameInfo struct {
|
||||
|
||||
// riscvComputeFrame derives the frame layout for a TEXT function.
|
||||
func riscvComputeFrame(t *ast.Text) riscvFrameInfo {
|
||||
frame := frameSize(t)
|
||||
if frame != 0 || !riscvIsLeaf(t) {
|
||||
leaf := riscvIsLeaf(t)
|
||||
if frame := frameSize(t); frame != 0 || !leaf {
|
||||
// FixedFrameSize = 8: space for the saved link register. A
|
||||
// zero-frame non-leaf function still opens an 8-byte frame for LR.
|
||||
autosize := frame + 8
|
||||
fi := riscvFrameInfo{autosize: autosize}
|
||||
fi := riscvFrameInfo{autosize: autosize, leaf: leaf}
|
||||
if !hasNoSplitFlag(t) {
|
||||
fi.needSplit = true
|
||||
switch {
|
||||
@@ -63,7 +68,9 @@ func riscvComputeFrame(t *ast.Text) riscvFrameInfo {
|
||||
}
|
||||
return fi
|
||||
}
|
||||
return riscvFrameInfo{}
|
||||
// A zero-frame leaf: no prologue, no guard, and the link register still
|
||||
// holding the caller's address.
|
||||
return riscvFrameInfo{leaf: leaf}
|
||||
}
|
||||
|
||||
// hasNoSplitFlag reports whether the TEXT directive carries NOSPLIT.
|
||||
|
||||
Reference in new issue
Block a user