Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
PredIteratorCache.h
Go to the documentation of this file.
1//===- PredIteratorCache.h - pred_iterator Cache ----------------*- 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//
9// This file defines the PredIteratorCache class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_IR_PREDITERATORCACHE_H
14#define LLVM_IR_PREDITERATORCACHE_H
15
16#include "llvm/ADT/ArrayRef.h"
17#include "llvm/ADT/DenseMap.h"
18#include "llvm/ADT/SmallVector.h"
19#include "llvm/IR/CFG.h"
20#include "llvm/Support/Allocator.h"
21
22namespacellvm {
23
24/// PredIteratorCache - This class is an extremely trivial cache for
25/// predecessor iterator queries. This is useful for code that repeatedly
26/// wants the predecessor list for the same blocks.
27classPredIteratorCache {
28 /// Cached list of predecessors, allocated in Memory.
29DenseMap<BasicBlock *, ArrayRef<BasicBlock *>> BlockToPredsMap;
30
31 /// Memory - This is the space that holds cached preds.
32BumpPtrAllocatorMemory;
33
34public:
35size_tsize(BasicBlock *BB) {returnget(BB).size(); }
36ArrayRef<BasicBlock *>get(BasicBlock *BB) {
37ArrayRef<BasicBlock *> &Entry = BlockToPredsMap[BB];
38if (Entry.data())
39return Entry;
40
41SmallVector<BasicBlock *, 32> PredCache(predecessors(BB));
42BasicBlock **Data =Memory.Allocate<BasicBlock *>(PredCache.size());
43 std::copy(PredCache.begin(), PredCache.end(),Data);
44 Entry =ArrayRef(Data, PredCache.size());
45return Entry;
46 }
47
48 /// clear - Remove all information.
49voidclear() {
50 BlockToPredsMap.clear();
51Memory.Reset();
52 }
53};
54
55}// end namespace llvm
56
57#endif
Allocator.h
This file defines the BumpPtrAllocator interface.
ArrayRef.h
DenseMap.h
This file defines the DenseMap class.
CFG.h
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
SmallVector.h
This file defines the SmallVector class.
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:BasicBlock.h:61
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition:Allocator.h:66
llvm::DenseMapBase::clear
void clear()
Definition:DenseMap.h:110
llvm::DenseMap
Definition:DenseMap.h:727
llvm::PredIteratorCache
PredIteratorCache - This class is an extremely trivial cache for predecessor iterator queries.
Definition:PredIteratorCache.h:27
llvm::PredIteratorCache::size
size_t size(BasicBlock *BB)
Definition:PredIteratorCache.h:35
llvm::PredIteratorCache::clear
void clear()
clear - Remove all information.
Definition:PredIteratorCache.h:49
llvm::PredIteratorCache::get
ArrayRef< BasicBlock * > get(BasicBlock *BB)
Definition:PredIteratorCache.h:36
llvm::SmallVectorBase::size
size_t size() const
Definition:SmallVector.h:78
llvm::SmallVectorTemplateCommon::end
iterator end()
Definition:SmallVector.h:269
llvm::SmallVectorTemplateCommon::begin
iterator begin()
Definition:SmallVector.h:267
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::sys::Memory
This class provides various memory handling functions that manipulate MemoryBlock instances.
Definition:Memory.h:53
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::predecessors
auto predecessors(const MachineBasicBlock *BB)
Definition:MachineBasicBlock.h:1377
llvm::Data
@ Data
Definition:SIMachineScheduler.h:55

Generated on Thu Jul 17 2025 10:06:29 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp