You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nudt-compiler-cpp/test_tmp/debug_slot.py

30 lines
1.1 KiB

# 检查第 222 个参数的帧槽索引
num_params = 390
num_reg_params = 8
# 模拟帧槽分配
frame_slots = []
param_to_slot = {} # 参数索引 -> 参数帧槽索引
param_to_arg_slot = {} # 参数索引 -> callee_stack_arg 帧槽索引
for param_idx in range(num_params):
# 创建参数帧槽
slot = len(frame_slots)
frame_slots.append({"type": "param", "param_idx": param_idx, "is_stack_arg": False})
param_to_slot[param_idx] = slot
# 如果参数在栈上,创建 callee_stack_arg 帧槽
if param_idx >= num_reg_params:
arg_slot = len(frame_slots)
frame_slots.append({"type": "callee_stack_arg", "param_idx": param_idx, "is_stack_arg": True})
param_to_arg_slot[param_idx] = arg_slot
# 检查第 221, 222, 223 个参数的帧槽索引
for param_idx in [220, 221, 222]:
print(f"参数索引 {param_idx} (第 {param_idx+1} 个参数):")
print(f" 参数帧槽索引: {param_to_slot[param_idx]}")
if param_idx in param_to_arg_slot:
print(f" callee_stack_arg 帧槽索引: {param_to_arg_slot[param_idx]}")
print()