LLVM
15.0.0git
lib
Bitcode
Reader
ValueList.h
Go to the documentation of this file.
1
//===-- Bitcode/Reader/ValueList.h - Number values --------------*- 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 class gives values and types Unique ID's.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_LIB_BITCODE_READER_VALUELIST_H
14
#define LLVM_LIB_BITCODE_READER_VALUELIST_H
15
16
#include "
llvm/IR/ValueHandle.h
"
17
#include <cassert>
18
#include <utility>
19
#include <vector>
20
21
namespace
llvm
{
22
23
class
Constant
;
24
class
Error
;
25
class
LLVMContext;
26
class
Type
;
27
class
Value
;
28
29
class
BitcodeReaderValueList
{
30
/// Maps Value ID to pair of Value* and Type ID.
31
std::vector<std::pair<WeakTrackingVH, unsigned>> ValuePtrs;
32
33
/// As we resolve forward-referenced constants, we add information about them
34
/// to this vector. This allows us to resolve them in bulk instead of
35
/// resolving each reference at a time. See the code in
36
/// ResolveConstantForwardRefs for more information about this.
37
///
38
/// The key of this vector is the placeholder constant, the value is the slot
39
/// number that holds the resolved value.
40
using
ResolveConstantsTy = std::vector<std::pair<Constant *, unsigned>>;
41
ResolveConstantsTy ResolveConstants;
42
LLVMContext
&Context;
43
44
/// Maximum number of valid references. Forward references exceeding the
45
/// maximum must be invalid.
46
unsigned
RefsUpperBound;
47
48
public
:
49
BitcodeReaderValueList
(
LLVMContext
&
C
,
size_t
RefsUpperBound)
50
:
Context
(
C
),
51
RefsUpperBound(
std
::
min
((
size_t
)
std
::numeric_limits<unsigned>::
max
(),
52
RefsUpperBound)) {}
53
54
~BitcodeReaderValueList
() {
55
assert
(ResolveConstants.empty() &&
"Constants not resolved?"
);
56
}
57
58
// vector compatibility methods
59
unsigned
size
()
const
{
return
ValuePtrs.size(); }
60
void
resize
(
unsigned
N
) {
61
ValuePtrs.resize(
N
);
62
}
63
void
push_back
(
Value
*V,
unsigned
TypeID
) {
64
ValuePtrs.emplace_back(V,
TypeID
);
65
}
66
67
void
clear
() {
68
assert
(ResolveConstants.empty() &&
"Constants not resolved?"
);
69
ValuePtrs.clear();
70
}
71
72
Value
*
operator[]
(
unsigned
i
)
const
{
73
assert
(
i
< ValuePtrs.size());
74
return
ValuePtrs[
i
].first;
75
}
76
77
unsigned
getTypeID
(
unsigned
ValNo)
const
{
78
assert
(ValNo < ValuePtrs.size());
79
return
ValuePtrs[ValNo].second;
80
}
81
82
Value
*
back
()
const
{
return
ValuePtrs.back().first; }
83
void
pop_back
() {
84
ValuePtrs.pop_back();
85
}
86
bool
empty
()
const
{
return
ValuePtrs.empty(); }
87
88
void
shrinkTo
(
unsigned
N
) {
89
assert
(
N
<=
size
() &&
"Invalid shrinkTo request!"
);
90
ValuePtrs.resize(
N
);
91
}
92
93
Constant
*
getConstantFwdRef
(
unsigned
Idx,
Type
*Ty,
unsigned
TyID);
94
Value
*
getValueFwdRef
(
unsigned
Idx,
Type
*Ty,
unsigned
TyID);
95
96
Error
assignValue
(
unsigned
Idx,
Value
*V,
unsigned
TypeID
);
97
98
/// Once all constants are read, this method bulk resolves any forward
99
/// references.
100
void
resolveConstantForwardRefs
();
101
};
102
103
}
// end namespace llvm
104
105
#endif // LLVM_LIB_BITCODE_READER_VALUELIST_H
i
i
Definition:
README.txt:29
llvm::BitcodeReaderValueList::operator[]
Value * operator[](unsigned i) const
Definition:
ValueList.h:72
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:17
llvm::lltok::Error
@ Error
Definition:
LLToken.h:21
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:
Type.h:45
size_t
Context
LLVMContext & Context
Definition:
NVVMIntrRange.cpp:66
llvm::BitcodeReaderValueList::clear
void clear()
Definition:
ValueList.h:67
llvm::ISD::Constant
@ Constant
Definition:
ISDOpcodes.h:76
C
(vector float) vec_cmpeq(*A, *B) C
Definition:
README_ALTIVEC.txt:86
llvm::BitcodeReaderValueList::getTypeID
unsigned getTypeID(unsigned ValNo) const
Definition:
ValueList.h:77
TypeID
Type::TypeID TypeID
Definition:
Mips16HardFloat.cpp:102
llvm::BitcodeReaderValueList
Definition:
ValueList.h:29
llvm::Constant
This is an important base class in LLVM.
Definition:
Constant.h:41
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition:
LLVMContext.h:68
llvm::BitcodeReaderValueList::back
Value * back() const
Definition:
ValueList.h:82
llvm::BitcodeReaderValueList::push_back
void push_back(Value *V, unsigned TypeID)
Definition:
ValueList.h:63
llvm::BitcodeReaderValueList::assignValue
Error assignValue(unsigned Idx, Value *V, unsigned TypeID)
Definition:
ValueList.cpp:64
TemplateParamKind::Type
@ Type
llvm::BitcodeReaderValueList::getConstantFwdRef
Constant * getConstantFwdRef(unsigned Idx, Type *Ty, unsigned TyID)
Definition:
ValueList.cpp:100
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::BitcodeReaderValueList::empty
bool empty() const
Definition:
ValueList.h:86
llvm::BitcodeReaderValueList::resize
void resize(unsigned N)
Definition:
ValueList.h:60
llvm::BitcodeReaderValueList::resolveConstantForwardRefs
void resolveConstantForwardRefs()
Once all constants are read, this method bulk resolves any forward references.
Definition:
ValueList.cpp:153
llvm::BitcodeReaderValueList::pop_back
void pop_back()
Definition:
ValueList.h:83
llvm::BitcodeReaderValueList::size
unsigned size() const
Definition:
ValueList.h:59
llvm::BitcodeReaderValueList::getValueFwdRef
Value * getValueFwdRef(unsigned Idx, Type *Ty, unsigned TyID)
Definition:
ValueList.cpp:121
llvm::min
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition:
FileCheck.cpp:357
ValueHandle.h
llvm::BitcodeReaderValueList::BitcodeReaderValueList
BitcodeReaderValueList(LLVMContext &C, size_t RefsUpperBound)
Definition:
ValueList.h:49
std
Definition:
BitVector.h:851
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition:
Error.h:155
llvm::BitcodeReaderValueList::shrinkTo
void shrinkTo(unsigned N)
Definition:
ValueList.h:88
llvm::TargetStackID::Value
Value
Definition:
TargetFrameLowering.h:27
N
#define N
llvm::max
Align max(MaybeAlign Lhs, Align Rhs)
Definition:
Alignment.h:340
llvm::BitcodeReaderValueList::~BitcodeReaderValueList
~BitcodeReaderValueList()
Definition:
ValueList.h:54
llvm::Value
LLVM Value Representation.
Definition:
Value.h:74
Generated on Wed May 25 2022 04:15:04 for LLVM by
1.8.17