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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef ARMASMPRINTER_H
|
|
|
|
#define ARMASMPRINTER_H
|
|
|
|
|
|
|
|
#include "ARM.h"
|
|
|
|
#include "ARMTargetMachine.h"
|
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
|
|
|
#include "llvm/Support/Compiler.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2011-07-08 17:40:42 +00:00
|
|
|
class MCOperand;
|
|
|
|
|
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;
|
2010-12-01 03:45:07 +00:00
|
|
|
public:
|
|
|
|
explicit ARMAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
2012-05-18 19:12:01 +00:00
|
|
|
: AsmPrinter(TM, Streamer), AFI(NULL), MCP(NULL), InConstantPool(false) {
|
2010-12-01 03:45:07 +00:00
|
|
|
Subtarget = &TM.getSubtarget<ARMSubtarget>();
|
|
|
|
}
|
|
|
|
|
2012-10-09 04:23:49 +00:00
|
|
|
virtual const char *getPassName() const LLVM_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,
|
|
|
|
const char *Modifier = 0);
|
|
|
|
|
|
|
|
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
|
|
|
|
unsigned AsmVariant, const char *ExtraCode,
|
2012-10-09 04:23:49 +00:00
|
|
|
raw_ostream &O) LLVM_OVERRIDE;
|
2010-12-01 03:45:07 +00:00
|
|
|
virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
|
2012-10-09 04:23:49 +00:00
|
|
|
unsigned AsmVariant, const char *ExtraCode,
|
|
|
|
raw_ostream &O) LLVM_OVERRIDE;
|
2010-12-01 03:45:07 +00:00
|
|
|
|
|
|
|
void EmitJumpTable(const MachineInstr *MI);
|
|
|
|
void EmitJump2Table(const MachineInstr *MI);
|
2012-10-09 04:23:49 +00:00
|
|
|
virtual void EmitInstruction(const MachineInstr *MI) LLVM_OVERRIDE;
|
|
|
|
virtual bool runOnMachineFunction(MachineFunction &F) LLVM_OVERRIDE;
|
2010-12-01 03:45:07 +00:00
|
|
|
|
2012-10-09 04:23:49 +00:00
|
|
|
virtual void EmitConstantPool() LLVM_OVERRIDE {
|
|
|
|
// we emit constant pools customly!
|
|
|
|
}
|
|
|
|
virtual void EmitFunctionBodyEnd() LLVM_OVERRIDE;
|
|
|
|
virtual void EmitFunctionEntryLabel() LLVM_OVERRIDE;
|
|
|
|
virtual void EmitStartOfAsmFile(Module &M) LLVM_OVERRIDE;
|
|
|
|
virtual void EmitEndOfAsmFile(Module &M) LLVM_OVERRIDE;
|
|
|
|
virtual void EmitXXStructor(const Constant *CV) LLVM_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();
|
|
|
|
|
|
|
|
// Helper for ELF .o only
|
|
|
|
void emitARMAttributeSection();
|
|
|
|
|
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:
|
2011-04-21 22:48:26 +00:00
|
|
|
/// EmitDwarfRegOp - Emit dwarf register operation.
|
2013-06-19 21:55:13 +00:00
|
|
|
virtual void EmitDwarfRegOp(const MachineLocation &MLoc, bool Indirect) const
|
|
|
|
LLVM_OVERRIDE;
|
2011-04-21 22:48:26 +00:00
|
|
|
|
2012-10-09 04:23:49 +00:00
|
|
|
virtual unsigned getISAEncoding() LLVM_OVERRIDE {
|
2010-12-01 03:45:07 +00:00
|
|
|
// ARM/Darwin adds ISA to the DWARF info for each function.
|
2014-01-06 14:28:05 +00:00
|
|
|
if (!Subtarget->isTargetMachO())
|
2010-12-01 03:45:07 +00:00
|
|
|
return 0;
|
|
|
|
return Subtarget->isThumb() ?
|
2012-03-27 07:21:54 +00:00
|
|
|
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.
|
2012-10-09 04:23:49 +00:00
|
|
|
virtual void
|
|
|
|
EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) LLVM_OVERRIDE;
|
2010-12-01 03:45:07 +00:00
|
|
|
};
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|