Why should I know this?

Backend 주요 로직 모음 본문

LLVM-STUDY/BACKEND

Backend 주요 로직 모음

die4taoam 2024. 3. 19. 01:39
    SmallVector<Register, 8> WorkList;
    WorkList.push_back(RetagReg);

    while (!WorkList.empty()) {
      Register UseReg = WorkList.pop_back_val();
      for (auto &UseI : MRI->use_instructions(UseReg)) {
        unsigned Opcode = UseI.getOpcode();
        if (Opcode == AArch64::STGi || Opcode == AArch64::ST2Gi ||
            Opcode == AArch64::STZGi || Opcode == AArch64::STZ2Gi ||
            Opcode == AArch64::STGPi || Opcode == AArch64::STGloop ||
            Opcode == AArch64::STZGloop || Opcode == AArch64::STGloop_wback ||
            Opcode == AArch64::STZGloop_wback)
          continue;
        if (UseI.isCopy()) {
          Register DstReg = UseI.getOperand(0).getReg();
          if (DstReg.isVirtual())
            WorkList.push_back(DstReg);
          continue;
        }
        LLVM_DEBUG(dbgs() << "[" << ST.FI << ":" << ST.Tag << "] use of %"
                          << Register::virtReg2Index(UseReg) << " in " << UseI
                          << "\n");
        Score++;
      }
    }

Peephole 최적화에서 자주 보던 패턴. AArch64 Backend에 맞게 구성되어 있다.

 

 

Comments