ARMAsmPrinter.h revision 218885
1218885Sdim//===-- ARMAsmPrinter.h - Print machine code to an ARM .s file ------------===//
2218885Sdim//
3218885Sdim//                     The LLVM Compiler Infrastructure
4218885Sdim//
5218885Sdim// This file is distributed under the University of Illinois Open Source
6218885Sdim// License. See LICENSE.TXT for details.
7218885Sdim//
8218885Sdim//===----------------------------------------------------------------------===//
9218885Sdim//
10218885Sdim// ARM Assembly printer class.
11218885Sdim//
12218885Sdim//===----------------------------------------------------------------------===//
13218885Sdim
14218885Sdim#ifndef ARMASMPRINTER_H
15218885Sdim#define ARMASMPRINTER_H
16218885Sdim
17218885Sdim#include "ARM.h"
18218885Sdim#include "ARMTargetMachine.h"
19218885Sdim#include "llvm/CodeGen/AsmPrinter.h"
20218885Sdim#include "llvm/Support/Compiler.h"
21218885Sdim
22218885Sdimnamespace llvm {
23218885Sdim
24218885Sdimnamespace ARM {
25218885Sdim  enum DW_ISA {
26218885Sdim    DW_ISA_ARM_thumb = 1,
27218885Sdim    DW_ISA_ARM_arm = 2
28218885Sdim  };
29218885Sdim}
30218885Sdim
31218885Sdimclass LLVM_LIBRARY_VISIBILITY ARMAsmPrinter : public AsmPrinter {
32218885Sdim
33218885Sdim  /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
34218885Sdim  /// make the right decision when printing asm code for different targets.
35218885Sdim  const ARMSubtarget *Subtarget;
36218885Sdim
37218885Sdim  /// AFI - Keep a pointer to ARMFunctionInfo for the current
38218885Sdim  /// MachineFunction.
39218885Sdim  ARMFunctionInfo *AFI;
40218885Sdim
41218885Sdim  /// MCP - Keep a pointer to constantpool entries of the current
42218885Sdim  /// MachineFunction.
43218885Sdim  const MachineConstantPool *MCP;
44218885Sdim
45218885Sdimpublic:
46218885Sdim  explicit ARMAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
47218885Sdim    : AsmPrinter(TM, Streamer), AFI(NULL), MCP(NULL) {
48218885Sdim      Subtarget = &TM.getSubtarget<ARMSubtarget>();
49218885Sdim    }
50218885Sdim
51218885Sdim  virtual const char *getPassName() const {
52218885Sdim    return "ARM Assembly Printer";
53218885Sdim  }
54218885Sdim
55218885Sdim  void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O,
56218885Sdim                    const char *Modifier = 0);
57218885Sdim
58218885Sdim  virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
59218885Sdim                               unsigned AsmVariant, const char *ExtraCode,
60218885Sdim                               raw_ostream &O);
61218885Sdim  virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
62218885Sdim                                     unsigned AsmVariant,
63218885Sdim                                     const char *ExtraCode, raw_ostream &O);
64218885Sdim
65218885Sdim  void EmitJumpTable(const MachineInstr *MI);
66218885Sdim  void EmitJump2Table(const MachineInstr *MI);
67218885Sdim  virtual void EmitInstruction(const MachineInstr *MI);
68218885Sdim  bool runOnMachineFunction(MachineFunction &F);
69218885Sdim
70218885Sdim  virtual void EmitConstantPool() {} // we emit constant pools customly!
71218885Sdim  virtual void EmitFunctionEntryLabel();
72218885Sdim  void EmitStartOfAsmFile(Module &M);
73218885Sdim  void EmitEndOfAsmFile(Module &M);
74218885Sdim
75218885Sdimprivate:
76218885Sdim  // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile()
77218885Sdim  void emitAttributes();
78218885Sdim
79218885Sdim  // Helper for ELF .o only
80218885Sdim  void emitARMAttributeSection();
81218885Sdim
82218885Sdim  // Generic helper used to emit e.g. ARMv5 mul pseudos
83218885Sdim  void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc);
84218885Sdim
85218885Sdimpublic:
86218885Sdim  void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
87218885Sdim
88218885Sdim  MachineLocation getDebugValueLocation(const MachineInstr *MI) const;
89218885Sdim
90218885Sdim  virtual unsigned getISAEncoding() {
91218885Sdim    // ARM/Darwin adds ISA to the DWARF info for each function.
92218885Sdim    if (!Subtarget->isTargetDarwin())
93218885Sdim      return 0;
94218885Sdim    return Subtarget->isThumb() ?
95218885Sdim      llvm::ARM::DW_ISA_ARM_thumb : llvm::ARM::DW_ISA_ARM_arm;
96218885Sdim  }
97218885Sdim
98218885Sdim  MCSymbol *GetARMSetPICJumpTableLabel2(unsigned uid, unsigned uid2,
99218885Sdim                                        const MachineBasicBlock *MBB) const;
100218885Sdim  MCSymbol *GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const;
101218885Sdim
102218885Sdim  MCSymbol *GetARMSJLJEHLabel(void) const;
103218885Sdim
104218885Sdim  MCSymbol *GetARMGVSymbol(const GlobalValue *GV);
105218885Sdim
106218885Sdim  /// EmitMachineConstantPoolValue - Print a machine constantpool value to
107218885Sdim  /// the .s file.
108218885Sdim  virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV);
109218885Sdim};
110218885Sdim} // end namespace llvm
111218885Sdim
112218885Sdim#endif
113