LLVM  15.0.0git
SSAContext.cpp
Go to the documentation of this file.
1 //===- SSAContext.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 LLVM IR.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #include "llvm/IR/SSAContext.h"
16 #include "llvm/IR/BasicBlock.h"
17 #include "llvm/IR/Function.h"
18 #include "llvm/IR/Instruction.h"
20 #include "llvm/IR/Value.h"
22 
23 using namespace llvm;
24 
26  return &F.getEntryBlock();
27 }
28 
29 void SSAContext::setFunction(Function &Fn) { F = &Fn; }
30 
32  return Printable([V](raw_ostream &Out) { V->print(Out); });
33 }
34 
36  return print(cast<Value>(Inst));
37 }
38 
40  if (BB->hasName())
41  return Printable([BB](raw_ostream &Out) { Out << BB->getName(); });
42 
43  return Printable([BB](raw_ostream &Out) {
44  ModuleSlotTracker MST{BB->getParent()->getParent(), false};
45  MST.incorporateFunction(*BB->getParent());
46  Out << MST.getLocalSlot(BB);
47  });
48 }
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
print
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
Definition: ArchiveWriter.cpp:189
llvm::Function
Definition: Function.h:60
llvm::ModuleSlotTracker
Manage lifetime of a slot tracker for printing IR.
Definition: ModuleSlotTracker.h:44
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
Instruction.h
llvm::Instruction
Definition: Instruction.h:42
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::GenericSSAContext< Function >::print
Printable print(BasicBlock *Block) const
Definition: SSAContext.cpp:39
llvm::GenericSSAContext< Function >::getEntryBlock
static BasicBlock * getEntryBlock(Function &F)
Definition: SSAContext.cpp:25
BasicBlock.h
llvm::Value::print
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
Definition: AsmWriter.cpp:4586
getParent
static const Function * getParent(const Value *V)
Definition: BasicAliasAnalysis.cpp:845
Function.h
SSAContext.h
llvm::Printable
Simple wrapper around std::function<void(raw_ostream&)>.
Definition: Printable.h:38
ModuleSlotTracker.h
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
raw_ostream.h
llvm::GenericSSAContext< Function >::setFunction
void setFunction(Function &Fn)
Definition: SSAContext.cpp:29
Value.h
llvm::Value
LLVM Value Representation.
Definition: Value.h:74