forked from NUDT-compiler/nudt-compiler-cpp
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.
45 lines
1.3 KiB
45 lines
1.3 KiB
#include <iostream>
|
|
#include <vector>
|
|
|
|
// 模拟帧槽创建
|
|
int main() {
|
|
std::vector<int> frame_slots;
|
|
int gp_idx = 0;
|
|
int num_params = 120;
|
|
|
|
// LowerFunctionParams
|
|
for (int i = 0; i < num_params; i++) {
|
|
// CreateFrameIndex
|
|
int slot = frame_slots.size();
|
|
frame_slots.push_back(slot);
|
|
std::cout << "参数 " << i << ": CreateFrameIndex -> 索引 " << slot << std::endl;
|
|
|
|
// 如果是栈参数
|
|
if (gp_idx >= 8) {
|
|
int arg_slot = frame_slots.size();
|
|
frame_slots.push_back(arg_slot);
|
|
std::cout << "参数 " << i << ": CreateCalleeStackArgFrameIndex -> 索引 " << arg_slot << std::endl;
|
|
} else {
|
|
gp_idx++;
|
|
}
|
|
}
|
|
|
|
std::cout << "\nLowerFunctionParams 结束后 frame_slots 大小: " << frame_slots.size() << std::endl;
|
|
|
|
// Alloca 指令
|
|
int alloca_start = frame_slots.size();
|
|
for (int i = 0; i < num_params; i++) {
|
|
int slot = frame_slots.size();
|
|
frame_slots.push_back(slot);
|
|
}
|
|
std::cout << "Alloca 帧槽起始索引: " << alloca_start << std::endl;
|
|
|
|
// Load 指令
|
|
int load_slot = frame_slots.size();
|
|
frame_slots.push_back(load_slot);
|
|
|
|
std::cout << "最终 frame_slots 大小: " << frame_slots.size() << std::endl;
|
|
|
|
return 0;
|
|
}
|