Revert r354244 "[DAGCombiner] Eliminate dead stores to stack."
[llvm-complete.git] / lib / Target / ARC / ARCAsmPrinter.cpp
blob487360ebc13c7f41dbf94d062fd2179b53b17a8a
1 //===- ARCAsmPrinter.cpp - ARC LLVM assembly writer -------------*- C++ -*-===//
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 contains a printer that converts from our internal representation
10 // of machine-dependent LLVM code to GNU format ARC assembly language.
12 //===----------------------------------------------------------------------===//
14 #include "ARC.h"
15 #include "ARCInstrInfo.h"
16 #include "ARCMCInstLower.h"
17 #include "ARCSubtarget.h"
18 #include "ARCTargetMachine.h"
19 #include "ARCTargetStreamer.h"
20 #include "InstPrinter/ARCInstPrinter.h"
21 #include "llvm/ADT/SmallString.h"
22 #include "llvm/ADT/StringExtras.h"
23 #include "llvm/CodeGen/AsmPrinter.h"
24 #include "llvm/CodeGen/MachineFunctionPass.h"
25 #include "llvm/CodeGen/MachineInstr.h"
26 #include "llvm/CodeGen/MachineModuleInfo.h"
27 #include "llvm/MC/MCAsmInfo.h"
28 #include "llvm/MC/MCExpr.h"
29 #include "llvm/MC/MCInst.h"
30 #include "llvm/MC/MCStreamer.h"
31 #include "llvm/MC/MCSymbolELF.h"
32 #include "llvm/Support/ErrorHandling.h"
33 #include "llvm/Support/TargetRegistry.h"
34 #include "llvm/Support/raw_ostream.h"
35 #include "llvm/Target/TargetLoweringObjectFile.h"
36 #include <algorithm>
38 using namespace llvm;
40 #define DEBUG_TYPE "asm-printer"
42 namespace {
44 class ARCAsmPrinter : public AsmPrinter {
45 ARCMCInstLower MCInstLowering;
46 ARCTargetStreamer &getTargetStreamer();
48 public:
49 explicit ARCAsmPrinter(TargetMachine &TM,
50 std::unique_ptr<MCStreamer> Streamer)
51 : AsmPrinter(TM, std::move(Streamer)),
52 MCInstLowering(&OutContext, *this) {}
54 StringRef getPassName() const override { return "ARC Assembly Printer"; }
55 void EmitInstruction(const MachineInstr *MI) override;
58 } // end anonymous namespace
60 ARCTargetStreamer &ARCAsmPrinter::getTargetStreamer() {
61 return static_cast<ARCTargetStreamer &>(*OutStreamer->getTargetStreamer());
64 void ARCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
65 SmallString<128> Str;
66 raw_svector_ostream O(Str);
68 switch (MI->getOpcode()) {
69 case ARC::DBG_VALUE:
70 llvm_unreachable("Should be handled target independently");
71 break;
74 MCInst TmpInst;
75 MCInstLowering.Lower(MI, TmpInst);
76 EmitToStreamer(*OutStreamer, TmpInst);
79 // Force static initialization.
80 extern "C" void LLVMInitializeARCAsmPrinter() {
81 RegisterAsmPrinter<ARCAsmPrinter> X(getTheARCTarget());