1 //===- LoongArchAsmPrinter.cpp - LoongArch LLVM Assembly Printer -*- 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 GAS-format LoongArch assembly language.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "LoongArchAsmPrinter.h"
15 #include "LoongArch.h"
16 #include "LoongArchTargetMachine.h"
17 #include "TargetInfo/LoongArchTargetInfo.h"
18 #include "llvm/CodeGen/AsmPrinter.h"
19 #include "llvm/MC/TargetRegistry.h"
20 
21 using namespace llvm;
22 
23 #define DEBUG_TYPE "loongarch-asm-printer"
24 
25 // Simple pseudo-instructions have their lowering (with expansion to real
26 // instructions) auto-generated.
27 #include "LoongArchGenMCPseudoLowering.inc"
28 
29 void LoongArchAsmPrinter::emitInstruction(const MachineInstr *MI) {
30   // Do any auto-generated pseudo lowerings.
31   if (emitPseudoExpansionLowering(*OutStreamer, MI))
32     return;
33 
34   MCInst TmpInst;
35   if (!lowerLoongArchMachineInstrToMCInst(MI, TmpInst, *this))
36     EmitToStreamer(*OutStreamer, TmpInst);
37 }
38 
39 bool LoongArchAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
40   AsmPrinter::runOnMachineFunction(MF);
41   return true;
42 }
43 
44 // Force static initialization.
45 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLoongArchAsmPrinter() {
46   RegisterAsmPrinter<LoongArchAsmPrinter> X(getTheLoongArch32Target());
47   RegisterAsmPrinter<LoongArchAsmPrinter> Y(getTheLoongArch64Target());
48 }
49