1//===-- LoongArchTargetStreamer.cpp - LoongArch 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 LoongArch specific target streamer methods.
10//
11//===----------------------------------------------------------------------===//
12
13#include "LoongArchTargetStreamer.h"
14#include "llvm/MC/MCAsmInfo.h"
15#include "llvm/MC/MCContext.h"
16
17using namespace llvm;
18
19LoongArchTargetStreamer::LoongArchTargetStreamer(MCStreamer &S)
20 : MCTargetStreamer(S) {}
21
22void LoongArchTargetStreamer::setTargetABI(LoongArchABI::ABI ABI) {
23 assert(ABI != LoongArchABI::ABI_Unknown &&
24 "Improperly initialized target ABI");
25 TargetABI = ABI;
26}
27
28void LoongArchTargetStreamer::emitDirectiveOptionPush() {}
29void LoongArchTargetStreamer::emitDirectiveOptionPop() {}
30void LoongArchTargetStreamer::emitDirectiveOptionRelax() {}
31void LoongArchTargetStreamer::emitDirectiveOptionNoRelax() {}
32void LoongArchTargetStreamer::emitDTPRel32Value(const MCExpr *) {}
33void LoongArchTargetStreamer::emitDTPRel64Value(const MCExpr *) {}
34
35// This part is for ascii assembly output.
36LoongArchTargetAsmStreamer::LoongArchTargetAsmStreamer(
37 MCStreamer &S, formatted_raw_ostream &OS)
38 : LoongArchTargetStreamer(S), OS(OS) {}
39
40void LoongArchTargetAsmStreamer::emitDirectiveOptionPush() {
41 OS << "\t.option\tpush\n";
42}
43
44void LoongArchTargetAsmStreamer::emitDirectiveOptionPop() {
45 OS << "\t.option\tpop\n";
46}
47
48void LoongArchTargetAsmStreamer::emitDirectiveOptionRelax() {
49 OS << "\t.option\trelax\n";
50}
51
52void LoongArchTargetAsmStreamer::emitDirectiveOptionNoRelax() {
53 OS << "\t.option\tnorelax\n";
54}
55
56void LoongArchTargetAsmStreamer::emitDTPRel32Value(const MCExpr *Value) {
57 auto &MAI = getStreamer().getContext().getAsmInfo();
58 OS << "\t.dtprelword\t";
59 MAI.printExpr(OS, *Value);
60 OS << '\n';
61}
62
63void LoongArchTargetAsmStreamer::emitDTPRel64Value(const MCExpr *Value) {
64 auto &MAI = getStreamer().getContext().getAsmInfo();
65 OS << "\t.dtpreldword\t";
66 MAI.printExpr(OS, *Value);
67 OS << '\n';
68}
69