LLVM 19.0.0git
XtensaAsmPrinter.cpp
Go to the documentation of this file.
1//===- XtensaAsmPrinter.cpp Xtensa LLVM Assembly Printer ------------------===//
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 Xtensa assembly language.
11//
12//===----------------------------------------------------------------------===//
13
14#include "XtensaAsmPrinter.h"
19#include "llvm/MC/MCExpr.h"
21#include "llvm/MC/MCStreamer.h"
22#include "llvm/MC/MCSymbol.h"
23#include "llvm/MC/MCSymbolELF.h"
25
26using namespace llvm;
27
29 MCInst LoweredMI;
30 lowerToMCInst(MI, LoweredMI);
31 EmitToStreamer(*OutStreamer, LoweredMI);
32}
33
35 unsigned Offset) const {
37
38 switch (MOTy) {
40 // Ignore all implicit register operands.
41 if (MO.isImplicit())
42 break;
43 return MCOperand::createReg(MO.getReg());
45 return MCOperand::createImm(MO.getImm() + Offset);
47 break;
48 default:
49 report_fatal_error("unknown operand type");
50 }
51
52 return MCOperand();
53}
54
56 MCInst &OutMI) const {
57 OutMI.setOpcode(MI->getOpcode());
58
59 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
60 const MachineOperand &MO = MI->getOperand(i);
61 MCOperand MCOp = lowerOperand(MO);
62
63 if (MCOp.isValid())
64 OutMI.addOperand(MCOp);
65 }
66}
67
70}
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:135
IRTranslator LLVM IR MI
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXtensaAsmPrinter()
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
Definition: AsmPrinter.cpp:418
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:99
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
void addOperand(const MCOperand Op)
Definition: MCInst.h:210
void setOpcode(unsigned Op)
Definition: MCInst.h:197
Instances of this class represent operands of the MCInst class.
Definition: MCInst.h:36
static MCOperand createReg(unsigned Reg)
Definition: MCInst.h:134
static MCOperand createImm(int64_t Val)
Definition: MCInst.h:141
bool isValid() const
Definition: MCInst.h:60
Representation of each machine instruction.
Definition: MachineInstr.h:69
MachineOperand class - Representation of each machine instruction operand.
int64_t getImm() const
bool isImplicit() const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
Register getReg() const
getReg - Returns the register number.
@ MO_Immediate
Immediate operand.
@ MO_RegisterMask
Mask of preserved registers.
@ MO_Register
Register operand.
void lowerToMCInst(const MachineInstr *MI, MCInst &OutMI) const
void emitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
MCOperand lowerOperand(const MachineOperand &MO, unsigned Offset=0) const
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:456
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:156
Target & getTheXtensaTarget()
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...