blob: e94901449a1050be35591c15966e0fda66175e2a [file] [log] [blame]
Jim Grosbachbaf120f2010-12-01 03:45:07 +00001//===-- ARMAsmPrinter.h - Print machine code to an ARM .s file ------------===//
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//
10// ARM Assembly printer class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef ARMASMPRINTER_H
15#define ARMASMPRINTER_H
16
17#include "ARM.h"
18#include "ARMTargetMachine.h"
19#include "llvm/CodeGen/AsmPrinter.h"
20#include "llvm/Support/Compiler.h"
21
22namespace llvm {
23
24namespace ARM {
25 enum DW_ISA {
26 DW_ISA_ARM_thumb = 1,
27 DW_ISA_ARM_arm = 2
28 };
29}
30
31class LLVM_LIBRARY_VISIBILITY ARMAsmPrinter : public AsmPrinter {
32
33 /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
34 /// make the right decision when printing asm code for different targets.
35 const ARMSubtarget *Subtarget;
36
37 /// AFI - Keep a pointer to ARMFunctionInfo for the current
38 /// MachineFunction.
39 ARMFunctionInfo *AFI;
40
41 /// MCP - Keep a pointer to constantpool entries of the current
42 /// MachineFunction.
43 const MachineConstantPool *MCP;
44
45public:
46 explicit ARMAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
47 : AsmPrinter(TM, Streamer), AFI(NULL), MCP(NULL) {
48 Subtarget = &TM.getSubtarget<ARMSubtarget>();
49 }
50
51 virtual const char *getPassName() const {
52 return "ARM Assembly Printer";
53 }
54
55 void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O,
56 const char *Modifier = 0);
57
58 virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
59 unsigned AsmVariant, const char *ExtraCode,
60 raw_ostream &O);
61 virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
62 unsigned AsmVariant,
63 const char *ExtraCode, raw_ostream &O);
64
65 void EmitJumpTable(const MachineInstr *MI);
66 void EmitJump2Table(const MachineInstr *MI);
67 virtual void EmitInstruction(const MachineInstr *MI);
68 bool runOnMachineFunction(MachineFunction &F);
69
70 virtual void EmitConstantPool() {} // we emit constant pools customly!
71 virtual void EmitFunctionEntryLabel();
72 void EmitStartOfAsmFile(Module &M);
73 void EmitEndOfAsmFile(Module &M);
74
75private:
76 // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile()
77 void emitAttributes();
78
79 // Helper for ELF .o only
80 void emitARMAttributeSection();
81
Anton Korobeynikov4d728602011-01-01 20:38:38 +000082 // Generic helper used to emit e.g. ARMv5 mul pseudos
83 void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc);
84
Anton Korobeynikov57caad72011-03-05 18:43:32 +000085 void EmitUnwindingInstruction(const MachineInstr *MI);
86
Jim Grosbachbaf120f2010-12-01 03:45:07 +000087public:
88 void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
89
90 MachineLocation getDebugValueLocation(const MachineInstr *MI) const;
91
Devang Patel27f5acb2011-04-21 22:48:26 +000092 /// EmitDwarfRegOp - Emit dwarf register operation.
Devang Patel0c998612011-04-26 00:12:46 +000093 virtual void EmitDwarfRegOp(const MachineLocation &MLoc,
94 unsigned ExtraExprSize = 0) const;
Devang Patel27f5acb2011-04-21 22:48:26 +000095
Jim Grosbachbaf120f2010-12-01 03:45:07 +000096 virtual unsigned getISAEncoding() {
97 // ARM/Darwin adds ISA to the DWARF info for each function.
98 if (!Subtarget->isTargetDarwin())
99 return 0;
100 return Subtarget->isThumb() ?
101 llvm::ARM::DW_ISA_ARM_thumb : llvm::ARM::DW_ISA_ARM_arm;
102 }
103
104 MCSymbol *GetARMSetPICJumpTableLabel2(unsigned uid, unsigned uid2,
105 const MachineBasicBlock *MBB) const;
106 MCSymbol *GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const;
107
108 MCSymbol *GetARMSJLJEHLabel(void) const;
109
Evan Cheng5de5d4b2011-01-17 08:03:18 +0000110 MCSymbol *GetARMGVSymbol(const GlobalValue *GV);
111
Jim Grosbachbaf120f2010-12-01 03:45:07 +0000112 /// EmitMachineConstantPoolValue - Print a machine constantpool value to
113 /// the .s file.
114 virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV);
115};
116} // end namespace llvm
117
118#endif