2013-02-19 16:47:59 +00:00
|
|
|
//===-- ARMAsmPrinter.h - ARM implementation of AsmPrinter ------*- C++ -*-===//
|
2010-12-01 03:45:07 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 16:26:38 +00:00
|
|
|
#ifndef LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H
|
|
|
|
#define LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H
|
2010-12-01 03:45:07 +00:00
|
|
|
|
2014-03-22 23:51:00 +00:00
|
|
|
#include "ARMSubtarget.h"
|
2010-12-01 03:45:07 +00:00
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
2014-03-22 23:51:00 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2010-12-01 03:45:07 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2014-03-22 23:51:00 +00:00
|
|
|
class ARMFunctionInfo;
|
2011-07-08 17:40:42 +00:00
|
|
|
class MCOperand;
|
2014-03-22 23:51:00 +00:00
|
|
|
class MachineConstantPool;
|
|
|
|
class MachineOperand;
|
2014-12-04 19:34:50 +00:00
|
|
|
class MCSymbol;
|
2011-07-08 17:40:42 +00:00
|
|
|
|
2010-12-01 03:45:07 +00: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-18 19:12:01 +00: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-04 19:34:50 +00: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 03:45:07 +00:00
|
|
|
public:
|
2015-01-18 20:29:04 +00:00
|
|
|
explicit ARMAsmPrinter(TargetMachine &TM,
|
|
|
|
std::unique_ptr<MCStreamer> Streamer);
|
2010-12-01 03:45:07 +00:00
|
|
|
|
2014-03-10 05:29:18 +00:00
|
|
|
const char *getPassName() const override {
|
2013-02-19 16:47:59 +00:00
|
|
|
return "ARM Assembly / Object Emitter";
|
2010-12-01 03:45:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O,
|
2014-04-28 04:05:08 +00:00
|
|
|
const char *Modifier = nullptr);
|
2010-12-01 03:45:07 +00:00
|
|
|
|
2014-03-10 05:29:18 +00: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 03:45:07 +00:00
|
|
|
|
2014-03-10 05:29:18 +00:00
|
|
|
void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
|
|
|
|
const MCSubtargetInfo *EndInfo) const override;
|
2014-01-24 15:47:54 +00:00
|
|
|
|
2010-12-01 03:45:07 +00:00
|
|
|
void EmitJumpTable(const MachineInstr *MI);
|
|
|
|
void EmitJump2Table(const MachineInstr *MI);
|
2014-03-10 05:29:18 +00:00
|
|
|
void EmitInstruction(const MachineInstr *MI) override;
|
|
|
|
bool runOnMachineFunction(MachineFunction &F) override;
|
2010-12-01 03:45:07 +00:00
|
|
|
|
2014-03-10 05:29:18 +00:00
|
|
|
void EmitConstantPool() override {
|
2012-10-09 04:23:49 +00:00
|
|
|
// we emit constant pools customly!
|
|
|
|
}
|
2014-03-10 05:29:18 +00: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 03:45:07 +00:00
|
|
|
|
2011-07-08 17:40:42 +00:00
|
|
|
// lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
|
|
|
|
bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
|
|
|
|
|
2010-12-01 03:45:07 +00:00
|
|
|
private:
|
|
|
|
// Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile()
|
|
|
|
void emitAttributes();
|
|
|
|
|
2011-01-01 20:38:38 +00:00
|
|
|
// Generic helper used to emit e.g. ARMv5 mul pseudos
|
|
|
|
void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc);
|
|
|
|
|
2011-03-05 18:43:32 +00:00
|
|
|
void EmitUnwindingInstruction(const MachineInstr *MI);
|
|
|
|
|
2011-07-08 17:40:42 +00:00
|
|
|
// emitPseudoExpansionLowering - tblgen'erated.
|
|
|
|
bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
|
|
|
|
const MachineInstr *MI);
|
|
|
|
|
2010-12-01 03:45:07 +00:00
|
|
|
public:
|
2015-02-17 20:02:32 +00:00
|
|
|
unsigned getISAEncoding(const Function *F) override {
|
2010-12-01 03:45:07 +00:00
|
|
|
// ARM/Darwin adds ISA to the DWARF info for each function.
|
2015-02-17 20:02:32 +00:00
|
|
|
Triple TT(TM.getTargetTriple());
|
|
|
|
if (!TT.isOSBinFormatMachO())
|
2010-12-01 03:45:07 +00:00
|
|
|
return 0;
|
2015-02-20 07:32:59 +00:00
|
|
|
const ARMSubtarget &STI = TM.getSubtarget<ARMSubtarget>(*F);
|
2015-02-17 20:02:32 +00:00
|
|
|
return STI.isThumb() ? ARM::DW_ISA_ARM_thumb : ARM::DW_ISA_ARM_arm;
|
2010-12-01 03:45:07 +00:00
|
|
|
}
|
|
|
|
|
2012-10-09 04:23:49 +00:00
|
|
|
private:
|
2011-07-08 17:40:42 +00:00
|
|
|
MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol);
|
2010-12-01 03:45:07 +00:00
|
|
|
MCSymbol *GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const;
|
|
|
|
|
2012-11-15 16:51:49 +00:00
|
|
|
MCSymbol *GetARMSJLJEHLabel() const;
|
2010-12-01 03:45:07 +00:00
|
|
|
|
2013-11-25 16:24:52 +00:00
|
|
|
MCSymbol *GetARMGVSymbol(const GlobalValue *GV, unsigned char TargetFlags);
|
2011-07-08 17:40:42 +00:00
|
|
|
|
2012-10-09 04:23:49 +00:00
|
|
|
public:
|
2010-12-01 03:45:07 +00:00
|
|
|
/// EmitMachineConstantPoolValue - Print a machine constantpool value to
|
|
|
|
/// the .s file.
|
2014-03-10 05:29:18 +00:00
|
|
|
void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override;
|
2010-12-01 03:45:07 +00:00
|
|
|
};
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|