[all-commits] [llvm/llvm-project] c0cdd2: Introduce CfgTraits abstraction
Nicolai Hähnle via All-commits
all-commits at lists.llvm.org
Tue Oct 20 04:51:27 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: c0cdd22c72fab47a3c37b5a8401763995cadaa77
https://github.com/llvm/llvm-project/commit/c0cdd22c72fab47a3c37b5a8401763995cadaa77
Author: Nicolai Hähnle <nicolai.haehnle at amd.com>
Date: 2020-10-20 (Tue, 20 Oct 2020)
Changed paths:
M clang/include/clang/Analysis/Analyses/Dominators.h
A llvm/include/llvm/CodeGen/MachineCfgTraits.h
M llvm/include/llvm/IR/CFG.h
A llvm/include/llvm/Support/CfgTraits.h
M llvm/lib/CodeGen/CMakeLists.txt
A llvm/lib/CodeGen/MachineCfgTraits.cpp
A llvm/lib/IR/CFG.cpp
M llvm/lib/IR/CMakeLists.txt
M llvm/lib/Support/CMakeLists.txt
A llvm/lib/Support/CfgTraits.cpp
M llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
M mlir/include/mlir/IR/Dominance.h
Log Message:
-----------
Introduce CfgTraits abstraction
The CfgTraits abstraction simplfies writing algorithms that are
generic over the type of CFG, and enables writing such algorithms
as regular non-template code that operates on opaque references
to CFG blocks and values.
Implementations of CfgTraits provide operations on the concrete
CFG types, e.g. `IrCfgTraits::BlockRef` is `BasicBlock *`.
CfgInterface is an abstract base class which provides operations
on opaque types CfgBlockRef and CfgValueRef. Those opaque types
encapsulate a `void *`, but the meaning depends on the concrete
CFG type. For example, MachineCfgTraits -- for use with MachineIR
in SSA form -- encodes a Register inside CfgValueRef. Converting
between concrete references and opaque/generic ones is done by
CfgTraits::{fromGeneric,toGeneric}. Convenience methods
CfgTraits::{un}wrap{Iterator,Range} are available as well.
Writing algorithms in terms of CfgInterface adds some overhead
(virtual method calls, plus in same cases it removes the
opportunity to inline iterators), but can be much more convenient
since generic algorithms can be written as non-templates.
This patch adds implementations of CfgTraits for all CFGs on
which dominator trees are calculated, so that the dominator
tree can be ported to this machinery. Only IrCfgTraits (LLVM IR)
and MachineCfgTraits (Machine IR in SSA form) are complete, the
other implementations are limited to the absolute minimum
required to make the upcoming dominator tree changes work.
v5:
- fix MachineCfgTraits::blockdef_iterator and allow it to iterate over
the instructions in a bundle
- use MachineBasicBlock::printName
v6:
- implement predecessors/successors for all CfgTraits implementations
- fix error in unwrapRange
- rename toGeneric/fromGeneric into wrapRef/unwrapRef to have naming
that is consistent with {wrap,unwrap}{Iterator,Range}
- use getVRegDef instead of getUniqueVRegDef
v7:
- std::forward fix in wrapping_iterator
- fix typos
v8:
- cleanup operators on CfgOpaqueType
- address other review comments
Change-Id: Ia75f4f268fded33fca11218a7d578c9aec1f3f4d
Differential Revision: https://reviews.llvm.org/D83088
More information about the All-commits
mailing list