LLVM 18.0.0git
RISCVTargetStreamer.cpp
Go to the documentation of this file.
1//===-- RISCVTargetStreamer.cpp - RISC-V Target Streamer Methods ----------===//
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// This file provides RISC-V specific target streamer methods.
10//
11//===----------------------------------------------------------------------===//
12
13#include "RISCVTargetStreamer.h"
14#include "RISCVBaseInfo.h"
15#include "RISCVMCTargetDesc.h"
16#include "llvm/MC/MCSymbol.h"
20
21using namespace llvm;
22
24
27
44 unsigned IntValue,
45 StringRef StringValue) {}
47 assert(ABI != RISCVABI::ABI_Unknown && "Improperly initialized target ABI");
48 TargetABI = ABI;
49}
50
52 bool EmitStackAlign) {
53 if (STI.hasFeature(RISCV::FeatureRVE))
54 report_fatal_error("Codegen not yet implemented for RVE");
55
56 if (EmitStackAlign)
58
59 auto ParseResult = RISCVFeatures::parseFeatureBits(
60 STI.hasFeature(RISCV::Feature64Bit), STI.getFeatureBits());
61 if (!ParseResult) {
62 report_fatal_error(ParseResult.takeError());
63 } else {
64 auto &ISAInfo = *ParseResult;
65 emitTextAttribute(RISCVAttrs::ARCH, ISAInfo->toString());
66 }
67}
68
69// This part is for ascii assembly output
72 : RISCVTargetStreamer(S), OS(OS) {}
73
75 OS << "\t.option\tpush\n";
76}
77
79 OS << "\t.option\tpop\n";
80}
81
83 OS << "\t.option\tpic\n";
84}
85
87 OS << "\t.option\tnopic\n";
88}
89
91 OS << "\t.option\trvc\n";
92}
93
95 OS << "\t.option\tnorvc\n";
96}
97
99 OS << "\t.option\trelax\n";
100}
101
103 OS << "\t.option\tnorelax\n";
104}
105
108 OS << "\t.option\tarch";
109 for (const auto &Arg : Args) {
110 OS << ", ";
111 switch (Arg.Type) {
113 break;
115 OS << "+";
116 break;
118 OS << "-";
119 break;
120 }
121 OS << Arg.Value;
122 }
123 OS << "\n";
124}
125
127 OS << "\t.variant_cc\t" << Symbol.getName() << "\n";
128}
129
130void RISCVTargetAsmStreamer::emitAttribute(unsigned Attribute, unsigned Value) {
131 OS << "\t.attribute\t" << Attribute << ", " << Twine(Value) << "\n";
132}
133
134void RISCVTargetAsmStreamer::emitTextAttribute(unsigned Attribute,
136 OS << "\t.attribute\t" << Attribute << ", \"" << String << "\"\n";
137}
138
139void RISCVTargetAsmStreamer::emitIntTextAttribute(unsigned Attribute,
140 unsigned IntValue,
141 StringRef StringValue) {}
142
143void RISCVTargetAsmStreamer::finishAttributeSection() {}
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Streaming machine code generation interface.
Definition: MCStreamer.h:212
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
const FeatureBitset & getFeatureBits() const
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
void emitDirectiveOptionArch(ArrayRef< RISCVOptionArchArg > Args) override
RISCVTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS)
void emitDirectiveVariantCC(MCSymbol &Symbol) override
virtual void emitDirectiveOptionNoRelax()
virtual void emitAttribute(unsigned Attribute, unsigned Value)
virtual void emitTextAttribute(unsigned Attribute, StringRef String)
virtual void emitDirectiveVariantCC(MCSymbol &Symbol)
void emitTargetAttributes(const MCSubtargetInfo &STI, bool EmitStackAlign)
virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue, StringRef StringValue)
void setTargetABI(RISCVABI::ABI ABI)
virtual void emitDirectiveOptionArch(ArrayRef< RISCVOptionArchArg > Args)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
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...
llvm::Expected< std::unique_ptr< RISCVISAInfo > > parseFeatureBits(bool IsRV64, const FeatureBitset &FeatureBits)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:156