LLVM 19.0.0git
CSKYTargetStreamer.h
Go to the documentation of this file.
1//===-- CSKYTargetStreamer.h - CSKY Target Streamer ----------*- 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#ifndef LLVM_LIB_TARGET_CSKY_CSKYTARGETSTREAMER_H
10#define LLVM_LIB_TARGET_CSKY_CSKYTARGETSTREAMER_H
11
14#include "llvm/MC/MCStreamer.h"
15
16namespace llvm {
17
20 EntryVecTy Entries;
21 std::map<int64_t, const MCSymbolRefExpr *> CachedEntries;
22
23 MCSection *CurrentSection = nullptr;
24
25public:
26 // Initialize a new empty constant pool
27 CSKYConstantPool() = default;
28
29 // Add a new entry to the constant pool in the next slot.
30 // \param Value is the new entry to put in the constant pool.
31 // \param Size is the size in bytes of the entry
32 //
33 // \returns a MCExpr that references the newly inserted value
34 const MCExpr *addEntry(MCStreamer &Streamer, const MCExpr *Value,
35 unsigned Size, SMLoc Loc, const MCExpr *AdjustExpr);
36
37 void emitAll(MCStreamer &Streamer);
38
39 // Return true if the constant pool is empty
40 bool empty();
41
42 void clearCache();
43};
44
46public:
47 typedef struct {
48 const MCSymbol *sym;
51
52protected:
53 std::unique_ptr<CSKYConstantPool> ConstantPool;
54
56
57 unsigned ConstantCounter = 0;
58
59public:
61
62 virtual void emitTextAttribute(unsigned Attribute, StringRef String);
63 virtual void emitAttribute(unsigned Attribute, unsigned Value);
64 virtual void finishAttributeSection();
65
66 virtual void emitTargetAttributes(const MCSubtargetInfo &STI);
67 /// Add a new entry to the constant pool for the current section and return an
68 /// MCExpr that can be used to refer to the constant pool location.
69 const MCExpr *addConstantPoolEntry(const MCExpr *, SMLoc Loc,
70 const MCExpr *AdjustExpr = nullptr);
71
73
74 void finish() override;
75};
76
77template <> struct DenseMapInfo<CSKYTargetStreamer::SymbolIndex> {
79 return {nullptr, CSKYMCExpr::VK_CSKY_Invalid};
80 }
82 return {nullptr, CSKYMCExpr::VK_CSKY_Invalid};
83 }
87 }
90 return A.sym == B.sym && A.kind == B.kind;
91 }
92};
93
94class formatted_raw_ostream;
95
98
99 void emitAttribute(unsigned Attribute, unsigned Value) override;
100 void emitTextAttribute(unsigned Attribute, StringRef String) override;
101 void finishAttributeSection() override;
102
103public:
105 : CSKYTargetStreamer(S), OS(OS) {}
106};
107
108} // namespace llvm
109
110#endif // LLVM_LIB_TARGET_CSKY_CSKYTARGETSTREAMER_H
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
uint64_t Size
raw_pwrite_stream & OS
void emitAll(MCStreamer &Streamer)
const MCExpr * addEntry(MCStreamer &Streamer, const MCExpr *Value, unsigned Size, SMLoc Loc, const MCExpr *AdjustExpr)
CSKYTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS)
virtual void emitTextAttribute(unsigned Attribute, StringRef String)
virtual void emitTargetAttributes(const MCSubtargetInfo &STI)
DenseMap< SymbolIndex, const MCExpr * > ConstantMap
const MCExpr * addConstantPoolEntry(const MCExpr *, SMLoc Loc, const MCExpr *AdjustExpr=nullptr)
Add a new entry to the constant pool for the current section and return an MCExpr that can be used to...
std::unique_ptr< CSKYConstantPool > ConstantPool
virtual void emitAttribute(unsigned Attribute, unsigned Value)
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:35
Streaming machine code generation interface.
Definition: MCStreamer.h:212
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:40
Target specific streamer interface.
Definition: MCStreamer.h:93
Represents a location in source code.
Definition: SMLoc.h:23
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
LLVM Value Representation.
Definition: Value.h:74
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition: Hashing.h:613
static bool isEqual(const CSKYTargetStreamer::SymbolIndex &A, const CSKYTargetStreamer::SymbolIndex &B)
static unsigned getHashValue(const CSKYTargetStreamer::SymbolIndex &V)
static CSKYTargetStreamer::SymbolIndex getEmptyKey()
static CSKYTargetStreamer::SymbolIndex getTombstoneKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: DenseMapInfo.h:50