LLVM 17.0.0git
RISCVTargetStreamer.cpp
Go to the documentation of this file.
1//===-- RISCVTargetStreamer.cpp - RISCV 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 RISCV 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
42 unsigned IntValue,
43 StringRef StringValue) {}
45 assert(ABI != RISCVABI::ABI_Unknown && "Improperly initialized target ABI");
46 TargetABI = ABI;
47}
48
50 if (STI.hasFeature(RISCV::FeatureRVE))
51 report_fatal_error("Codegen not yet implemented for RVE");
52
54
55 auto ParseResult = RISCVFeatures::parseFeatureBits(
56 STI.hasFeature(RISCV::Feature64Bit), STI.getFeatureBits());
57 if (!ParseResult) {
58 report_fatal_error(ParseResult.takeError());
59 } else {
60 auto &ISAInfo = *ParseResult;
61 emitTextAttribute(RISCVAttrs::ARCH, ISAInfo->toString());
62 }
63}
64
65// This part is for ascii assembly output
68 : RISCVTargetStreamer(S), OS(OS) {}
69
71 OS << "\t.option\tpush\n";
72}
73
75 OS << "\t.option\tpop\n";
76}
77
79 OS << "\t.option\tpic\n";
80}
81
83 OS << "\t.option\tnopic\n";
84}
85
87 OS << "\t.option\trvc\n";
88}
89
91 OS << "\t.option\tnorvc\n";
92}
93
95 OS << "\t.option\trelax\n";
96}
97
99 OS << "\t.option\tnorelax\n";
100}
101
103 OS << "\t.variant_cc\t" << Symbol.getName() << "\n";
104}
105
106void RISCVTargetAsmStreamer::emitAttribute(unsigned Attribute, unsigned Value) {
107 OS << "\t.attribute\t" << Attribute << ", " << Twine(Value) << "\n";
108}
109
110void RISCVTargetAsmStreamer::emitTextAttribute(unsigned Attribute,
112 OS << "\t.attribute\t" << Attribute << ", \"" << String << "\"\n";
113}
114
115void RISCVTargetAsmStreamer::emitIntTextAttribute(unsigned Attribute,
116 unsigned IntValue,
117 StringRef StringValue) {}
118
119void RISCVTargetAsmStreamer::finishAttributeSection() {}
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
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:41
Target specific streamer interface.
Definition: MCStreamer.h:93
RISCVTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS)
void emitDirectiveVariantCC(MCSymbol &Symbol) override
virtual void emitDirectiveOptionNoRelax()
void emitTargetAttributes(const MCSubtargetInfo &STI)
virtual void emitAttribute(unsigned Attribute, unsigned Value)
virtual void emitTextAttribute(unsigned Attribute, StringRef String)
virtual void emitDirectiveVariantCC(MCSymbol &Symbol)
virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue, StringRef StringValue)
void setTargetABI(RISCVABI::ABI ABI)
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:145