stage1 vm abi更新 修复更多问题
This commit is contained in:
1 parent
09d05e3a34
commit
f6a0bce9f0
6 files changed
+124
-60
No files matched your search
+16
-28
@@ -115,38 +115,26 @@ typedef enum {
|
||||
* [strtab] each: slen, str(pad8)
|
||||
* [gdata] each: dsize(8), data(dsize bytes, padded to 8)
|
||||
*
|
||||
* === Calling Convention ===
|
||||
* === Aggregate Return ABI (sret) ===
|
||||
*
|
||||
* 凡返回值类型为聚合(struct / union / enum / array / shape),
|
||||
* 采用调用者分配 / 被调用者填充的间接返回约定:
|
||||
*
|
||||
* Before CALL:
|
||||
* - args pushed left-to-right
|
||||
* - target address pushed last
|
||||
* - caller 在自己的帧里 alloca 一块 RetTy 大小的空间
|
||||
* - 该空间的地址作为第 0 个实参先压栈
|
||||
* - 其余实参照常从左到右压栈
|
||||
* - target 地址最后压栈
|
||||
* - CALL imm = 普通实参个数 + 1
|
||||
*
|
||||
* CALL (imm = nargs):
|
||||
* 1. pop target address
|
||||
* 2. callstack[cp++] = {saved_fp, saved_ip, nargs}
|
||||
* 3. fp = sp - nargs (fp points to arg0)
|
||||
* 4. ip = target address
|
||||
* Callee 进入后:
|
||||
* - fp+0 存放 sret 指针
|
||||
* - 形参 i 位于 fp + 8*(i+1)
|
||||
* - 返回值直接写入 *(fp+0),然后执行 RET void
|
||||
*
|
||||
* ALLOC k:
|
||||
* sp += k (slots zeroed; local[j] = stacks.data[fp + nargs + j])
|
||||
*
|
||||
* LADDR imm:
|
||||
* push &stacks.data[fp + imm]
|
||||
* (imm < nargs accesses args; imm >= nargs accesses locals)
|
||||
*
|
||||
* GADDR imm:
|
||||
* push prog->gdata[imm] (pointer to global data blob)
|
||||
*
|
||||
* RET:
|
||||
* 1. pop retval if non-void type
|
||||
* 2. sp = fp
|
||||
* 3. pop frame; fp = saved_fp, ip = saved_ip
|
||||
* 4. push retval if non-void type
|
||||
*
|
||||
* CALLI (indirect call):
|
||||
* - stack before: ..., arg0, ..., argN-1, nargs, func_addr
|
||||
* 1. pop func_addr, then pop nargs
|
||||
* 2. same as CALL steps 2-4
|
||||
* Caller 侧:
|
||||
* - 调用完成后,CALL 结果槽保存 sret 指针;
|
||||
* 后续对聚合值的所有读取都通过该指针进行
|
||||
*/
|
||||
|
||||
#define SPL_BINFMT_MAGIC "SPLBIN\0\0"
|
||||
|
||||
Reference in new issue
Block a user