123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- #pragma once
- #ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wunused-parameter"
- #endif
- #ifndef LLVM_MC_CONSTANTPOOLS_H
- #define LLVM_MC_CONSTANTPOOLS_H
- #include "llvm/ADT/MapVector.h"
- #include "llvm/ADT/SmallVector.h"
- #include "llvm/Support/SMLoc.h"
- #include <cstdint>
- #include <map>
- namespace llvm {
- class MCContext;
- class MCExpr;
- class MCSection;
- class MCStreamer;
- class MCSymbol;
- class MCSymbolRefExpr;
- struct ConstantPoolEntry {
- ConstantPoolEntry(MCSymbol *L, const MCExpr *Val, unsigned Sz, SMLoc Loc_)
- : Label(L), Value(Val), Size(Sz), Loc(Loc_) {}
- MCSymbol *Label;
- const MCExpr *Value;
- unsigned Size;
- SMLoc Loc;
- };
- class ConstantPool {
- using EntryVecTy = SmallVector<ConstantPoolEntry, 4>;
- EntryVecTy Entries;
- std::map<int64_t, const MCSymbolRefExpr *> CachedConstantEntries;
- DenseMap<const MCSymbol *, const MCSymbolRefExpr *> CachedSymbolEntries;
- public:
-
- ConstantPool() = default;
-
-
-
-
-
- const MCExpr *addEntry(const MCExpr *Value, MCContext &Context,
- unsigned Size, SMLoc Loc);
-
- void emitEntries(MCStreamer &Streamer);
-
- bool empty();
- void clearCache();
- };
- class AssemblerConstantPools {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- using ConstantPoolMapTy = MapVector<MCSection *, ConstantPool>;
- ConstantPoolMapTy ConstantPools;
- public:
- void emitAll(MCStreamer &Streamer);
- void emitForCurrentSection(MCStreamer &Streamer);
- void clearCacheForCurrentSection(MCStreamer &Streamer);
- const MCExpr *addEntry(MCStreamer &Streamer, const MCExpr *Expr,
- unsigned Size, SMLoc Loc);
- private:
- ConstantPool *getConstantPool(MCSection *Section);
- ConstantPool &getOrCreateConstantPool(MCSection *Section);
- };
- }
- #endif
- #ifdef __GNUC__
- #pragma GCC diagnostic pop
- #endif
|