feat(includes): 新增 3 个跨模块链表访问器(GlobalVariable/PhiIncoming/SwitchCase)
GlobalVariable.Next / PhiIncoming.Next / SwitchCase.Next 均继承自泛型基类 GSListNode[T],泛型特化体不在任何 .vpi 中 ⇒ 导入侧 class_members 只有 __inherited_N 占位名,裸字段访问在严格属性解析下 fail-fast。 沿用既有约定(paramnode_get_next / value_set_next 等)在**定义模块内**补同名同义 访问器(None 守卫 + x.Next,零行为变化): · llvmlite/__module.vp: globalvariable_get_next(读) · llvmlite/__builder.vp: phiincoming_set_next / switchcase_set_next(写) · mlirlite 同形镜像同步(保持"逐名同形"不变量,MLIR 侧 llvmlite.→mlirlite. 重命名可编译) 并在两库 __init__.vp 的 from-import 列表登记导出。
This commit is contained in:
1 parent
987f91ce32
commit
832e570e1a
6 files changed
+80
-3
No files matched your search
@@ -1751,6 +1751,18 @@ def new_phi_incoming(pool: memhub.MemBuddy*,
|
||||
return ptr
|
||||
|
||||
|
||||
def phiincoming_set_next(inc: rawptr[PhiIncoming], nxt: rawptr[PhiIncoming]):
|
||||
"""设置 phi 入边链表的下一个节点(跨模块访问器)。
|
||||
|
||||
PhiIncoming.Next 继承自泛型基类 GSListNode[PhiIncoming],泛型特化体不在
|
||||
任何 .vpi 中 ⇒ 导入侧 class_members 只有 __inherited_N 占位名,裸字段访问
|
||||
会 fail-fast。本模块内执行能正确访问该字段(与 paramnode_set_next 同一约定)。
|
||||
"""
|
||||
if inc is None:
|
||||
return
|
||||
inc.Next = nxt
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Phi 指令
|
||||
# ============================================================
|
||||
@@ -1786,6 +1798,18 @@ def new_switch_case(pool: memhub.MemBuddy*,
|
||||
return ptr
|
||||
|
||||
|
||||
def switchcase_set_next(sc: rawptr[SwitchCase], nxt: rawptr[SwitchCase]):
|
||||
"""设置 switch case 链表的下一个节点(跨模块访问器)。
|
||||
|
||||
SwitchCase.Next 继承自泛型基类 GSListNode[SwitchCase],泛型特化体不在任何
|
||||
.vpi 中 ⇒ 导入侧 class_members 只有 __inherited_N 占位名,裸字段访问会
|
||||
fail-fast。本模块内执行能正确访问该字段(与 paramnode_set_next 同一约定)。
|
||||
"""
|
||||
if sc is None:
|
||||
return
|
||||
sc.Next = nxt
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Switch 指令
|
||||
# ============================================================
|
||||
|
||||
@@ -39,6 +39,7 @@ from .__module import (
|
||||
module_set_named_type_packed,
|
||||
module_set_target, module_set_datalayout,
|
||||
module_add_di_node, module_add_named_metadata,
|
||||
globalvariable_get_next,
|
||||
global_set_constant, global_set_linkage, global_set_unnamed_addr, global_set_section,
|
||||
LLVMModulePrint, OUTPUT_FULL, OUTPUT_STUB, OUTPUT_TEXT,
|
||||
module_ensure_opaque_for_type,
|
||||
@@ -59,7 +60,8 @@ from .__builder import (
|
||||
build_gep, build_gep_array, build_gep_struct,
|
||||
build_phi, build_switch, build_select, build_unreachable,
|
||||
build_atomicrmw, build_cmpxchg, build_inline_asm, build_va_arg,
|
||||
PhiIncoming, new_phi_incoming, SwitchCase, new_switch_case,
|
||||
PhiIncoming, new_phi_incoming, SwitchCase, new_switch_case,
|
||||
phiincoming_set_next, switchcase_set_next,
|
||||
ICMP_EQ, ICMP_NE, ICMP_SGT, ICMP_SGE, ICMP_SLT, ICMP_SLE,
|
||||
ICMP_UGT, ICMP_UGE, ICMP_ULT, ICMP_ULE,
|
||||
FCMP_FALSE, FCMP_OEQ, FCMP_OGT, FCMP_OGE, FCMP_OLT, FCMP_OLE,
|
||||
|
||||
@@ -588,6 +588,19 @@ def module_add_global(mod: rawptr[LLVMModule], gv: rawptr[GlobalVariable]):
|
||||
mod.add_global(gv)
|
||||
|
||||
|
||||
def globalvariable_get_next(gv: rawptr[GlobalVariable]) -> rawptr[GlobalVariable]:
|
||||
"""获取链表中的下一个全局变量(跨模块访问器)。
|
||||
|
||||
GlobalVariable.Next 继承自泛型基类 GSListNode[GlobalVariable],而泛型特化体
|
||||
不在任何 .vpi 中 ⇒ 导入侧 class_members 只有 __inherited_N 占位名,裸字段
|
||||
访问会 fail-fast("属性 'Next' 在类 'GlobalVariable' 中找不到")。本模块内
|
||||
执行能正确访问该字段,与 paramnode_get_next/value_get_next 同一约定。
|
||||
"""
|
||||
if gv is None:
|
||||
return None
|
||||
return gv.Next
|
||||
|
||||
|
||||
def module_set_target(mod: rawptr[LLVMModule], triple: str):
|
||||
mod.set_target(triple)
|
||||
|
||||
|
||||
@@ -1687,6 +1687,18 @@ def new_phi_incoming(pool: memhub.MemBuddy*,
|
||||
return ptr
|
||||
|
||||
|
||||
def phiincoming_set_next(inc: rawptr[PhiIncoming], nxt: rawptr[PhiIncoming]):
|
||||
"""设置 phi 入边链表的下一个节点(跨模块访问器)。
|
||||
|
||||
PhiIncoming.Next 继承自泛型基类 GSListNode[PhiIncoming],泛型特化体不在任何
|
||||
.vpi 中 ⇒ 导入侧 class_members 只有 __inherited_N 占位名,裸字段访问会
|
||||
fail-fast。本模块内执行能正确访问该字段(与 llvmlite 同形镜像同名同义)。
|
||||
"""
|
||||
if inc is None:
|
||||
return
|
||||
inc.Next = nxt
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Phi 指令
|
||||
# ============================================================
|
||||
@@ -1722,6 +1734,18 @@ def new_switch_case(pool: memhub.MemBuddy*,
|
||||
return ptr
|
||||
|
||||
|
||||
def switchcase_set_next(sc: rawptr[SwitchCase], nxt: rawptr[SwitchCase]):
|
||||
"""设置 switch case 链表的下一个节点(跨模块访问器)。
|
||||
|
||||
SwitchCase.Next 继承自泛型基类 GSListNode[SwitchCase],泛型特化体不在任何
|
||||
.vpi 中 ⇒ 导入侧 class_members 只有 __inherited_N 占位名,裸字段访问会
|
||||
fail-fast。本模块内执行能正确访问该字段(与 llvmlite 同形镜像同名同义)。
|
||||
"""
|
||||
if sc is None:
|
||||
return
|
||||
sc.Next = nxt
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Switch 指令
|
||||
# ============================================================
|
||||
|
||||
@@ -45,7 +45,8 @@ from .__function import (
|
||||
)
|
||||
from .__module import (
|
||||
LLVMModule, GlobalVariable, NamedTypeNode, new_module, new_global_variable,
|
||||
module_add_function, module_add_global, module_add_named_type,
|
||||
module_add_function, module_add_global, module_add_named_type,
|
||||
globalvariable_get_next,
|
||||
module_set_named_type_packed,
|
||||
module_set_target, module_set_datalayout,
|
||||
global_set_constant, global_set_linkage, global_set_unnamed_addr, global_set_section,
|
||||
@@ -67,7 +68,8 @@ from .__builder import (
|
||||
build_gep, build_gep_array, build_gep_struct,
|
||||
build_phi, build_switch, build_select, build_unreachable,
|
||||
build_atomicrmw, build_cmpxchg, build_inline_asm, build_va_arg,
|
||||
PhiIncoming, new_phi_incoming, SwitchCase, new_switch_case,
|
||||
PhiIncoming, new_phi_incoming, SwitchCase, new_switch_case,
|
||||
phiincoming_set_next, switchcase_set_next,
|
||||
ICMP_EQ, ICMP_NE, ICMP_SGT, ICMP_SGE, ICMP_SLT, ICMP_SLE,
|
||||
ICMP_UGT, ICMP_UGE, ICMP_ULT, ICMP_ULE,
|
||||
FCMP_FALSE, FCMP_OEQ, FCMP_OGT, FCMP_OGE, FCMP_OLT, FCMP_OLE,
|
||||
|
||||
@@ -409,6 +409,18 @@ def module_add_global(mod: rawptr[LLVMModule], gv: rawptr[GlobalVariable]):
|
||||
mod.add_global(gv)
|
||||
|
||||
|
||||
def globalvariable_get_next(gv: rawptr[GlobalVariable]) -> rawptr[GlobalVariable]:
|
||||
"""获取链表中的下一个全局变量(跨模块访问器)。
|
||||
|
||||
GlobalVariable.Next 继承自泛型基类 GSListNode[GlobalVariable],泛型特化体不在
|
||||
任何 .vpi 中 ⇒ 导入侧 class_members 只有 __inherited_N 占位名,裸字段访问会
|
||||
fail-fast。本模块内执行能正确访问该字段(与 llvmlite 同形镜像同名同义)。
|
||||
"""
|
||||
if gv is None:
|
||||
return None
|
||||
return gv.Next
|
||||
|
||||
|
||||
def module_set_target(mod: rawptr[LLVMModule], triple: str):
|
||||
mod.set_target(triple)
|
||||
|
||||
|
||||
Reference in new issue
Block a user