Revert " [LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)"
[llvm-project.git] / llvm / lib / CodeGen / MIRNamerPass.cpp
blobbc65700aba066d2f7eb7d933cb87022517226571
1 //===----------------------- MIRNamer.cpp - MIR Namer ---------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // The purpose of this pass is to rename virtual register operands with the goal
10 // of making it easier to author easier to read tests for MIR. This pass reuses
11 // the vreg renamer used by MIRCanonicalizerPass.
13 // Basic Usage:
15 // llc -o - -run-pass mir-namer example.mir
17 //===----------------------------------------------------------------------===//
19 #include "MIRVRegNamerUtils.h"
20 #include "llvm/ADT/PostOrderIterator.h"
21 #include "llvm/CodeGen/MachineFunctionPass.h"
22 #include "llvm/InitializePasses.h"
24 using namespace llvm;
26 namespace llvm {
27 extern char &MIRNamerID;
28 } // namespace llvm
30 #define DEBUG_TYPE "mir-namer"
32 namespace {
34 class MIRNamer : public MachineFunctionPass {
35 public:
36 static char ID;
37 MIRNamer() : MachineFunctionPass(ID) {}
39 StringRef getPassName() const override {
40 return "Rename virtual register operands";
43 void getAnalysisUsage(AnalysisUsage &AU) const override {
44 AU.setPreservesCFG();
45 MachineFunctionPass::getAnalysisUsage(AU);
48 bool runOnMachineFunction(MachineFunction &MF) override {
49 bool Changed = false;
51 if (MF.empty())
52 return Changed;
54 VRegRenamer Renamer(MF.getRegInfo());
56 unsigned BBIndex = 0;
57 ReversePostOrderTraversal<MachineBasicBlock *> RPOT(&*MF.begin());
58 for (auto &MBB : RPOT)
59 Changed |= Renamer.renameVRegs(MBB, BBIndex++);
61 return Changed;
65 } // end anonymous namespace
67 char MIRNamer::ID;
69 char &llvm::MIRNamerID = MIRNamer::ID;
71 INITIALIZE_PASS_BEGIN(MIRNamer, "mir-namer", "Rename Register Operands", false,
72 false)
74 INITIALIZE_PASS_END(MIRNamer, "mir-namer", "Rename Register Operands", false,
75 false)