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