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;
|
|
|
|
|
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
|
|
|
|
2014-03-10 13:29:18 +08:00
|
|
|
const char *getPassName() const override {
|
2013-02-20 00:47:59 +08:00
|
|
|
return "ARM Assembly / Object Emitter";
|
2010-12-01 11:45:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O,
|
2014-04-28 12:05:08 +08:00
|
|
|
const char *Modifier = nullptr);
|
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
|
|
|
|
2010-12-01 11:45:07 +08:00
|
|
|
void EmitJumpTable(const MachineInstr *MI);
|
|
|
|
void EmitJump2Table(const MachineInstr *MI);
|
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;
|
|
|
|
void EmitXXStructor(const Constant *CV) override;
|
2010-12-01 11:45:07 +08:00
|
|
|
|
2011-07-09 01:40:42 +08:00
|
|
|
// lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
|
|
|
|
bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
|
|
|
|
|
2010-12-01 11:45:07 +08:00
|
|
|
private:
|
|
|
|
// 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-02-18 04:02:32 +08:00
|
|
|
unsigned getISAEncoding(const Function *F) override {
|
2010-12-01 11:45:07 +08:00
|
|
|
// ARM/Darwin adds ISA to the DWARF info for each function.
|
2015-02-18 04:02:32 +08:00
|
|
|
Triple TT(TM.getTargetTriple());
|
|
|
|
if (!TT.isOSBinFormatMachO())
|
2010-12-01 11:45:07 +08:00
|
|
|
return 0;
|
2015-02-20 15:32:59 +08:00
|
|
|
const ARMSubtarget &STI = TM.getSubtarget<ARMSubtarget>(*F);
|
2015-02-18 04:02:32 +08:00
|
|
|
return STI.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);
|
2010-12-01 11:45:07 +08:00
|
|
|
MCSymbol *GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const;
|
|
|
|
|
2012-11-16 00:51:49 +08:00
|
|
|
MCSymbol *GetARMSJLJEHLabel() 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
|