2013-02-20 00:47:59 +08:00
|
|
|
//===-- ARMAsmPrinter.h - ARM implementation of AsmPrinter ------*- C++ -*-===//
|
2010-12-01 11:45:07 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H
|
|
|
|
#define LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H
|
2010-12-01 11:45:07 +08:00
|
|
|
|
2014-03-23 07:51:00 +08:00
|
|
|
#include "ARMSubtarget.h"
|
2010-12-01 11:45:07 +08:00
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
2014-03-23 07:51:00 +08:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2010-12-01 11:45:07 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2014-03-23 07:51:00 +08:00
|
|
|
class ARMFunctionInfo;
|
2011-07-09 01:40:42 +08:00
|
|
|
class MCOperand;
|
2014-03-23 07:51:00 +08:00
|
|
|
class MachineConstantPool;
|
|
|
|
class MachineOperand;
|
2014-12-05 03:34:50 +08:00
|
|
|
class MCSymbol;
|
2011-07-09 01:40:42 +08:00
|
|
|
|
2010-12-01 11:45:07 +08:00
|
|
|
namespace ARM {
|
|
|
|
enum DW_ISA {
|
|
|
|
DW_ISA_ARM_thumb = 1,
|
|
|
|
DW_ISA_ARM_arm = 2
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
class LLVM_LIBRARY_VISIBILITY ARMAsmPrinter : public AsmPrinter {
|
|
|
|
|
|
|
|
/// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
|
|
|
|
/// make the right decision when printing asm code for different targets.
|
|
|
|
const ARMSubtarget *Subtarget;
|
|
|
|
|
|
|
|
/// AFI - Keep a pointer to ARMFunctionInfo for the current
|
|
|
|
/// MachineFunction.
|
|
|
|
ARMFunctionInfo *AFI;
|
|
|
|
|
|
|
|
/// MCP - Keep a pointer to constantpool entries of the current
|
|
|
|
/// MachineFunction.
|
|
|
|
const MachineConstantPool *MCP;
|
|
|
|
|
2012-05-19 03:12:01 +08:00
|
|
|
/// InConstantPool - Maintain state when emitting a sequence of constant
|
|
|
|
/// pool entries so we can properly mark them as data regions.
|
|
|
|
bool InConstantPool;
|
2014-12-05 03:34:50 +08:00
|
|
|
|
|
|
|
/// ThumbIndirectPads - These maintain a per-function list of jump pad
|
|
|
|
/// labels used for ARMv4t thumb code to make register indirect calls.
|
|
|
|
SmallVector<std::pair<unsigned, MCSymbol*>, 4> ThumbIndirectPads;
|
|
|
|
|
2015-12-07 22:22:39 +08:00
|
|
|
/// OptimizationGoals - Maintain a combined optimization goal for all
|
|
|
|
/// functions in a module: one of Tag_ABI_optimization_goals values,
|
|
|
|
/// -1 if uninitialized, 0 if conflicting goals
|
|
|
|
int OptimizationGoals;
|
|
|
|
|
2016-09-26 15:26:24 +08:00
|
|
|
/// List of globals that have had their storage promoted to a constant
|
|
|
|
/// pool. This lives between calls to runOnMachineFunction and collects
|
|
|
|
/// data from every MachineFunction. It is used during doFinalization
|
|
|
|
/// when all non-function globals are emitted.
|
|
|
|
SmallPtrSet<const GlobalVariable*,2> PromotedGlobals;
|
|
|
|
/// Set of globals in PromotedGlobals that we've emitted labels for.
|
|
|
|
/// We need to emit labels even for promoted globals so that DWARF
|
|
|
|
/// debug info can link properly.
|
|
|
|
SmallPtrSet<const GlobalVariable*,2> EmittedPromotedGlobalLabels;
|
|
|
|
|
2010-12-01 11:45:07 +08:00
|
|
|
public:
|
2015-01-19 04:29:04 +08:00
|
|
|
explicit ARMAsmPrinter(TargetMachine &TM,
|
|
|
|
std::unique_ptr<MCStreamer> Streamer);
|
2010-12-01 11:45:07 +08:00
|
|
|
|
2016-10-01 10:56:57 +08:00
|
|
|
StringRef getPassName() const override {
|
2016-11-11 02:39:31 +08:00
|
|
|
return "ARM Assembly Printer";
|
2010-12-01 11:45:07 +08:00
|
|
|
}
|
|
|
|
|
2015-05-14 04:28:41 +08:00
|
|
|
void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O);
|
2010-12-01 11:45:07 +08:00
|
|
|
|
2014-03-10 13:29:18 +08:00
|
|
|
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
|
|
|
|
unsigned AsmVariant, const char *ExtraCode,
|
|
|
|
raw_ostream &O) override;
|
|
|
|
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
|
|
|
|
unsigned AsmVariant, const char *ExtraCode,
|
|
|
|
raw_ostream &O) override;
|
2010-12-01 11:45:07 +08:00
|
|
|
|
2014-03-10 13:29:18 +08:00
|
|
|
void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
|
|
|
|
const MCSubtargetInfo *EndInfo) const override;
|
2014-01-24 23:47:54 +08:00
|
|
|
|
2015-06-01 03:22:07 +08:00
|
|
|
void EmitJumpTableAddrs(const MachineInstr *MI);
|
|
|
|
void EmitJumpTableInsts(const MachineInstr *MI);
|
|
|
|
void EmitJumpTableTBInst(const MachineInstr *MI, unsigned OffsetWidth);
|
2014-03-10 13:29:18 +08:00
|
|
|
void EmitInstruction(const MachineInstr *MI) override;
|
|
|
|
bool runOnMachineFunction(MachineFunction &F) override;
|
2010-12-01 11:45:07 +08:00
|
|
|
|
2014-03-10 13:29:18 +08:00
|
|
|
void EmitConstantPool() override {
|
2012-10-09 12:23:49 +08:00
|
|
|
// we emit constant pools customly!
|
|
|
|
}
|
2014-03-10 13:29:18 +08:00
|
|
|
void EmitFunctionBodyEnd() override;
|
|
|
|
void EmitFunctionEntryLabel() override;
|
|
|
|
void EmitStartOfAsmFile(Module &M) override;
|
|
|
|
void EmitEndOfAsmFile(Module &M) override;
|
2015-07-16 14:11:10 +08:00
|
|
|
void EmitXXStructor(const DataLayout &DL, const Constant *CV) override;
|
2016-09-26 15:26:24 +08:00
|
|
|
void EmitGlobalVariable(const GlobalVariable *GV) override;
|
|
|
|
|
2011-07-09 01:40:42 +08:00
|
|
|
// lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
|
|
|
|
bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
|
|
|
|
|
2016-09-19 08:54:35 +08:00
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
// XRay implementation
|
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
public:
|
|
|
|
// XRay-specific lowering for ARM.
|
|
|
|
void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI);
|
|
|
|
void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI);
|
2016-10-18 13:54:15 +08:00
|
|
|
void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI);
|
2016-09-19 08:54:35 +08:00
|
|
|
|
2010-12-01 11:45:07 +08:00
|
|
|
private:
|
2016-09-19 08:54:35 +08:00
|
|
|
void EmitSled(const MachineInstr &MI, SledKind Kind);
|
2016-06-21 22:21:53 +08:00
|
|
|
|
2010-12-01 11:45:07 +08:00
|
|
|
// Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile()
|
|
|
|
void emitAttributes();
|
|
|
|
|
2011-01-02 04:38:38 +08:00
|
|
|
// Generic helper used to emit e.g. ARMv5 mul pseudos
|
|
|
|
void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc);
|
|
|
|
|
2011-03-06 02:43:32 +08:00
|
|
|
void EmitUnwindingInstruction(const MachineInstr *MI);
|
|
|
|
|
2011-07-09 01:40:42 +08:00
|
|
|
// emitPseudoExpansionLowering - tblgen'erated.
|
|
|
|
bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
|
|
|
|
const MachineInstr *MI);
|
|
|
|
|
2010-12-01 11:45:07 +08:00
|
|
|
public:
|
2015-03-21 11:13:01 +08:00
|
|
|
unsigned getISAEncoding() override {
|
2010-12-01 11:45:07 +08:00
|
|
|
// ARM/Darwin adds ISA to the DWARF info for each function.
|
2015-06-16 23:44:21 +08:00
|
|
|
const Triple &TT = TM.getTargetTriple();
|
2015-02-18 04:02:32 +08:00
|
|
|
if (!TT.isOSBinFormatMachO())
|
2010-12-01 11:45:07 +08:00
|
|
|
return 0;
|
2017-08-13 01:40:18 +08:00
|
|
|
bool isThumb = TT.isThumb() ||
|
2015-03-21 11:13:01 +08:00
|
|
|
TT.getSubArch() == Triple::ARMSubArch_v7m ||
|
|
|
|
TT.getSubArch() == Triple::ARMSubArch_v6m;
|
|
|
|
return isThumb ? ARM::DW_ISA_ARM_thumb : ARM::DW_ISA_ARM_arm;
|
2010-12-01 11:45:07 +08:00
|
|
|
}
|
|
|
|
|
2012-10-09 12:23:49 +08:00
|
|
|
private:
|
2011-07-09 01:40:42 +08:00
|
|
|
MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol);
|
2015-05-14 04:28:38 +08:00
|
|
|
MCSymbol *GetARMJTIPICJumpTableLabel(unsigned uid) const;
|
2010-12-01 11:45:07 +08:00
|
|
|
|
2013-11-26 00:24:52 +08:00
|
|
|
MCSymbol *GetARMGVSymbol(const GlobalValue *GV, unsigned char TargetFlags);
|
2011-07-09 01:40:42 +08:00
|
|
|
|
2012-10-09 12:23:49 +08:00
|
|
|
public:
|
2010-12-01 11:45:07 +08:00
|
|
|
/// EmitMachineConstantPoolValue - Print a machine constantpool value to
|
|
|
|
/// the .s file.
|
2014-03-10 13:29:18 +08:00
|
|
|
void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override;
|
2010-12-01 11:45:07 +08:00
|
|
|
};
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|