2010-12-01 04:45:07 +01:00
|
|
|
//===-- ARMAsmPrinter.h - Print machine code to an ARM .s file ------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// ARM Assembly printer class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#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 19:40:42 +02:00
|
|
|
class MCOperand;
|
|
|
|
|
2010-12-01 04:45:07 +01: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;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ARMAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
|
|
|
: AsmPrinter(TM, Streamer), AFI(NULL), MCP(NULL) {
|
|
|
|
Subtarget = &TM.getSubtarget<ARMSubtarget>();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual const char *getPassName() const {
|
|
|
|
return "ARM Assembly Printer";
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
raw_ostream &O);
|
|
|
|
virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
|
|
|
|
unsigned AsmVariant,
|
|
|
|
const char *ExtraCode, raw_ostream &O);
|
|
|
|
|
|
|
|
void EmitJumpTable(const MachineInstr *MI);
|
|
|
|
void EmitJump2Table(const MachineInstr *MI);
|
|
|
|
virtual void EmitInstruction(const MachineInstr *MI);
|
|
|
|
bool runOnMachineFunction(MachineFunction &F);
|
|
|
|
|
|
|
|
virtual void EmitConstantPool() {} // we emit constant pools customly!
|
|
|
|
virtual void EmitFunctionEntryLabel();
|
|
|
|
void EmitStartOfAsmFile(Module &M);
|
|
|
|
void EmitEndOfAsmFile(Module &M);
|
|
|
|
|
2011-07-08 19:40:42 +02:00
|
|
|
// lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
|
|
|
|
bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
|
|
|
|
|
2010-12-01 04:45:07 +01:00
|
|
|
private:
|
|
|
|
// Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile()
|
|
|
|
void emitAttributes();
|
|
|
|
|
|
|
|
// Helper for ELF .o only
|
|
|
|
void emitARMAttributeSection();
|
|
|
|
|
2011-01-01 21:38:38 +01:00
|
|
|
// Generic helper used to emit e.g. ARMv5 mul pseudos
|
|
|
|
void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc);
|
|
|
|
|
2011-03-05 19:43:32 +01:00
|
|
|
void EmitUnwindingInstruction(const MachineInstr *MI);
|
|
|
|
|
2011-07-08 19:40:42 +02:00
|
|
|
// emitPseudoExpansionLowering - tblgen'erated.
|
|
|
|
bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
|
|
|
|
const MachineInstr *MI);
|
|
|
|
|
2010-12-01 04:45:07 +01:00
|
|
|
public:
|
|
|
|
void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
|
|
|
|
|
|
|
|
MachineLocation getDebugValueLocation(const MachineInstr *MI) const;
|
|
|
|
|
2011-04-22 00:48:26 +02:00
|
|
|
/// EmitDwarfRegOp - Emit dwarf register operation.
|
2011-04-27 22:29:27 +02:00
|
|
|
virtual void EmitDwarfRegOp(const MachineLocation &MLoc) const;
|
2011-04-22 00:48:26 +02:00
|
|
|
|
2010-12-01 04:45:07 +01:00
|
|
|
virtual unsigned getISAEncoding() {
|
|
|
|
// ARM/Darwin adds ISA to the DWARF info for each function.
|
|
|
|
if (!Subtarget->isTargetDarwin())
|
|
|
|
return 0;
|
|
|
|
return Subtarget->isThumb() ?
|
|
|
|
llvm::ARM::DW_ISA_ARM_thumb : llvm::ARM::DW_ISA_ARM_arm;
|
|
|
|
}
|
|
|
|
|
2011-07-08 19:40:42 +02:00
|
|
|
MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol);
|
2010-12-01 04:45:07 +01:00
|
|
|
MCSymbol *GetARMSetPICJumpTableLabel2(unsigned uid, unsigned uid2,
|
|
|
|
const MachineBasicBlock *MBB) const;
|
|
|
|
MCSymbol *GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const;
|
|
|
|
|
|
|
|
MCSymbol *GetARMSJLJEHLabel(void) const;
|
|
|
|
|
2011-01-17 09:03:18 +01:00
|
|
|
MCSymbol *GetARMGVSymbol(const GlobalValue *GV);
|
2011-07-08 19:40:42 +02:00
|
|
|
|
2010-12-01 04:45:07 +01:00
|
|
|
/// EmitMachineConstantPoolValue - Print a machine constantpool value to
|
|
|
|
/// the .s file.
|
|
|
|
virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV);
|
|
|
|
};
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|