2010-11-15 03:53:02 +08:00
|
|
|
//===-- PPCMCInstLower.cpp - Convert PPC MachineInstr to an MCInst --------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains code to lower PPC MachineInstrs to their corresponding
|
|
|
|
// MCInst records.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-11-15 05:12:33 +08:00
|
|
|
#include "PPC.h"
|
2013-05-24 06:26:41 +08:00
|
|
|
#include "MCTargetDesc/PPCMCExpr.h"
|
2015-01-14 19:23:27 +08:00
|
|
|
#include "PPCSubtarget.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/ADT/SmallString.h"
|
2013-04-27 08:43:16 +08:00
|
|
|
#include "llvm/ADT/Twine.h"
|
2010-11-15 03:53:02 +08:00
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
2010-11-15 10:46:57 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2010-11-15 07:42:06 +08:00
|
|
|
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
|
2014-01-04 03:21:54 +08:00
|
|
|
#include "llvm/IR/DataLayout.h"
|
2013-02-20 08:31:54 +08:00
|
|
|
#include "llvm/IR/GlobalValue.h"
|
2014-01-08 05:19:40 +08:00
|
|
|
#include "llvm/IR/Mangler.h"
|
2010-11-15 07:42:06 +08:00
|
|
|
#include "llvm/MC/MCAsmInfo.h"
|
2010-11-15 03:53:02 +08:00
|
|
|
#include "llvm/MC/MCExpr.h"
|
|
|
|
#include "llvm/MC/MCInst.h"
|
2014-02-20 01:23:20 +08:00
|
|
|
#include "llvm/Target/TargetLowering.h"
|
|
|
|
#include "llvm/Target/TargetLoweringObjectFile.h"
|
2010-11-15 03:53:02 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2010-11-15 07:42:06 +08:00
|
|
|
static MachineModuleInfoMachO &getMachOMMI(AsmPrinter &AP) {
|
|
|
|
return AP.MMI->getObjFileInfo<MachineModuleInfoMachO>();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static MCSymbol *GetSymbolFromOperand(const MachineOperand &MO, AsmPrinter &AP){
|
2014-02-20 01:23:20 +08:00
|
|
|
const TargetMachine &TM = AP.TM;
|
|
|
|
Mangler *Mang = AP.Mang;
|
2015-01-27 03:03:15 +08:00
|
|
|
const DataLayout *DL = TM.getDataLayout();
|
2010-11-15 07:42:06 +08:00
|
|
|
MCContext &Ctx = AP.OutContext;
|
2014-10-14 16:25:26 +08:00
|
|
|
bool isDarwin = Triple(TM.getTargetTriple()).isOSDarwin();
|
2010-11-15 07:42:06 +08:00
|
|
|
|
|
|
|
SmallString<128> Name;
|
2013-12-02 11:26:43 +08:00
|
|
|
StringRef Suffix;
|
2014-07-19 07:29:49 +08:00
|
|
|
if (MO.getTargetFlags() == PPCII::MO_PLT_OR_STUB) {
|
|
|
|
if (isDarwin)
|
|
|
|
Suffix = "$stub";
|
|
|
|
} else if (MO.getTargetFlags() & PPCII::MO_NLP_FLAG)
|
2013-12-02 11:26:43 +08:00
|
|
|
Suffix = "$non_lazy_ptr";
|
|
|
|
|
|
|
|
if (!Suffix.empty())
|
2014-01-04 03:21:54 +08:00
|
|
|
Name += DL->getPrivateGlobalPrefix();
|
2013-12-02 11:26:43 +08:00
|
|
|
|
|
|
|
unsigned PrefixLen = Name.size();
|
|
|
|
|
2010-11-15 07:42:06 +08:00
|
|
|
if (!MO.isGlobal()) {
|
|
|
|
assert(MO.isSymbol() && "Isn't a symbol reference");
|
2014-02-20 01:23:20 +08:00
|
|
|
Mang->getNameWithPrefix(Name, MO.getSymbolName());
|
2013-12-02 11:26:43 +08:00
|
|
|
} else {
|
2010-11-15 07:42:06 +08:00
|
|
|
const GlobalValue *GV = MO.getGlobal();
|
2014-02-20 04:30:41 +08:00
|
|
|
TM.getNameWithPrefix(Name, GV, *Mang);
|
2010-11-15 07:42:06 +08:00
|
|
|
}
|
2013-12-02 11:26:43 +08:00
|
|
|
|
|
|
|
unsigned OrigLen = Name.size() - PrefixLen;
|
|
|
|
|
|
|
|
Name += Suffix;
|
2015-03-28 01:51:30 +08:00
|
|
|
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name);
|
2013-12-02 11:26:43 +08:00
|
|
|
StringRef OrigName = StringRef(Name).substr(PrefixLen, OrigLen);
|
|
|
|
|
2010-11-15 07:42:06 +08:00
|
|
|
// If the target flags on the operand changes the name of the symbol, do that
|
|
|
|
// before we return the symbol.
|
2014-07-19 07:29:49 +08:00
|
|
|
if (MO.getTargetFlags() == PPCII::MO_PLT_OR_STUB && isDarwin) {
|
2010-11-15 07:42:06 +08:00
|
|
|
MachineModuleInfoImpl::StubValueTy &StubSym =
|
|
|
|
getMachOMMI(AP).getFnStubEntry(Sym);
|
|
|
|
if (StubSym.getPointer())
|
|
|
|
return Sym;
|
|
|
|
|
|
|
|
if (MO.isGlobal()) {
|
|
|
|
StubSym =
|
|
|
|
MachineModuleInfoImpl::
|
2013-10-30 01:07:16 +08:00
|
|
|
StubValueTy(AP.getSymbol(MO.getGlobal()),
|
2010-11-15 07:42:06 +08:00
|
|
|
!MO.getGlobal()->hasInternalLinkage());
|
|
|
|
} else {
|
|
|
|
StubSym =
|
|
|
|
MachineModuleInfoImpl::
|
2013-12-02 11:26:43 +08:00
|
|
|
StubValueTy(Ctx.GetOrCreateSymbol(OrigName), false);
|
2010-11-15 07:42:06 +08:00
|
|
|
}
|
|
|
|
return Sym;
|
|
|
|
}
|
2010-11-15 11:13:19 +08:00
|
|
|
|
|
|
|
// If the symbol reference is actually to a non_lazy_ptr, not to the symbol,
|
|
|
|
// then add the suffix.
|
|
|
|
if (MO.getTargetFlags() & PPCII::MO_NLP_FLAG) {
|
|
|
|
MachineModuleInfoMachO &MachO = getMachOMMI(AP);
|
|
|
|
|
|
|
|
MachineModuleInfoImpl::StubValueTy &StubSym =
|
|
|
|
(MO.getTargetFlags() & PPCII::MO_NLP_HIDDEN_FLAG) ?
|
|
|
|
MachO.getHiddenGVStubEntry(Sym) : MachO.getGVStubEntry(Sym);
|
|
|
|
|
2014-04-25 13:30:21 +08:00
|
|
|
if (!StubSym.getPointer()) {
|
2010-11-15 11:13:19 +08:00
|
|
|
assert(MO.isGlobal() && "Extern symbol not handled yet");
|
|
|
|
StubSym = MachineModuleInfoImpl::
|
2013-10-30 01:07:16 +08:00
|
|
|
StubValueTy(AP.getSymbol(MO.getGlobal()),
|
2010-11-15 11:13:19 +08:00
|
|
|
!MO.getGlobal()->hasInternalLinkage());
|
|
|
|
}
|
|
|
|
return Sym;
|
2010-11-15 07:42:06 +08:00
|
|
|
}
|
|
|
|
|
2013-12-02 11:26:43 +08:00
|
|
|
return Sym;
|
2010-11-15 07:42:06 +08:00
|
|
|
}
|
|
|
|
|
2010-11-15 05:20:46 +08:00
|
|
|
static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol,
|
[PowerPC] Always use "assembler dialect" 1
A setting in MCAsmInfo defines the "assembler dialect" to use. This is used
by common code to choose between alternatives in a multi-alternative GNU
inline asm statement like the following:
__asm__ ("{sfe|subfe} %0,%1,%2" : "=r" (out) : "r" (in1), "r" (in2));
The meaning of these dialects is platform specific, and GCC defines those
for PowerPC to use dialect 0 for old-style (POWER) mnemonics and 1 for
new-style (PowerPC) mnemonics, like in the example above.
To be compatible with inline asm used with GCC, LLVM ought to do the same.
Specifically, this means we should always use assembler dialect 1 since
old-style mnemonics really aren't supported on any current platform.
However, the current LLVM back-end uses:
AssemblerDialect = 1; // New-Style mnemonics.
in PPCMCAsmInfoDarwin, and
AssemblerDialect = 0; // Old-Style mnemonics.
in PPCLinuxMCAsmInfo.
The Linux setting really isn't correct, we should be using new-style
mnemonics everywhere. This is changed by this commit.
Unfortunately, the setting of this variable is overloaded in the back-end
to decide whether or not we are on a Darwin target. This is done in
PPCInstPrinter (the "SyntaxVariant" is initialized from the MCAsmInfo
AssemblerDialect setting), and also in PPCMCExpr. Setting AssemblerDialect
to 1 for both Darwin and Linux no longer allows us to make this distinction.
Instead, this patch uses the MCSubtargetInfo passed to createPPCMCInstPrinter
to distinguish Darwin targets, and ignores the SyntaxVariant parameter.
As to PPCMCExpr, this patch adds an explicit isDarwin argument that needs
to be passed in by the caller when creating a target MCExpr. (To do so
this patch implicitly also reverts commit 184441.)
llvm-svn: 185858
2013-07-09 04:20:51 +08:00
|
|
|
AsmPrinter &Printer, bool isDarwin) {
|
2010-11-15 05:20:46 +08:00
|
|
|
MCContext &Ctx = Printer.OutContext;
|
2010-11-15 07:42:06 +08:00
|
|
|
MCSymbolRefExpr::VariantKind RefKind = MCSymbolRefExpr::VK_None;
|
|
|
|
|
2012-06-05 01:36:38 +08:00
|
|
|
unsigned access = MO.getTargetFlags() & PPCII::MO_ACCESS_MASK;
|
|
|
|
|
2013-06-21 00:23:52 +08:00
|
|
|
switch (access) {
|
2013-06-21 22:42:20 +08:00
|
|
|
case PPCII::MO_TPREL_LO:
|
|
|
|
RefKind = MCSymbolRefExpr::VK_PPC_TPREL_LO;
|
2013-06-21 00:23:52 +08:00
|
|
|
break;
|
2013-06-21 22:42:20 +08:00
|
|
|
case PPCII::MO_TPREL_HA:
|
|
|
|
RefKind = MCSymbolRefExpr::VK_PPC_TPREL_HA;
|
2013-06-21 00:23:52 +08:00
|
|
|
break;
|
2013-06-21 22:42:20 +08:00
|
|
|
case PPCII::MO_DTPREL_LO:
|
|
|
|
RefKind = MCSymbolRefExpr::VK_PPC_DTPREL_LO;
|
2013-06-21 00:23:52 +08:00
|
|
|
break;
|
2013-06-21 22:42:20 +08:00
|
|
|
case PPCII::MO_TLSLD_LO:
|
|
|
|
RefKind = MCSymbolRefExpr::VK_PPC_GOT_TLSLD_LO;
|
2013-06-21 00:23:52 +08:00
|
|
|
break;
|
2013-06-21 22:42:20 +08:00
|
|
|
case PPCII::MO_TOC_LO:
|
|
|
|
RefKind = MCSymbolRefExpr::VK_PPC_TOC_LO;
|
2013-06-21 00:23:52 +08:00
|
|
|
break;
|
2013-07-05 20:22:36 +08:00
|
|
|
case PPCII::MO_TLS:
|
|
|
|
RefKind = MCSymbolRefExpr::VK_PPC_TLS;
|
|
|
|
break;
|
2013-05-24 06:26:41 +08:00
|
|
|
}
|
2010-11-15 07:42:06 +08:00
|
|
|
|
2014-07-19 07:29:49 +08:00
|
|
|
if (MO.getTargetFlags() == PPCII::MO_PLT_OR_STUB && !isDarwin)
|
|
|
|
RefKind = MCSymbolRefExpr::VK_PLT;
|
|
|
|
|
2010-11-15 11:13:19 +08:00
|
|
|
const MCExpr *Expr = MCSymbolRefExpr::Create(Symbol, RefKind, Ctx);
|
2010-11-15 07:42:06 +08:00
|
|
|
|
2010-11-15 05:20:46 +08:00
|
|
|
if (!MO.isJTI() && MO.getOffset())
|
|
|
|
Expr = MCBinaryExpr::CreateAdd(Expr,
|
|
|
|
MCConstantExpr::Create(MO.getOffset(), Ctx),
|
|
|
|
Ctx);
|
2010-11-15 10:46:57 +08:00
|
|
|
|
2010-11-15 11:13:19 +08:00
|
|
|
// Subtract off the PIC base if required.
|
|
|
|
if (MO.getTargetFlags() & PPCII::MO_PIC_FLAG) {
|
2010-11-15 10:46:57 +08:00
|
|
|
const MachineFunction *MF = MO.getParent()->getParent()->getParent();
|
|
|
|
|
|
|
|
const MCExpr *PB = MCSymbolRefExpr::Create(MF->getPICBaseSymbol(), Ctx);
|
|
|
|
Expr = MCBinaryExpr::CreateSub(Expr, PB, Ctx);
|
|
|
|
}
|
2013-05-24 06:26:41 +08:00
|
|
|
|
2013-06-21 00:23:52 +08:00
|
|
|
// Add ha16() / lo16() markers if required.
|
|
|
|
switch (access) {
|
2013-06-21 22:42:20 +08:00
|
|
|
case PPCII::MO_LO:
|
[PowerPC] Always use "assembler dialect" 1
A setting in MCAsmInfo defines the "assembler dialect" to use. This is used
by common code to choose between alternatives in a multi-alternative GNU
inline asm statement like the following:
__asm__ ("{sfe|subfe} %0,%1,%2" : "=r" (out) : "r" (in1), "r" (in2));
The meaning of these dialects is platform specific, and GCC defines those
for PowerPC to use dialect 0 for old-style (POWER) mnemonics and 1 for
new-style (PowerPC) mnemonics, like in the example above.
To be compatible with inline asm used with GCC, LLVM ought to do the same.
Specifically, this means we should always use assembler dialect 1 since
old-style mnemonics really aren't supported on any current platform.
However, the current LLVM back-end uses:
AssemblerDialect = 1; // New-Style mnemonics.
in PPCMCAsmInfoDarwin, and
AssemblerDialect = 0; // Old-Style mnemonics.
in PPCLinuxMCAsmInfo.
The Linux setting really isn't correct, we should be using new-style
mnemonics everywhere. This is changed by this commit.
Unfortunately, the setting of this variable is overloaded in the back-end
to decide whether or not we are on a Darwin target. This is done in
PPCInstPrinter (the "SyntaxVariant" is initialized from the MCAsmInfo
AssemblerDialect setting), and also in PPCMCExpr. Setting AssemblerDialect
to 1 for both Darwin and Linux no longer allows us to make this distinction.
Instead, this patch uses the MCSubtargetInfo passed to createPPCMCInstPrinter
to distinguish Darwin targets, and ignores the SyntaxVariant parameter.
As to PPCMCExpr, this patch adds an explicit isDarwin argument that needs
to be passed in by the caller when creating a target MCExpr. (To do so
this patch implicitly also reverts commit 184441.)
llvm-svn: 185858
2013-07-09 04:20:51 +08:00
|
|
|
Expr = PPCMCExpr::CreateLo(Expr, isDarwin, Ctx);
|
2013-06-21 00:23:52 +08:00
|
|
|
break;
|
2013-06-21 22:42:20 +08:00
|
|
|
case PPCII::MO_HA:
|
[PowerPC] Always use "assembler dialect" 1
A setting in MCAsmInfo defines the "assembler dialect" to use. This is used
by common code to choose between alternatives in a multi-alternative GNU
inline asm statement like the following:
__asm__ ("{sfe|subfe} %0,%1,%2" : "=r" (out) : "r" (in1), "r" (in2));
The meaning of these dialects is platform specific, and GCC defines those
for PowerPC to use dialect 0 for old-style (POWER) mnemonics and 1 for
new-style (PowerPC) mnemonics, like in the example above.
To be compatible with inline asm used with GCC, LLVM ought to do the same.
Specifically, this means we should always use assembler dialect 1 since
old-style mnemonics really aren't supported on any current platform.
However, the current LLVM back-end uses:
AssemblerDialect = 1; // New-Style mnemonics.
in PPCMCAsmInfoDarwin, and
AssemblerDialect = 0; // Old-Style mnemonics.
in PPCLinuxMCAsmInfo.
The Linux setting really isn't correct, we should be using new-style
mnemonics everywhere. This is changed by this commit.
Unfortunately, the setting of this variable is overloaded in the back-end
to decide whether or not we are on a Darwin target. This is done in
PPCInstPrinter (the "SyntaxVariant" is initialized from the MCAsmInfo
AssemblerDialect setting), and also in PPCMCExpr. Setting AssemblerDialect
to 1 for both Darwin and Linux no longer allows us to make this distinction.
Instead, this patch uses the MCSubtargetInfo passed to createPPCMCInstPrinter
to distinguish Darwin targets, and ignores the SyntaxVariant parameter.
As to PPCMCExpr, this patch adds an explicit isDarwin argument that needs
to be passed in by the caller when creating a target MCExpr. (To do so
this patch implicitly also reverts commit 184441.)
llvm-svn: 185858
2013-07-09 04:20:51 +08:00
|
|
|
Expr = PPCMCExpr::CreateHa(Expr, isDarwin, Ctx);
|
2013-06-21 00:23:52 +08:00
|
|
|
break;
|
2013-05-24 06:26:41 +08:00
|
|
|
}
|
|
|
|
|
2015-05-14 02:37:00 +08:00
|
|
|
return MCOperand::createExpr(Expr);
|
2010-11-15 05:20:46 +08:00
|
|
|
}
|
|
|
|
|
2010-11-15 05:12:33 +08:00
|
|
|
void llvm::LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI,
|
[PowerPC] Always use "assembler dialect" 1
A setting in MCAsmInfo defines the "assembler dialect" to use. This is used
by common code to choose between alternatives in a multi-alternative GNU
inline asm statement like the following:
__asm__ ("{sfe|subfe} %0,%1,%2" : "=r" (out) : "r" (in1), "r" (in2));
The meaning of these dialects is platform specific, and GCC defines those
for PowerPC to use dialect 0 for old-style (POWER) mnemonics and 1 for
new-style (PowerPC) mnemonics, like in the example above.
To be compatible with inline asm used with GCC, LLVM ought to do the same.
Specifically, this means we should always use assembler dialect 1 since
old-style mnemonics really aren't supported on any current platform.
However, the current LLVM back-end uses:
AssemblerDialect = 1; // New-Style mnemonics.
in PPCMCAsmInfoDarwin, and
AssemblerDialect = 0; // Old-Style mnemonics.
in PPCLinuxMCAsmInfo.
The Linux setting really isn't correct, we should be using new-style
mnemonics everywhere. This is changed by this commit.
Unfortunately, the setting of this variable is overloaded in the back-end
to decide whether or not we are on a Darwin target. This is done in
PPCInstPrinter (the "SyntaxVariant" is initialized from the MCAsmInfo
AssemblerDialect setting), and also in PPCMCExpr. Setting AssemblerDialect
to 1 for both Darwin and Linux no longer allows us to make this distinction.
Instead, this patch uses the MCSubtargetInfo passed to createPPCMCInstPrinter
to distinguish Darwin targets, and ignores the SyntaxVariant parameter.
As to PPCMCExpr, this patch adds an explicit isDarwin argument that needs
to be passed in by the caller when creating a target MCExpr. (To do so
this patch implicitly also reverts commit 184441.)
llvm-svn: 185858
2013-07-09 04:20:51 +08:00
|
|
|
AsmPrinter &AP, bool isDarwin) {
|
2010-11-15 03:53:02 +08:00
|
|
|
OutMI.setOpcode(MI->getOpcode());
|
|
|
|
|
|
|
|
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
|
|
|
const MachineOperand &MO = MI->getOperand(i);
|
|
|
|
|
|
|
|
MCOperand MCOp;
|
|
|
|
switch (MO.getType()) {
|
|
|
|
default:
|
|
|
|
MI->dump();
|
2012-02-07 10:50:20 +08:00
|
|
|
llvm_unreachable("unknown operand type");
|
2010-11-15 03:53:02 +08:00
|
|
|
case MachineOperand::MO_Register:
|
|
|
|
assert(!MO.getSubReg() && "Subregs should be eliminated!");
|
2015-03-18 03:31:19 +08:00
|
|
|
assert(MO.getReg() > PPC::NoRegister &&
|
|
|
|
MO.getReg() < PPC::NUM_TARGET_REGS &&
|
|
|
|
"Invalid register for this target!");
|
2015-05-14 02:37:00 +08:00
|
|
|
MCOp = MCOperand::createReg(MO.getReg());
|
2010-11-15 03:53:02 +08:00
|
|
|
break;
|
|
|
|
case MachineOperand::MO_Immediate:
|
2015-05-14 02:37:00 +08:00
|
|
|
MCOp = MCOperand::createImm(MO.getImm());
|
2010-11-15 03:53:02 +08:00
|
|
|
break;
|
2010-11-15 05:20:46 +08:00
|
|
|
case MachineOperand::MO_MachineBasicBlock:
|
2015-05-14 02:37:00 +08:00
|
|
|
MCOp = MCOperand::createExpr(MCSymbolRefExpr::Create(
|
2010-11-15 05:20:46 +08:00
|
|
|
MO.getMBB()->getSymbol(), AP.OutContext));
|
|
|
|
break;
|
|
|
|
case MachineOperand::MO_GlobalAddress:
|
|
|
|
case MachineOperand::MO_ExternalSymbol:
|
[PowerPC] Always use "assembler dialect" 1
A setting in MCAsmInfo defines the "assembler dialect" to use. This is used
by common code to choose between alternatives in a multi-alternative GNU
inline asm statement like the following:
__asm__ ("{sfe|subfe} %0,%1,%2" : "=r" (out) : "r" (in1), "r" (in2));
The meaning of these dialects is platform specific, and GCC defines those
for PowerPC to use dialect 0 for old-style (POWER) mnemonics and 1 for
new-style (PowerPC) mnemonics, like in the example above.
To be compatible with inline asm used with GCC, LLVM ought to do the same.
Specifically, this means we should always use assembler dialect 1 since
old-style mnemonics really aren't supported on any current platform.
However, the current LLVM back-end uses:
AssemblerDialect = 1; // New-Style mnemonics.
in PPCMCAsmInfoDarwin, and
AssemblerDialect = 0; // Old-Style mnemonics.
in PPCLinuxMCAsmInfo.
The Linux setting really isn't correct, we should be using new-style
mnemonics everywhere. This is changed by this commit.
Unfortunately, the setting of this variable is overloaded in the back-end
to decide whether or not we are on a Darwin target. This is done in
PPCInstPrinter (the "SyntaxVariant" is initialized from the MCAsmInfo
AssemblerDialect setting), and also in PPCMCExpr. Setting AssemblerDialect
to 1 for both Darwin and Linux no longer allows us to make this distinction.
Instead, this patch uses the MCSubtargetInfo passed to createPPCMCInstPrinter
to distinguish Darwin targets, and ignores the SyntaxVariant parameter.
As to PPCMCExpr, this patch adds an explicit isDarwin argument that needs
to be passed in by the caller when creating a target MCExpr. (To do so
this patch implicitly also reverts commit 184441.)
llvm-svn: 185858
2013-07-09 04:20:51 +08:00
|
|
|
MCOp = GetSymbolRef(MO, GetSymbolFromOperand(MO, AP), AP, isDarwin);
|
2010-11-15 05:20:46 +08:00
|
|
|
break;
|
|
|
|
case MachineOperand::MO_JumpTableIndex:
|
[PowerPC] Always use "assembler dialect" 1
A setting in MCAsmInfo defines the "assembler dialect" to use. This is used
by common code to choose between alternatives in a multi-alternative GNU
inline asm statement like the following:
__asm__ ("{sfe|subfe} %0,%1,%2" : "=r" (out) : "r" (in1), "r" (in2));
The meaning of these dialects is platform specific, and GCC defines those
for PowerPC to use dialect 0 for old-style (POWER) mnemonics and 1 for
new-style (PowerPC) mnemonics, like in the example above.
To be compatible with inline asm used with GCC, LLVM ought to do the same.
Specifically, this means we should always use assembler dialect 1 since
old-style mnemonics really aren't supported on any current platform.
However, the current LLVM back-end uses:
AssemblerDialect = 1; // New-Style mnemonics.
in PPCMCAsmInfoDarwin, and
AssemblerDialect = 0; // Old-Style mnemonics.
in PPCLinuxMCAsmInfo.
The Linux setting really isn't correct, we should be using new-style
mnemonics everywhere. This is changed by this commit.
Unfortunately, the setting of this variable is overloaded in the back-end
to decide whether or not we are on a Darwin target. This is done in
PPCInstPrinter (the "SyntaxVariant" is initialized from the MCAsmInfo
AssemblerDialect setting), and also in PPCMCExpr. Setting AssemblerDialect
to 1 for both Darwin and Linux no longer allows us to make this distinction.
Instead, this patch uses the MCSubtargetInfo passed to createPPCMCInstPrinter
to distinguish Darwin targets, and ignores the SyntaxVariant parameter.
As to PPCMCExpr, this patch adds an explicit isDarwin argument that needs
to be passed in by the caller when creating a target MCExpr. (To do so
this patch implicitly also reverts commit 184441.)
llvm-svn: 185858
2013-07-09 04:20:51 +08:00
|
|
|
MCOp = GetSymbolRef(MO, AP.GetJTISymbol(MO.getIndex()), AP, isDarwin);
|
2010-11-15 05:20:46 +08:00
|
|
|
break;
|
|
|
|
case MachineOperand::MO_ConstantPoolIndex:
|
[PowerPC] Always use "assembler dialect" 1
A setting in MCAsmInfo defines the "assembler dialect" to use. This is used
by common code to choose between alternatives in a multi-alternative GNU
inline asm statement like the following:
__asm__ ("{sfe|subfe} %0,%1,%2" : "=r" (out) : "r" (in1), "r" (in2));
The meaning of these dialects is platform specific, and GCC defines those
for PowerPC to use dialect 0 for old-style (POWER) mnemonics and 1 for
new-style (PowerPC) mnemonics, like in the example above.
To be compatible with inline asm used with GCC, LLVM ought to do the same.
Specifically, this means we should always use assembler dialect 1 since
old-style mnemonics really aren't supported on any current platform.
However, the current LLVM back-end uses:
AssemblerDialect = 1; // New-Style mnemonics.
in PPCMCAsmInfoDarwin, and
AssemblerDialect = 0; // Old-Style mnemonics.
in PPCLinuxMCAsmInfo.
The Linux setting really isn't correct, we should be using new-style
mnemonics everywhere. This is changed by this commit.
Unfortunately, the setting of this variable is overloaded in the back-end
to decide whether or not we are on a Darwin target. This is done in
PPCInstPrinter (the "SyntaxVariant" is initialized from the MCAsmInfo
AssemblerDialect setting), and also in PPCMCExpr. Setting AssemblerDialect
to 1 for both Darwin and Linux no longer allows us to make this distinction.
Instead, this patch uses the MCSubtargetInfo passed to createPPCMCInstPrinter
to distinguish Darwin targets, and ignores the SyntaxVariant parameter.
As to PPCMCExpr, this patch adds an explicit isDarwin argument that needs
to be passed in by the caller when creating a target MCExpr. (To do so
this patch implicitly also reverts commit 184441.)
llvm-svn: 185858
2013-07-09 04:20:51 +08:00
|
|
|
MCOp = GetSymbolRef(MO, AP.GetCPISymbol(MO.getIndex()), AP, isDarwin);
|
2010-11-15 05:20:46 +08:00
|
|
|
break;
|
|
|
|
case MachineOperand::MO_BlockAddress:
|
[PowerPC] Always use "assembler dialect" 1
A setting in MCAsmInfo defines the "assembler dialect" to use. This is used
by common code to choose between alternatives in a multi-alternative GNU
inline asm statement like the following:
__asm__ ("{sfe|subfe} %0,%1,%2" : "=r" (out) : "r" (in1), "r" (in2));
The meaning of these dialects is platform specific, and GCC defines those
for PowerPC to use dialect 0 for old-style (POWER) mnemonics and 1 for
new-style (PowerPC) mnemonics, like in the example above.
To be compatible with inline asm used with GCC, LLVM ought to do the same.
Specifically, this means we should always use assembler dialect 1 since
old-style mnemonics really aren't supported on any current platform.
However, the current LLVM back-end uses:
AssemblerDialect = 1; // New-Style mnemonics.
in PPCMCAsmInfoDarwin, and
AssemblerDialect = 0; // Old-Style mnemonics.
in PPCLinuxMCAsmInfo.
The Linux setting really isn't correct, we should be using new-style
mnemonics everywhere. This is changed by this commit.
Unfortunately, the setting of this variable is overloaded in the back-end
to decide whether or not we are on a Darwin target. This is done in
PPCInstPrinter (the "SyntaxVariant" is initialized from the MCAsmInfo
AssemblerDialect setting), and also in PPCMCExpr. Setting AssemblerDialect
to 1 for both Darwin and Linux no longer allows us to make this distinction.
Instead, this patch uses the MCSubtargetInfo passed to createPPCMCInstPrinter
to distinguish Darwin targets, and ignores the SyntaxVariant parameter.
As to PPCMCExpr, this patch adds an explicit isDarwin argument that needs
to be passed in by the caller when creating a target MCExpr. (To do so
this patch implicitly also reverts commit 184441.)
llvm-svn: 185858
2013-07-09 04:20:51 +08:00
|
|
|
MCOp = GetSymbolRef(MO,AP.GetBlockAddressSymbol(MO.getBlockAddress()),AP,
|
|
|
|
isDarwin);
|
2010-11-15 05:20:46 +08:00
|
|
|
break;
|
2012-01-19 07:52:19 +08:00
|
|
|
case MachineOperand::MO_RegisterMask:
|
|
|
|
continue;
|
2010-11-15 03:53:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
OutMI.addOperand(MCOp);
|
|
|
|
}
|
|
|
|
}
|