LLVM 19.0.0git
ARCAsmPrinter.cpp
Go to the documentation of this file.
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.
11//
12//===----------------------------------------------------------------------===//
13
14#include "ARC.h"
15#include "ARCMCInstLower.h"
16#include "ARCSubtarget.h"
17#include "ARCTargetMachine.h"
22#include "llvm/MC/MCAsmInfo.h"
23#include "llvm/MC/MCInst.h"
24#include "llvm/MC/MCStreamer.h"
27
28using namespace llvm;
29
30#define DEBUG_TYPE "asm-printer"
31
32namespace {
33
34class ARCAsmPrinter : public AsmPrinter {
35 ARCMCInstLower MCInstLowering;
36
37public:
38 explicit ARCAsmPrinter(TargetMachine &TM,
39 std::unique_ptr<MCStreamer> Streamer)
40 : AsmPrinter(TM, std::move(Streamer)),
41 MCInstLowering(&OutContext, *this) {}
42
43 StringRef getPassName() const override { return "ARC Assembly Printer"; }
44 void emitInstruction(const MachineInstr *MI) override;
45
46 bool runOnMachineFunction(MachineFunction &MF) override;
47};
48
49} // end anonymous namespace
50
51void ARCAsmPrinter::emitInstruction(const MachineInstr *MI) {
52 ARC_MC::verifyInstructionPredicates(MI->getOpcode(),
53 getSubtargetInfo().getFeatureBits());
54
57
58 switch (MI->getOpcode()) {
59 case ARC::DBG_VALUE:
60 llvm_unreachable("Should be handled target independently");
61 break;
62 }
63
64 MCInst TmpInst;
65 MCInstLowering.Lower(MI, TmpInst);
66 EmitToStreamer(*OutStreamer, TmpInst);
67}
68
69bool ARCAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
70 // Functions are 4-byte aligned.
73}
74
75// Force static initialization.
78}
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCAsmPrinter()
This file contains the declaration of the ARCInstPrinter class, which is used to print ARC MCInst to ...
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:135
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
IRTranslator LLVM IR MI
const char LLVMTargetMachineRef TM
This class is used to lower an MachineInstr into an MCInst.
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:84
virtual void emitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
Definition: AsmPrinter.h:567
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
Definition: AsmPrinter.h:395
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
void ensureAlignment(Align A)
ensureAlignment - Make sure the function is at least A bytes aligned.
Representation of each machine instruction.
Definition: MachineInstr.h:69
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Definition: Pass.cpp:81
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:76
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:690
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Target & getTheARCTarget()
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...