switch PPC to a simplified MCInstLowering model.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119074 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-11-14 21:12:33 +00:00
parent 55d02f3a13
commit a7217c824d
4 changed files with 13 additions and 92 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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