LLVM 17.0.0git
SSAContext.h
Go to the documentation of this file.
1//===- SSAContext.h ---------------------------------------------*- 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 declares a specialization of the GenericSSAContext<X>
11/// class template for LLVM IR.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_IR_SSACONTEXT_H
16#define LLVM_IR_SSACONTEXT_H
17
19#include "llvm/IR/BasicBlock.h"
22
23#include <memory>
24
25namespace llvm {
26class BasicBlock;
27class Function;
28class Instruction;
29class Value;
30template <typename> class SmallVectorImpl;
31template <typename, bool> class DominatorTreeBase;
32
33inline auto instrs(const BasicBlock &BB) {
34 return llvm::make_range(BB.begin(), BB.end());
35}
36
37template <> class GenericSSAContext<Function> {
38 Function *F;
39
40public:
44 using ValueRefT = Value *;
45 using ConstValueRefT = const Value *;
48
49 void setFunction(Function &Fn);
50 Function *getFunction() const { return F; }
51
52 static BasicBlock *getEntryBlock(Function &F);
53 static const BasicBlock *getEntryBlock(const Function &F);
54
55 static void appendBlockDefs(SmallVectorImpl<Value *> &defs,
57 static void appendBlockDefs(SmallVectorImpl<const Value *> &defs,
58 const BasicBlock &block);
59
60 static void appendBlockTerms(SmallVectorImpl<Instruction *> &terms,
62 static void appendBlockTerms(SmallVectorImpl<const Instruction *> &terms,
63 const BasicBlock &block);
64
65 static bool comesBefore(const Instruction *lhs, const Instruction *rhs);
66 static bool isConstantValuePhi(const Instruction &Instr);
67 const BasicBlock *getDefBlock(const Value *value) const;
68
69 Printable print(const BasicBlock *Block) const;
70 Printable print(const Instruction *Inst) const;
71 Printable print(const Value *Value) const;
72};
73
75
76} // namespace llvm
77
78#endif // LLVM_IR_SSACONTEXT_H
Given that RA is a live value
This file defines the little GenericSSAContext<X> template class that can be used to implement IR ana...
#define F(x, y, z)
Definition: MD5.cpp:55
unify loop Fixup each natural loop to have a single exit block
LLVM Basic Block Representation.
Definition: BasicBlock.h:56
iterator end()
Definition: BasicBlock.h:316
iterator begin()
Instruction iterator methods.
Definition: BasicBlock.h:314
Core dominator tree base class.
Function * getFunction() const
Definition: SSAContext.h:50
Simple wrapper around std::function<void(raw_ostream&)>.
Definition: Printable.h:38
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:577
LLVM Value Representation.
Definition: Value.h:74
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr)
auto instrs(const MachineBasicBlock &BB)