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 LoongArch_MC::verifyInstructionPredicates( 31 MI->getOpcode(), getSubtargetInfo().getFeatureBits()); 32 33 // Do any auto-generated pseudo lowerings. 34 if (emitPseudoExpansionLowering(*OutStreamer, MI)) 35 return; 36 37 MCInst TmpInst; 38 if (!lowerLoongArchMachineInstrToMCInst(MI, TmpInst, *this)) 39 EmitToStreamer(*OutStreamer, TmpInst); 40 } 41 42 bool LoongArchAsmPrinter::runOnMachineFunction(MachineFunction &MF) { 43 AsmPrinter::runOnMachineFunction(MF); 44 return true; 45 } 46 47 // Force static initialization. 48 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLoongArchAsmPrinter() { 49 RegisterAsmPrinter<LoongArchAsmPrinter> X(getTheLoongArch32Target()); 50 RegisterAsmPrinter<LoongArchAsmPrinter> Y(getTheLoongArch64Target()); 51 } 52