mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
switch PPC to a simplified MCInstLowering model.
llvm-svn: 119074
This commit is contained in:
parent
59a93284d7
commit
32848508af
@ -24,12 +24,18 @@ namespace llvm {
|
||||
class formatted_raw_ostream;
|
||||
class JITCodeEmitter;
|
||||
class Target;
|
||||
class MachineInstr;
|
||||
class MCInst;
|
||||
class AsmPrinter;
|
||||
|
||||
FunctionPass *createPPCBranchSelectionPass();
|
||||
FunctionPass *createPPCISelDag(PPCTargetMachine &TM);
|
||||
FunctionPass *createPPCJITCodeEmitterPass(PPCTargetMachine &TM,
|
||||
JITCodeEmitter &MCE);
|
||||
|
||||
void LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI,
|
||||
AsmPrinter &AP);
|
||||
|
||||
extern Target ThePPC32Target;
|
||||
extern Target ThePPC64Target;
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "PPC.h"
|
||||
#include "PPCPredicates.h"
|
||||
#include "PPCTargetMachine.h"
|
||||
#include "PPCMCInstLower.h"
|
||||
#include "PPCSubtarget.h"
|
||||
#include "llvm/Analysis/DebugInfo.h"
|
||||
#include "llvm/Constants.h"
|
||||
@ -59,7 +58,9 @@ using namespace llvm;
|
||||
// This option tells the asmprinter to use the new (experimental) MCInstPrinter
|
||||
// path.
|
||||
static cl::opt<bool> UseInstPrinter("enable-ppc-inst-printer",
|
||||
cl::ReallyHidden);
|
||||
cl::ReallyHidden
|
||||
//, cl::init(true)
|
||||
);
|
||||
|
||||
namespace {
|
||||
class PPCAsmPrinter : public AsmPrinter {
|
||||
@ -553,8 +554,6 @@ void PPCAsmPrinter::printPredicateOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
///
|
||||
void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
||||
if (UseInstPrinter) {
|
||||
PPCMCInstLower MCInstLowering(OutContext, *Mang, *this);
|
||||
|
||||
// Lower multi-instruction pseudo operations.
|
||||
switch (MI->getOpcode()) {
|
||||
default: break;
|
||||
@ -562,7 +561,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
||||
}
|
||||
|
||||
MCInst TmpInst;
|
||||
MCInstLowering.Lower(MI, TmpInst);
|
||||
LowerPPCMachineInstrToMCInst(MI, TmpInst, *this);
|
||||
OutStreamer.EmitInstruction(TmpInst);
|
||||
return;
|
||||
}
|
||||
|
@ -12,15 +12,15 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "PPCMCInstLower.h"
|
||||
#include "PPC.h"
|
||||
#include "llvm/CodeGen/AsmPrinter.h"
|
||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
void PPCMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
|
||||
void llvm::LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI,
|
||||
AsmPrinter &Printer) {
|
||||
OutMI.setOpcode(MI->getOpcode());
|
||||
|
||||
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
||||
@ -38,36 +38,6 @@ void PPCMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
|
||||
case MachineOperand::MO_Immediate:
|
||||
MCOp = MCOperand::CreateImm(MO.getImm());
|
||||
break;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
|
||||
MO.getMBB()->getSymbol(), Ctx));
|
||||
break;
|
||||
#if 0
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
MCOp = LowerSymbolRefOperand(MO, GetSymbolRef(MO));
|
||||
break;
|
||||
case MachineOperand::MO_ExternalSymbol:
|
||||
MCOp = LowerSymbolRefOperand(MO, GetExternalSymbolSymbol(MO));
|
||||
break;
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
MCOp = LowerSymbolOperand(MO, GetJumpTableSymbol(MO));
|
||||
break;
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
MCOp = LowerSymbolOperand(MO, GetConstantPoolIndexSymbol(MO));
|
||||
break;
|
||||
case MachineOperand::MO_BlockAddress:
|
||||
MCOp = LowerSymbolOperand(MO, Printer.GetBlockAddressSymbol(
|
||||
MO.getBlockAddress()));
|
||||
break;
|
||||
#endif
|
||||
#if 0
|
||||
case MachineOperand::MO_FPImmediate:
|
||||
APFloat Val = MO.getFPImm()->getValueAPF();
|
||||
bool ignored;
|
||||
Val.convert(APFloat::IEEEdouble, APFloat::rmTowardZero, &ignored);
|
||||
MCOp = MCOperand::CreateFPImm(Val.convertToDouble());
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
OutMI.addOperand(MCOp);
|
||||
|
@ -1,54 +0,0 @@
|
||||
//===-- PPCMCInstLower.h - Lower MachineInstr to MCInst -------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef PPC_MCINSTLOWER_H
|
||||
#define PPC_MCINSTLOWER_H
|
||||
|
||||
#include "llvm/Support/Compiler.h"
|
||||
|
||||
namespace llvm {
|
||||
class AsmPrinter;
|
||||
class GlobalValue;
|
||||
class MCAsmInfo;
|
||||
class MCContext;
|
||||
class MCInst;
|
||||
class MCOperand;
|
||||
class MCSymbol;
|
||||
class MCSymbolRefExpr;
|
||||
class MachineInstr;
|
||||
class MachineModuleInfoMachO;
|
||||
class MachineOperand;
|
||||
class Mangler;
|
||||
|
||||
/// PPCMCInstLower - This class is used to lower an MachineInstr into an MCInst.
|
||||
class LLVM_LIBRARY_VISIBILITY PPCMCInstLower {
|
||||
MCContext &Ctx;
|
||||
Mangler &Mang;
|
||||
AsmPrinter &Printer;
|
||||
public:
|
||||
PPCMCInstLower(MCContext &ctx, Mangler &mang, AsmPrinter &printer)
|
||||
: Ctx(ctx), Mang(mang), Printer(printer) {}
|
||||
|
||||
void Lower(const MachineInstr *MI, MCInst &OutMI) const;
|
||||
|
||||
private:
|
||||
MCSymbol *GetGlobalAddressSymbol(const GlobalValue *GV) const;
|
||||
const MCSymbolRefExpr *GetSymbolRef(const MachineOperand &MO) const;
|
||||
const MCSymbolRefExpr *GetExternalSymbolSymbol(const MachineOperand &MO)
|
||||
const;
|
||||
MCSymbol *GetJumpTableSymbol(const MachineOperand &MO) const;
|
||||
MCSymbol *GetConstantPoolIndexSymbol(const MachineOperand &MO) const;
|
||||
MCOperand LowerSymbolRefOperand(const MachineOperand &MO,
|
||||
const MCSymbolRefExpr *Expr) const;
|
||||
MCOperand LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const;
|
||||
|
||||
};
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user