LLVM 17.0.0git
GenericSSAContext.h
Go to the documentation of this file.
1//===- GenericSSAContext.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 defines the little GenericSSAContext<X> template class
11/// that can be used to implement IR analyses as templates.
12/// Specializing these templates allows the analyses to be used over
13/// both LLVM IR and Machine IR.
14///
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_ADT_GENERICSSACONTEXT_H
18#define LLVM_ADT_GENERICSSACONTEXT_H
19
21
22namespace llvm {
23
24template <typename _FunctionT> class GenericSSAContext {
25public:
26 // Specializations should provide the following types that are similar to how
27 // LLVM IR is structured:
28
29 // The smallest unit of the IR is a ValueT. The SSA context uses a ValueRefT,
30 // which is a pointer to a ValueT, since Machine IR does not have the
31 // equivalent of a ValueT.
32 //
33 // using ValueRefT = ...
34
35 // An InstT is a subclass of ValueT that itself defines one or more ValueT
36 // objects.
37 //
38 // using InstT = ... must be a subclass of Value
39
40 // A BlockT is a sequence of InstT, and forms a node of the CFG. It
41 // has global methods predecessors() and successors() that return
42 // the list of incoming CFG edges and outgoing CFG edges
43 // respectively.
44 //
45 // using BlockT = ...
46
47 // A FunctionT represents a CFG along with arguments and return values. It is
48 // the smallest complete unit of code in a Module.
49 //
50 // The compiler produces an error here if this class is implicitly
51 // specialized due to an instantiation. An explicit specialization
52 // of this template needs to be added before the instantiation point
53 // indicated by the compiler.
54 using FunctionT = typename _FunctionT::invalidTemplateInstanceError;
55
56 // A UseT represents a data-edge from the defining instruction to the using
57 // instruction.
58 //
59 // using UseT = ...
60
61 // Initialize the SSA context with information about the FunctionT being
62 // processed.
63 //
64 // void setFunction(FunctionT &function);
65 // FunctionT* getFunction() const;
66
67 // Every FunctionT has a unique BlockT marked as its entry.
68 //
69 // static BlockT* getEntryBlock(FunctionT &F);
70
71 // Methods to examine basic blocks and values
72 //
73 // static void appendBlockDefs(SmallVectorImpl<ValueRefT> &defs,
74 // BlockT &block);
75 // static void appendBlockDefs(SmallVectorImpl<const ValueRefT> &defs,
76 // const BlockT &block);
77
78 // static void appendBlockTerms(SmallVectorImpl<InstT *> &terms,
79 // BlockT &block);
80 // static void appendBlockTerms(SmallVectorImpl<const InstT *> &terms,
81 // const BlockT &block);
82 //
83 // static bool comesBefore(const InstT *lhs, const InstT *rhs);
84 // static bool isConstantOrUndefValuePhi(const InstT &Instr);
85 // const BlockT *getDefBlock(const ValueRefT value) const;
86
87 // Methods to print various objects.
88 //
89 // Printable print(BlockT *block) const;
90 // Printable print(InstT *inst) const;
91 // Printable print(ValueRefT value) const;
92};
93} // namespace llvm
94
95#endif // LLVM_ADT_GENERICSSACONTEXT_H
typename _FunctionT::invalidTemplateInstanceError FunctionT
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18