44 InitialArchString = (*ParseResult)->toString();
45 ArchString = InitialArchString;
51 std::unique_ptr<MCAsmBackend> MAB,
52 std::unique_ptr<MCObjectWriter> MOW,
53 std::unique_ptr<MCCodeEmitter> MCE)
61 if (Arch == ArchString)
63 ArchString = std::string(Arch);
68 ArchStringStack.push_back(ArchString);
72 if (!ArchStringStack.empty())
85void RISCVTargetELFStreamer::emitAttribute(
unsigned Attribute,
unsigned Value) {
89void RISCVTargetELFStreamer::emitTextAttribute(
unsigned Attribute,
94void RISCVTargetELFStreamer::emitIntTextAttribute(
unsigned Attribute,
115 unsigned EFlags = W.getELFHeaderEFlags();
150 W.setELFHeaderEFlags(EFlags);
154 AttributeSection =
nullptr;
155 ArchString = InitialArchString;
156 ArchStringStack.
clear();
160 if (!InitialArchString.empty())
171 LastMappingSymbols.clear();
173 MappingSymbolArch.clear();
174 LastEmittedArch.clear();
175 LastEmittedArchInSection.clear();
181void RISCVELFStreamer::emitDataMappingSymbol() {
182 if (LastEMS == EMS_Data)
184 emitMappingSymbol(
"$d");
188void RISCVELFStreamer::emitInstructionsMappingSymbol() {
197 LastEMS != EMS_Instructions || LastEmittedArch != MappingSymbolArch;
199 if (MappingSymbolArch.empty())
200 emitMappingSymbol(
"$x");
202 emitMappingSymbol(
"$x" + MappingSymbolArch);
203 LastEmittedArch = MappingSymbolArch;
205 LastEMS = EMS_Instructions;
208void RISCVELFStreamer::emitMappingSymbol(
StringRef Name) {
217 MappingSymbolArch = std::string(Arch);
227 LastMappingSymbols[Prev] = LastEMS;
228 LastEmittedArchInSection[Prev] = LastEmittedArch;
229 LastEMS = LastMappingSymbols.lookup(Section);
230 auto It = LastEmittedArchInSection.find(Section);
231 LastEmittedArch = It != LastEmittedArchInSection.end() ? It->second :
"";
238 emitInstructionsMappingSymbol();
243 emitDataMappingSymbol();
249 emitDataMappingSymbol();
255 emitDataMappingSymbol();
260 std::unique_ptr<MCAsmBackend> &&MAB,
261 std::unique_ptr<MCObjectWriter> &&MOW,
262 std::unique_ptr<MCCodeEmitter> &&MCE) {
276 NoteAlign =
Align(8);
280 NoteAlign =
Align(4);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Functions, function parameters, and return types can have attributes to indicate how they should be t...
MCAsmBackend & getBackend() const
LLVM_ABI bool registerSymbol(const MCSymbol &Symbol)
Context object for machine code objects.
LLVM_ABI MCSymbol * createLocalSymbol(StringRef Name)
Create a local, non-temporary symbol like an ELF mapping symbol.
SmallVector< AttributeItem, 64 > Contents
void emitAttributesSection(StringRef Vendor, const Twine &Section, unsigned Type, MCSection *&AttributeSection)
void changeSection(MCSection *Section, uint32_t Subsection=0) override
This is called by popSection and switchSection, if the current section changes.
void setAttributeItems(unsigned Attribute, unsigned IntValue, StringRef StringValue, bool OverwriteExisting)
ELFObjectWriter & getWriter()
void setAttributeItem(unsigned Attribute, unsigned Value, bool OverwriteExisting)
void reset() override
state management
void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
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.
MCAssembler & getAssembler()
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.
MCSectionSubPair getPreviousSection() const
Return the previous section that the streamer is emitting code to.
virtual bool popSection()
Restore the current and previous section from the section stack.
MCContext & getContext() const
virtual void emitValueToAlignment(Align Alignment, int64_t Fill=0, uint8_t FillLen=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
MCTargetStreamer * getTargetStreamer()
virtual void emitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers.
void pushSection()
Save the current and previous section on the section stack.
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
This class represents success/failure for parsing-like operations that find it important to chain tog...
void setMappingSymbolArch(StringRef Arch)
void changeSection(MCSection *Section, uint32_t Subsection) override
This is called by popSection and switchSection, if the current section changes.
void emitBytes(StringRef Data) override
Emit the bytes in Data into the output.
RISCVELFStreamer(MCContext &C, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > MOW, std::unique_ptr< MCCodeEmitter > MCE)
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc) override
Emit Size bytes worth of the value specified by FillValue.
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.
void setArchString(StringRef Arch) override
void emitDirectiveOptionExact() override
void emitDirectiveOptionPop() override
void emitDirectiveOptionPush() override
void emitDirectiveOptionNoPIC() override
void emitDirectiveOptionNoRVC() override
void emitNoteGnuPropertySection(const uint32_t Feature1And)
void emitDirectiveOptionNoExact() override
RISCVTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
void emitDirectiveVariantCC(MCSymbol &Symbol) override
void emitDirectiveOptionRelax() override
RISCVELFStreamer & getStreamer()
void emitDirectiveOptionNoRelax() override
void emitDirectiveOptionPIC() override
void emitDirectiveOptionRVC() override
RISCVABI::ABI getTargetABI() const
void setFlagsFromFeatures(const MCSubtargetInfo &STI)
void setTargetABI(RISCVABI::ABI ABI)
RISCVTargetStreamer(MCStreamer &S)
virtual void finishAttributeSection()
Represents a location in source code.
Represent a constant reference to a string, i.e.
Triple - Helper class for working with autoconf configuration names.
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
@ GNU_PROPERTY_RISCV_FEATURE_1_AND
@ EF_RISCV_FLOAT_ABI_SINGLE
@ EF_RISCV_FLOAT_ABI_DOUBLE
ABI computeTargetABI(const MCSubtargetInfo &STI, StringRef ABIName)
llvm::Expected< std::unique_ptr< RISCVISAInfo > > parseFeatureBits(const MCSubtargetInfo &STI)
This is an optimization pass for GlobalISel generic memory operations.
MCStreamer * createRISCVELFStreamer(const Triple &, MCContext &C, std::unique_ptr< MCAsmBackend > &&MAB, std::unique_ptr< MCObjectWriter > &&MOW, std::unique_ptr< MCCodeEmitter > &&MCE)
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.
This struct is a compact representation of a valid (non-zero power of two) alignment.