2009-10-20 04:20:46 +08:00
|
|
|
//===-- ARMAsmPrinter.cpp - Print machine code to an ARM .s file ----------===//
|
|
|
|
//
|
2006-05-15 06:18:28 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
2006-05-15 06:18:28 +08:00
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains a printer that converts from our internal representation
|
|
|
|
// of machine-dependent LLVM code to GAS-format ARM assembly language.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-01-12 05:46:47 +08:00
|
|
|
#include "ARMAsmPrinter.h"
|
2012-03-17 15:33:42 +08:00
|
|
|
#include "ARM.h"
|
2007-01-19 15:51:42 +08:00
|
|
|
#include "ARMConstantPoolValue.h"
|
2009-10-20 04:20:46 +08:00
|
|
|
#include "ARMMachineFunctionInfo.h"
|
|
|
|
#include "ARMTargetMachine.h"
|
2010-10-12 07:01:44 +08:00
|
|
|
#include "ARMTargetObjectFile.h"
|
2011-01-12 05:46:47 +08:00
|
|
|
#include "InstPrinter/ARMInstPrinter.h"
|
2011-07-21 07:34:39 +08:00
|
|
|
#include "MCTargetDesc/ARMAddressingModes.h"
|
|
|
|
#include "MCTargetDesc/ARMMCExpr.h"
|
2012-10-05 05:33:24 +08:00
|
|
|
#include "llvm/ADT/SetVector.h"
|
|
|
|
#include "llvm/ADT/SmallString.h"
|
2006-05-15 06:18:28 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2007-01-19 15:51:42 +08:00
|
|
|
#include "llvm/CodeGen/MachineJumpTableInfo.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
|
2013-01-02 19:36:10 +08:00
|
|
|
#include "llvm/IR/Constants.h"
|
|
|
|
#include "llvm/IR/DataLayout.h"
|
2014-03-06 08:46:21 +08:00
|
|
|
#include "llvm/IR/DebugInfo.h"
|
2014-01-08 05:19:40 +08:00
|
|
|
#include "llvm/IR/Mangler.h"
|
2013-01-02 19:36:10 +08:00
|
|
|
#include "llvm/IR/Module.h"
|
|
|
|
#include "llvm/IR/Type.h"
|
2009-10-20 02:38:33 +08:00
|
|
|
#include "llvm/MC/MCAsmInfo.h"
|
2010-10-26 01:50:35 +08:00
|
|
|
#include "llvm/MC/MCAssembler.h"
|
2009-10-20 02:38:33 +08:00
|
|
|
#include "llvm/MC/MCContext.h"
|
2013-01-30 10:24:33 +08:00
|
|
|
#include "llvm/MC/MCELFStreamer.h"
|
2009-10-20 04:20:46 +08:00
|
|
|
#include "llvm/MC/MCInst.h"
|
2012-11-26 21:34:22 +08:00
|
|
|
#include "llvm/MC/MCInstBuilder.h"
|
2010-10-26 01:50:35 +08:00
|
|
|
#include "llvm/MC/MCObjectStreamer.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/MC/MCSectionMachO.h"
|
2009-08-19 13:49:37 +08:00
|
|
|
#include "llvm/MC/MCStreamer.h"
|
2009-09-14 01:14:04 +08:00
|
|
|
#include "llvm/MC/MCSymbol.h"
|
2014-01-19 16:25:27 +08:00
|
|
|
#include "llvm/Support/ARMBuildAttributes.h"
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
#include "llvm/Support/TargetParser.h"
|
2014-04-30 14:14:25 +08:00
|
|
|
#include "llvm/Support/COFF.h"
|
2009-10-20 04:20:46 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2010-08-05 06:39:39 +08:00
|
|
|
#include "llvm/Support/Debug.h"
|
2013-01-30 10:24:33 +08:00
|
|
|
#include "llvm/Support/ELF.h"
|
2009-07-09 04:55:50 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2011-08-25 02:08:43 +08:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2010-04-04 16:18:47 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2006-05-15 06:18:28 +08:00
|
|
|
#include <cctype>
|
|
|
|
using namespace llvm;
|
|
|
|
|
2014-04-22 10:41:26 +08:00
|
|
|
#define DEBUG_TYPE "asm-printer"
|
|
|
|
|
2015-01-19 04:29:04 +08:00
|
|
|
ARMAsmPrinter::ARMAsmPrinter(TargetMachine &TM,
|
|
|
|
std::unique_ptr<MCStreamer> Streamer)
|
|
|
|
: AsmPrinter(TM, std::move(Streamer)), AFI(nullptr), MCP(nullptr),
|
2015-12-07 22:22:39 +08:00
|
|
|
InConstantPool(false), OptimizationGoals(-1) {}
|
2015-01-19 04:29:04 +08:00
|
|
|
|
2012-05-19 03:12:01 +08:00
|
|
|
void ARMAsmPrinter::EmitFunctionBodyEnd() {
|
|
|
|
// Make sure to terminate any constant pools that were at the end
|
|
|
|
// of the function.
|
|
|
|
if (!InConstantPool)
|
|
|
|
return;
|
|
|
|
InConstantPool = false;
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
|
2012-05-19 03:12:01 +08:00
|
|
|
}
|
2011-10-05 07:26:17 +08:00
|
|
|
|
2012-05-19 03:12:01 +08:00
|
|
|
void ARMAsmPrinter::EmitFunctionEntryLabel() {
|
2010-01-28 07:58:11 +08:00
|
|
|
if (AFI->isThumbFunction()) {
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitAssemblerFlag(MCAF_Code16);
|
|
|
|
OutStreamer->EmitThumbFunc(CurrentFnSym);
|
2010-01-28 07:58:11 +08:00
|
|
|
}
|
2010-09-02 09:02:06 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitLabel(CurrentFnSym);
|
2010-01-28 07:58:11 +08:00
|
|
|
}
|
|
|
|
|
2015-07-16 14:11:10 +08:00
|
|
|
void ARMAsmPrinter::EmitXXStructor(const DataLayout &DL, const Constant *CV) {
|
|
|
|
uint64_t Size = getDataLayout().getTypeAllocSize(CV->getType());
|
2012-01-26 17:25:43 +08:00
|
|
|
assert(Size && "C++ constructor pointer had zero size!");
|
|
|
|
|
2012-02-15 17:14:08 +08:00
|
|
|
const GlobalValue *GV = dyn_cast<GlobalValue>(CV->stripPointerCasts());
|
2012-01-26 17:25:43 +08:00
|
|
|
assert(GV && "C++ constructor pointer was not a GlobalValue!");
|
|
|
|
|
2015-05-30 09:25:56 +08:00
|
|
|
const MCExpr *E = MCSymbolRefExpr::create(GetARMGVSymbol(GV,
|
2014-07-07 13:18:22 +08:00
|
|
|
ARMII::MO_NO_FLAG),
|
2014-01-06 22:28:05 +08:00
|
|
|
(Subtarget->isTargetELF()
|
|
|
|
? MCSymbolRefExpr::VK_ARM_TARGET1
|
|
|
|
: MCSymbolRefExpr::VK_None),
|
2012-01-26 17:25:43 +08:00
|
|
|
OutContext);
|
2014-04-04 07:43:18 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitValue(E, Size);
|
2012-01-26 17:25:43 +08:00
|
|
|
}
|
|
|
|
|
2010-09-30 09:57:53 +08:00
|
|
|
/// runOnMachineFunction - This uses the EmitInstruction()
|
2006-05-15 06:18:28 +08:00
|
|
|
/// method to print assembly for each instruction.
|
|
|
|
///
|
|
|
|
bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
2007-01-19 15:51:42 +08:00
|
|
|
AFI = MF.getInfo<ARMFunctionInfo>();
|
2008-09-18 15:27:23 +08:00
|
|
|
MCP = MF.getConstantPool();
|
2015-02-18 04:02:32 +08:00
|
|
|
Subtarget = &MF.getSubtarget<ARMSubtarget>();
|
2007-01-19 15:51:42 +08:00
|
|
|
|
2014-04-30 14:14:25 +08:00
|
|
|
SetupMachineFunction(MF);
|
2015-12-07 22:22:39 +08:00
|
|
|
const Function* F = MF.getFunction();
|
|
|
|
const TargetMachine& TM = MF.getTarget();
|
|
|
|
|
|
|
|
// Calculate this function's optimization goal.
|
|
|
|
unsigned OptimizationGoal;
|
|
|
|
if (F->hasFnAttribute(Attribute::OptimizeNone))
|
|
|
|
// For best debugging illusion, speed and small size sacrificed
|
|
|
|
OptimizationGoal = 6;
|
|
|
|
else if (F->optForMinSize())
|
|
|
|
// Aggressively for small size, speed and debug illusion sacrificed
|
|
|
|
OptimizationGoal = 4;
|
|
|
|
else if (F->optForSize())
|
|
|
|
// For small size, but speed and debugging illusion preserved
|
|
|
|
OptimizationGoal = 3;
|
|
|
|
else if (TM.getOptLevel() == CodeGenOpt::Aggressive)
|
|
|
|
// Aggressively for speed, small size and debug illusion sacrificed
|
|
|
|
OptimizationGoal = 2;
|
|
|
|
else if (TM.getOptLevel() > CodeGenOpt::None)
|
|
|
|
// For speed, but small size and good debug illusion preserved
|
|
|
|
OptimizationGoal = 1;
|
|
|
|
else // TM.getOptLevel() == CodeGenOpt::None
|
|
|
|
// For good debugging, but speed and small size preserved
|
|
|
|
OptimizationGoal = 5;
|
|
|
|
|
|
|
|
// Combine a new optimization goal with existing ones.
|
|
|
|
if (OptimizationGoals == -1) // uninitialized goals
|
|
|
|
OptimizationGoals = OptimizationGoal;
|
|
|
|
else if (OptimizationGoals != (int)OptimizationGoal) // conflicting goals
|
|
|
|
OptimizationGoals = 0;
|
2014-04-30 14:14:25 +08:00
|
|
|
|
|
|
|
if (Subtarget->isTargetCOFF()) {
|
2015-12-07 22:22:39 +08:00
|
|
|
bool Internal = F->hasInternalLinkage();
|
2014-04-30 14:14:25 +08:00
|
|
|
COFF::SymbolStorageClass Scl = Internal ? COFF::IMAGE_SYM_CLASS_STATIC
|
|
|
|
: COFF::IMAGE_SYM_CLASS_EXTERNAL;
|
|
|
|
int Type = COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT;
|
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->BeginCOFFSymbolDef(CurrentFnSym);
|
|
|
|
OutStreamer->EmitCOFFSymbolStorageClass(Scl);
|
|
|
|
OutStreamer->EmitCOFFSymbolType(Type);
|
|
|
|
OutStreamer->EndCOFFSymbolDef();
|
2014-04-30 14:14:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Emit the rest of the function body.
|
|
|
|
EmitFunctionBody();
|
|
|
|
|
2014-12-05 03:34:50 +08:00
|
|
|
// If we need V4T thumb mode Register Indirect Jump pads, emit them.
|
|
|
|
// These are created per function, rather than per TU, since it's
|
|
|
|
// relatively easy to exceed the thumb branch range within a TU.
|
|
|
|
if (! ThumbIndirectPads.empty()) {
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitAssemblerFlag(MCAF_Code16);
|
2014-12-05 03:34:50 +08:00
|
|
|
EmitAlignment(1);
|
|
|
|
for (unsigned i = 0, e = ThumbIndirectPads.size(); i < e; i++) {
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitLabel(ThumbIndirectPads[i].second);
|
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tBX)
|
2014-12-05 03:34:50 +08:00
|
|
|
.addReg(ThumbIndirectPads[i].first)
|
|
|
|
// Add predicate operands.
|
|
|
|
.addImm(ARMCC::AL)
|
|
|
|
.addReg(0));
|
|
|
|
}
|
|
|
|
ThumbIndirectPads.clear();
|
|
|
|
}
|
|
|
|
|
2014-04-30 14:14:25 +08:00
|
|
|
// We didn't modify anything.
|
|
|
|
return false;
|
2006-10-18 02:04:53 +08:00
|
|
|
}
|
|
|
|
|
2009-06-29 15:51:04 +08:00
|
|
|
void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
2015-05-14 04:28:41 +08:00
|
|
|
raw_ostream &O) {
|
2009-06-29 15:51:04 +08:00
|
|
|
const MachineOperand &MO = MI->getOperand(OpNum);
|
2009-11-24 08:44:37 +08:00
|
|
|
unsigned TF = MO.getTargetFlags();
|
|
|
|
|
2006-05-25 20:57:06 +08:00
|
|
|
switch (MO.getType()) {
|
2012-02-07 10:50:20 +08:00
|
|
|
default: llvm_unreachable("<unknown operand type>");
|
2009-06-23 07:27:02 +08:00
|
|
|
case MachineOperand::MO_Register: {
|
|
|
|
unsigned Reg = MO.getReg();
|
2009-10-20 04:59:55 +08:00
|
|
|
assert(TargetRegisterInfo::isPhysicalRegister(Reg));
|
2010-10-07 05:22:32 +08:00
|
|
|
assert(!MO.getSubReg() && "Subregs should be eliminated!");
|
2013-02-15 02:10:21 +08:00
|
|
|
if(ARM::GPRPairRegClass.contains(Reg)) {
|
|
|
|
const MachineFunction &MF = *MI->getParent()->getParent();
|
2014-08-05 10:39:49 +08:00
|
|
|
const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
|
2013-02-15 02:10:21 +08:00
|
|
|
Reg = TRI->getSubReg(Reg, ARM::gsub_0);
|
|
|
|
}
|
2010-10-07 05:22:32 +08:00
|
|
|
O << ARMInstPrinter::getRegisterName(Reg);
|
2006-05-25 20:57:06 +08:00
|
|
|
break;
|
2009-06-23 07:27:02 +08:00
|
|
|
}
|
2007-01-19 15:51:42 +08:00
|
|
|
case MachineOperand::MO_Immediate: {
|
2009-09-28 17:14:39 +08:00
|
|
|
int64_t Imm = MO.getImm();
|
2009-10-09 04:43:22 +08:00
|
|
|
O << '#';
|
2015-05-14 04:28:41 +08:00
|
|
|
if (TF == ARMII::MO_LO16)
|
2009-11-24 08:44:37 +08:00
|
|
|
O << ":lower16:";
|
2015-05-14 04:28:41 +08:00
|
|
|
else if (TF == ARMII::MO_HI16)
|
2009-11-24 08:44:37 +08:00
|
|
|
O << ":upper16:";
|
2009-10-09 04:43:22 +08:00
|
|
|
O << Imm;
|
2006-05-25 20:57:06 +08:00
|
|
|
break;
|
2007-01-19 15:51:42 +08:00
|
|
|
}
|
2006-05-25 20:57:06 +08:00
|
|
|
case MachineOperand::MO_MachineBasicBlock:
|
2015-06-09 08:31:39 +08:00
|
|
|
MO.getMBB()->getSymbol()->print(O, MAI);
|
2006-05-25 20:57:06 +08:00
|
|
|
return;
|
2006-07-16 09:02:57 +08:00
|
|
|
case MachineOperand::MO_GlobalAddress: {
|
2010-04-15 09:51:59 +08:00
|
|
|
const GlobalValue *GV = MO.getGlobal();
|
2015-05-14 04:28:41 +08:00
|
|
|
if (TF & ARMII::MO_LO16)
|
2009-11-24 08:44:37 +08:00
|
|
|
O << ":lower16:";
|
2015-05-14 04:28:41 +08:00
|
|
|
else if (TF & ARMII::MO_HI16)
|
2009-11-24 08:44:37 +08:00
|
|
|
O << ":upper16:";
|
2015-06-09 08:31:39 +08:00
|
|
|
GetARMGVSymbol(GV, TF)->print(O, MAI);
|
2008-11-23 00:15:34 +08:00
|
|
|
|
2010-04-04 06:28:33 +08:00
|
|
|
printOffset(MO.getOffset(), O);
|
2010-10-07 05:36:43 +08:00
|
|
|
if (TF == ARMII::MO_PLT)
|
2007-04-22 08:04:12 +08:00
|
|
|
O << "(PLT)";
|
2006-05-25 20:57:06 +08:00
|
|
|
break;
|
2007-01-19 15:51:42 +08:00
|
|
|
}
|
2006-05-25 20:57:06 +08:00
|
|
|
case MachineOperand::MO_ConstantPoolIndex:
|
2015-06-09 08:31:39 +08:00
|
|
|
GetCPISymbol(MO.getIndex())->print(O, MAI);
|
2006-05-25 20:57:06 +08:00
|
|
|
break;
|
|
|
|
}
|
2006-05-15 06:18:28 +08:00
|
|
|
}
|
|
|
|
|
2009-06-29 15:51:04 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
2010-01-26 03:51:38 +08:00
|
|
|
MCSymbol *ARMAsmPrinter::
|
2015-05-14 04:28:38 +08:00
|
|
|
GetARMJTIPICJumpTableLabel(unsigned uid) const {
|
2015-07-16 14:11:10 +08:00
|
|
|
const DataLayout &DL = getDataLayout();
|
2010-01-26 03:51:38 +08:00
|
|
|
SmallString<60> Name;
|
2015-07-16 14:11:10 +08:00
|
|
|
raw_svector_ostream(Name) << DL.getPrivateGlobalPrefix() << "JTI"
|
2015-05-14 04:28:38 +08:00
|
|
|
<< getFunctionNumber() << '_' << uid;
|
2015-05-19 02:43:14 +08:00
|
|
|
return OutContext.getOrCreateSymbol(Name);
|
2010-01-26 03:39:52 +08:00
|
|
|
}
|
|
|
|
|
2009-06-29 15:51:04 +08:00
|
|
|
bool ARMAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
|
2010-04-04 13:29:35 +08:00
|
|
|
unsigned AsmVariant, const char *ExtraCode,
|
|
|
|
raw_ostream &O) {
|
2007-01-19 15:51:42 +08:00
|
|
|
// Does this asm operand have a single letter operand modifier?
|
|
|
|
if (ExtraCode && ExtraCode[0]) {
|
|
|
|
if (ExtraCode[1] != 0) return true; // Unknown modifier.
|
2009-08-09 07:10:41 +08:00
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
switch (ExtraCode[0]) {
|
2012-06-26 21:49:27 +08:00
|
|
|
default:
|
|
|
|
// See if this is a generic print operand
|
|
|
|
return AsmPrinter::PrintAsmOperand(MI, OpNum, AsmVariant, ExtraCode, O);
|
2009-07-10 07:54:51 +08:00
|
|
|
case 'a': // Print as a memory address.
|
|
|
|
if (MI->getOperand(OpNum).isReg()) {
|
2010-09-30 23:25:22 +08:00
|
|
|
O << "["
|
|
|
|
<< ARMInstPrinter::getRegisterName(MI->getOperand(OpNum).getReg())
|
|
|
|
<< "]";
|
2009-07-10 07:54:51 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Fallthrough
|
|
|
|
case 'c': // Don't print "#" before an immediate operand.
|
2009-08-22 05:58:55 +08:00
|
|
|
if (!MI->getOperand(OpNum).isImm())
|
|
|
|
return true;
|
2010-09-30 09:57:53 +08:00
|
|
|
O << MI->getOperand(OpNum).getImm();
|
2009-04-07 05:46:51 +08:00
|
|
|
return false;
|
2007-04-04 08:13:29 +08:00
|
|
|
case 'P': // Print a VFP double precision register.
|
2009-12-09 07:06:22 +08:00
|
|
|
case 'q': // Print a NEON quad precision register.
|
2010-04-04 12:47:45 +08:00
|
|
|
printOperand(MI, OpNum, O);
|
2007-03-09 06:42:46 +08:00
|
|
|
return false;
|
2011-05-25 06:10:34 +08:00
|
|
|
case 'y': // Print a VFP single precision register as indexed double.
|
|
|
|
if (MI->getOperand(OpNum).isReg()) {
|
|
|
|
unsigned Reg = MI->getOperand(OpNum).getReg();
|
2014-08-05 10:39:49 +08:00
|
|
|
const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
|
2012-05-31 07:00:43 +08:00
|
|
|
// Find the 'd' register that has this 's' register as a sub-register,
|
|
|
|
// and determine the lane number.
|
|
|
|
for (MCSuperRegIterator SR(Reg, TRI); SR.isValid(); ++SR) {
|
|
|
|
if (!ARM::DPRRegClass.contains(*SR))
|
|
|
|
continue;
|
|
|
|
bool Lane0 = TRI->getSubReg(*SR, ARM::ssub_0) == Reg;
|
|
|
|
O << ARMInstPrinter::getRegisterName(*SR) << (Lane0 ? "[0]" : "[1]");
|
|
|
|
return false;
|
|
|
|
}
|
2011-05-25 06:10:34 +08:00
|
|
|
}
|
2011-05-25 07:27:13 +08:00
|
|
|
return true;
|
2011-05-25 06:27:43 +08:00
|
|
|
case 'B': // Bitwise inverse of integer or symbol without a preceding #.
|
2011-05-25 07:15:43 +08:00
|
|
|
if (!MI->getOperand(OpNum).isImm())
|
|
|
|
return true;
|
|
|
|
O << ~(MI->getOperand(OpNum).getImm());
|
|
|
|
return false;
|
2011-05-25 06:27:43 +08:00
|
|
|
case 'L': // The low 16 bits of an immediate constant.
|
2011-05-25 07:27:13 +08:00
|
|
|
if (!MI->getOperand(OpNum).isImm())
|
|
|
|
return true;
|
|
|
|
O << (MI->getOperand(OpNum).getImm() & 0xffff);
|
|
|
|
return false;
|
2011-05-28 09:40:44 +08:00
|
|
|
case 'M': { // A register range suitable for LDM/STM.
|
|
|
|
if (!MI->getOperand(OpNum).isReg())
|
|
|
|
return true;
|
|
|
|
const MachineOperand &MO = MI->getOperand(OpNum);
|
|
|
|
unsigned RegBegin = MO.getReg();
|
|
|
|
// This takes advantage of the 2 operand-ness of ldm/stm and that we've
|
|
|
|
// already got the operands in registers that are operands to the
|
|
|
|
// inline asm statement.
|
2013-06-29 01:26:02 +08:00
|
|
|
O << "{";
|
|
|
|
if (ARM::GPRPairRegClass.contains(RegBegin)) {
|
2014-08-05 10:39:49 +08:00
|
|
|
const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
|
2013-06-29 01:26:02 +08:00
|
|
|
unsigned Reg0 = TRI->getSubReg(RegBegin, ARM::gsub_0);
|
2014-04-20 07:56:35 +08:00
|
|
|
O << ARMInstPrinter::getRegisterName(Reg0) << ", ";
|
2013-06-29 01:26:02 +08:00
|
|
|
RegBegin = TRI->getSubReg(RegBegin, ARM::gsub_1);
|
|
|
|
}
|
|
|
|
O << ARMInstPrinter::getRegisterName(RegBegin);
|
2011-09-03 02:46:15 +08:00
|
|
|
|
2011-05-28 09:40:44 +08:00
|
|
|
// FIXME: The register allocator not only may not have given us the
|
|
|
|
// registers in sequence, but may not be in ascending registers. This
|
|
|
|
// will require changes in the register allocator that'll need to be
|
|
|
|
// propagated down here if the operands change.
|
|
|
|
unsigned RegOps = OpNum + 1;
|
|
|
|
while (MI->getOperand(RegOps).isReg()) {
|
2011-09-03 02:46:15 +08:00
|
|
|
O << ", "
|
2011-05-28 09:40:44 +08:00
|
|
|
<< ARMInstPrinter::getRegisterName(MI->getOperand(RegOps).getReg());
|
|
|
|
RegOps++;
|
|
|
|
}
|
|
|
|
|
|
|
|
O << "}";
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2011-08-11 00:26:42 +08:00
|
|
|
case 'R': // The most significant register of a pair.
|
|
|
|
case 'Q': { // The least significant register of a pair.
|
|
|
|
if (OpNum == 0)
|
|
|
|
return true;
|
|
|
|
const MachineOperand &FlagsOP = MI->getOperand(OpNum - 1);
|
|
|
|
if (!FlagsOP.isImm())
|
|
|
|
return true;
|
|
|
|
unsigned Flags = FlagsOP.getImm();
|
2013-08-22 14:51:04 +08:00
|
|
|
|
|
|
|
// This operand may not be the one that actually provides the register. If
|
|
|
|
// it's tied to a previous one then we should refer instead to that one
|
|
|
|
// for registers and their classes.
|
|
|
|
unsigned TiedIdx;
|
|
|
|
if (InlineAsm::isUseOperandTiedToDef(Flags, TiedIdx)) {
|
|
|
|
for (OpNum = InlineAsm::MIOp_FirstOperand; TiedIdx; --TiedIdx) {
|
|
|
|
unsigned OpFlags = MI->getOperand(OpNum).getImm();
|
|
|
|
OpNum += InlineAsm::getNumOperandRegisters(OpFlags) + 1;
|
|
|
|
}
|
|
|
|
Flags = MI->getOperand(OpNum).getImm();
|
|
|
|
|
|
|
|
// Later code expects OpNum to be pointing at the register rather than
|
|
|
|
// the flags.
|
|
|
|
OpNum += 1;
|
|
|
|
}
|
|
|
|
|
2011-08-11 00:26:42 +08:00
|
|
|
unsigned NumVals = InlineAsm::getNumOperandRegisters(Flags);
|
2013-06-29 01:26:02 +08:00
|
|
|
unsigned RC;
|
|
|
|
InlineAsm::hasRegClassConstraint(Flags, RC);
|
|
|
|
if (RC == ARM::GPRPairRegClassID) {
|
|
|
|
if (NumVals != 1)
|
|
|
|
return true;
|
|
|
|
const MachineOperand &MO = MI->getOperand(OpNum);
|
|
|
|
if (!MO.isReg())
|
|
|
|
return true;
|
2014-08-05 10:39:49 +08:00
|
|
|
const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
|
2013-06-29 01:26:02 +08:00
|
|
|
unsigned Reg = TRI->getSubReg(MO.getReg(), ExtraCode[0] == 'Q' ?
|
|
|
|
ARM::gsub_0 : ARM::gsub_1);
|
|
|
|
O << ARMInstPrinter::getRegisterName(Reg);
|
|
|
|
return false;
|
|
|
|
}
|
2011-08-11 00:26:42 +08:00
|
|
|
if (NumVals != 2)
|
|
|
|
return true;
|
|
|
|
unsigned RegOp = ExtraCode[0] == 'Q' ? OpNum : OpNum + 1;
|
|
|
|
if (RegOp >= MI->getNumOperands())
|
|
|
|
return true;
|
|
|
|
const MachineOperand &MO = MI->getOperand(RegOp);
|
|
|
|
if (!MO.isReg())
|
|
|
|
return true;
|
|
|
|
unsigned Reg = MO.getReg();
|
|
|
|
O << ARMInstPrinter::getRegisterName(Reg);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-25 06:27:43 +08:00
|
|
|
case 'e': // The low doubleword register of a NEON quad register.
|
2011-12-13 05:45:15 +08:00
|
|
|
case 'f': { // The high doubleword register of a NEON quad register.
|
|
|
|
if (!MI->getOperand(OpNum).isReg())
|
|
|
|
return true;
|
|
|
|
unsigned Reg = MI->getOperand(OpNum).getReg();
|
|
|
|
if (!ARM::QPRRegClass.contains(Reg))
|
|
|
|
return true;
|
2014-08-05 10:39:49 +08:00
|
|
|
const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
|
2011-12-13 05:45:15 +08:00
|
|
|
unsigned SubReg = TRI->getSubReg(Reg, ExtraCode[0] == 'e' ?
|
|
|
|
ARM::dsub_0 : ARM::dsub_1);
|
|
|
|
O << ARMInstPrinter::getRegisterName(SubReg);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-08-14 02:18:52 +08:00
|
|
|
// This modifier is not yet supported.
|
2011-05-25 06:27:43 +08:00
|
|
|
case 'h': // A range of VFP/NEON registers suitable for VLD1/VST1.
|
2010-05-28 04:23:42 +08:00
|
|
|
return true;
|
2012-08-15 07:32:15 +08:00
|
|
|
case 'H': { // The highest-numbered register of a pair.
|
2012-08-14 02:18:52 +08:00
|
|
|
const MachineOperand &MO = MI->getOperand(OpNum);
|
|
|
|
if (!MO.isReg())
|
|
|
|
return true;
|
|
|
|
const MachineFunction &MF = *MI->getParent()->getParent();
|
2014-08-05 10:39:49 +08:00
|
|
|
const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
|
2013-02-15 02:10:21 +08:00
|
|
|
unsigned Reg = MO.getReg();
|
|
|
|
if(!ARM::GPRPairRegClass.contains(Reg))
|
|
|
|
return false;
|
|
|
|
Reg = TRI->getSubReg(Reg, ARM::gsub_1);
|
2012-08-14 02:18:52 +08:00
|
|
|
O << ARMInstPrinter::getRegisterName(Reg);
|
|
|
|
return false;
|
2010-05-28 06:08:38 +08:00
|
|
|
}
|
2012-08-15 07:32:15 +08:00
|
|
|
}
|
2007-01-19 15:51:42 +08:00
|
|
|
}
|
2009-09-04 09:38:51 +08:00
|
|
|
|
2010-04-04 12:47:45 +08:00
|
|
|
printOperand(MI, OpNum, O);
|
2007-01-19 15:51:42 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-05-19 13:53:42 +08:00
|
|
|
bool ARMAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
|
2009-06-29 15:51:04 +08:00
|
|
|
unsigned OpNum, unsigned AsmVariant,
|
2010-04-04 13:29:35 +08:00
|
|
|
const char *ExtraCode,
|
|
|
|
raw_ostream &O) {
|
2011-05-26 04:51:58 +08:00
|
|
|
// Does this asm operand have a single letter operand modifier?
|
|
|
|
if (ExtraCode && ExtraCode[0]) {
|
|
|
|
if (ExtraCode[1] != 0) return true; // Unknown modifier.
|
2011-09-03 02:46:15 +08:00
|
|
|
|
2011-05-26 04:51:58 +08:00
|
|
|
switch (ExtraCode[0]) {
|
2011-05-27 02:22:26 +08:00
|
|
|
case 'A': // A memory operand for a VLD1/VST1 instruction.
|
2011-05-26 04:51:58 +08:00
|
|
|
default: return true; // Unknown modifier.
|
|
|
|
case 'm': // The base register of a memory operand.
|
|
|
|
if (!MI->getOperand(OpNum).isReg())
|
|
|
|
return true;
|
|
|
|
O << ARMInstPrinter::getRegisterName(MI->getOperand(OpNum).getReg());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-09-03 02:46:15 +08:00
|
|
|
|
2009-10-14 04:50:28 +08:00
|
|
|
const MachineOperand &MO = MI->getOperand(OpNum);
|
|
|
|
assert(MO.isReg() && "unexpected inline asm memory operand");
|
2010-09-30 09:57:53 +08:00
|
|
|
O << "[" << ARMInstPrinter::getRegisterName(MO.getReg()) << "]";
|
2009-05-19 13:53:42 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-24 23:47:54 +08:00
|
|
|
static bool isThumb(const MCSubtargetInfo& STI) {
|
2015-05-26 18:47:10 +08:00
|
|
|
return STI.getFeatureBits()[ARM::ModeThumb];
|
2014-01-24 23:47:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ARMAsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
|
2014-02-07 02:19:40 +08:00
|
|
|
const MCSubtargetInfo *EndInfo) const {
|
2014-01-24 23:47:54 +08:00
|
|
|
// If either end mode is unknown (EndInfo == NULL) or different than
|
|
|
|
// the start mode, then restore the start mode.
|
|
|
|
const bool WasThumb = isThumb(StartInfo);
|
2014-04-25 13:30:21 +08:00
|
|
|
if (!EndInfo || WasThumb != isThumb(*EndInfo)) {
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitAssemblerFlag(WasThumb ? MCAF_Code16 : MCAF_Code32);
|
2014-01-24 23:47:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-01 06:06:26 +08:00
|
|
|
void ARMAsmPrinter::EmitStartOfAsmFile(Module &M) {
|
2015-06-16 23:44:21 +08:00
|
|
|
const Triple &TT = TM.getTargetTriple();
|
2009-11-09 08:11:35 +08:00
|
|
|
// Use unified assembler syntax.
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitAssemblerFlag(MCAF_SyntaxUnified);
|
2009-06-18 07:43:18 +08:00
|
|
|
|
2009-05-24 03:51:20 +08:00
|
|
|
// Emit ARM Build Attributes
|
2015-02-18 04:02:32 +08:00
|
|
|
if (TT.isOSBinFormatELF())
|
2010-10-07 06:36:46 +08:00
|
|
|
emitAttributes();
|
2014-07-25 13:12:49 +08:00
|
|
|
|
2015-02-18 04:02:32 +08:00
|
|
|
// Use the triple's architecture and subarchitecture to determine
|
|
|
|
// if we're thumb for the purposes of the top level code16 assembler
|
|
|
|
// flag.
|
|
|
|
bool isThumb = TT.getArch() == Triple::thumb ||
|
|
|
|
TT.getArch() == Triple::thumbeb ||
|
|
|
|
TT.getSubArch() == Triple::ARMSubArch_v7m ||
|
|
|
|
TT.getSubArch() == Triple::ARMSubArch_v6m;
|
|
|
|
if (!M.getModuleInlineAsm().empty() && isThumb)
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitAssemblerFlag(MCAF_Code16);
|
2006-05-15 06:18:28 +08:00
|
|
|
}
|
|
|
|
|
2014-04-29 18:06:05 +08:00
|
|
|
static void
|
|
|
|
emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel,
|
|
|
|
MachineModuleInfoImpl::StubValueTy &MCSym) {
|
|
|
|
// L_foo$stub:
|
|
|
|
OutStreamer.EmitLabel(StubLabel);
|
|
|
|
// .indirect_symbol _foo
|
|
|
|
OutStreamer.EmitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol);
|
|
|
|
|
|
|
|
if (MCSym.getInt())
|
|
|
|
// External to current translation unit.
|
|
|
|
OutStreamer.EmitIntValue(0, 4/*size*/);
|
|
|
|
else
|
|
|
|
// Internal to current translation unit.
|
|
|
|
//
|
|
|
|
// When we place the LSDA into the TEXT section, the type info
|
|
|
|
// pointers need to be indirect and pc-rel. We accomplish this by
|
|
|
|
// using NLPs; however, sometimes the types are local to the file.
|
|
|
|
// We need to fill in the value for the NLP in those cases.
|
|
|
|
OutStreamer.EmitValue(
|
2015-05-30 09:25:56 +08:00
|
|
|
MCSymbolRefExpr::create(MCSym.getPointer(), OutStreamer.getContext()),
|
2014-04-29 18:06:05 +08:00
|
|
|
4 /*size*/);
|
|
|
|
}
|
|
|
|
|
2008-08-07 17:54:23 +08:00
|
|
|
|
2009-10-20 01:59:19 +08:00
|
|
|
void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) {
|
2015-06-16 23:44:21 +08:00
|
|
|
const Triple &TT = TM.getTargetTriple();
|
2015-02-18 04:02:32 +08:00
|
|
|
if (TT.isOSBinFormatMachO()) {
|
2009-08-04 06:18:15 +08:00
|
|
|
// All darwin targets use mach-o.
|
2010-04-18 00:44:48 +08:00
|
|
|
const TargetLoweringObjectFileMachO &TLOFMacho =
|
|
|
|
static_cast<const TargetLoweringObjectFileMachO &>(getObjFileLowering());
|
2009-10-20 02:38:33 +08:00
|
|
|
MachineModuleInfoMachO &MMIMacho =
|
|
|
|
MMI->getObjFileInfo<MachineModuleInfoMachO>();
|
2009-09-04 09:38:51 +08:00
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
// Output non-lazy-pointers for external and common global variables.
|
2009-10-20 02:38:33 +08:00
|
|
|
MachineModuleInfoMachO::SymbolListTy Stubs = MMIMacho.GetGVStubList();
|
2010-03-11 06:34:10 +08:00
|
|
|
|
2009-10-20 02:38:33 +08:00
|
|
|
if (!Stubs.empty()) {
|
2009-08-10 09:39:42 +08:00
|
|
|
// Switch with ".non_lazy_symbol_pointer" directive.
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->SwitchSection(TLOFMacho.getNonLazySymbolPointerSection());
|
2009-08-11 02:01:34 +08:00
|
|
|
EmitAlignment(2);
|
2014-04-29 18:06:05 +08:00
|
|
|
|
|
|
|
for (auto &Stub : Stubs)
|
2015-04-25 03:11:51 +08:00
|
|
|
emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second);
|
2010-03-09 08:40:17 +08:00
|
|
|
|
|
|
|
Stubs.clear();
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->AddBlankLine();
|
2007-01-19 15:51:42 +08:00
|
|
|
}
|
|
|
|
|
2009-10-20 02:44:38 +08:00
|
|
|
Stubs = MMIMacho.GetHiddenGVStubList();
|
|
|
|
if (!Stubs.empty()) {
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->SwitchSection(TLOFMacho.getNonLazySymbolPointerSection());
|
2009-08-11 02:02:16 +08:00
|
|
|
EmitAlignment(2);
|
2014-04-29 18:06:05 +08:00
|
|
|
|
|
|
|
for (auto &Stub : Stubs)
|
2015-04-25 03:11:51 +08:00
|
|
|
emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second);
|
2010-03-09 08:43:34 +08:00
|
|
|
|
|
|
|
Stubs.clear();
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->AddBlankLine();
|
2008-12-05 09:06:39 +08:00
|
|
|
}
|
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
// Funny Darwin hack: This flag tells the linker that no global symbols
|
|
|
|
// contain code that falls through to other global symbols (e.g. the obvious
|
|
|
|
// implementation of multiple entry points). If this doesn't occur, the
|
|
|
|
// linker can safely perform dead code stripping. Since LLVM never
|
|
|
|
// generates code that does this, it is always safe to set.
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
|
2006-07-27 19:38:51 +08:00
|
|
|
}
|
2015-12-07 22:22:39 +08:00
|
|
|
|
|
|
|
// The last attribute to be emitted is ABI_optimization_goals
|
|
|
|
MCTargetStreamer &TS = *OutStreamer->getTargetStreamer();
|
|
|
|
ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
|
|
|
|
|
|
|
|
if (OptimizationGoals > 0)
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_optimization_goals, OptimizationGoals);
|
|
|
|
OptimizationGoals = -1;
|
|
|
|
|
|
|
|
ATS.finishAttributeSection();
|
2006-05-15 06:18:28 +08:00
|
|
|
}
|
2008-08-17 21:55:10 +08:00
|
|
|
|
2010-10-07 06:36:46 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Helper routines for EmitStartOfAsmFile() and EmitEndOfAsmFile()
|
|
|
|
// FIXME:
|
|
|
|
// The following seem like one-off assembler flags, but they actually need
|
2010-10-07 06:46:47 +08:00
|
|
|
// to appear in the .ARM.attributes section in ELF.
|
2010-10-07 06:36:46 +08:00
|
|
|
// Instead of subclassing the MCELFStreamer, we do the work here.
|
|
|
|
|
2013-10-08 00:55:23 +08:00
|
|
|
static ARMBuildAttrs::CPUArch getArchForCPU(StringRef CPU,
|
|
|
|
const ARMSubtarget *Subtarget) {
|
|
|
|
if (CPU == "xscale")
|
|
|
|
return ARMBuildAttrs::v5TEJ;
|
|
|
|
|
|
|
|
if (Subtarget->hasV8Ops())
|
|
|
|
return ARMBuildAttrs::v8;
|
|
|
|
else if (Subtarget->hasV7Ops()) {
|
2015-09-25 01:31:16 +08:00
|
|
|
if (Subtarget->isMClass() && Subtarget->hasDSP())
|
2013-10-08 00:55:23 +08:00
|
|
|
return ARMBuildAttrs::v7E_M;
|
|
|
|
return ARMBuildAttrs::v7;
|
|
|
|
} else if (Subtarget->hasV6T2Ops())
|
|
|
|
return ARMBuildAttrs::v6T2;
|
|
|
|
else if (Subtarget->hasV6MOps())
|
|
|
|
return ARMBuildAttrs::v6S_M;
|
|
|
|
else if (Subtarget->hasV6Ops())
|
|
|
|
return ARMBuildAttrs::v6;
|
|
|
|
else if (Subtarget->hasV5TEOps())
|
|
|
|
return ARMBuildAttrs::v5TE;
|
|
|
|
else if (Subtarget->hasV5TOps())
|
|
|
|
return ARMBuildAttrs::v5T;
|
|
|
|
else if (Subtarget->hasV4TOps())
|
|
|
|
return ARMBuildAttrs::v4T;
|
|
|
|
else
|
|
|
|
return ARMBuildAttrs::v4;
|
|
|
|
}
|
|
|
|
|
2010-10-07 06:36:46 +08:00
|
|
|
void ARMAsmPrinter::emitAttributes() {
|
2015-04-25 03:11:51 +08:00
|
|
|
MCTargetStreamer &TS = *OutStreamer->getTargetStreamer();
|
[arm] Implement eabi_attribute, cpu, and fpu directives.
This commit allows the ARM integrated assembler to parse
and assemble the code with .eabi_attribute, .cpu, and
.fpu directives.
To implement the feature, this commit moves the code from
AttrEmitter to ARMTargetStreamers, and several new test
cases related to cortex-m4, cortex-r5, and cortex-a15 are
added.
Besides, this commit also change the Subtarget->isFPOnlySP()
to Subtarget->hasD16() to match the usage of .fpu directive.
This commit changes the test cases:
* Several .eabi_attribute directives in
2010-09-29-mc-asm-header-test.ll are removed because the .fpu
directive already cover the functionality.
* In the Cortex-A15 test case, the value for
Tag_Advanced_SIMD_arch has be changed from 1 to 2,
which is more precise.
llvm-svn: 193524
2013-10-29 01:51:12 +08:00
|
|
|
ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
|
2010-10-07 06:46:47 +08:00
|
|
|
|
2015-01-05 21:12:17 +08:00
|
|
|
ATS.emitTextAttribute(ARMBuildAttrs::conformance, "2.09");
|
|
|
|
|
[arm] Implement eabi_attribute, cpu, and fpu directives.
This commit allows the ARM integrated assembler to parse
and assemble the code with .eabi_attribute, .cpu, and
.fpu directives.
To implement the feature, this commit moves the code from
AttrEmitter to ARMTargetStreamers, and several new test
cases related to cortex-m4, cortex-r5, and cortex-a15 are
added.
Besides, this commit also change the Subtarget->isFPOnlySP()
to Subtarget->hasD16() to match the usage of .fpu directive.
This commit changes the test cases:
* Several .eabi_attribute directives in
2010-09-29-mc-asm-header-test.ll are removed because the .fpu
directive already cover the functionality.
* In the Cortex-A15 test case, the value for
Tag_Advanced_SIMD_arch has be changed from 1 to 2,
which is more precise.
llvm-svn: 193524
2013-10-29 01:51:12 +08:00
|
|
|
ATS.switchVendor("aeabi");
|
2010-10-26 01:50:35 +08:00
|
|
|
|
2015-02-18 04:02:32 +08:00
|
|
|
// Compute ARM ELF Attributes based on the default subtarget that
|
|
|
|
// we'd have constructed. The existing ARM behavior isn't LTO clean
|
|
|
|
// anyhow.
|
|
|
|
// FIXME: For ifunc related functions we could iterate over and look
|
|
|
|
// for a feature string that doesn't match the default one.
|
2015-06-16 23:44:21 +08:00
|
|
|
const Triple &TT = TM.getTargetTriple();
|
2015-02-18 04:02:32 +08:00
|
|
|
StringRef CPU = TM.getTargetCPU();
|
|
|
|
StringRef FS = TM.getTargetFeatureString();
|
2015-09-16 00:17:27 +08:00
|
|
|
std::string ArchFS = ARM_MC::ParseARMTriple(TT, CPU);
|
2015-02-18 04:02:32 +08:00
|
|
|
if (!FS.empty()) {
|
|
|
|
if (!ArchFS.empty())
|
2015-03-30 23:42:36 +08:00
|
|
|
ArchFS = (Twine(ArchFS) + "," + FS).str();
|
2015-02-18 04:02:32 +08:00
|
|
|
else
|
|
|
|
ArchFS = FS;
|
|
|
|
}
|
|
|
|
const ARMBaseTargetMachine &ATM =
|
|
|
|
static_cast<const ARMBaseTargetMachine &>(TM);
|
|
|
|
const ARMSubtarget STI(TT, CPU, ArchFS, ATM, ATM.isLittleEndian());
|
|
|
|
|
|
|
|
std::string CPUString = STI.getCPUString();
|
2011-02-07 08:49:53 +08:00
|
|
|
|
2015-03-27 01:05:54 +08:00
|
|
|
if (CPUString.find("generic") != 0) { //CPUString doesn't start with "generic"
|
2015-02-27 02:08:41 +08:00
|
|
|
// FIXME: remove krait check when GNU tools support krait cpu
|
|
|
|
if (STI.isKrait()) {
|
|
|
|
ATS.emitTextAttribute(ARMBuildAttrs::CPU_name, "cortex-a9");
|
|
|
|
// We consider krait as a "cortex-a9" + hwdiv CPU
|
|
|
|
// Enable hwdiv through ".arch_extension idiv"
|
|
|
|
if (STI.hasDivide() || STI.hasDivideInARMMode())
|
2015-07-28 06:26:59 +08:00
|
|
|
ATS.emitArchExtension(ARM::AEK_HWDIV | ARM::AEK_HWDIVARM);
|
2015-02-27 02:08:41 +08:00
|
|
|
} else
|
|
|
|
ATS.emitTextAttribute(ARMBuildAttrs::CPU_name, CPUString);
|
|
|
|
}
|
2013-10-08 00:55:23 +08:00
|
|
|
|
2015-02-18 04:02:32 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::CPU_arch, getArchForCPU(CPUString, &STI));
|
2013-10-08 00:55:23 +08:00
|
|
|
|
2014-01-11 00:42:55 +08:00
|
|
|
// Tag_CPU_arch_profile must have the default value of 0 when "Architecture
|
2014-04-04 07:43:18 +08:00
|
|
|
// profile is not applicable (e.g. pre v7, or cross-profile code)".
|
2015-02-18 04:02:32 +08:00
|
|
|
if (STI.hasV7Ops()) {
|
|
|
|
if (STI.isAClass()) {
|
2014-01-11 00:42:55 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::CPU_arch_profile,
|
|
|
|
ARMBuildAttrs::ApplicationProfile);
|
2015-02-18 04:02:32 +08:00
|
|
|
} else if (STI.isRClass()) {
|
2014-01-11 00:42:55 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::CPU_arch_profile,
|
|
|
|
ARMBuildAttrs::RealTimeProfile);
|
2015-02-18 04:02:32 +08:00
|
|
|
} else if (STI.isMClass()) {
|
2014-01-11 00:42:55 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::CPU_arch_profile,
|
|
|
|
ARMBuildAttrs::MicroControllerProfile);
|
|
|
|
}
|
2013-10-08 00:55:23 +08:00
|
|
|
}
|
|
|
|
|
2015-02-18 04:02:32 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ARM_ISA_use,
|
|
|
|
STI.hasARMOps() ? ARMBuildAttrs::Allowed
|
|
|
|
: ARMBuildAttrs::Not_Allowed);
|
|
|
|
if (STI.isThumb1Only()) {
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::THUMB_ISA_use, ARMBuildAttrs::Allowed);
|
|
|
|
} else if (STI.hasThumb2()) {
|
[arm] Implement eabi_attribute, cpu, and fpu directives.
This commit allows the ARM integrated assembler to parse
and assemble the code with .eabi_attribute, .cpu, and
.fpu directives.
To implement the feature, this commit moves the code from
AttrEmitter to ARMTargetStreamers, and several new test
cases related to cortex-m4, cortex-r5, and cortex-a15 are
added.
Besides, this commit also change the Subtarget->isFPOnlySP()
to Subtarget->hasD16() to match the usage of .fpu directive.
This commit changes the test cases:
* Several .eabi_attribute directives in
2010-09-29-mc-asm-header-test.ll are removed because the .fpu
directive already cover the functionality.
* In the Cortex-A15 test case, the value for
Tag_Advanced_SIMD_arch has be changed from 1 to 2,
which is more precise.
llvm-svn: 193524
2013-10-29 01:51:12 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::THUMB_ISA_use,
|
|
|
|
ARMBuildAttrs::AllowThumb32);
|
2013-10-08 00:55:23 +08:00
|
|
|
}
|
2010-10-07 06:36:46 +08:00
|
|
|
|
2015-02-18 04:02:32 +08:00
|
|
|
if (STI.hasNEON()) {
|
2011-03-01 06:04:27 +08:00
|
|
|
/* NEON is not exactly a VFP architecture, but GAS emit one of
|
2013-09-13 19:51:52 +08:00
|
|
|
* neon/neon-fp-armv8/neon-vfpv4/vfpv3/vfpv2 for .fpu parameters */
|
2015-02-18 04:02:32 +08:00
|
|
|
if (STI.hasFPARMv8()) {
|
|
|
|
if (STI.hasCrypto())
|
2015-05-12 18:33:58 +08:00
|
|
|
ATS.emitFPU(ARM::FK_CRYPTO_NEON_FP_ARMV8);
|
2013-10-08 00:55:23 +08:00
|
|
|
else
|
2015-05-12 18:33:58 +08:00
|
|
|
ATS.emitFPU(ARM::FK_NEON_FP_ARMV8);
|
2015-02-18 04:02:32 +08:00
|
|
|
} else if (STI.hasVFP4())
|
2015-05-12 18:33:58 +08:00
|
|
|
ATS.emitFPU(ARM::FK_NEON_VFPV4);
|
2012-01-22 20:07:33 +08:00
|
|
|
else
|
2015-06-29 17:32:29 +08:00
|
|
|
ATS.emitFPU(STI.hasFP16() ? ARM::FK_NEON_FP16 : ARM::FK_NEON);
|
[arm] Implement eabi_attribute, cpu, and fpu directives.
This commit allows the ARM integrated assembler to parse
and assemble the code with .eabi_attribute, .cpu, and
.fpu directives.
To implement the feature, this commit moves the code from
AttrEmitter to ARMTargetStreamers, and several new test
cases related to cortex-m4, cortex-r5, and cortex-a15 are
added.
Besides, this commit also change the Subtarget->isFPOnlySP()
to Subtarget->hasD16() to match the usage of .fpu directive.
This commit changes the test cases:
* Several .eabi_attribute directives in
2010-09-29-mc-asm-header-test.ll are removed because the .fpu
directive already cover the functionality.
* In the Cortex-A15 test case, the value for
Tag_Advanced_SIMD_arch has be changed from 1 to 2,
which is more precise.
llvm-svn: 193524
2013-10-29 01:51:12 +08:00
|
|
|
// Emit Tag_Advanced_SIMD_arch for ARMv8 architecture
|
2015-02-18 04:02:32 +08:00
|
|
|
if (STI.hasV8Ops())
|
[arm] Implement eabi_attribute, cpu, and fpu directives.
This commit allows the ARM integrated assembler to parse
and assemble the code with .eabi_attribute, .cpu, and
.fpu directives.
To implement the feature, this commit moves the code from
AttrEmitter to ARMTargetStreamers, and several new test
cases related to cortex-m4, cortex-r5, and cortex-a15 are
added.
Besides, this commit also change the Subtarget->isFPOnlySP()
to Subtarget->hasD16() to match the usage of .fpu directive.
This commit changes the test cases:
* Several .eabi_attribute directives in
2010-09-29-mc-asm-header-test.ll are removed because the .fpu
directive already cover the functionality.
* In the Cortex-A15 test case, the value for
Tag_Advanced_SIMD_arch has be changed from 1 to 2,
which is more precise.
llvm-svn: 193524
2013-10-29 01:51:12 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::Advanced_SIMD_arch,
|
2015-04-01 22:54:56 +08:00
|
|
|
STI.hasV8_1aOps() ? ARMBuildAttrs::AllowNeonARMv8_1a:
|
|
|
|
ARMBuildAttrs::AllowNeonARMv8);
|
[arm] Implement eabi_attribute, cpu, and fpu directives.
This commit allows the ARM integrated assembler to parse
and assemble the code with .eabi_attribute, .cpu, and
.fpu directives.
To implement the feature, this commit moves the code from
AttrEmitter to ARMTargetStreamers, and several new test
cases related to cortex-m4, cortex-r5, and cortex-a15 are
added.
Besides, this commit also change the Subtarget->isFPOnlySP()
to Subtarget->hasD16() to match the usage of .fpu directive.
This commit changes the test cases:
* Several .eabi_attribute directives in
2010-09-29-mc-asm-header-test.ll are removed because the .fpu
directive already cover the functionality.
* In the Cortex-A15 test case, the value for
Tag_Advanced_SIMD_arch has be changed from 1 to 2,
which is more precise.
llvm-svn: 193524
2013-10-29 01:51:12 +08:00
|
|
|
} else {
|
2015-02-18 04:02:32 +08:00
|
|
|
if (STI.hasFPARMv8())
|
2014-10-01 17:02:17 +08:00
|
|
|
// FPv5 and FP-ARMv8 have the same instructions, so are modeled as one
|
|
|
|
// FPU, but there are two different names for it depending on the CPU.
|
2015-06-05 21:31:19 +08:00
|
|
|
ATS.emitFPU(STI.hasD16()
|
|
|
|
? (STI.isFPOnlySP() ? ARM::FK_FPV5_SP_D16 : ARM::FK_FPV5_D16)
|
|
|
|
: ARM::FK_FP_ARMV8);
|
2015-02-18 04:02:32 +08:00
|
|
|
else if (STI.hasVFP4())
|
2015-06-05 21:31:19 +08:00
|
|
|
ATS.emitFPU(STI.hasD16()
|
|
|
|
? (STI.isFPOnlySP() ? ARM::FK_FPV4_SP_D16 : ARM::FK_VFPV4_D16)
|
|
|
|
: ARM::FK_VFPV4);
|
2015-02-18 04:02:32 +08:00
|
|
|
else if (STI.hasVFP3())
|
2015-06-29 17:32:29 +08:00
|
|
|
ATS.emitFPU(STI.hasD16()
|
|
|
|
// +d16
|
|
|
|
? (STI.isFPOnlySP()
|
|
|
|
? (STI.hasFP16() ? ARM::FK_VFPV3XD_FP16 : ARM::FK_VFPV3XD)
|
|
|
|
: (STI.hasFP16() ? ARM::FK_VFPV3_D16_FP16 : ARM::FK_VFPV3_D16))
|
|
|
|
// -d16
|
|
|
|
: (STI.hasFP16() ? ARM::FK_VFPV3_FP16 : ARM::FK_VFPV3));
|
2015-02-18 04:02:32 +08:00
|
|
|
else if (STI.hasVFP2())
|
2015-05-12 18:33:58 +08:00
|
|
|
ATS.emitFPU(ARM::FK_VFPV2);
|
2011-03-01 06:04:27 +08:00
|
|
|
}
|
2010-10-07 06:36:46 +08:00
|
|
|
|
2014-05-27 21:30:21 +08:00
|
|
|
if (TM.getRelocationModel() == Reloc::PIC_) {
|
|
|
|
// PIC specific attributes.
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_PCS_RW_data,
|
|
|
|
ARMBuildAttrs::AddressRWPCRel);
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_PCS_RO_data,
|
|
|
|
ARMBuildAttrs::AddressROPCRel);
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_PCS_GOT_use,
|
|
|
|
ARMBuildAttrs::AddressGOT);
|
|
|
|
} else {
|
|
|
|
// Allow direct addressing of imported data for all other relocation models.
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_PCS_GOT_use,
|
|
|
|
ARMBuildAttrs::AddressDirect);
|
|
|
|
}
|
|
|
|
|
2010-10-07 06:36:46 +08:00
|
|
|
// Signal various FP modes.
|
2013-10-12 00:03:43 +08:00
|
|
|
if (!TM.Options.UnsafeFPMath) {
|
2014-12-02 16:22:29 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_denormal,
|
|
|
|
ARMBuildAttrs::IEEEDenormals);
|
2015-02-18 04:02:32 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_exceptions, ARMBuildAttrs::Allowed);
|
2014-12-03 16:12:26 +08:00
|
|
|
|
|
|
|
// If the user has permitted this code to choose the IEEE 754
|
|
|
|
// rounding at run-time, emit the rounding attribute.
|
|
|
|
if (TM.Options.HonorSignDependentRoundingFPMathOption)
|
2015-02-18 04:02:32 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_rounding, ARMBuildAttrs::Allowed);
|
2014-12-02 16:22:29 +08:00
|
|
|
} else {
|
2015-02-18 04:02:32 +08:00
|
|
|
if (!STI.hasVFP2()) {
|
2014-12-02 16:22:29 +08:00
|
|
|
// When the target doesn't have an FPU (by design or
|
|
|
|
// intention), the assumptions made on the software support
|
|
|
|
// mirror that of the equivalent hardware support *if it
|
|
|
|
// existed*. For v7 and better we indicate that denormals are
|
|
|
|
// flushed preserving sign, and for V6 we indicate that
|
|
|
|
// denormals are flushed to positive zero.
|
2015-02-18 04:02:32 +08:00
|
|
|
if (STI.hasV7Ops())
|
2014-12-02 16:22:29 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_denormal,
|
|
|
|
ARMBuildAttrs::PreserveFPSign);
|
2015-02-18 04:02:32 +08:00
|
|
|
} else if (STI.hasVFP3()) {
|
2014-12-02 16:22:29 +08:00
|
|
|
// In VFPv4, VFPv4U, VFPv3, or VFPv3U, it is preserved. That is,
|
|
|
|
// the sign bit of the zero matches the sign bit of the input or
|
|
|
|
// result that is being flushed to zero.
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_denormal,
|
|
|
|
ARMBuildAttrs::PreserveFPSign);
|
|
|
|
}
|
|
|
|
// For VFPv2 implementations it is implementation defined as
|
|
|
|
// to whether denormals are flushed to positive zero or to
|
|
|
|
// whatever the sign of zero is (ARM v7AR ARM 2.7.5). Historically
|
|
|
|
// LLVM has chosen to flush this to positive zero (most likely for
|
|
|
|
// GCC compatibility), so that's the chosen value here (the
|
|
|
|
// absence of its emission implies zero).
|
2013-10-08 00:55:23 +08:00
|
|
|
}
|
2010-10-07 06:36:46 +08:00
|
|
|
|
2014-12-05 16:22:47 +08:00
|
|
|
// TM.Options.NoInfsFPMath && TM.Options.NoNaNsFPMath is the
|
|
|
|
// equivalent of GCC's -ffinite-math-only flag.
|
2013-10-12 00:03:43 +08:00
|
|
|
if (TM.Options.NoInfsFPMath && TM.Options.NoNaNsFPMath)
|
[arm] Implement eabi_attribute, cpu, and fpu directives.
This commit allows the ARM integrated assembler to parse
and assemble the code with .eabi_attribute, .cpu, and
.fpu directives.
To implement the feature, this commit moves the code from
AttrEmitter to ARMTargetStreamers, and several new test
cases related to cortex-m4, cortex-r5, and cortex-a15 are
added.
Besides, this commit also change the Subtarget->isFPOnlySP()
to Subtarget->hasD16() to match the usage of .fpu directive.
This commit changes the test cases:
* Several .eabi_attribute directives in
2010-09-29-mc-asm-header-test.ll are removed because the .fpu
directive already cover the functionality.
* In the Cortex-A15 test case, the value for
Tag_Advanced_SIMD_arch has be changed from 1 to 2,
which is more precise.
llvm-svn: 193524
2013-10-29 01:51:12 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_number_model,
|
|
|
|
ARMBuildAttrs::Allowed);
|
2013-10-12 00:03:43 +08:00
|
|
|
else
|
[arm] Implement eabi_attribute, cpu, and fpu directives.
This commit allows the ARM integrated assembler to parse
and assemble the code with .eabi_attribute, .cpu, and
.fpu directives.
To implement the feature, this commit moves the code from
AttrEmitter to ARMTargetStreamers, and several new test
cases related to cortex-m4, cortex-r5, and cortex-a15 are
added.
Besides, this commit also change the Subtarget->isFPOnlySP()
to Subtarget->hasD16() to match the usage of .fpu directive.
This commit changes the test cases:
* Several .eabi_attribute directives in
2010-09-29-mc-asm-header-test.ll are removed because the .fpu
directive already cover the functionality.
* In the Cortex-A15 test case, the value for
Tag_Advanced_SIMD_arch has be changed from 1 to 2,
which is more precise.
llvm-svn: 193524
2013-10-29 01:51:12 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_number_model,
|
|
|
|
ARMBuildAttrs::AllowIEE754);
|
2013-10-12 00:03:43 +08:00
|
|
|
|
2015-02-18 04:02:32 +08:00
|
|
|
if (STI.allowsUnalignedMem())
|
2014-10-08 20:26:22 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::CPU_unaligned_access,
|
|
|
|
ARMBuildAttrs::Allowed);
|
|
|
|
else
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::CPU_unaligned_access,
|
|
|
|
ARMBuildAttrs::Not_Allowed);
|
|
|
|
|
2014-01-19 16:25:27 +08:00
|
|
|
// FIXME: add more flags to ARMBuildAttributes.h
|
2010-10-07 06:36:46 +08:00
|
|
|
// 8-bytes alignment stuff.
|
2014-01-19 16:25:35 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_align_needed, 1);
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_align_preserved, 1);
|
2010-10-07 06:36:46 +08:00
|
|
|
|
2013-11-01 19:21:16 +08:00
|
|
|
// ABI_HardFP_use attribute to indicate single precision FP.
|
2015-02-18 04:02:32 +08:00
|
|
|
if (STI.isFPOnlySP())
|
2013-11-01 19:21:16 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_HardFP_use,
|
|
|
|
ARMBuildAttrs::HardFPSinglePrecision);
|
|
|
|
|
2010-10-07 06:36:46 +08:00
|
|
|
// Hard float. Use both S and D registers and conform to AAPCS-VFP.
|
2015-02-18 04:02:32 +08:00
|
|
|
if (STI.isAAPCS_ABI() && TM.Options.FloatABIType == FloatABI::Hard)
|
2013-11-01 19:21:16 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_VFP_args, ARMBuildAttrs::HardFPAAPCS);
|
|
|
|
|
2010-10-07 06:36:46 +08:00
|
|
|
// FIXME: Should we signal R9 usage?
|
2010-10-26 01:50:35 +08:00
|
|
|
|
2015-02-18 04:02:32 +08:00
|
|
|
if (STI.hasFP16())
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::FP_HP_extension, ARMBuildAttrs::AllowHPFP);
|
2013-11-12 18:38:05 +08:00
|
|
|
|
2014-12-12 19:59:18 +08:00
|
|
|
// FIXME: To support emitting this build attribute as GCC does, the
|
|
|
|
// -mfp16-format option and associated plumbing must be
|
|
|
|
// supported. For now the __fp16 type is exposed by default, so this
|
|
|
|
// attribute should be emitted with value 1.
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_16bit_format,
|
|
|
|
ARMBuildAttrs::FP16FormatIEEE);
|
|
|
|
|
2015-02-18 04:02:32 +08:00
|
|
|
if (STI.hasMPExtension())
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::MPextension_use, ARMBuildAttrs::AllowMP);
|
2013-11-01 21:27:35 +08:00
|
|
|
|
2014-01-20 18:18:42 +08:00
|
|
|
// Hardware divide in ARM mode is part of base arch, starting from ARMv8.
|
|
|
|
// If only Thumb hwdiv is present, it must also be in base arch (ARMv7-R/M).
|
|
|
|
// It is not possible to produce DisallowDIV: if hwdiv is present in the base
|
|
|
|
// arch, supplying -hwdiv downgrades the effective arch, via ClearImpliedBits.
|
|
|
|
// AllowDIVExt is only emitted if hwdiv isn't available in the base arch;
|
|
|
|
// otherwise, the default value (AllowDIVIfExists) applies.
|
2015-02-18 04:02:32 +08:00
|
|
|
if (STI.hasDivideInARMMode() && !STI.hasV8Ops())
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::DIV_use, ARMBuildAttrs::AllowDIVExt);
|
2010-10-26 01:50:35 +08:00
|
|
|
|
2014-06-20 18:08:11 +08:00
|
|
|
if (MMI) {
|
|
|
|
if (const Module *SourceModule = MMI->getModule()) {
|
|
|
|
// ABI_PCS_wchar_t to indicate wchar_t width
|
|
|
|
// FIXME: There is no way to emit value 0 (wchar_t prohibited).
|
IR: Split Metadata from Value
Split `Metadata` away from the `Value` class hierarchy, as part of
PR21532. Assembly and bitcode changes are in the wings, but this is the
bulk of the change for the IR C++ API.
I have a follow-up patch prepared for `clang`. If this breaks other
sub-projects, I apologize in advance :(. Help me compile it on Darwin
I'll try to fix it. FWIW, the errors should be easy to fix, so it may
be simpler to just fix it yourself.
This breaks the build for all metadata-related code that's out-of-tree.
Rest assured the transition is mechanical and the compiler should catch
almost all of the problems.
Here's a quick guide for updating your code:
- `Metadata` is the root of a class hierarchy with three main classes:
`MDNode`, `MDString`, and `ValueAsMetadata`. It is distinct from
the `Value` class hierarchy. It is typeless -- i.e., instances do
*not* have a `Type`.
- `MDNode`'s operands are all `Metadata *` (instead of `Value *`).
- `TrackingVH<MDNode>` and `WeakVH` referring to metadata can be
replaced with `TrackingMDNodeRef` and `TrackingMDRef`, respectively.
If you're referring solely to resolved `MDNode`s -- post graph
construction -- just use `MDNode*`.
- `MDNode` (and the rest of `Metadata`) have only limited support for
`replaceAllUsesWith()`.
As long as an `MDNode` is pointing at a forward declaration -- the
result of `MDNode::getTemporary()` -- it maintains a side map of its
uses and can RAUW itself. Once the forward declarations are fully
resolved RAUW support is dropped on the ground. This means that
uniquing collisions on changing operands cause nodes to become
"distinct". (This already happened fairly commonly, whenever an
operand went to null.)
If you're constructing complex (non self-reference) `MDNode` cycles,
you need to call `MDNode::resolveCycles()` on each node (or on a
top-level node that somehow references all of the nodes). Also,
don't do that. Metadata cycles (and the RAUW machinery needed to
construct them) are expensive.
- An `MDNode` can only refer to a `Constant` through a bridge called
`ConstantAsMetadata` (one of the subclasses of `ValueAsMetadata`).
As a side effect, accessing an operand of an `MDNode` that is known
to be, e.g., `ConstantInt`, takes three steps: first, cast from
`Metadata` to `ConstantAsMetadata`; second, extract the `Constant`;
third, cast down to `ConstantInt`.
The eventual goal is to introduce `MDInt`/`MDFloat`/etc. and have
metadata schema owners transition away from using `Constant`s when
the type isn't important (and they don't care about referring to
`GlobalValue`s).
In the meantime, I've added transitional API to the `mdconst`
namespace that matches semantics with the old code, in order to
avoid adding the error-prone three-step equivalent to every call
site. If your old code was:
MDNode *N = foo();
bar(isa <ConstantInt>(N->getOperand(0)));
baz(cast <ConstantInt>(N->getOperand(1)));
bak(cast_or_null <ConstantInt>(N->getOperand(2)));
bat(dyn_cast <ConstantInt>(N->getOperand(3)));
bay(dyn_cast_or_null<ConstantInt>(N->getOperand(4)));
you can trivially match its semantics with:
MDNode *N = foo();
bar(mdconst::hasa <ConstantInt>(N->getOperand(0)));
baz(mdconst::extract <ConstantInt>(N->getOperand(1)));
bak(mdconst::extract_or_null <ConstantInt>(N->getOperand(2)));
bat(mdconst::dyn_extract <ConstantInt>(N->getOperand(3)));
bay(mdconst::dyn_extract_or_null<ConstantInt>(N->getOperand(4)));
and when you transition your metadata schema to `MDInt`:
MDNode *N = foo();
bar(isa <MDInt>(N->getOperand(0)));
baz(cast <MDInt>(N->getOperand(1)));
bak(cast_or_null <MDInt>(N->getOperand(2)));
bat(dyn_cast <MDInt>(N->getOperand(3)));
bay(dyn_cast_or_null<MDInt>(N->getOperand(4)));
- A `CallInst` -- specifically, intrinsic instructions -- can refer to
metadata through a bridge called `MetadataAsValue`. This is a
subclass of `Value` where `getType()->isMetadataTy()`.
`MetadataAsValue` is the *only* class that can legally refer to a
`LocalAsMetadata`, which is a bridged form of non-`Constant` values
like `Argument` and `Instruction`. It can also refer to any other
`Metadata` subclass.
(I'll break all your testcases in a follow-up commit, when I propagate
this change to assembly.)
llvm-svn: 223802
2014-12-10 02:38:53 +08:00
|
|
|
if (auto WCharWidthValue = mdconst::extract_or_null<ConstantInt>(
|
2014-06-20 18:08:11 +08:00
|
|
|
SourceModule->getModuleFlag("wchar_size"))) {
|
|
|
|
int WCharWidth = WCharWidthValue->getZExtValue();
|
|
|
|
assert((WCharWidth == 2 || WCharWidth == 4) &&
|
|
|
|
"wchar_t width must be 2 or 4 bytes");
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_PCS_wchar_t, WCharWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ABI_enum_size to indicate enum width
|
|
|
|
// FIXME: There is no way to emit value 0 (enums prohibited) or value 3
|
|
|
|
// (all enums contain a value needing 32 bits to encode).
|
IR: Split Metadata from Value
Split `Metadata` away from the `Value` class hierarchy, as part of
PR21532. Assembly and bitcode changes are in the wings, but this is the
bulk of the change for the IR C++ API.
I have a follow-up patch prepared for `clang`. If this breaks other
sub-projects, I apologize in advance :(. Help me compile it on Darwin
I'll try to fix it. FWIW, the errors should be easy to fix, so it may
be simpler to just fix it yourself.
This breaks the build for all metadata-related code that's out-of-tree.
Rest assured the transition is mechanical and the compiler should catch
almost all of the problems.
Here's a quick guide for updating your code:
- `Metadata` is the root of a class hierarchy with three main classes:
`MDNode`, `MDString`, and `ValueAsMetadata`. It is distinct from
the `Value` class hierarchy. It is typeless -- i.e., instances do
*not* have a `Type`.
- `MDNode`'s operands are all `Metadata *` (instead of `Value *`).
- `TrackingVH<MDNode>` and `WeakVH` referring to metadata can be
replaced with `TrackingMDNodeRef` and `TrackingMDRef`, respectively.
If you're referring solely to resolved `MDNode`s -- post graph
construction -- just use `MDNode*`.
- `MDNode` (and the rest of `Metadata`) have only limited support for
`replaceAllUsesWith()`.
As long as an `MDNode` is pointing at a forward declaration -- the
result of `MDNode::getTemporary()` -- it maintains a side map of its
uses and can RAUW itself. Once the forward declarations are fully
resolved RAUW support is dropped on the ground. This means that
uniquing collisions on changing operands cause nodes to become
"distinct". (This already happened fairly commonly, whenever an
operand went to null.)
If you're constructing complex (non self-reference) `MDNode` cycles,
you need to call `MDNode::resolveCycles()` on each node (or on a
top-level node that somehow references all of the nodes). Also,
don't do that. Metadata cycles (and the RAUW machinery needed to
construct them) are expensive.
- An `MDNode` can only refer to a `Constant` through a bridge called
`ConstantAsMetadata` (one of the subclasses of `ValueAsMetadata`).
As a side effect, accessing an operand of an `MDNode` that is known
to be, e.g., `ConstantInt`, takes three steps: first, cast from
`Metadata` to `ConstantAsMetadata`; second, extract the `Constant`;
third, cast down to `ConstantInt`.
The eventual goal is to introduce `MDInt`/`MDFloat`/etc. and have
metadata schema owners transition away from using `Constant`s when
the type isn't important (and they don't care about referring to
`GlobalValue`s).
In the meantime, I've added transitional API to the `mdconst`
namespace that matches semantics with the old code, in order to
avoid adding the error-prone three-step equivalent to every call
site. If your old code was:
MDNode *N = foo();
bar(isa <ConstantInt>(N->getOperand(0)));
baz(cast <ConstantInt>(N->getOperand(1)));
bak(cast_or_null <ConstantInt>(N->getOperand(2)));
bat(dyn_cast <ConstantInt>(N->getOperand(3)));
bay(dyn_cast_or_null<ConstantInt>(N->getOperand(4)));
you can trivially match its semantics with:
MDNode *N = foo();
bar(mdconst::hasa <ConstantInt>(N->getOperand(0)));
baz(mdconst::extract <ConstantInt>(N->getOperand(1)));
bak(mdconst::extract_or_null <ConstantInt>(N->getOperand(2)));
bat(mdconst::dyn_extract <ConstantInt>(N->getOperand(3)));
bay(mdconst::dyn_extract_or_null<ConstantInt>(N->getOperand(4)));
and when you transition your metadata schema to `MDInt`:
MDNode *N = foo();
bar(isa <MDInt>(N->getOperand(0)));
baz(cast <MDInt>(N->getOperand(1)));
bak(cast_or_null <MDInt>(N->getOperand(2)));
bat(dyn_cast <MDInt>(N->getOperand(3)));
bay(dyn_cast_or_null<MDInt>(N->getOperand(4)));
- A `CallInst` -- specifically, intrinsic instructions -- can refer to
metadata through a bridge called `MetadataAsValue`. This is a
subclass of `Value` where `getType()->isMetadataTy()`.
`MetadataAsValue` is the *only* class that can legally refer to a
`LocalAsMetadata`, which is a bridged form of non-`Constant` values
like `Argument` and `Instruction`. It can also refer to any other
`Metadata` subclass.
(I'll break all your testcases in a follow-up commit, when I propagate
this change to assembly.)
llvm-svn: 223802
2014-12-10 02:38:53 +08:00
|
|
|
if (auto EnumWidthValue = mdconst::extract_or_null<ConstantInt>(
|
2014-06-20 18:08:11 +08:00
|
|
|
SourceModule->getModuleFlag("min_enum_size"))) {
|
|
|
|
int EnumWidth = EnumWidthValue->getZExtValue();
|
|
|
|
assert((EnumWidth == 1 || EnumWidth == 4) &&
|
|
|
|
"Minimum enum width must be 1 or 4 bytes");
|
|
|
|
int EnumBuildAttr = EnumWidth == 1 ? 1 : 2;
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_enum_size, EnumBuildAttr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-25 22:03:14 +08:00
|
|
|
// TODO: We currently only support either reserving the register, or treating
|
|
|
|
// it as another callee-saved register, but not as SB or a TLS pointer; It
|
|
|
|
// would instead be nicer to push this from the frontend as metadata, as we do
|
|
|
|
// for the wchar and enum size tags
|
2015-02-18 04:02:32 +08:00
|
|
|
if (STI.isR9Reserved())
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_PCS_R9_use, ARMBuildAttrs::R9Reserved);
|
2014-07-25 22:03:14 +08:00
|
|
|
else
|
2015-02-18 04:02:32 +08:00
|
|
|
ATS.emitAttribute(ARMBuildAttrs::ABI_PCS_R9_use, ARMBuildAttrs::R9IsGPR);
|
|
|
|
|
|
|
|
if (STI.hasTrustZone() && STI.hasVirtualization())
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::Virtualization_use,
|
|
|
|
ARMBuildAttrs::AllowTZVirtualization);
|
|
|
|
else if (STI.hasTrustZone())
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::Virtualization_use,
|
|
|
|
ARMBuildAttrs::AllowTZ);
|
|
|
|
else if (STI.hasVirtualization())
|
|
|
|
ATS.emitAttribute(ARMBuildAttrs::Virtualization_use,
|
|
|
|
ARMBuildAttrs::AllowVirtualization);
|
2010-10-07 06:36:46 +08:00
|
|
|
}
|
|
|
|
|
2009-10-20 04:20:46 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-09-18 08:05:05 +08:00
|
|
|
static MCSymbol *getPICLabel(const char *Prefix, unsigned FunctionNumber,
|
|
|
|
unsigned LabelId, MCContext &Ctx) {
|
|
|
|
|
2015-05-19 02:43:14 +08:00
|
|
|
MCSymbol *Label = Ctx.getOrCreateSymbol(Twine(Prefix)
|
2010-09-18 08:05:05 +08:00
|
|
|
+ "PC" + Twine(FunctionNumber) + "_" + Twine(LabelId));
|
|
|
|
return Label;
|
|
|
|
}
|
|
|
|
|
2010-11-10 11:26:07 +08:00
|
|
|
static MCSymbolRefExpr::VariantKind
|
|
|
|
getModifierVariantKind(ARMCP::ARMCPModifier Modifier) {
|
|
|
|
switch (Modifier) {
|
|
|
|
case ARMCP::no_modifier: return MCSymbolRefExpr::VK_None;
|
2013-12-05 06:43:20 +08:00
|
|
|
case ARMCP::TLSGD: return MCSymbolRefExpr::VK_TLSGD;
|
|
|
|
case ARMCP::TPOFF: return MCSymbolRefExpr::VK_TPOFF;
|
|
|
|
case ARMCP::GOTTPOFF: return MCSymbolRefExpr::VK_GOTTPOFF;
|
2015-10-27 02:23:16 +08:00
|
|
|
case ARMCP::GOT_PREL: return MCSymbolRefExpr::VK_ARM_GOT_PREL;
|
2010-11-10 11:26:07 +08:00
|
|
|
}
|
2012-01-21 05:51:11 +08:00
|
|
|
llvm_unreachable("Invalid ARMCPModifier!");
|
2010-11-10 11:26:07 +08:00
|
|
|
}
|
|
|
|
|
2013-11-26 00:24:52 +08:00
|
|
|
MCSymbol *ARMAsmPrinter::GetARMGVSymbol(const GlobalValue *GV,
|
|
|
|
unsigned char TargetFlags) {
|
2014-07-07 13:18:30 +08:00
|
|
|
if (Subtarget->isTargetMachO()) {
|
|
|
|
bool IsIndirect = (TargetFlags & ARMII::MO_NONLAZY) &&
|
|
|
|
Subtarget->GVIsIndirectSymbol(GV, TM.getRelocationModel());
|
|
|
|
|
|
|
|
if (!IsIndirect)
|
|
|
|
return getSymbol(GV);
|
2011-01-17 16:03:18 +08:00
|
|
|
|
2014-07-07 13:18:30 +08:00
|
|
|
// FIXME: Remove this when Darwin transition to @GOT like syntax.
|
|
|
|
MCSymbol *MCSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
|
|
|
MachineModuleInfoMachO &MMIMachO =
|
|
|
|
MMI->getObjFileInfo<MachineModuleInfoMachO>();
|
|
|
|
MachineModuleInfoImpl::StubValueTy &StubSym =
|
|
|
|
GV->hasHiddenVisibility() ? MMIMachO.getHiddenGVStubEntry(MCSym)
|
|
|
|
: MMIMachO.getGVStubEntry(MCSym);
|
|
|
|
if (!StubSym.getPointer())
|
|
|
|
StubSym = MachineModuleInfoImpl::StubValueTy(getSymbol(GV),
|
|
|
|
!GV->hasInternalLinkage());
|
|
|
|
return MCSym;
|
|
|
|
} else if (Subtarget->isTargetCOFF()) {
|
|
|
|
assert(Subtarget->isTargetWindows() &&
|
|
|
|
"Windows is the only supported COFF target");
|
2015-06-11 09:31:48 +08:00
|
|
|
|
|
|
|
bool IsIndirect = (TargetFlags & ARMII::MO_DLLIMPORT);
|
|
|
|
if (!IsIndirect)
|
|
|
|
return getSymbol(GV);
|
|
|
|
|
|
|
|
SmallString<128> Name;
|
|
|
|
Name = "__imp_";
|
|
|
|
getNameWithPrefix(Name, GV);
|
|
|
|
|
|
|
|
return OutContext.getOrCreateSymbol(Name);
|
2014-07-07 13:18:30 +08:00
|
|
|
} else if (Subtarget->isTargetELF()) {
|
|
|
|
return getSymbol(GV);
|
|
|
|
}
|
|
|
|
llvm_unreachable("unexpected target");
|
2011-01-17 16:03:18 +08:00
|
|
|
}
|
|
|
|
|
2010-11-10 02:45:04 +08:00
|
|
|
void ARMAsmPrinter::
|
|
|
|
EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
|
2015-07-16 14:11:10 +08:00
|
|
|
const DataLayout &DL = getDataLayout();
|
|
|
|
int Size = DL.getTypeAllocSize(MCPV->getType());
|
2010-11-10 02:45:04 +08:00
|
|
|
|
|
|
|
ARMConstantPoolValue *ACPV = static_cast<ARMConstantPoolValue*>(MCPV);
|
|
|
|
|
2010-11-11 01:59:10 +08:00
|
|
|
MCSymbol *MCSym;
|
2010-11-10 02:45:04 +08:00
|
|
|
if (ACPV->isLSDA()) {
|
2015-03-17 21:57:48 +08:00
|
|
|
MCSym = getCurExceptionSym();
|
2010-11-10 02:45:04 +08:00
|
|
|
} else if (ACPV->isBlockAddress()) {
|
2011-10-01 16:00:54 +08:00
|
|
|
const BlockAddress *BA =
|
|
|
|
cast<ARMConstantPoolConstant>(ACPV)->getBlockAddress();
|
|
|
|
MCSym = GetBlockAddressSymbol(BA);
|
2010-11-10 02:45:04 +08:00
|
|
|
} else if (ACPV->isGlobalValue()) {
|
2011-10-01 16:00:54 +08:00
|
|
|
const GlobalValue *GV = cast<ARMConstantPoolConstant>(ACPV)->getGV();
|
2013-11-26 00:24:52 +08:00
|
|
|
|
|
|
|
// On Darwin, const-pool entries may get the "FOO$non_lazy_ptr" mangling, so
|
|
|
|
// flag the global as MO_NONLAZY.
|
2014-01-06 22:28:05 +08:00
|
|
|
unsigned char TF = Subtarget->isTargetMachO() ? ARMII::MO_NONLAZY : 0;
|
2013-11-26 01:04:35 +08:00
|
|
|
MCSym = GetARMGVSymbol(GV, TF);
|
2011-09-30 07:50:42 +08:00
|
|
|
} else if (ACPV->isMachineBasicBlock()) {
|
2011-10-01 17:30:42 +08:00
|
|
|
const MachineBasicBlock *MBB = cast<ARMConstantPoolMBB>(ACPV)->getMBB();
|
2011-09-30 07:50:42 +08:00
|
|
|
MCSym = MBB->getSymbol();
|
2010-11-10 02:45:04 +08:00
|
|
|
} else {
|
|
|
|
assert(ACPV->isExtSymbol() && "unrecognized constant pool value");
|
2011-10-01 16:58:29 +08:00
|
|
|
const char *Sym = cast<ARMConstantPoolSymbol>(ACPV)->getSymbol();
|
|
|
|
MCSym = GetExternalSymbolSymbol(Sym);
|
2010-11-10 02:45:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create an MCSymbol for the reference.
|
2010-11-10 11:26:07 +08:00
|
|
|
const MCExpr *Expr =
|
2015-05-30 09:25:56 +08:00
|
|
|
MCSymbolRefExpr::create(MCSym, getModifierVariantKind(ACPV->getModifier()),
|
2010-11-10 11:26:07 +08:00
|
|
|
OutContext);
|
|
|
|
|
|
|
|
if (ACPV->getPCAdjustment()) {
|
2015-07-16 14:11:10 +08:00
|
|
|
MCSymbol *PCLabel =
|
|
|
|
getPICLabel(DL.getPrivateGlobalPrefix(), getFunctionNumber(),
|
|
|
|
ACPV->getLabelId(), OutContext);
|
2015-05-30 09:25:56 +08:00
|
|
|
const MCExpr *PCRelExpr = MCSymbolRefExpr::create(PCLabel, OutContext);
|
2010-11-10 11:26:07 +08:00
|
|
|
PCRelExpr =
|
2015-05-30 09:25:56 +08:00
|
|
|
MCBinaryExpr::createAdd(PCRelExpr,
|
|
|
|
MCConstantExpr::create(ACPV->getPCAdjustment(),
|
2010-11-10 11:26:07 +08:00
|
|
|
OutContext),
|
|
|
|
OutContext);
|
|
|
|
if (ACPV->mustAddCurrentAddress()) {
|
|
|
|
// We want "(<expr> - .)", but MC doesn't have a concept of the '.'
|
|
|
|
// label, so just emit a local label end reference that instead.
|
2015-05-19 02:43:14 +08:00
|
|
|
MCSymbol *DotSym = OutContext.createTempSymbol();
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitLabel(DotSym);
|
2015-05-30 09:25:56 +08:00
|
|
|
const MCExpr *DotExpr = MCSymbolRefExpr::create(DotSym, OutContext);
|
|
|
|
PCRelExpr = MCBinaryExpr::createSub(PCRelExpr, DotExpr, OutContext);
|
2010-11-10 02:45:04 +08:00
|
|
|
}
|
2015-05-30 09:25:56 +08:00
|
|
|
Expr = MCBinaryExpr::createSub(Expr, PCRelExpr, OutContext);
|
2010-11-10 02:45:04 +08:00
|
|
|
}
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitValue(Expr, Size);
|
2010-11-10 02:45:04 +08:00
|
|
|
}
|
|
|
|
|
2015-06-01 03:22:07 +08:00
|
|
|
void ARMAsmPrinter::EmitJumpTableAddrs(const MachineInstr *MI) {
|
|
|
|
const MachineOperand &MO1 = MI->getOperand(1);
|
2010-09-23 01:39:48 +08:00
|
|
|
unsigned JTI = MO1.getIndex();
|
|
|
|
|
2015-06-01 03:22:07 +08:00
|
|
|
// Make sure the Thumb jump table is 4-byte aligned. This will be a nop for
|
|
|
|
// ARM mode tables.
|
|
|
|
EmitAlignment(2);
|
|
|
|
|
2010-09-23 01:39:48 +08:00
|
|
|
// Emit a label for the jump table.
|
2015-05-14 04:28:38 +08:00
|
|
|
MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel(JTI);
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitLabel(JTISymbol);
|
2010-09-23 01:39:48 +08:00
|
|
|
|
2012-05-19 03:12:01 +08:00
|
|
|
// Mark the jump table as data-in-code.
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitDataRegion(MCDR_DataRegionJT32);
|
2012-05-19 03:12:01 +08:00
|
|
|
|
2010-09-23 01:39:48 +08:00
|
|
|
// Emit each entry of the table.
|
|
|
|
const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
|
|
|
|
const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
|
|
|
|
const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
|
|
|
|
|
|
|
|
for (unsigned i = 0, e = JTBBs.size(); i != e; ++i) {
|
|
|
|
MachineBasicBlock *MBB = JTBBs[i];
|
|
|
|
// Construct an MCExpr for the entry. We want a value of the form:
|
|
|
|
// (BasicBlockAddr - TableBeginAddr)
|
|
|
|
//
|
|
|
|
// For example, a table with entries jumping to basic blocks BB0 and BB1
|
|
|
|
// would look like:
|
|
|
|
// LJTI_0_0:
|
|
|
|
// .word (LBB0 - LJTI_0_0)
|
|
|
|
// .word (LBB1 - LJTI_0_0)
|
2015-05-30 09:25:56 +08:00
|
|
|
const MCExpr *Expr = MCSymbolRefExpr::create(MBB->getSymbol(), OutContext);
|
2010-09-23 01:39:48 +08:00
|
|
|
|
|
|
|
if (TM.getRelocationModel() == Reloc::PIC_)
|
2015-05-30 09:25:56 +08:00
|
|
|
Expr = MCBinaryExpr::createSub(Expr, MCSymbolRefExpr::create(JTISymbol,
|
2010-09-23 01:39:48 +08:00
|
|
|
OutContext),
|
|
|
|
OutContext);
|
2011-09-01 06:23:09 +08:00
|
|
|
// If we're generating a table of Thumb addresses in static relocation
|
|
|
|
// model, we need to add one to keep interworking correctly.
|
|
|
|
else if (AFI->isThumbFunction())
|
2015-05-30 09:25:56 +08:00
|
|
|
Expr = MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(1,OutContext),
|
2011-09-01 06:23:09 +08:00
|
|
|
OutContext);
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitValue(Expr, 4);
|
2010-09-23 01:39:48 +08:00
|
|
|
}
|
2012-05-19 03:12:01 +08:00
|
|
|
// Mark the end of jump table data-in-code region.
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
|
2010-09-23 01:39:48 +08:00
|
|
|
}
|
|
|
|
|
2015-06-01 03:22:07 +08:00
|
|
|
void ARMAsmPrinter::EmitJumpTableInsts(const MachineInstr *MI) {
|
|
|
|
const MachineOperand &MO1 = MI->getOperand(1);
|
2010-09-22 07:28:16 +08:00
|
|
|
unsigned JTI = MO1.getIndex();
|
|
|
|
|
2015-05-14 04:28:38 +08:00
|
|
|
MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel(JTI);
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitLabel(JTISymbol);
|
2010-09-22 07:28:16 +08:00
|
|
|
|
|
|
|
// Emit each entry of the table.
|
|
|
|
const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
|
|
|
|
const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
|
|
|
|
const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
|
|
|
|
|
|
|
|
for (unsigned i = 0, e = JTBBs.size(); i != e; ++i) {
|
|
|
|
MachineBasicBlock *MBB = JTBBs[i];
|
2015-05-30 09:25:56 +08:00
|
|
|
const MCExpr *MBBSymbolExpr = MCSymbolRefExpr::create(MBB->getSymbol(),
|
2014-07-07 13:18:22 +08:00
|
|
|
OutContext);
|
2010-09-22 07:28:16 +08:00
|
|
|
// If this isn't a TBB or TBH, the entries are direct branch instructions.
|
2015-06-01 03:22:07 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::t2B)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addExpr(MBBSymbolExpr)
|
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2015-06-01 03:22:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ARMAsmPrinter::EmitJumpTableTBInst(const MachineInstr *MI,
|
|
|
|
unsigned OffsetWidth) {
|
|
|
|
assert((OffsetWidth == 1 || OffsetWidth == 2) && "invalid tbb/tbh width");
|
|
|
|
const MachineOperand &MO1 = MI->getOperand(1);
|
|
|
|
unsigned JTI = MO1.getIndex();
|
|
|
|
|
|
|
|
MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel(JTI);
|
|
|
|
OutStreamer->EmitLabel(JTISymbol);
|
|
|
|
|
|
|
|
// Emit each entry of the table.
|
|
|
|
const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
|
|
|
|
const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
|
|
|
|
const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
|
|
|
|
|
|
|
|
// Mark the jump table as data-in-code.
|
|
|
|
OutStreamer->EmitDataRegion(OffsetWidth == 1 ? MCDR_DataRegionJT8
|
|
|
|
: MCDR_DataRegionJT16);
|
|
|
|
|
|
|
|
for (auto MBB : JTBBs) {
|
|
|
|
const MCExpr *MBBSymbolExpr = MCSymbolRefExpr::create(MBB->getSymbol(),
|
|
|
|
OutContext);
|
2010-09-22 07:28:16 +08:00
|
|
|
// Otherwise it's an offset from the dispatch instruction. Construct an
|
2010-09-23 01:15:35 +08:00
|
|
|
// MCExpr for the entry. We want a value of the form:
|
2015-06-01 03:22:07 +08:00
|
|
|
// (BasicBlockAddr - TBBInstAddr + 4) / 2
|
2010-09-23 01:15:35 +08:00
|
|
|
//
|
|
|
|
// For example, a TBB table with entries jumping to basic blocks BB0 and BB1
|
|
|
|
// would look like:
|
|
|
|
// LJTI_0_0:
|
2015-06-01 03:22:07 +08:00
|
|
|
// .byte (LBB0 - (LCPI0_0 + 4)) / 2
|
|
|
|
// .byte (LBB1 - (LCPI0_0 + 4)) / 2
|
|
|
|
// where LCPI0_0 is a label defined just before the TBB instruction using
|
|
|
|
// this table.
|
|
|
|
MCSymbol *TBInstPC = GetCPISymbol(MI->getOperand(0).getImm());
|
|
|
|
const MCExpr *Expr = MCBinaryExpr::createAdd(
|
|
|
|
MCSymbolRefExpr::create(TBInstPC, OutContext),
|
|
|
|
MCConstantExpr::create(4, OutContext), OutContext);
|
|
|
|
Expr = MCBinaryExpr::createSub(MBBSymbolExpr, Expr, OutContext);
|
2015-05-30 09:25:56 +08:00
|
|
|
Expr = MCBinaryExpr::createDiv(Expr, MCConstantExpr::create(2, OutContext),
|
2010-09-23 01:15:35 +08:00
|
|
|
OutContext);
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitValue(Expr, OffsetWidth);
|
2010-09-22 07:28:16 +08:00
|
|
|
}
|
2012-05-22 07:34:42 +08:00
|
|
|
// Mark the end of jump table data-in-code region. 32-bit offsets use
|
|
|
|
// actual branch instructions here, so we don't mark those as a data-region
|
|
|
|
// at all.
|
2015-06-01 03:22:07 +08:00
|
|
|
OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
|
|
|
|
|
|
|
|
// Make sure the next instruction is 2-byte aligned.
|
|
|
|
EmitAlignment(1);
|
2010-09-22 07:28:16 +08:00
|
|
|
}
|
|
|
|
|
2011-03-06 02:43:32 +08:00
|
|
|
void ARMAsmPrinter::EmitUnwindingInstruction(const MachineInstr *MI) {
|
|
|
|
assert(MI->getFlag(MachineInstr::FrameSetup) &&
|
|
|
|
"Only instruction which are involved into frame setup code are allowed");
|
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
MCTargetStreamer &TS = *OutStreamer->getTargetStreamer();
|
2013-10-08 21:08:17 +08:00
|
|
|
ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
|
2011-03-06 02:43:32 +08:00
|
|
|
const MachineFunction &MF = *MI->getParent()->getParent();
|
2014-08-05 10:39:49 +08:00
|
|
|
const TargetRegisterInfo *RegInfo = MF.getSubtarget().getRegisterInfo();
|
2011-03-06 02:43:55 +08:00
|
|
|
const ARMFunctionInfo &AFI = *MF.getInfo<ARMFunctionInfo>();
|
2011-03-06 02:43:32 +08:00
|
|
|
|
|
|
|
unsigned FramePtr = RegInfo->getFrameRegister(MF);
|
|
|
|
unsigned Opc = MI->getOpcode();
|
2011-03-06 02:43:43 +08:00
|
|
|
unsigned SrcReg, DstReg;
|
|
|
|
|
2011-03-06 02:43:50 +08:00
|
|
|
if (Opc == ARM::tPUSH || Opc == ARM::tLDRpci) {
|
|
|
|
// Two special cases:
|
|
|
|
// 1) tPUSH does not have src/dst regs.
|
|
|
|
// 2) for Thumb1 code we sometimes materialize the constant via constpool
|
|
|
|
// load. Yes, this is pretty fragile, but for now I don't see better
|
|
|
|
// way... :(
|
2011-03-06 02:43:43 +08:00
|
|
|
SrcReg = DstReg = ARM::SP;
|
|
|
|
} else {
|
2011-03-06 02:43:50 +08:00
|
|
|
SrcReg = MI->getOperand(1).getReg();
|
2011-03-06 02:43:43 +08:00
|
|
|
DstReg = MI->getOperand(0).getReg();
|
|
|
|
}
|
2011-03-06 02:43:32 +08:00
|
|
|
|
|
|
|
// Try to figure out the unwinding opcode out of src / dst regs.
|
2011-12-07 15:15:52 +08:00
|
|
|
if (MI->mayStore()) {
|
2011-03-06 02:43:32 +08:00
|
|
|
// Register saves.
|
|
|
|
assert(DstReg == ARM::SP &&
|
|
|
|
"Only stack pointer as a destination reg is supported");
|
|
|
|
|
|
|
|
SmallVector<unsigned, 4> RegList;
|
2011-03-06 02:43:43 +08:00
|
|
|
// Skip src & dst reg, and pred ops.
|
|
|
|
unsigned StartOp = 2 + 2;
|
|
|
|
// Use all the operands.
|
|
|
|
unsigned NumOffset = 0;
|
|
|
|
|
2011-03-06 02:43:32 +08:00
|
|
|
switch (Opc) {
|
|
|
|
default:
|
|
|
|
MI->dump();
|
2012-02-07 10:50:20 +08:00
|
|
|
llvm_unreachable("Unsupported opcode for unwinding information");
|
2011-03-06 02:43:43 +08:00
|
|
|
case ARM::tPUSH:
|
|
|
|
// Special case here: no src & dst reg, but two extra imp ops.
|
|
|
|
StartOp = 2; NumOffset = 2;
|
2011-03-06 02:43:32 +08:00
|
|
|
case ARM::STMDB_UPD:
|
2011-03-06 02:43:43 +08:00
|
|
|
case ARM::t2STMDB_UPD:
|
2011-03-06 02:43:32 +08:00
|
|
|
case ARM::VSTMDDB_UPD:
|
|
|
|
assert(SrcReg == ARM::SP &&
|
|
|
|
"Only stack pointer as a source reg is supported");
|
2011-03-06 02:43:43 +08:00
|
|
|
for (unsigned i = StartOp, NumOps = MI->getNumOperands() - NumOffset;
|
2012-08-04 21:25:58 +08:00
|
|
|
i != NumOps; ++i) {
|
|
|
|
const MachineOperand &MO = MI->getOperand(i);
|
|
|
|
// Actually, there should never be any impdef stuff here. Skip it
|
|
|
|
// temporary to workaround PR11902.
|
|
|
|
if (MO.isImplicit())
|
|
|
|
continue;
|
|
|
|
RegList.push_back(MO.getReg());
|
|
|
|
}
|
2011-03-06 02:43:32 +08:00
|
|
|
break;
|
2011-07-27 04:54:26 +08:00
|
|
|
case ARM::STR_PRE_IMM:
|
|
|
|
case ARM::STR_PRE_REG:
|
2012-01-19 20:53:06 +08:00
|
|
|
case ARM::t2STR_PRE:
|
2011-03-06 02:43:32 +08:00
|
|
|
assert(MI->getOperand(2).getReg() == ARM::SP &&
|
|
|
|
"Only stack pointer as a source reg is supported");
|
|
|
|
RegList.push_back(SrcReg);
|
|
|
|
break;
|
|
|
|
}
|
2014-05-01 06:43:13 +08:00
|
|
|
if (MAI->getExceptionHandlingType() == ExceptionHandling::ARM)
|
|
|
|
ATS.emitRegSave(RegList, Opc == ARM::VSTMDDB_UPD);
|
2011-03-06 02:43:32 +08:00
|
|
|
} else {
|
|
|
|
// Changes of stack / frame pointer.
|
|
|
|
if (SrcReg == ARM::SP) {
|
|
|
|
int64_t Offset = 0;
|
|
|
|
switch (Opc) {
|
|
|
|
default:
|
|
|
|
MI->dump();
|
2012-02-07 10:50:20 +08:00
|
|
|
llvm_unreachable("Unsupported opcode for unwinding information");
|
2011-03-06 02:43:32 +08:00
|
|
|
case ARM::MOVr:
|
2012-01-19 20:53:06 +08:00
|
|
|
case ARM::tMOVr:
|
2011-03-06 02:43:32 +08:00
|
|
|
Offset = 0;
|
|
|
|
break;
|
|
|
|
case ARM::ADDri:
|
2015-11-10 08:10:41 +08:00
|
|
|
case ARM::t2ADDri:
|
2011-03-06 02:43:32 +08:00
|
|
|
Offset = -MI->getOperand(2).getImm();
|
|
|
|
break;
|
|
|
|
case ARM::SUBri:
|
2012-01-19 20:53:06 +08:00
|
|
|
case ARM::t2SUBri:
|
2011-06-30 07:25:04 +08:00
|
|
|
Offset = MI->getOperand(2).getImm();
|
2011-03-06 02:43:32 +08:00
|
|
|
break;
|
2011-03-06 02:43:43 +08:00
|
|
|
case ARM::tSUBspi:
|
2011-06-30 07:25:04 +08:00
|
|
|
Offset = MI->getOperand(2).getImm()*4;
|
2011-03-06 02:43:43 +08:00
|
|
|
break;
|
|
|
|
case ARM::tADDspi:
|
|
|
|
case ARM::tADDrSPi:
|
|
|
|
Offset = -MI->getOperand(2).getImm()*4;
|
|
|
|
break;
|
2011-03-06 02:43:55 +08:00
|
|
|
case ARM::tLDRpci: {
|
|
|
|
// Grab the constpool index and check, whether it corresponds to
|
|
|
|
// original or cloned constpool entry.
|
|
|
|
unsigned CPI = MI->getOperand(1).getIndex();
|
|
|
|
const MachineConstantPool *MCP = MF.getConstantPool();
|
|
|
|
if (CPI >= MCP->getConstants().size())
|
|
|
|
CPI = AFI.getOriginalCPIdx(CPI);
|
|
|
|
assert(CPI != -1U && "Invalid constpool index");
|
|
|
|
|
|
|
|
// Derive the actual offset.
|
|
|
|
const MachineConstantPoolEntry &CPE = MCP->getConstants()[CPI];
|
|
|
|
assert(!CPE.isMachineConstantPoolEntry() && "Invalid constpool entry");
|
|
|
|
// FIXME: Check for user, it should be "add" instruction!
|
|
|
|
Offset = -cast<ConstantInt>(CPE.Val.ConstVal)->getSExtValue();
|
2011-03-06 02:43:50 +08:00
|
|
|
break;
|
2011-03-06 02:43:32 +08:00
|
|
|
}
|
2011-03-06 02:43:55 +08:00
|
|
|
}
|
2011-03-06 02:43:32 +08:00
|
|
|
|
2014-05-01 06:43:13 +08:00
|
|
|
if (MAI->getExceptionHandlingType() == ExceptionHandling::ARM) {
|
|
|
|
if (DstReg == FramePtr && FramePtr != ARM::SP)
|
|
|
|
// Set-up of the frame pointer. Positive values correspond to "add"
|
|
|
|
// instruction.
|
|
|
|
ATS.emitSetFP(FramePtr, ARM::SP, -Offset);
|
|
|
|
else if (DstReg == ARM::SP) {
|
|
|
|
// Change of SP by an offset. Positive values correspond to "sub"
|
|
|
|
// instruction.
|
|
|
|
ATS.emitPad(Offset);
|
|
|
|
} else {
|
|
|
|
// Move of SP to a register. Positive values correspond to an "add"
|
|
|
|
// instruction.
|
|
|
|
ATS.emitMovSP(DstReg, -Offset);
|
|
|
|
}
|
2011-03-06 02:43:32 +08:00
|
|
|
}
|
|
|
|
} else if (DstReg == ARM::SP) {
|
|
|
|
MI->dump();
|
2012-02-07 10:50:20 +08:00
|
|
|
llvm_unreachable("Unsupported opcode for unwinding information");
|
2011-03-06 02:43:32 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
MI->dump();
|
2012-02-07 10:50:20 +08:00
|
|
|
llvm_unreachable("Unsupported opcode for unwinding information");
|
2011-03-06 02:43:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-09 01:40:42 +08:00
|
|
|
// Simple pseudo-instructions have their lowering (with expansion to real
|
|
|
|
// instructions) auto-generated.
|
|
|
|
#include "ARMGenMCPseudoLowering.inc"
|
|
|
|
|
2010-09-29 23:23:40 +08:00
|
|
|
void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
2015-07-16 14:11:10 +08:00
|
|
|
const DataLayout &DL = getDataLayout();
|
2014-01-04 03:21:54 +08:00
|
|
|
|
2012-05-19 03:12:01 +08:00
|
|
|
// If we just ended a constant pool, mark it as such.
|
|
|
|
if (InConstantPool && MI->getOpcode() != ARM::CONSTPOOL_ENTRY) {
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
|
2012-05-19 03:12:01 +08:00
|
|
|
InConstantPool = false;
|
|
|
|
}
|
2011-10-05 07:26:17 +08:00
|
|
|
|
2011-08-24 05:32:34 +08:00
|
|
|
// Emit unwinding stuff for frame-related instructions
|
2014-02-08 04:12:49 +08:00
|
|
|
if (Subtarget->isTargetEHABICompatible() &&
|
2014-01-29 19:50:56 +08:00
|
|
|
MI->getFlag(MachineInstr::FrameSetup))
|
2011-08-24 05:32:34 +08:00
|
|
|
EmitUnwindingInstruction(MI);
|
|
|
|
|
2011-07-09 01:40:42 +08:00
|
|
|
// Do any auto-generated pseudo lowerings.
|
2015-04-25 03:11:51 +08:00
|
|
|
if (emitPseudoExpansionLowering(*OutStreamer, MI))
|
2011-07-01 02:25:42 +08:00
|
|
|
return;
|
2010-12-09 09:22:19 +08:00
|
|
|
|
2011-09-21 10:20:46 +08:00
|
|
|
assert(!convertAddSubFlagsOpcode(MI->getOpcode()) &&
|
|
|
|
"Pseudo flag setting opcode should be expanded early");
|
|
|
|
|
2011-07-09 01:40:42 +08:00
|
|
|
// Check for manual lowerings.
|
|
|
|
unsigned Opc = MI->getOpcode();
|
|
|
|
switch (Opc) {
|
2012-02-07 10:50:20 +08:00
|
|
|
case ARM::t2MOVi32imm: llvm_unreachable("Should be lowered by thumb2it pass");
|
2013-06-17 04:34:27 +08:00
|
|
|
case ARM::DBG_VALUE: llvm_unreachable("Should be handled by generic printing");
|
2010-12-15 05:10:47 +08:00
|
|
|
case ARM::LEApcrel:
|
2010-12-15 06:28:03 +08:00
|
|
|
case ARM::tLEApcrel:
|
2010-12-15 05:10:47 +08:00
|
|
|
case ARM::t2LEApcrel: {
|
2010-12-02 08:28:45 +08:00
|
|
|
// FIXME: Need to also handle globals and externals
|
2012-11-26 21:34:22 +08:00
|
|
|
MCSymbol *CPISymbol = GetCPISymbol(MI->getOperand(1).getIndex());
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(MI->getOpcode() ==
|
|
|
|
ARM::t2LEApcrel ? ARM::t2ADR
|
2012-11-26 21:34:22 +08:00
|
|
|
: (MI->getOpcode() == ARM::tLEApcrel ? ARM::tADR
|
|
|
|
: ARM::ADR))
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
2015-05-30 09:25:56 +08:00
|
|
|
.addExpr(MCSymbolRefExpr::create(CPISymbol, OutContext))
|
2012-11-26 21:34:22 +08:00
|
|
|
// Add predicate operands.
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(MI->getOperand(3).getReg()));
|
2010-12-02 08:28:45 +08:00
|
|
|
return;
|
|
|
|
}
|
2010-12-15 06:28:03 +08:00
|
|
|
case ARM::LEApcrelJT:
|
|
|
|
case ARM::tLEApcrelJT:
|
|
|
|
case ARM::t2LEApcrelJT: {
|
2012-11-26 21:34:22 +08:00
|
|
|
MCSymbol *JTIPICSymbol =
|
2015-05-14 04:28:38 +08:00
|
|
|
GetARMJTIPICJumpTableLabel(MI->getOperand(1).getIndex());
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(MI->getOpcode() ==
|
|
|
|
ARM::t2LEApcrelJT ? ARM::t2ADR
|
2012-11-26 21:34:22 +08:00
|
|
|
: (MI->getOpcode() == ARM::tLEApcrelJT ? ARM::tADR
|
|
|
|
: ARM::ADR))
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
2015-05-30 09:25:56 +08:00
|
|
|
.addExpr(MCSymbolRefExpr::create(JTIPICSymbol, OutContext))
|
2012-11-26 21:34:22 +08:00
|
|
|
// Add predicate operands.
|
2015-05-14 04:28:38 +08:00
|
|
|
.addImm(MI->getOperand(2).getImm())
|
|
|
|
.addReg(MI->getOperand(3).getReg()));
|
2010-12-02 03:47:31 +08:00
|
|
|
return;
|
|
|
|
}
|
2011-03-12 08:45:26 +08:00
|
|
|
// Darwin call instructions are just normal call instructions with different
|
|
|
|
// clobber semantics (they clobber R9).
|
2010-12-01 02:30:19 +08:00
|
|
|
case ARM::BX_CALL: {
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVr)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::LR)
|
|
|
|
.addReg(ARM::PC)
|
2010-12-01 02:30:19 +08:00
|
|
|
// Add predicate operands.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
|
|
|
.addReg(0)
|
2010-12-01 02:30:19 +08:00
|
|
|
// Add 's' bit operand (always reg0 for this)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::BX)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(MI->getOperand(0).getReg()));
|
2010-12-01 02:30:19 +08:00
|
|
|
return;
|
|
|
|
}
|
2011-05-26 05:53:50 +08:00
|
|
|
case ARM::tBX_CALL: {
|
2014-12-05 03:34:50 +08:00
|
|
|
if (Subtarget->hasV5TOps())
|
|
|
|
llvm_unreachable("Expected BLX to be selected for v5t+");
|
|
|
|
|
|
|
|
// On ARM v4t, when doing a call from thumb mode, we need to ensure
|
|
|
|
// that the saved lr has its LSB set correctly (the arch doesn't
|
|
|
|
// have blx).
|
|
|
|
// So here we generate a bl to a small jump pad that does bx rN.
|
|
|
|
// The jump pads are emitted after the function body.
|
|
|
|
|
|
|
|
unsigned TReg = MI->getOperand(0).getReg();
|
|
|
|
MCSymbol *TRegSym = nullptr;
|
|
|
|
for (unsigned i = 0, e = ThumbIndirectPads.size(); i < e; i++) {
|
|
|
|
if (ThumbIndirectPads[i].first == TReg) {
|
|
|
|
TRegSym = ThumbIndirectPads[i].second;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2014-12-05 03:34:50 +08:00
|
|
|
if (!TRegSym) {
|
2015-05-19 02:43:14 +08:00
|
|
|
TRegSym = OutContext.createTempSymbol();
|
2014-12-05 03:34:50 +08:00
|
|
|
ThumbIndirectPads.push_back(std::make_pair(TReg, TRegSym));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a link-saving branch to the Reg Indirect Jump Pad.
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tBL)
|
2014-12-05 03:34:50 +08:00
|
|
|
// Predicate comes first here.
|
|
|
|
.addImm(ARMCC::AL).addReg(0)
|
2015-05-30 09:25:56 +08:00
|
|
|
.addExpr(MCSymbolRefExpr::create(TRegSym, OutContext)));
|
2011-05-26 05:53:50 +08:00
|
|
|
return;
|
|
|
|
}
|
2010-12-01 02:30:19 +08:00
|
|
|
case ARM::BMOVPCRX_CALL: {
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVr)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::LR)
|
|
|
|
.addReg(ARM::PC)
|
2010-12-01 02:30:19 +08:00
|
|
|
// Add predicate operands.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
|
|
|
.addReg(0)
|
2010-12-01 02:30:19 +08:00
|
|
|
// Add 's' bit operand (always reg0 for this)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVr)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::PC)
|
2013-03-16 01:27:39 +08:00
|
|
|
.addReg(MI->getOperand(0).getReg())
|
2010-12-01 02:30:19 +08:00
|
|
|
// Add predicate operands.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
|
|
|
.addReg(0)
|
2010-12-01 02:30:19 +08:00
|
|
|
// Add 's' bit operand (always reg0 for this)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2010-12-01 02:30:19 +08:00
|
|
|
return;
|
|
|
|
}
|
2012-02-29 02:51:51 +08:00
|
|
|
case ARM::BMOVPCB_CALL: {
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVr)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::LR)
|
|
|
|
.addReg(ARM::PC)
|
2012-02-29 02:51:51 +08:00
|
|
|
// Add predicate operands.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
|
|
|
.addReg(0)
|
2012-02-29 02:51:51 +08:00
|
|
|
// Add 's' bit operand (always reg0 for this)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2014-07-07 13:18:22 +08:00
|
|
|
const MachineOperand &Op = MI->getOperand(0);
|
|
|
|
const GlobalValue *GV = Op.getGlobal();
|
|
|
|
const unsigned TF = Op.getTargetFlags();
|
|
|
|
MCSymbol *GVSym = GetARMGVSymbol(GV, TF);
|
2015-05-30 09:25:56 +08:00
|
|
|
const MCExpr *GVSymExpr = MCSymbolRefExpr::create(GVSym, OutContext);
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::Bcc)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addExpr(GVSymExpr)
|
2012-02-29 02:51:51 +08:00
|
|
|
// Add predicate operands.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-02-29 02:51:51 +08:00
|
|
|
return;
|
|
|
|
}
|
2011-01-22 02:55:51 +08:00
|
|
|
case ARM::MOVi16_ga_pcrel:
|
|
|
|
case ARM::t2MOVi16_ga_pcrel: {
|
2011-01-17 16:03:18 +08:00
|
|
|
MCInst TmpInst;
|
2011-01-22 02:55:51 +08:00
|
|
|
TmpInst.setOpcode(Opc == ARM::MOVi16_ga_pcrel? ARM::MOVi16 : ARM::t2MOVi16);
|
2015-05-14 02:37:00 +08:00
|
|
|
TmpInst.addOperand(MCOperand::createReg(MI->getOperand(0).getReg()));
|
2011-01-17 16:03:18 +08:00
|
|
|
|
2011-01-22 02:55:51 +08:00
|
|
|
unsigned TF = MI->getOperand(1).getTargetFlags();
|
2011-01-17 16:03:18 +08:00
|
|
|
const GlobalValue *GV = MI->getOperand(1).getGlobal();
|
2013-11-26 00:24:52 +08:00
|
|
|
MCSymbol *GVSym = GetARMGVSymbol(GV, TF);
|
2015-05-30 09:25:56 +08:00
|
|
|
const MCExpr *GVSymExpr = MCSymbolRefExpr::create(GVSym, OutContext);
|
2013-11-26 00:24:52 +08:00
|
|
|
|
2015-07-16 14:11:10 +08:00
|
|
|
MCSymbol *LabelSym =
|
|
|
|
getPICLabel(DL.getPrivateGlobalPrefix(), getFunctionNumber(),
|
|
|
|
MI->getOperand(2).getImm(), OutContext);
|
2015-05-30 09:25:56 +08:00
|
|
|
const MCExpr *LabelSymExpr= MCSymbolRefExpr::create(LabelSym, OutContext);
|
2013-11-26 00:24:52 +08:00
|
|
|
unsigned PCAdj = (Opc == ARM::MOVi16_ga_pcrel) ? 8 : 4;
|
|
|
|
const MCExpr *PCRelExpr =
|
2015-05-30 09:25:56 +08:00
|
|
|
ARMMCExpr::createLower16(MCBinaryExpr::createSub(GVSymExpr,
|
|
|
|
MCBinaryExpr::createAdd(LabelSymExpr,
|
|
|
|
MCConstantExpr::create(PCAdj, OutContext),
|
2013-11-26 00:24:52 +08:00
|
|
|
OutContext), OutContext), OutContext);
|
2015-05-14 02:37:00 +08:00
|
|
|
TmpInst.addOperand(MCOperand::createExpr(PCRelExpr));
|
2011-01-22 02:55:51 +08:00
|
|
|
|
2011-01-17 16:03:18 +08:00
|
|
|
// Add predicate operands.
|
2015-05-14 02:37:00 +08:00
|
|
|
TmpInst.addOperand(MCOperand::createImm(ARMCC::AL));
|
|
|
|
TmpInst.addOperand(MCOperand::createReg(0));
|
2011-01-17 16:03:18 +08:00
|
|
|
// Add 's' bit operand (always reg0 for this)
|
2015-05-14 02:37:00 +08:00
|
|
|
TmpInst.addOperand(MCOperand::createReg(0));
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, TmpInst);
|
2011-01-17 16:03:18 +08:00
|
|
|
return;
|
|
|
|
}
|
2011-01-22 02:55:51 +08:00
|
|
|
case ARM::MOVTi16_ga_pcrel:
|
|
|
|
case ARM::t2MOVTi16_ga_pcrel: {
|
2011-01-17 16:03:18 +08:00
|
|
|
MCInst TmpInst;
|
2011-01-22 02:55:51 +08:00
|
|
|
TmpInst.setOpcode(Opc == ARM::MOVTi16_ga_pcrel
|
|
|
|
? ARM::MOVTi16 : ARM::t2MOVTi16);
|
2015-05-14 02:37:00 +08:00
|
|
|
TmpInst.addOperand(MCOperand::createReg(MI->getOperand(0).getReg()));
|
|
|
|
TmpInst.addOperand(MCOperand::createReg(MI->getOperand(1).getReg()));
|
2011-01-17 16:03:18 +08:00
|
|
|
|
2011-01-22 02:55:51 +08:00
|
|
|
unsigned TF = MI->getOperand(2).getTargetFlags();
|
2011-01-17 16:03:18 +08:00
|
|
|
const GlobalValue *GV = MI->getOperand(2).getGlobal();
|
2013-11-26 00:24:52 +08:00
|
|
|
MCSymbol *GVSym = GetARMGVSymbol(GV, TF);
|
2015-05-30 09:25:56 +08:00
|
|
|
const MCExpr *GVSymExpr = MCSymbolRefExpr::create(GVSym, OutContext);
|
2013-11-26 00:24:52 +08:00
|
|
|
|
2015-07-16 14:11:10 +08:00
|
|
|
MCSymbol *LabelSym =
|
|
|
|
getPICLabel(DL.getPrivateGlobalPrefix(), getFunctionNumber(),
|
|
|
|
MI->getOperand(3).getImm(), OutContext);
|
2015-05-30 09:25:56 +08:00
|
|
|
const MCExpr *LabelSymExpr= MCSymbolRefExpr::create(LabelSym, OutContext);
|
2013-11-26 00:24:52 +08:00
|
|
|
unsigned PCAdj = (Opc == ARM::MOVTi16_ga_pcrel) ? 8 : 4;
|
|
|
|
const MCExpr *PCRelExpr =
|
2015-05-30 09:25:56 +08:00
|
|
|
ARMMCExpr::createUpper16(MCBinaryExpr::createSub(GVSymExpr,
|
|
|
|
MCBinaryExpr::createAdd(LabelSymExpr,
|
|
|
|
MCConstantExpr::create(PCAdj, OutContext),
|
2011-01-17 16:03:18 +08:00
|
|
|
OutContext), OutContext), OutContext);
|
2015-05-14 02:37:00 +08:00
|
|
|
TmpInst.addOperand(MCOperand::createExpr(PCRelExpr));
|
2011-01-17 16:03:18 +08:00
|
|
|
// Add predicate operands.
|
2015-05-14 02:37:00 +08:00
|
|
|
TmpInst.addOperand(MCOperand::createImm(ARMCC::AL));
|
|
|
|
TmpInst.addOperand(MCOperand::createReg(0));
|
2011-01-17 16:03:18 +08:00
|
|
|
// Add 's' bit operand (always reg0 for this)
|
2015-05-14 02:37:00 +08:00
|
|
|
TmpInst.addOperand(MCOperand::createReg(0));
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, TmpInst);
|
2011-01-17 16:03:18 +08:00
|
|
|
return;
|
|
|
|
}
|
2010-09-18 07:41:53 +08:00
|
|
|
case ARM::tPICADD: {
|
|
|
|
// This is a pseudo op for a label + instruction sequence, which looks like:
|
|
|
|
// LPC0:
|
|
|
|
// add r0, pc
|
|
|
|
// This adds the address of LPC0 to r0.
|
|
|
|
|
|
|
|
// Emit the label.
|
2015-07-16 14:11:10 +08:00
|
|
|
OutStreamer->EmitLabel(getPICLabel(DL.getPrivateGlobalPrefix(),
|
2015-04-25 03:11:51 +08:00
|
|
|
getFunctionNumber(),
|
2015-07-16 14:11:10 +08:00
|
|
|
MI->getOperand(2).getImm(), OutContext));
|
2010-09-18 07:41:53 +08:00
|
|
|
|
|
|
|
// Form and emit the add.
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tADDhirr)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(ARM::PC)
|
|
|
|
// Add predicate operands.
|
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2010-09-18 07:41:53 +08:00
|
|
|
return;
|
|
|
|
}
|
2010-10-01 03:53:58 +08:00
|
|
|
case ARM::PICADD: {
|
2009-10-20 06:23:04 +08:00
|
|
|
// This is a pseudo op for a label + instruction sequence, which looks like:
|
|
|
|
// LPC0:
|
|
|
|
// add r0, pc, r0
|
|
|
|
// This adds the address of LPC0 to r0.
|
2010-09-02 09:02:06 +08:00
|
|
|
|
2009-10-20 06:23:04 +08:00
|
|
|
// Emit the label.
|
2015-07-16 14:11:10 +08:00
|
|
|
OutStreamer->EmitLabel(getPICLabel(DL.getPrivateGlobalPrefix(),
|
2015-04-25 03:11:51 +08:00
|
|
|
getFunctionNumber(),
|
2015-07-16 14:11:10 +08:00
|
|
|
MI->getOperand(2).getImm(), OutContext));
|
2010-09-02 09:02:06 +08:00
|
|
|
|
2010-09-15 05:05:34 +08:00
|
|
|
// Form and emit the add.
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::ADDrr)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(ARM::PC)
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
// Add predicate operands.
|
|
|
|
.addImm(MI->getOperand(3).getImm())
|
|
|
|
.addReg(MI->getOperand(4).getReg())
|
|
|
|
// Add 's' bit operand (always reg0 for this)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2009-10-20 06:23:04 +08:00
|
|
|
return;
|
2010-09-17 01:43:25 +08:00
|
|
|
}
|
2010-09-18 00:25:52 +08:00
|
|
|
case ARM::PICSTR:
|
|
|
|
case ARM::PICSTRB:
|
|
|
|
case ARM::PICSTRH:
|
|
|
|
case ARM::PICLDR:
|
|
|
|
case ARM::PICLDRB:
|
|
|
|
case ARM::PICLDRH:
|
|
|
|
case ARM::PICLDRSB:
|
|
|
|
case ARM::PICLDRSH: {
|
2010-09-17 01:43:25 +08:00
|
|
|
// This is a pseudo op for a label + instruction sequence, which looks like:
|
|
|
|
// LPC0:
|
2010-09-18 00:25:52 +08:00
|
|
|
// OP r0, [pc, r0]
|
2010-09-17 01:43:25 +08:00
|
|
|
// The LCP0 label is referenced by a constant pool entry in order to get
|
|
|
|
// a PC-relative address at the ldr instruction.
|
|
|
|
|
|
|
|
// Emit the label.
|
2015-07-16 14:11:10 +08:00
|
|
|
OutStreamer->EmitLabel(getPICLabel(DL.getPrivateGlobalPrefix(),
|
2015-04-25 03:11:51 +08:00
|
|
|
getFunctionNumber(),
|
2015-07-16 14:11:10 +08:00
|
|
|
MI->getOperand(2).getImm(), OutContext));
|
2010-09-17 01:43:25 +08:00
|
|
|
|
|
|
|
// Form and emit the load
|
2010-09-18 00:25:52 +08:00
|
|
|
unsigned Opcode;
|
|
|
|
switch (MI->getOpcode()) {
|
|
|
|
default:
|
|
|
|
llvm_unreachable("Unexpected opcode!");
|
2010-10-28 07:12:14 +08:00
|
|
|
case ARM::PICSTR: Opcode = ARM::STRrs; break;
|
|
|
|
case ARM::PICSTRB: Opcode = ARM::STRBrs; break;
|
2010-09-18 00:25:52 +08:00
|
|
|
case ARM::PICSTRH: Opcode = ARM::STRH; break;
|
2010-10-27 06:37:02 +08:00
|
|
|
case ARM::PICLDR: Opcode = ARM::LDRrs; break;
|
2010-10-27 08:19:44 +08:00
|
|
|
case ARM::PICLDRB: Opcode = ARM::LDRBrs; break;
|
2010-09-18 00:25:52 +08:00
|
|
|
case ARM::PICLDRH: Opcode = ARM::LDRH; break;
|
|
|
|
case ARM::PICLDRSB: Opcode = ARM::LDRSB; break;
|
|
|
|
case ARM::PICLDRSH: Opcode = ARM::LDRSH; break;
|
|
|
|
}
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(Opcode)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(ARM::PC)
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
.addImm(0)
|
|
|
|
// Add predicate operands.
|
|
|
|
.addImm(MI->getOperand(3).getImm())
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(MI->getOperand(4).getReg()));
|
2010-09-17 01:43:25 +08:00
|
|
|
|
|
|
|
return;
|
2009-10-20 06:23:04 +08:00
|
|
|
}
|
2010-10-01 03:53:58 +08:00
|
|
|
case ARM::CONSTPOOL_ENTRY: {
|
2009-10-20 06:33:05 +08:00
|
|
|
/// CONSTPOOL_ENTRY - This instruction represents a floating constant pool
|
|
|
|
/// in the function. The first operand is the ID# for this instruction, the
|
|
|
|
/// second is the index into the MachineConstantPool that this is, the third
|
|
|
|
/// is the size in bytes of this constant pool entry.
|
2011-12-06 09:43:02 +08:00
|
|
|
/// The required alignment is specified on the basic block holding this MI.
|
2009-10-20 06:33:05 +08:00
|
|
|
unsigned LabelId = (unsigned)MI->getOperand(0).getImm();
|
|
|
|
unsigned CPIdx = (unsigned)MI->getOperand(1).getIndex();
|
|
|
|
|
2012-05-19 03:12:01 +08:00
|
|
|
// If this is the first entry of the pool, mark it.
|
|
|
|
if (!InConstantPool) {
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitDataRegion(MCDR_DataRegion);
|
2012-05-19 03:12:01 +08:00
|
|
|
InConstantPool = true;
|
|
|
|
}
|
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitLabel(GetCPISymbol(LabelId));
|
2009-10-20 06:33:05 +08:00
|
|
|
|
|
|
|
const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPIdx];
|
|
|
|
if (MCPE.isMachineConstantPoolEntry())
|
|
|
|
EmitMachineConstantPoolValue(MCPE.Val.MachineCPVal);
|
|
|
|
else
|
2015-07-16 14:11:10 +08:00
|
|
|
EmitGlobalConstant(DL, MCPE.Val.ConstVal);
|
2009-10-20 06:33:05 +08:00
|
|
|
return;
|
|
|
|
}
|
2015-06-01 03:22:07 +08:00
|
|
|
case ARM::JUMPTABLE_ADDRS:
|
|
|
|
EmitJumpTableAddrs(MI);
|
|
|
|
return;
|
|
|
|
case ARM::JUMPTABLE_INSTS:
|
|
|
|
EmitJumpTableInsts(MI);
|
|
|
|
return;
|
|
|
|
case ARM::JUMPTABLE_TBB:
|
|
|
|
case ARM::JUMPTABLE_TBH:
|
|
|
|
EmitJumpTableTBInst(MI, MI->getOpcode() == ARM::JUMPTABLE_TBB ? 1 : 2);
|
|
|
|
return;
|
2010-09-22 07:28:16 +08:00
|
|
|
case ARM::t2BR_JT: {
|
|
|
|
// Lower and emit the instruction itself, then the jump table following it.
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVr)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::PC)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
// Add predicate operands.
|
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2010-11-30 06:37:40 +08:00
|
|
|
return;
|
|
|
|
}
|
2015-06-01 03:22:07 +08:00
|
|
|
case ARM::t2TBB_JT:
|
2010-11-30 06:37:40 +08:00
|
|
|
case ARM::t2TBH_JT: {
|
2015-06-01 03:22:07 +08:00
|
|
|
unsigned Opc = MI->getOpcode() == ARM::t2TBB_JT ? ARM::t2TBB : ARM::t2TBH;
|
|
|
|
// Lower and emit the PC label, then the instruction itself.
|
|
|
|
OutStreamer->EmitLabel(GetCPISymbol(MI->getOperand(3).getImm()));
|
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(Opc)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
// Add predicate operands.
|
|
|
|
.addImm(ARMCC::AL)
|
|
|
|
.addReg(0));
|
2010-09-22 07:28:16 +08:00
|
|
|
return;
|
|
|
|
}
|
2010-11-30 03:32:47 +08:00
|
|
|
case ARM::tBR_JTr:
|
2010-11-30 02:37:44 +08:00
|
|
|
case ARM::BR_JTr: {
|
|
|
|
// Lower and emit the instruction itself, then the jump table following it.
|
|
|
|
// mov pc, target
|
|
|
|
MCInst TmpInst;
|
2010-11-30 06:37:40 +08:00
|
|
|
unsigned Opc = MI->getOpcode() == ARM::BR_JTr ?
|
2011-07-01 07:38:17 +08:00
|
|
|
ARM::MOVr : ARM::tMOVr;
|
2010-11-30 03:32:47 +08:00
|
|
|
TmpInst.setOpcode(Opc);
|
2015-05-14 02:37:00 +08:00
|
|
|
TmpInst.addOperand(MCOperand::createReg(ARM::PC));
|
|
|
|
TmpInst.addOperand(MCOperand::createReg(MI->getOperand(0).getReg()));
|
2010-11-30 02:37:44 +08:00
|
|
|
// Add predicate operands.
|
2015-05-14 02:37:00 +08:00
|
|
|
TmpInst.addOperand(MCOperand::createImm(ARMCC::AL));
|
|
|
|
TmpInst.addOperand(MCOperand::createReg(0));
|
2010-12-01 02:30:19 +08:00
|
|
|
// Add 's' bit operand (always reg0 for this)
|
|
|
|
if (Opc == ARM::MOVr)
|
2015-05-14 02:37:00 +08:00
|
|
|
TmpInst.addOperand(MCOperand::createReg(0));
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, TmpInst);
|
2010-11-30 02:37:44 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ARM::BR_JTm: {
|
|
|
|
// Lower and emit the instruction itself, then the jump table following it.
|
|
|
|
// ldr pc, target
|
|
|
|
MCInst TmpInst;
|
|
|
|
if (MI->getOperand(1).getReg() == 0) {
|
|
|
|
// literal offset
|
|
|
|
TmpInst.setOpcode(ARM::LDRi12);
|
2015-05-14 02:37:00 +08:00
|
|
|
TmpInst.addOperand(MCOperand::createReg(ARM::PC));
|
|
|
|
TmpInst.addOperand(MCOperand::createReg(MI->getOperand(0).getReg()));
|
|
|
|
TmpInst.addOperand(MCOperand::createImm(MI->getOperand(2).getImm()));
|
2010-11-30 02:37:44 +08:00
|
|
|
} else {
|
|
|
|
TmpInst.setOpcode(ARM::LDRrs);
|
2015-05-14 02:37:00 +08:00
|
|
|
TmpInst.addOperand(MCOperand::createReg(ARM::PC));
|
|
|
|
TmpInst.addOperand(MCOperand::createReg(MI->getOperand(0).getReg()));
|
|
|
|
TmpInst.addOperand(MCOperand::createReg(MI->getOperand(1).getReg()));
|
|
|
|
TmpInst.addOperand(MCOperand::createImm(0));
|
2010-11-30 02:37:44 +08:00
|
|
|
}
|
|
|
|
// Add predicate operands.
|
2015-05-14 02:37:00 +08:00
|
|
|
TmpInst.addOperand(MCOperand::createImm(ARMCC::AL));
|
|
|
|
TmpInst.addOperand(MCOperand::createReg(0));
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, TmpInst);
|
2010-09-23 01:39:48 +08:00
|
|
|
return;
|
|
|
|
}
|
2010-11-18 05:05:55 +08:00
|
|
|
case ARM::BR_JTadd: {
|
|
|
|
// Lower and emit the instruction itself, then the jump table following it.
|
|
|
|
// add pc, target, idx
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::ADDrr)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::PC)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
// Add predicate operands.
|
|
|
|
.addImm(ARMCC::AL)
|
|
|
|
.addReg(0)
|
|
|
|
// Add 's' bit operand (always reg0 for this)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2010-11-18 05:05:55 +08:00
|
|
|
return;
|
|
|
|
}
|
2014-11-14 01:58:48 +08:00
|
|
|
case ARM::SPACE:
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitZeros(MI->getOperand(1).getImm());
|
2014-11-14 01:58:48 +08:00
|
|
|
return;
|
2010-09-24 02:05:37 +08:00
|
|
|
case ARM::TRAP: {
|
|
|
|
// Non-Darwin binutils don't yet support the "trap" mnemonic.
|
|
|
|
// FIXME: Remove this special case when they do.
|
2014-01-06 22:28:05 +08:00
|
|
|
if (!Subtarget->isTargetMachO()) {
|
2010-10-02 07:21:38 +08:00
|
|
|
//.long 0xe7ffdefe @ trap
|
2010-09-24 03:42:17 +08:00
|
|
|
uint32_t Val = 0xe7ffdefeUL;
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->AddComment("trap");
|
|
|
|
OutStreamer->EmitIntValue(Val, 4);
|
2010-09-24 02:05:37 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-01-31 00:30:19 +08:00
|
|
|
case ARM::TRAPNaCl: {
|
|
|
|
//.long 0xe7fedef0 @ trap
|
|
|
|
uint32_t Val = 0xe7fedef0UL;
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->AddComment("trap");
|
|
|
|
OutStreamer->EmitIntValue(Val, 4);
|
2013-01-31 00:30:19 +08:00
|
|
|
return;
|
|
|
|
}
|
2010-09-24 02:05:37 +08:00
|
|
|
case ARM::tTRAP: {
|
|
|
|
// Non-Darwin binutils don't yet support the "trap" mnemonic.
|
|
|
|
// FIXME: Remove this special case when they do.
|
2014-01-06 22:28:05 +08:00
|
|
|
if (!Subtarget->isTargetMachO()) {
|
2010-10-02 07:21:38 +08:00
|
|
|
//.short 57086 @ trap
|
2010-09-24 02:57:26 +08:00
|
|
|
uint16_t Val = 0xdefe;
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->AddComment("trap");
|
|
|
|
OutStreamer->EmitIntValue(Val, 2);
|
2010-09-24 02:05:37 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2010-09-25 04:47:58 +08:00
|
|
|
case ARM::t2Int_eh_sjlj_setjmp:
|
|
|
|
case ARM::t2Int_eh_sjlj_setjmp_nofp:
|
2010-10-01 03:53:58 +08:00
|
|
|
case ARM::tInt_eh_sjlj_setjmp: {
|
2010-09-25 04:47:58 +08:00
|
|
|
// Two incoming args: GPR:$src, GPR:$val
|
|
|
|
// mov $val, pc
|
|
|
|
// adds $val, #7
|
|
|
|
// str $val, [$src, #4]
|
|
|
|
// movs r0, #0
|
2015-07-17 06:34:20 +08:00
|
|
|
// b LSJLJEH
|
2010-09-25 04:47:58 +08:00
|
|
|
// movs r0, #1
|
2015-07-17 06:34:20 +08:00
|
|
|
// LSJLJEH:
|
2010-09-25 04:47:58 +08:00
|
|
|
unsigned SrcReg = MI->getOperand(0).getReg();
|
|
|
|
unsigned ValReg = MI->getOperand(1).getReg();
|
2015-07-17 06:34:20 +08:00
|
|
|
MCSymbol *Label = OutContext.createTempSymbol("SJLJEH", false, true);
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->AddComment("eh_setjmp begin");
|
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVr)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ValReg)
|
|
|
|
.addReg(ARM::PC)
|
2011-07-01 06:10:46 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tADDi3)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ValReg)
|
2010-09-25 04:47:58 +08:00
|
|
|
// 's' bit operand
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::CPSR)
|
|
|
|
.addReg(ValReg)
|
|
|
|
.addImm(7)
|
2010-09-25 04:47:58 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tSTRi)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ValReg)
|
|
|
|
.addReg(SrcReg)
|
2010-09-25 04:47:58 +08:00
|
|
|
// The offset immediate is #4. The operand value is scaled by 4 for the
|
|
|
|
// tSTR instruction.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(1)
|
2010-09-25 04:47:58 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVi8)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::R0)
|
|
|
|
.addReg(ARM::CPSR)
|
|
|
|
.addImm(0)
|
2010-09-25 04:47:58 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-05-30 09:25:56 +08:00
|
|
|
const MCExpr *SymbolExpr = MCSymbolRefExpr::create(Label, OutContext);
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tB)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addExpr(SymbolExpr)
|
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->AddComment("eh_setjmp end");
|
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVi8)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::R0)
|
|
|
|
.addReg(ARM::CPSR)
|
|
|
|
.addImm(1)
|
2010-09-25 04:47:58 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->EmitLabel(Label);
|
2010-09-25 04:47:58 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-24 07:33:56 +08:00
|
|
|
case ARM::Int_eh_sjlj_setjmp_nofp:
|
2010-10-01 03:53:58 +08:00
|
|
|
case ARM::Int_eh_sjlj_setjmp: {
|
2010-09-24 07:33:56 +08:00
|
|
|
// Two incoming args: GPR:$src, GPR:$val
|
|
|
|
// add $val, pc, #8
|
|
|
|
// str $val, [$src, #+4]
|
|
|
|
// mov r0, #0
|
|
|
|
// add pc, pc, #0
|
|
|
|
// mov r0, #1
|
|
|
|
unsigned SrcReg = MI->getOperand(0).getReg();
|
|
|
|
unsigned ValReg = MI->getOperand(1).getReg();
|
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->AddComment("eh_setjmp begin");
|
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::ADDri)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ValReg)
|
|
|
|
.addReg(ARM::PC)
|
|
|
|
.addImm(8)
|
2010-09-24 07:33:56 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
|
|
|
.addReg(0)
|
2010-09-24 07:33:56 +08:00
|
|
|
// 's' bit operand (always reg0 for this).
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::STRi12)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ValReg)
|
|
|
|
.addReg(SrcReg)
|
|
|
|
.addImm(4)
|
2010-09-24 07:33:56 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVi)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::R0)
|
|
|
|
.addImm(0)
|
2010-09-24 07:33:56 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
|
|
|
.addReg(0)
|
2010-09-24 07:33:56 +08:00
|
|
|
// 's' bit operand (always reg0 for this).
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::ADDri)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::PC)
|
|
|
|
.addReg(ARM::PC)
|
|
|
|
.addImm(0)
|
2010-09-24 07:33:56 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
|
|
|
.addReg(0)
|
2010-09-24 07:33:56 +08:00
|
|
|
// 's' bit operand (always reg0 for this).
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
OutStreamer->AddComment("eh_setjmp end");
|
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVi)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::R0)
|
|
|
|
.addImm(1)
|
2010-09-24 07:33:56 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
|
|
|
.addReg(0)
|
2010-09-24 07:33:56 +08:00
|
|
|
// 's' bit operand (always reg0 for this).
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2010-09-24 07:33:56 +08:00
|
|
|
return;
|
|
|
|
}
|
2010-09-28 05:47:04 +08:00
|
|
|
case ARM::Int_eh_sjlj_longjmp: {
|
|
|
|
// ldr sp, [$src, #8]
|
|
|
|
// ldr $scratch, [$src, #4]
|
|
|
|
// ldr r7, [$src]
|
|
|
|
// bx $scratch
|
|
|
|
unsigned SrcReg = MI->getOperand(0).getReg();
|
|
|
|
unsigned ScratchReg = MI->getOperand(1).getReg();
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::LDRi12)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::SP)
|
|
|
|
.addReg(SrcReg)
|
|
|
|
.addImm(8)
|
2010-09-28 05:47:04 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::LDRi12)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ScratchReg)
|
|
|
|
.addReg(SrcReg)
|
|
|
|
.addImm(4)
|
2010-09-28 05:47:04 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::LDRi12)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::R7)
|
|
|
|
.addReg(SrcReg)
|
|
|
|
.addImm(0)
|
2010-09-28 05:47:04 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::BX)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ScratchReg)
|
2010-09-28 05:47:04 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2010-09-28 06:28:11 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ARM::tInt_eh_sjlj_longjmp: {
|
|
|
|
// ldr $scratch, [$src, #8]
|
|
|
|
// mov sp, $scratch
|
|
|
|
// ldr $scratch, [$src, #4]
|
|
|
|
// ldr r7, [$src]
|
|
|
|
// bx $scratch
|
|
|
|
unsigned SrcReg = MI->getOperand(0).getReg();
|
|
|
|
unsigned ScratchReg = MI->getOperand(1).getReg();
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tLDRi)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ScratchReg)
|
|
|
|
.addReg(SrcReg)
|
2010-09-28 06:28:11 +08:00
|
|
|
// The offset immediate is #8. The operand value is scaled by 4 for the
|
2010-12-14 11:36:38 +08:00
|
|
|
// tLDR instruction.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(2)
|
2010-09-28 06:28:11 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVr)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::SP)
|
|
|
|
.addReg(ScratchReg)
|
2010-09-28 06:28:11 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tLDRi)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ScratchReg)
|
|
|
|
.addReg(SrcReg)
|
|
|
|
.addImm(1)
|
2010-09-28 06:28:11 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tLDRi)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ARM::R7)
|
|
|
|
.addReg(SrcReg)
|
|
|
|
.addImm(0)
|
2010-09-28 06:28:11 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2012-11-26 21:34:22 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tBX)
|
2012-11-26 21:34:22 +08:00
|
|
|
.addReg(ScratchReg)
|
2010-09-28 06:28:11 +08:00
|
|
|
// Predicate.
|
2012-11-26 21:34:22 +08:00
|
|
|
.addImm(ARMCC::AL)
|
2012-11-27 02:05:52 +08:00
|
|
|
.addReg(0));
|
2010-09-28 05:47:04 +08:00
|
|
|
return;
|
|
|
|
}
|
2009-10-20 04:20:46 +08:00
|
|
|
}
|
2010-09-02 09:02:06 +08:00
|
|
|
|
2009-10-20 04:20:46 +08:00
|
|
|
MCInst TmpInst;
|
2010-11-15 05:00:02 +08:00
|
|
|
LowerARMMachineInstrToMCInst(MI, TmpInst, *this);
|
2011-03-06 02:43:32 +08:00
|
|
|
|
2015-04-25 03:11:51 +08:00
|
|
|
EmitToStreamer(*OutStreamer, TmpInst);
|
2009-10-20 04:20:46 +08:00
|
|
|
}
|
2009-10-20 13:15:36 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Target Registry Stuff
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// Force static initialization.
|
|
|
|
extern "C" void LLVMInitializeARMAsmPrinter() {
|
2014-04-01 23:19:30 +08:00
|
|
|
RegisterAsmPrinter<ARMAsmPrinter> X(TheARMLETarget);
|
|
|
|
RegisterAsmPrinter<ARMAsmPrinter> Y(TheARMBETarget);
|
|
|
|
RegisterAsmPrinter<ARMAsmPrinter> A(TheThumbLETarget);
|
|
|
|
RegisterAsmPrinter<ARMAsmPrinter> B(TheThumbBETarget);
|
2009-10-20 13:15:36 +08:00
|
|
|
}
|