LLVM
20.0.0git
lib
CodeGen
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
"
20
#include "
llvm/ADT/PostOrderIterator.h
"
21
#include "
llvm/CodeGen/MachineFunctionPass.h
"
22
#include "
llvm/InitializePasses.h
"
23
24
using namespace
llvm
;
25
26
namespace
llvm
{
27
extern
char
&
MIRNamerID
;
28
}
// namespace llvm
29
30
#define DEBUG_TYPE "mir-namer"
31
32
namespace
{
33
34
class
MIRNamer :
public
MachineFunctionPass
{
35
public
:
36
static
char
ID
;
37
MIRNamer() :
MachineFunctionPass
(
ID
) {}
38
39
StringRef
getPassName
()
const override
{
40
return
"Rename virtual register operands"
;
41
}
42
43
void
getAnalysisUsage
(
AnalysisUsage
&AU)
const override
{
44
AU.
setPreservesCFG
();
45
MachineFunctionPass::getAnalysisUsage
(AU);
46
}
47
48
bool
runOnMachineFunction
(
MachineFunction
&MF)
override
{
49
bool
Changed =
false
;
50
51
if
(MF.
empty
())
52
return
Changed;
53
54
VRegRenamer
Renamer(MF.
getRegInfo
());
55
56
unsigned
BBIndex = 0;
57
ReversePostOrderTraversal<MachineBasicBlock *>
RPOT(&*MF.
begin
());
58
for
(
auto
&
MBB
: RPOT)
59
Changed |= Renamer.
renameVRegs
(
MBB
, BBIndex++);
60
61
return
Changed;
62
}
63
};
64
65
}
// end anonymous namespace
66
67
char
MIRNamer::ID;
68
69
char
&
llvm::MIRNamerID
= MIRNamer::ID;
70
71
INITIALIZE_PASS_BEGIN
(MIRNamer,
"mir-namer"
,
"Rename Register Operands"
,
false
,
72
false
)
73
74
INITIALIZE_PASS_END
(MIRNamer, "mir-
namer
", "Rename
Register
Operands
",
false
,
75
false
)
MBB
MachineBasicBlock & MBB
Definition:
ARMSLSHardening.cpp:71
InitializePasses.h
Operands
mir Rename Register Operands
Definition:
MIRNamerPass.cpp:74
namer
mir namer
Definition:
MIRNamerPass.cpp:74
MIRVRegNamerUtils.h
MachineFunctionPass.h
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition:
PassSupport.h:57
INITIALIZE_PASS_BEGIN
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition:
PassSupport.h:52
PostOrderIterator.h
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition:
PassAnalysisSupport.h:47
llvm::AnalysisUsage::setPreservesCFG
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition:
Pass.cpp:256
llvm::MachineFunctionPass
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Definition:
MachineFunctionPass.h:30
llvm::MachineFunctionPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition:
MachineFunctionPass.cpp:169
llvm::MachineFunctionPass::runOnMachineFunction
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
llvm::MachineFunction
Definition:
MachineFunction.h:257
llvm::MachineFunction::getRegInfo
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Definition:
MachineFunction.h:728
llvm::MachineFunction::begin
iterator begin()
Definition:
MachineFunction.h:927
llvm::MachineFunction::empty
bool empty() const
Definition:
MachineFunction.h:938
llvm::Pass::getPassName
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Definition:
Pass.cpp:81
llvm::Register
Wrapper class representing virtual and physical registers.
Definition:
Register.h:19
llvm::ReversePostOrderTraversal
Definition:
PostOrderIterator.h:295
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:
StringRef.h:50
llvm::VRegRenamer
VRegRenamer - This class is used for renaming vregs in a machine basic block according to semantics o...
Definition:
MIRVRegNamerUtils.h:34
llvm::VRegRenamer::renameVRegs
bool renameVRegs(MachineBasicBlock *MBB, unsigned BBNum)
Same as the above, but sets a BBNum depending on BB traversal that will be used as prefix for the vre...
Definition:
MIRVRegNamerUtils.h:89
unsigned
false
Definition:
StackSlotColoring.cpp:194
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition:
CallingConv.h:24
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:18
llvm::MIRNamerID
char & MIRNamerID
Definition:
MIRNamerPass.cpp:69
Generated on Wed Nov 20 2024 05:38:05 for LLVM by
1.9.6