[midend][backend]同步后端逻辑,修复编译错误
This commit is contained in:
@@ -51,22 +51,28 @@ std::unique_ptr<MachineFunction> RISCv64ISel::runOnFunction(Function* func) {
|
||||
|
||||
// 指令选择主流程
|
||||
void RISCv64ISel::select() {
|
||||
// 遍历基本块,为它们创建对应的MachineBasicBlock
|
||||
for (const auto& bb_ptr : F->getBasicBlocks()) {
|
||||
auto mbb = std::make_unique<MachineBasicBlock>(bb_ptr->getName(), MFunc.get());
|
||||
bb_map[bb_ptr.get()] = mbb.get();
|
||||
MFunc->addBlock(std::move(mbb));
|
||||
}
|
||||
|
||||
if (F->getEntryBlock()) {
|
||||
for (auto* arg_alloca : F->getEntryBlock()->getArguments()) {
|
||||
getVReg(arg_alloca);
|
||||
// 遍历Argument对象,为它们分配虚拟寄存器。
|
||||
if (F) {
|
||||
for (Argument* arg : F->getArguments()) {
|
||||
// getVReg会为每个代表参数的Argument对象在vreg_map中创建一个条目。
|
||||
// 这样,当后续的store指令使用这个参数时,就能找到对应的vreg。
|
||||
getVReg(arg);
|
||||
}
|
||||
}
|
||||
|
||||
// 遍历基本块,进行指令选择
|
||||
for (const auto& bb_ptr : F->getBasicBlocks()) {
|
||||
selectBasicBlock(bb_ptr.get());
|
||||
}
|
||||
|
||||
// 链接MachineBasicBlock的前驱和后继
|
||||
for (const auto& bb_ptr : F->getBasicBlocks()) {
|
||||
CurMBB = bb_map.at(bb_ptr.get());
|
||||
for (auto succ : bb_ptr->getSuccessors()) {
|
||||
|
||||
Reference in New Issue
Block a user