Go to the documentation of this file.
39 MAB.getTargetOptions().getABIName()));
55 void RISCVTargetELFStreamer::emitAttribute(
unsigned Attribute,
unsigned Value) {
59 void RISCVTargetELFStreamer::emitTextAttribute(
unsigned Attribute,
61 setAttributeItem(
Attribute, String,
true);
64 void RISCVTargetELFStreamer::emitIntTextAttribute(
unsigned Attribute,
67 setAttributeItems(
Attribute, IntValue, StringValue,
71 void RISCVTargetELFStreamer::finishAttributeSection() {
75 if (AttributeSection) {
87 const size_t VendorHeaderSize = 4 + CurrentVendor.
size() + 1;
90 const size_t TagHeaderSize = 1 + 4;
92 const size_t ContentsSize = calculateContentSize();
103 for (AttributeItem item : Contents) {
108 case AttributeType::Numeric:
111 case AttributeType::Text:
115 case AttributeType::NumericAndText:
126 size_t RISCVTargetELFStreamer::calculateContentSize()
const {
128 for (AttributeItem item : Contents) {
130 case AttributeType::Hidden:
132 case AttributeType::Numeric:
136 case AttributeType::Text:
138 Result += item.StringValue.size() + 1;
140 case AttributeType::NumericAndText:
143 Result += item.StringValue.size() + 1;
158 if (Features[RISCV::FeatureStdExtC])
185 static std::pair<unsigned, unsigned> getRelocPairForSize(
unsigned Size) {
205 const auto *MBE = dyn_cast<MCBinaryExpr>(
Value);
210 if (!
Value->evaluateAsRelocatable(
E,
nullptr,
nullptr))
212 if (
E.getSymA() ==
nullptr ||
E.getSymB() ==
nullptr)
215 const auto &
A =
E.getSymA()->getSymbol();
216 const auto &
B =
E.getSymB()->getSymbol();
223 return (
A.isInSection() ?
A.getSection().hasInstructions()
224 : !
A.getName().empty()) ||
225 (
B.isInSection() ?
B.getSection().hasInstructions()
226 : !
B.getName().empty());
230 RISCVELFStreamer(
MCContext &
C, std::unique_ptr<MCAsmBackend> MAB,
231 std::unique_ptr<MCObjectWriter> MOW,
232 std::unique_ptr<MCCodeEmitter> MCE)
235 void emitValueImpl(
const MCExpr *
Value,
unsigned Size,
SMLoc Loc)
override {
237 if (!requiresFixups(getContext(),
Value, A,
B))
243 flushPendingLabels(
DF,
DF->getContents().size());
247 std::tie(Add, Sub) = getRelocPairForSize(Size);
250 DF->getContents().size(), A,
static_cast<MCFixupKind>(Add), Loc));
252 DF->getContents().size(),
B,
static_cast<MCFixupKind>(Sub), Loc));
254 DF->getContents().resize(
DF->getContents().size() + Size, 0);
261 std::unique_ptr<MCAsmBackend> MAB,
262 std::unique_ptr<MCObjectWriter> MOW,
263 std::unique_ptr<MCCodeEmitter> MCE,
265 RISCVELFStreamer *
S =
267 S->getAssembler().setRelaxAll(RelaxAll);
void emitDirectiveOptionPush() override
MCAsmBackend & getBackend() const
unsigned getELFHeaderEFlags() const
ELF e_header flags.
Generic address nodes are lowered to some combination of target independent and machine specific ABI
MCELFStreamer * createRISCVELFStreamer(MCContext &C, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > MOW, std::unique_ptr< MCCodeEmitter > MCE, bool RelaxAll)
This is an optimization pass for GlobalISel generic memory operations.
Context object for machine code objects.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
void emitInt8(uint64_t Value)
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
virtual void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Emit the expression Value into the output as a native integer of the given Size bytes.
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
void emitInt32(uint64_t Value)
void emitDirectiveOptionNoRelax() override
Container class for subtarget features.
Streaming machine code generation interface.
void emitDirectiveOptionPIC() override
Represents a location in source code.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
MCContext & getContext() const
(vector float) vec_cmpeq(*A, *B) C
const Triple & getTargetTriple() const
void emitDirectiveOptionPop() override
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
const FeatureBitset & getFeatureBits() const
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
void emitDirectiveOptionRelax() override
static const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
void setELFHeaderEFlags(unsigned Flags)
void emitDirectiveOptionNoRVC() override
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
@ EF_RISCV_FLOAT_ABI_DOUBLE
RISCVTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
MCAssembler & getAssembler()
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.
StringRef - Represent a constant reference to a string, i.e.
static void make(MCStreamer *MCOS, MCSection *Section)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
void emitDirectiveOptionNoPIC() override
@ EF_RISCV_FLOAT_ABI_SINGLE
void setTargetABI(RISCVABI::ABI ABI)
constexpr LLVM_NODISCARD size_t size() const
size - Get the string size.
MCELFStreamer & getStreamer()
ABI computeTargetABI(const Triple &TT, FeatureBitset FeatureBits, StringRef ABIName)
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
MCFixupKind
Extensible enumeration to represent the type of a fixup.
void emitULEB128IntValue(uint64_t Value, unsigned PadTo=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
void emitDirectiveOptionRVC() override
This represents an "assembler immediate".
Fragment for data and encoded instructions.
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
Generic base class for all target subtargets.
LLVM Value Representation.
Base class for the full range of assembler expressions which are needed for parsing.
RISCVABI::ABI getTargetABI() const