LLVM
4.0.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
llvm.src
include
llvm
MC
ConstantPools.h
Go to the documentation of this file.
1
//===- ConstantPool.h - Keep track of assembler-generated ------*- 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 file declares the ConstantPool and AssemblerConstantPools classes.
11
//
12
//===----------------------------------------------------------------------===//
13
14
15
#ifndef LLVM_MC_CONSTANTPOOLS_H
16
#define LLVM_MC_CONSTANTPOOLS_H
17
18
#include "
llvm/ADT/MapVector.h
"
19
#include "
llvm/ADT/SmallVector.h
"
20
#include "
llvm/Support/SMLoc.h
"
21
22
namespace
llvm {
23
class
MCContext;
24
class
MCExpr;
25
class
MCSection;
26
class
MCStreamer;
27
class
MCSymbol
;
28
class
MCSymbolRefExpr;
29
30
struct
ConstantPoolEntry
{
31
ConstantPoolEntry
(
MCSymbol
*
L
,
const
MCExpr
*Val,
unsigned
Sz,
SMLoc
Loc_)
32
:
Label
(L),
Value
(Val),
Size
(Sz),
Loc
(Loc_) {}
33
MCSymbol
*
Label
;
34
const
MCExpr
*
Value
;
35
unsigned
Size
;
36
SMLoc
Loc
;
37
};
38
39
// A class to keep track of assembler-generated constant pools that are use to
40
// implement the ldr-pseudo.
41
class
ConstantPool
{
42
typedef
SmallVector<ConstantPoolEntry, 4>
EntryVecTy
;
43
EntryVecTy
Entries;
44
DenseMap<int64_t, const MCSymbolRefExpr *>
CachedEntries;
45
46
public
:
47
// Initialize a new empty constant pool
48
ConstantPool
() {}
49
50
// Add a new entry to the constant pool in the next slot.
51
// \param Value is the new entry to put in the constant pool.
52
// \param Size is the size in bytes of the entry
53
//
54
// \returns a MCExpr that references the newly inserted value
55
const
MCExpr
*
addEntry
(
const
MCExpr
*
Value
,
MCContext
&
Context
,
56
unsigned
Size,
SMLoc
Loc);
57
58
// Emit the contents of the constant pool using the provided streamer.
59
void
emitEntries
(
MCStreamer
&Streamer);
60
61
// Return true if the constant pool is empty
62
bool
empty
();
63
};
64
65
class
AssemblerConstantPools
{
66
// Map type used to keep track of per-Section constant pools used by the
67
// ldr-pseudo opcode. The map associates a section to its constant pool. The
68
// constant pool is a vector of (label, value) pairs. When the ldr
69
// pseudo is parsed we insert a new (label, value) pair into the constant pool
70
// for the current section and add MCSymbolRefExpr to the new label as
71
// an opcode to the ldr. After we have parsed all the user input we
72
// output the (label, value) pairs in each constant pool at the end of the
73
// section.
74
//
75
// We use the MapVector for the map type to ensure stable iteration of
76
// the sections at the end of the parse. We need to iterate over the
77
// sections in a stable order to ensure that we have print the
78
// constant pools in a deterministic order when printing an assembly
79
// file.
80
typedef
MapVector<MCSection *, ConstantPool>
ConstantPoolMapTy
;
81
ConstantPoolMapTy
ConstantPools;
82
83
public
:
84
void
emitAll
(
MCStreamer
&Streamer);
85
void
emitForCurrentSection
(
MCStreamer
&Streamer);
86
const
MCExpr
*
addEntry
(
MCStreamer
&Streamer,
const
MCExpr
*Expr,
87
unsigned
Size,
SMLoc
Loc);
88
89
private
:
90
ConstantPool
*getConstantPool(
MCSection
*
Section
);
91
ConstantPool
&getOrCreateConstantPool(
MCSection
*Section);
92
};
93
}
// end namespace llvm
94
95
#endif
L
MachineLoop * L
Definition:
HexagonEarlyIfConv.cpp:232
MapVector.h
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition:
MCSection.h:40
llvm::ConstantPoolEntry::Value
const MCExpr * Value
Definition:
ConstantPools.h:34
Context
LLVMContext & Context
Definition:
NVVMIntrRange.cpp:72
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition:
MCSymbol.h:39
llvm::ConstantPoolEntry
Definition:
ConstantPools.h:30
llvm::DenseMap
Definition:
DenseMap.h:583
llvm::MapVector< MCSection *, ConstantPool >
llvm::ISD::MCSymbol
Definition:
ISDOpcodes.h:139
llvm::ConstantPoolEntry::Loc
SMLoc Loc
Definition:
ConstantPools.h:36
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition:
MCExpr.h:34
llvm::ConstantPoolEntry::ConstantPoolEntry
ConstantPoolEntry(MCSymbol *L, const MCExpr *Val, unsigned Sz, SMLoc Loc_)
Definition:
ConstantPools.h:31
llvm::MCContext
Context object for machine code objects.
Definition:
MCContext.h:51
SMLoc.h
llvm::ConstantPool::ConstantPool
ConstantPool()
Definition:
ConstantPools.h:48
llvm::ConstantPool::addEntry
const MCExpr * addEntry(const MCExpr *Value, MCContext &Context, unsigned Size, SMLoc Loc)
Definition:
ConstantPools.cpp:37
llvm::MCStreamer
Streaming machine code generation interface.
Definition:
MCStreamer.h:161
llvm::AssemblerConstantPools
Definition:
ConstantPools.h:65
llvm::AssemblerConstantPools::emitForCurrentSection
void emitForCurrentSection(MCStreamer &Streamer)
Definition:
ConstantPools.cpp:91
llvm::AssemblerConstantPools::addEntry
const MCExpr * addEntry(MCStreamer &Streamer, const MCExpr *Expr, unsigned Size, SMLoc Loc)
Definition:
ConstantPools.cpp:98
llvm::AssemblerConstantPools::emitAll
void emitAll(MCStreamer &Streamer)
Definition:
ConstantPools.cpp:81
llvm::ARMBuildAttrs::Section
Legacy Tags.
Definition:
ARMBuildAttributes.h:76
llvm::ConstantPool
Definition:
ConstantPools.h:41
llvm::ConstantPoolEntry::Label
MCSymbol * Label
Definition:
ConstantPools.h:33
llvm::SmallVector< ConstantPoolEntry, 4 >
llvm::ConstantPool::emitEntries
void emitEntries(MCStreamer &Streamer)
Definition:
ConstantPools.cpp:24
llvm::Value
LLVM Value Representation.
Definition:
Value.h:71
SmallVector.h
llvm::ConstantPoolEntry::Size
unsigned Size
Definition:
ConstantPools.h:35
llvm::SMLoc
Represents a location in source code.
Definition:
SMLoc.h:24
llvm::ConstantPool::empty
bool empty()
Definition:
ConstantPools.cpp:55
Generated on Wed Mar 8 2017 17:07:20 for LLVM by
1.8.6