2013-02-19 16:47:59 +00:00
|
|
|
//===-- ARMAsmPrinter.h - ARM implementation of AsmPrinter ------*- C++ -*-===//
|
2010-12-01 03:45:07 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-12-01 03:45:07 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
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;
|
|
|
|
|
2015-12-07 14:22:39 +00: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 07:26:24 +00: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 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
|
|
|
|
2016-10-01 02:56:57 +00:00
|
|
|
StringRef getPassName() const override {
|
2016-11-10 18:39:31 +00:00
|
|
|
return "ARM Assembly Printer";
|
2010-12-01 03:45:07 +00:00
|
|
|
}
|
|
|
|
|
2015-05-13 20:28:41 +00:00
|
|
|
void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O);
|
2010-12-01 03:45:07 +00:00
|
|
|
|
[AsmPrinter] refactor to support %c w/ GlobalAddress'
Summary:
Targets like ARM, MSP430, PPC, and SystemZ have complex behavior when
printing the address of a MachineOperand::MO_GlobalAddress. Move that
handling into a new overriden method in each base class. A virtual
method was added to the base class for handling the generic case.
Refactors a few subclasses to support the target independent %a, %c, and
%n.
The patch also contains small cleanups for AVRAsmPrinter and
SystemZAsmPrinter.
It seems that NVPTXTargetLowering is possibly missing some logic to
transform GlobalAddressSDNodes for
TargetLowering::LowerAsmOperandForConstraint to handle with "i" extended
inline assembly asm constraints.
Fixes:
- https://bugs.llvm.org/show_bug.cgi?id=41402
- https://github.com/ClangBuiltLinux/linux/issues/449
Reviewers: echristo, void
Reviewed By: void
Subscribers: void, craig.topper, jholewinski, dschuff, jyknight, dylanmckay, sdardis, nemanjai, javed.absar, sbc100, jgravelle-google, eraman, kristof.beyls, hiraditya, aheejin, kbarton, fedor.sergeev, jrtc27, atanasyan, jsji, llvm-commits, kees, tpimh, nathanchance, peter.smith, srhines
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60887
llvm-svn: 359337
2019-04-26 18:45:04 +00:00
|
|
|
void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &O) override;
|
2014-03-10 05:29:18 +00:00
|
|
|
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
|
[AsmPrinter] refactor to remove remove AsmVariant. NFC
Summary:
The InlineAsm::AsmDialect is only required for X86; no architecture
makes use of it and as such it gets passed around between arch-specific
and general code while being unused for all architectures but X86.
Since the AsmDialect is queried from a MachineInstr, which we also pass
around, remove the additional AsmDialect parameter and query for it deep
in the X86AsmPrinter only when needed/as late as possible.
This refactor should help later planned refactors to AsmPrinter, as this
difference in the X86AsmPrinter makes it harder to make AsmPrinter more
generic.
Reviewers: craig.topper
Subscribers: jholewinski, arsenm, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, javed.absar, sbc100, jgravelle-google, eraman, hiraditya, aheejin, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, llvm-commits, peter.smith, srhines
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60488
llvm-svn: 358101
2019-04-10 16:38:43 +00:00
|
|
|
const char *ExtraCode, raw_ostream &O) override;
|
2014-03-10 05:29:18 +00:00
|
|
|
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
|
[AsmPrinter] refactor to remove remove AsmVariant. NFC
Summary:
The InlineAsm::AsmDialect is only required for X86; no architecture
makes use of it and as such it gets passed around between arch-specific
and general code while being unused for all architectures but X86.
Since the AsmDialect is queried from a MachineInstr, which we also pass
around, remove the additional AsmDialect parameter and query for it deep
in the X86AsmPrinter only when needed/as late as possible.
This refactor should help later planned refactors to AsmPrinter, as this
difference in the X86AsmPrinter makes it harder to make AsmPrinter more
generic.
Reviewers: craig.topper
Subscribers: jholewinski, arsenm, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, javed.absar, sbc100, jgravelle-google, eraman, hiraditya, aheejin, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, llvm-commits, peter.smith, srhines
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60488
llvm-svn: 358101
2019-04-10 16:38:43 +00:00
|
|
|
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
|
|
|
|
2015-05-31 19:22:07 +00:00
|
|
|
void EmitJumpTableAddrs(const MachineInstr *MI);
|
|
|
|
void EmitJumpTableInsts(const MachineInstr *MI);
|
|
|
|
void EmitJumpTableTBInst(const MachineInstr *MI, unsigned OffsetWidth);
|
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;
|
2015-07-16 06:11:10 +00:00
|
|
|
void EmitXXStructor(const DataLayout &DL, const Constant *CV) override;
|
2016-09-26 07:26:24 +00:00
|
|
|
void EmitGlobalVariable(const GlobalVariable *GV) override;
|
2018-07-25 18:35:31 +00:00
|
|
|
|
2018-07-25 19:01:36 +00:00
|
|
|
MCSymbol *GetCPISymbol(unsigned CPID) const override;
|
2018-07-25 18:35:31 +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);
|
|
|
|
|
2016-09-19 00:54:35 +00: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 05:54:15 +00:00
|
|
|
void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI);
|
2016-09-19 00:54:35 +00:00
|
|
|
|
2010-12-01 03:45:07 +00:00
|
|
|
private:
|
2016-09-19 00:54:35 +00:00
|
|
|
void EmitSled(const MachineInstr &MI, SledKind Kind);
|
2016-06-21 14:21:53 +00:00
|
|
|
|
2010-12-01 03:45:07 +00:00
|
|
|
// 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-03-21 03:13:01 +00:00
|
|
|
unsigned getISAEncoding() override {
|
2010-12-01 03:45:07 +00:00
|
|
|
// ARM/Darwin adds ISA to the DWARF info for each function.
|
2015-06-16 15:44:21 +00:00
|
|
|
const Triple &TT = TM.getTargetTriple();
|
2015-02-17 20:02:32 +00:00
|
|
|
if (!TT.isOSBinFormatMachO())
|
2010-12-01 03:45:07 +00:00
|
|
|
return 0;
|
2017-08-12 17:40:18 +00:00
|
|
|
bool isThumb = TT.isThumb() ||
|
2015-03-21 03:13:01 +00: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 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);
|
2015-05-13 20:28:38 +00:00
|
|
|
MCSymbol *GetARMJTIPICJumpTableLabel(unsigned uid) 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
|