blob: b6f9ee6ebef8fc71ccbd9c0d87c65348e02abfe1 [file] [log] [blame]
Tim Northovere0e3aef2013-01-31 12:12:40 +00001// AArch64AsmPrinter.h - Print machine code to an AArch64 .s file -*- C++ -*-=//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
Tim Northover75f436c2013-02-14 16:17:01 +000010// This file defines the AArch64 assembly printer class.
Tim Northovere0e3aef2013-01-31 12:12:40 +000011//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_AARCH64ASMPRINTER_H
15#define LLVM_AARCH64ASMPRINTER_H
16
17#include "AArch64.h"
18#include "AArch64TargetMachine.h"
19#include "llvm/CodeGen/AsmPrinter.h"
20#include "llvm/MC/MCStreamer.h"
21#include "llvm/Support/Compiler.h"
22
23namespace llvm {
24
25class MCOperand;
26
27class LLVM_LIBRARY_VISIBILITY AArch64AsmPrinter : public AsmPrinter {
28
29 /// Subtarget - Keep a pointer to the AArch64Subtarget around so that we can
30 /// make the right decision when printing asm code for different targets.
31 const AArch64Subtarget *Subtarget;
32 const MachineConstantPool *MCP;
33
34 // emitPseudoExpansionLowering - tblgen'erated.
35 bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
36 const MachineInstr *MI);
37
38 public:
39 explicit AArch64AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
40 : AsmPrinter(TM, Streamer) {
41 Subtarget = &TM.getSubtarget<AArch64Subtarget>();
42 }
43
44 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const;
45
46 MCOperand lowerSymbolOperand(const MachineOperand &MO,
47 const MCSymbol *Sym) const;
48
49 void EmitInstruction(const MachineInstr *MI);
50 void EmitEndOfAsmFile(Module &M);
51
52 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
53 unsigned AsmVariant, const char *ExtraCode,
54 raw_ostream &O);
55 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
56 unsigned AsmVariant, const char *ExtraCode,
57 raw_ostream &O);
58
59 void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
60
61 /// printSymbolicAddress - Given some kind of reasonably bare symbolic
62 /// reference, print out the appropriate asm string to represent it. If
63 /// appropriate, a relocation-specifier will be produced, composed of a
64 /// general class derived from the MO parameter and an instruction-specific
65 /// suffix, provided in Suffix. E.g. ":got_lo12:" if a Suffix of "lo12" is
66 /// given.
67 bool printSymbolicAddress(const MachineOperand &MO,
68 bool PrintImmediatePrefix,
69 StringRef Suffix, raw_ostream &O);
70
71 MachineLocation getDebugValueLocation(const MachineInstr *MI) const;
72
73 virtual const char *getPassName() const {
74 return "AArch64 Assembly Printer";
75 }
76
77 /// A no-op on AArch64 because we emit our constant pool entries inline with
78 /// the function.
79 virtual void EmitConstantPool() {}
80
81 virtual bool runOnMachineFunction(MachineFunction &MF);
82};
83} // end namespace llvm
84
85#endif