LLVM
7.0.0
lib
Bitcode
Reader
ValueList.h
Go to the documentation of this file.
1
//===-- Bitcode/Reader/ValueList.h - Number values --------------*- C++ -*-===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This class gives values and types Unique ID's.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_LIB_BITCODE_READER_VALUELIST_H
15
#define LLVM_LIB_BITCODE_READER_VALUELIST_H
16
17
#include "
llvm/IR/ValueHandle.h
"
18
#include <cassert>
19
#include <utility>
20
#include <vector>
21
22
namespace
llvm
{
23
24
class
Constant
;
25
class
LLVMContext;
26
class
Type
;
27
class
Value;
28
29
class
BitcodeReaderValueList
{
30
std::vector<WeakTrackingVH> ValuePtrs;
31
32
/// As we resolve forward-referenced constants, we add information about them
33
/// to this vector. This allows us to resolve them in bulk instead of
34
/// resolving each reference at a time. See the code in
35
/// ResolveConstantForwardRefs for more information about this.
36
///
37
/// The key of this vector is the placeholder constant, the value is the slot
38
/// number that holds the resolved value.
39
using
ResolveConstantsTy = std::vector<std::pair<Constant *, unsigned>>;
40
ResolveConstantsTy ResolveConstants;
41
LLVMContext
&Context;
42
43
public
:
44
BitcodeReaderValueList
(
LLVMContext
&
C
) : Context(C) {}
45
46
~BitcodeReaderValueList
() {
47
assert
(ResolveConstants.empty() &&
"Constants not resolved?"
);
48
}
49
50
// vector compatibility methods
51
unsigned
size
()
const
{
return
ValuePtrs.size(); }
52
void
resize
(
unsigned
N
) { ValuePtrs.resize(N); }
53
void
push_back
(
Value
*V) { ValuePtrs.emplace_back(V); }
54
55
void
clear
() {
56
assert
(ResolveConstants.empty() &&
"Constants not resolved?"
);
57
ValuePtrs.clear();
58
}
59
60
Value
*
operator[]
(
unsigned
i)
const
{
61
assert
(i < ValuePtrs.size());
62
return
ValuePtrs[i];
63
}
64
65
Value
*
back
()
const
{
return
ValuePtrs.back(); }
66
void
pop_back
() { ValuePtrs.pop_back(); }
67
bool
empty
()
const
{
return
ValuePtrs.empty(); }
68
69
void
shrinkTo
(
unsigned
N
) {
70
assert
(N <=
size
() &&
"Invalid shrinkTo request!"
);
71
ValuePtrs.resize(N);
72
}
73
74
Constant
*
getConstantFwdRef
(
unsigned
Idx,
Type
*Ty);
75
Value
*
getValueFwdRef
(
unsigned
Idx,
Type
*Ty);
76
77
void
assignValue
(
Value
*V,
unsigned
Idx);
78
79
/// Once all constants are read, this method bulk resolves any forward
80
/// references.
81
void
resolveConstantForwardRefs
();
82
};
83
84
}
// end namespace llvm
85
86
#endif // LLVM_LIB_BITCODE_READER_VALUELIST_H
C
uint64_t CallInst * C
Definition:
NVVMIntrRange.cpp:67
llvm
Compute iterated dominance frontiers using a linear time algorithm.
Definition:
AllocatorList.h:24
llvm::BitcodeReaderValueList::BitcodeReaderValueList
BitcodeReaderValueList(LLVMContext &C)
Definition:
ValueList.h:44
llvm::BitcodeReaderValueList::shrinkTo
void shrinkTo(unsigned N)
Definition:
ValueList.h:69
llvm::BitcodeReaderValueList::getValueFwdRef
Value * getValueFwdRef(unsigned Idx, Type *Ty)
Definition:
ValueList.cpp:113
llvm::BitcodeReaderValueList::operator[]
Value * operator[](unsigned i) const
Definition:
ValueList.h:60
llvm::BitcodeReaderValueList::pop_back
void pop_back()
Definition:
ValueList.h:66
llvm::BitcodeReaderValueList::empty
bool empty() const
Definition:
ValueList.h:67
llvm::BitcodeReaderValueList::back
Value * back() const
Definition:
ValueList.h:65
llvm::BitcodeReaderValueList::push_back
void push_back(Value *V)
Definition:
ValueList.h:53
llvm::BitcodeReaderValueList::size
unsigned size() const
Definition:
ValueList.h:51
llvm::BitcodeReaderValueList::assignValue
void assignValue(Value *V, unsigned Idx)
Definition:
ValueList.cpp:69
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed...
Definition:
Type.h:46
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition:
LLVMContext.h:69
llvm::Constant
This is an important base class in LLVM.
Definition:
Constant.h:42
llvm::BitcodeReaderValueList::resolveConstantForwardRefs
void resolveConstantForwardRefs()
Once all constants are read, this method bulk resolves any forward references.
Definition:
ValueList.cpp:144
llvm::BitcodeReaderValueList::getConstantFwdRef
Constant * getConstantFwdRef(unsigned Idx, Type *Ty)
Definition:
ValueList.cpp:97
llvm::BitcodeReaderValueList::~BitcodeReaderValueList
~BitcodeReaderValueList()
Definition:
ValueList.h:46
llvm::BitcodeReaderValueList
Definition:
ValueList.h:29
llvm::HexagonII::Type
Type
Definition:
HexagonDepITypes.h:15
llvm::BitcodeReaderValueList::clear
void clear()
Definition:
ValueList.h:55
ValueHandle.h
llvm::BitcodeReaderValueList::resize
void resize(unsigned N)
Definition:
ValueList.h:52
N
#define N
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::Value
LLVM Value Representation.
Definition:
Value.h:73
llvm::ISD::Constant
Definition:
ISDOpcodes.h:61
Generated on Thu Aug 23 2018 18:52:56 for LLVM by
1.8.13