LLVM  3.7.0
ARMAsmPrinter.h
Go to the documentation of this file.
1 //===-- ARMAsmPrinter.h - ARM implementation of AsmPrinter ------*- 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 
10 #ifndef LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H
11 #define LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H
12 
13 #include "ARMSubtarget.h"
16 
17 namespace llvm {
18 
19 class ARMFunctionInfo;
20 class MCOperand;
21 class MachineConstantPool;
22 class MachineOperand;
23 class MCSymbol;
24 
25 namespace ARM {
26  enum DW_ISA {
29  };
30 }
31 
33 
34  /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
35  /// make the right decision when printing asm code for different targets.
36  const ARMSubtarget *Subtarget;
37 
38  /// AFI - Keep a pointer to ARMFunctionInfo for the current
39  /// MachineFunction.
40  ARMFunctionInfo *AFI;
41 
42  /// MCP - Keep a pointer to constantpool entries of the current
43  /// MachineFunction.
44  const MachineConstantPool *MCP;
45 
46  /// InConstantPool - Maintain state when emitting a sequence of constant
47  /// pool entries so we can properly mark them as data regions.
48  bool InConstantPool;
49 
50  /// ThumbIndirectPads - These maintain a per-function list of jump pad
51  /// labels used for ARMv4t thumb code to make register indirect calls.
52  SmallVector<std::pair<unsigned, MCSymbol*>, 4> ThumbIndirectPads;
53 
54 public:
55  explicit ARMAsmPrinter(TargetMachine &TM,
56  std::unique_ptr<MCStreamer> Streamer);
57 
58  const char *getPassName() const override {
59  return "ARM Assembly / Object Emitter";
60  }
61 
62  void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O);
63 
64  bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
65  unsigned AsmVariant, const char *ExtraCode,
66  raw_ostream &O) override;
67  bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
68  unsigned AsmVariant, const char *ExtraCode,
69  raw_ostream &O) override;
70 
71  void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
72  const MCSubtargetInfo *EndInfo) const override;
73 
74  void EmitJumpTableAddrs(const MachineInstr *MI);
75  void EmitJumpTableInsts(const MachineInstr *MI);
76  void EmitJumpTableTBInst(const MachineInstr *MI, unsigned OffsetWidth);
77  void EmitInstruction(const MachineInstr *MI) override;
78  bool runOnMachineFunction(MachineFunction &F) override;
79 
80  void EmitConstantPool() override {
81  // we emit constant pools customly!
82  }
83  void EmitFunctionBodyEnd() override;
84  void EmitFunctionEntryLabel() override;
85  void EmitStartOfAsmFile(Module &M) override;
86  void EmitEndOfAsmFile(Module &M) override;
87  void EmitXXStructor(const Constant *CV) override;
88 
89  // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
90  bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
91 
92 private:
93  // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile()
94  void emitAttributes();
95 
96  // Generic helper used to emit e.g. ARMv5 mul pseudos
97  void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc);
98 
99  void EmitUnwindingInstruction(const MachineInstr *MI);
100 
101  // emitPseudoExpansionLowering - tblgen'erated.
102  bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
103  const MachineInstr *MI);
104 
105 public:
106  unsigned getISAEncoding() override {
107  // ARM/Darwin adds ISA to the DWARF info for each function.
108  const Triple &TT = TM.getTargetTriple();
109  if (!TT.isOSBinFormatMachO())
110  return 0;
111  bool isThumb = TT.getArch() == Triple::thumb ||
112  TT.getArch() == Triple::thumbeb ||
115  return isThumb ? ARM::DW_ISA_ARM_thumb : ARM::DW_ISA_ARM_arm;
116  }
117 
118 private:
120  MCSymbol *GetARMJTIPICJumpTableLabel(unsigned uid) const;
121 
122  MCSymbol *GetARMSJLJEHLabel() const;
123 
124  MCSymbol *GetARMGVSymbol(const GlobalValue *GV, unsigned char TargetFlags);
125 
126 public:
127  /// EmitMachineConstantPoolValue - Print a machine constantpool value to
128  /// the .s file.
129  void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override;
130 };
131 } // end namespace llvm
132 
133 #endif
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:489
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
void EmitConstantPool() override
Print to the current output stream assembly representations of the constants in the constant pool MCP...
Definition: ARMAsmPrinter.h:80
static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol, HexagonAsmPrinter &Printer)
unsigned getISAEncoding() override
Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
F(f)
static bool isThumb(const MCSubtargetInfo &STI)
const Triple & getTargetTriple() const
static void printOperand(raw_ostream &OS, uint8_t Opcode, unsigned OperandIdx, uint64_t Operand, uint64_t CodeAlignmentFactor, int64_t DataAlignmentFactor)
Print Opcode's operand number OperandIdx which has value Operand.
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:242
SubArchType getSubArch() const
getSubArch - get the parsed subarchitecture type for this triple.
Definition: Triple.h:245
const char * getPassName() const override
getPassName - Return a nice clean name for a pass.
Definition: ARMAsmPrinter.h:58
Streaming machine code generation interface.
Definition: MCStreamer.h:157
This is an important base class in LLVM.
Definition: Constant.h:41
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:66
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library...
Definition: Compiler.h:110
Abstract base class for all machine specific constantpool value subclasses.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:861
Representation of each machine instruction.
Definition: MachineInstr.h:51
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
MCSubtargetInfo - Generic base class for all target subtargets.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
Primary interface to the complete machine description for the target machine.
Instances of this class represent operands of the MCInst class.
Definition: MCInst.h:33