LLVM 22.0.0git
MIRNamerPass.cpp
Go to the documentation of this file.
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.
12//
13// Basic Usage:
14//
15// llc -o - -run-pass mir-namer example.mir
16//
17//===----------------------------------------------------------------------===//
18
19#include "MIRVRegNamerUtils.h"
23
24using namespace llvm;
25
26#define DEBUG_TYPE "mir-namer"
27
28namespace {
29
30class MIRNamer : public MachineFunctionPass {
31public:
32 static char ID;
33 MIRNamer() : MachineFunctionPass(ID) {}
34
35 StringRef getPassName() const override {
36 return "Rename virtual register operands";
37 }
38
39 void getAnalysisUsage(AnalysisUsage &AU) const override {
40 AU.setPreservesCFG();
42 }
43
44 bool runOnMachineFunction(MachineFunction &MF) override {
45 bool Changed = false;
46
47 if (MF.empty())
48 return Changed;
49
50 VRegRenamer Renamer(MF.getRegInfo());
51
53 for (const auto &[BBIndex, MBB] : enumerate(RPOT))
54 Changed |= Renamer.renameVRegs(MBB, BBIndex);
55
56 return Changed;
57 }
58};
59
60} // end anonymous namespace
61
62char MIRNamer::ID;
63
64INITIALIZE_PASS(MIRNamer, "mir-namer", "Rename Register Operands", false, false)
MachineBasicBlock & MBB
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
Represent the analysis usage information of a pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition Pass.cpp:270
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
VRegRenamer - This class is used for renaming vregs in a machine basic block according to semantics o...
Changed
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
Definition STLExtras.h:2472