LLVM  10.0.0
VEAsmPrinter.cpp
Go to the documentation of this file.
1 //===-- VEAsmPrinter.cpp - VE LLVM assembly writer ------------------------===//
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 GAS-format VE assembly language.
11 //
12 //===----------------------------------------------------------------------===//
13 
16 #include "VE.h"
17 #include "VEInstrInfo.h"
18 #include "VETargetMachine.h"
24 #include "llvm/IR/Mangler.h"
25 #include "llvm/MC/MCAsmInfo.h"
26 #include "llvm/MC/MCContext.h"
27 #include "llvm/MC/MCInst.h"
28 #include "llvm/MC/MCInstBuilder.h"
29 #include "llvm/MC/MCStreamer.h"
30 #include "llvm/MC/MCSymbol.h"
33 using namespace llvm;
34 
35 #define DEBUG_TYPE "ve-asmprinter"
36 
37 namespace {
38 class VEAsmPrinter : public AsmPrinter {
39  VETargetStreamer &getTargetStreamer() {
40  return static_cast<VETargetStreamer &>(*OutStreamer->getTargetStreamer());
41  }
42 
43 public:
44  explicit VEAsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
45  : AsmPrinter(TM, std::move(Streamer)) {}
46 
47  StringRef getPassName() const override { return "VE Assembly Printer"; }
48 
49  void EmitInstruction(const MachineInstr *MI) override;
50 
51  static const char *getRegisterName(unsigned RegNo) {
52  return VEInstPrinter::getRegisterName(RegNo);
53  }
54 };
55 } // end of anonymous namespace
56 
57 void VEAsmPrinter::EmitInstruction(const MachineInstr *MI) {
58 
59  switch (MI->getOpcode()) {
60  default:
61  break;
62  case TargetOpcode::DBG_VALUE:
63  // FIXME: Debug Value.
64  return;
65  }
68  do {
69  MCInst TmpInst;
70  LowerVEMachineInstrToMCInst(&*I, TmpInst, *this);
71  EmitToStreamer(*OutStreamer, TmpInst);
72  } while ((++I != E) && I->isInsideBundle()); // Delay slot check.
73 }
74 
75 // Force static initialization.
76 extern "C" void LLVMInitializeVEAsmPrinter() {
78 }
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
instr_iterator instr_end()
This class represents lattice values for constants.
Definition: AllocatorList.h:23
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Definition: MachineInstr.h:426
static std::string getRegisterName(const TargetRegisterInfo *TRI, unsigned Reg)
Definition: MIParser.cpp:1125
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:158
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:80
void LLVMInitializeVEAsmPrinter()
self_iterator getIterator()
Definition: ilist_node.h:81
Target & getTheVETarget()
Iterator for intrusive lists based on ilist_node.
const MachineBasicBlock * getParent() const
Definition: MachineInstr.h:271
Representation of each machine instruction.
Definition: MachineInstr.h:63
void LowerVEMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP)
#define I(x, y, z)
Definition: MD5.cpp:58
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:65
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:54
static const char * getRegisterName(unsigned RegNo)