LLVM  15.0.0git
MachineSSAContext.cpp
Go to the documentation of this file.
1 //===- MachineSSAContext.cpp ------------------------------------*- C++ -*-===//
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 /// \file
9 ///
10 /// This file defines a specialization of the GenericSSAContext<X>
11 /// template class for Machine IR.
12 ///
13 //===----------------------------------------------------------------------===//
14 
21 
22 using namespace llvm;
23 
25  return &F.front();
26 }
27 
29  MF = &Fn;
30  RegInfo = &MF->getRegInfo();
31 }
32 
34  return Printable([Block](raw_ostream &Out) { Block->printName(Out); });
35 }
36 
38  return Printable([I](raw_ostream &Out) { I->print(Out); });
39 }
40 
42  auto *MRI = RegInfo;
43  return Printable([MRI, Value](raw_ostream &Out) {
44  Out << printReg(Value, MRI->getTargetRegisterInfo(), 0, MRI);
45 
46  if (Value) {
47  // Try to print the definition.
48  if (auto *Instr = MRI->getUniqueVRegDef(Value)) {
49  Out << ": ";
50  Instr->print(Out);
51  }
52  }
53  });
54 }
MachineInstr.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::MachineRegisterInfo::getTargetRegisterInfo
const TargetRegisterInfo * getTargetRegisterInfo() const
Definition: MachineRegisterInfo.h:151
llvm::MachineRegisterInfo::getUniqueVRegDef
MachineInstr * getUniqueVRegDef(Register Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
Definition: MachineRegisterInfo.cpp:407
MachineBasicBlock.h
llvm::GenericSSAContext< MachineFunction >::getEntryBlock
static MachineBasicBlock * getEntryBlock(MachineFunction &F)
Definition: MachineSSAContext.cpp:24
F
#define F(x, y, z)
Definition: MD5.cpp:55
MachineRegisterInfo.h
llvm::MachineFunction::getRegInfo
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Definition: MachineFunction.h:666
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:94
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:66
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::GenericSSAContext< MachineFunction >::setFunction
void setFunction(MachineFunction &Fn)
Definition: MachineSSAContext.cpp:28
llvm::MachineFunction
Definition: MachineFunction.h:257
MachineSSAContext.h
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::GenericSSAContext< MachineFunction >::print
Printable print(MachineBasicBlock *Block) const
Definition: MachineSSAContext.cpp:33
llvm::Printable
Simple wrapper around std::function<void(raw_ostream&)>.
Definition: Printable.h:38
raw_ostream.h
MachineFunction.h
llvm::printReg
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
Definition: TargetRegisterInfo.cpp:111
llvm::Value
LLVM Value Representation.
Definition: Value.h:74