LLVM: lib/Target/CSKY/MCTargetDesc/CSKYELFStreamer.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_LIB_TARGET_CSKY_CSKYELFSTREAMER_H
10#define LLVM_LIB_TARGET_CSKY_CSKYELFSTREAMER_H
11
16
17namespace llvm {
18
20private:
21 enum class AttributeType { Hidden, Numeric, Text, NumericAndText };
22
23 struct AttributeItem {
24 AttributeType Type;
25 unsigned Tag;
26 unsigned IntValue;
27 std::string StringValue;
28 };
29
32
33 MCSection *AttributeSection = nullptr;
34
35 AttributeItem *getAttributeItem(unsigned Attribute) {
36 for (size_t i = 0; i < Contents.size(); ++i)
38 return &Contents[i];
39 return nullptr;
40 }
41
42 void setAttributeItem(unsigned Attribute, unsigned Value,
43 bool OverwriteExisting) {
44
45 if (AttributeItem *Item = getAttributeItem(Attribute)) {
46 if (!OverwriteExisting)
47 return;
48 Item->Type = AttributeType::Numeric;
49 Item->IntValue = Value;
50 return;
51 }
52
53
54 Contents.push_back({AttributeType::Numeric, Attribute, Value, ""});
55 }
56
58 bool OverwriteExisting) {
59
60 if (AttributeItem *Item = getAttributeItem(Attribute)) {
61 if (!OverwriteExisting)
62 return;
63 Item->Type = AttributeType::Text;
64 Item->StringValue = std::string(Value);
65 return;
66 }
67
68
69 Contents.push_back({AttributeType::Text, Attribute, 0, std::string(Value)});
70 }
71
72 void setAttributeItems(unsigned Attribute, unsigned IntValue,
73 StringRef StringValue, bool OverwriteExisting) {
74
75 if (AttributeItem *Item = getAttributeItem(Attribute)) {
76 if (!OverwriteExisting)
77 return;
78 Item->Type = AttributeType::NumericAndText;
79 Item->IntValue = IntValue;
80 Item->StringValue = std::string(StringValue);
81 return;
82 }
83
84
85 Contents.push_back({AttributeType::NumericAndText, Attribute, IntValue,
86 std::string(StringValue)});
87 }
88
89 void emitAttribute(unsigned Attribute, unsigned Value) override;
92 size_t calculateContentSize() const;
93
94 void emitTargetAttributes(const MCSubtargetInfo &STI) override;
95
96public:
99};
100
102 void EmitMappingSymbol(StringRef Name);
103
104public:
106
108
110
112 std::unique_ptr OW,
113 std::unique_ptr Emitter)
117
119
122 EmitMappingSymbol("$d");
124 }
126 EmitMappingSymbol("$d");
128 }
131 EmitMappingSymbol("$t");
133 }
135 EmitMappingSymbol("$d");
137 }
142};
143
144}
145#endif
dxil DXContainer Global Emitter
Functions, function parameters, and return types can have attributes to indicate how they should be t...
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
Definition CSKYELFStreamer.h:129
void emitBytes(StringRef Data) override
Emit the bytes in Data into the output.
Definition CSKYELFStreamer.h:125
CSKYELFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > TAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter)
Definition CSKYELFStreamer.h:111
void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override
Emit the expression Value into the output as a native integer of the given Size bytes.
Definition CSKYELFStreamer.h:134
friend class CSKYTargetELFStreamer
Definition CSKYELFStreamer.h:105
ElfMappingSymbol State
Definition CSKYELFStreamer.h:109
void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc) override
Emit Size bytes worth of the value specified by FillValue.
Definition CSKYELFStreamer.h:120
~CSKYELFStreamer() override=default
ElfMappingSymbol
Definition CSKYELFStreamer.h:107
@ EMS_Data
Definition CSKYELFStreamer.h:107
@ EMS_None
Definition CSKYELFStreamer.h:107
@ EMS_Text
Definition CSKYELFStreamer.h:107
void reset() override
State management.
Definition CSKYELFStreamer.h:138
MCELFStreamer & getStreamer()
CSKYTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
virtual void finishAttributeSection()
CSKYTargetStreamer(MCStreamer &S)
Context object for machine code objects.
void reset() override
state management
MCELFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > TAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter)
Base class for the full range of assembler expressions which are needed for parsing.
Instances of this class represent a single low-level machine instruction.
void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc=SMLoc()) override
Emit Size bytes worth of the value specified by FillValue.
void emitBytes(StringRef Data) override
Emit the bytes in Data into the output.
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc()) override
Emit the expression Value into the output as a native integer of the given Size bytes.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Streaming machine code generation interface.
Generic base class for all target subtargets.
Represents a location in source code.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.