mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-22 13:29:44 +00:00
even more simplifications. ARM MCInstLowering is now just
a single function instead of a class. It doesn't need the complexity that X86 does. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119070 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
01928b9a40
commit
1612a619f1
@ -28,6 +28,9 @@ class JITCodeEmitter;
|
|||||||
class formatted_raw_ostream;
|
class formatted_raw_ostream;
|
||||||
class MCCodeEmitter;
|
class MCCodeEmitter;
|
||||||
class TargetAsmBackend;
|
class TargetAsmBackend;
|
||||||
|
class MachineInstr;
|
||||||
|
class AsmPrinter;
|
||||||
|
class MCInst;
|
||||||
|
|
||||||
MCCodeEmitter *createARMMCCodeEmitter(const Target &,
|
MCCodeEmitter *createARMMCCodeEmitter(const Target &,
|
||||||
TargetMachine &TM,
|
TargetMachine &TM,
|
||||||
@ -51,6 +54,8 @@ FunctionPass *createThumb2SizeReductionPass();
|
|||||||
|
|
||||||
extern Target TheARMTarget, TheThumbTarget;
|
extern Target TheARMTarget, TheThumbTarget;
|
||||||
|
|
||||||
|
void LowerToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP);
|
||||||
|
|
||||||
} // end namespace llvm;
|
} // end namespace llvm;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include "ARMConstantPoolValue.h"
|
#include "ARMConstantPoolValue.h"
|
||||||
#include "InstPrinter/ARMInstPrinter.h"
|
#include "InstPrinter/ARMInstPrinter.h"
|
||||||
#include "ARMMachineFunctionInfo.h"
|
#include "ARMMachineFunctionInfo.h"
|
||||||
#include "ARMMCInstLower.h"
|
|
||||||
#include "ARMTargetMachine.h"
|
#include "ARMTargetMachine.h"
|
||||||
#include "ARMTargetObjectFile.h"
|
#include "ARMTargetObjectFile.h"
|
||||||
#include "llvm/Analysis/DebugInfo.h"
|
#include "llvm/Analysis/DebugInfo.h"
|
||||||
@ -800,7 +799,6 @@ void ARMAsmPrinter::PrintDebugValueComment(const MachineInstr *MI,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
||||||
ARMMCInstLower MCInstLowering(OutContext, *Mang, *this);
|
|
||||||
switch (MI->getOpcode()) {
|
switch (MI->getOpcode()) {
|
||||||
default: break;
|
default: break;
|
||||||
case ARM::t2MOVi32imm: assert(0 && "Should be lowered by thumb2it pass");
|
case ARM::t2MOVi32imm: assert(0 && "Should be lowered by thumb2it pass");
|
||||||
@ -931,7 +929,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
|||||||
case ARM::t2BR_JT: {
|
case ARM::t2BR_JT: {
|
||||||
// Lower and emit the instruction itself, then the jump table following it.
|
// Lower and emit the instruction itself, then the jump table following it.
|
||||||
MCInst TmpInst;
|
MCInst TmpInst;
|
||||||
MCInstLowering.Lower(MI, TmpInst);
|
LowerToMCInst(MI, TmpInst, *this);
|
||||||
OutStreamer.EmitInstruction(TmpInst);
|
OutStreamer.EmitInstruction(TmpInst);
|
||||||
EmitJump2Table(MI);
|
EmitJump2Table(MI);
|
||||||
return;
|
return;
|
||||||
@ -942,7 +940,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
|||||||
case ARM::BR_JTadd: {
|
case ARM::BR_JTadd: {
|
||||||
// Lower and emit the instruction itself, then the jump table following it.
|
// Lower and emit the instruction itself, then the jump table following it.
|
||||||
MCInst TmpInst;
|
MCInst TmpInst;
|
||||||
MCInstLowering.Lower(MI, TmpInst);
|
LowerToMCInst(MI, TmpInst, *this);
|
||||||
OutStreamer.EmitInstruction(TmpInst);
|
OutStreamer.EmitInstruction(TmpInst);
|
||||||
EmitJumpTable(MI);
|
EmitJumpTable(MI);
|
||||||
return;
|
return;
|
||||||
@ -1253,7 +1251,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MCInst TmpInst;
|
MCInst TmpInst;
|
||||||
MCInstLowering.Lower(MI, TmpInst);
|
LowerToMCInst(MI, TmpInst, *this);
|
||||||
OutStreamer.EmitInstruction(TmpInst);
|
OutStreamer.EmitInstruction(TmpInst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "ARMMCInstLower.h"
|
|
||||||
#include "ARM.h"
|
#include "ARM.h"
|
||||||
#include "llvm/CodeGen/AsmPrinter.h"
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
@ -26,8 +25,10 @@
|
|||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
MCOperand ARMMCInstLower::
|
|
||||||
GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol) const {
|
static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol,
|
||||||
|
AsmPrinter &Printer) {
|
||||||
|
MCContext &Ctx = Printer.OutContext;
|
||||||
const MCExpr *Expr;
|
const MCExpr *Expr;
|
||||||
switch (MO.getTargetFlags()) {
|
switch (MO.getTargetFlags()) {
|
||||||
default: assert(0 && "Unknown target flag on symbol operand");
|
default: assert(0 && "Unknown target flag on symbol operand");
|
||||||
@ -53,7 +54,7 @@ GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol) const {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARMMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
|
void llvm::LowerToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP){
|
||||||
OutMI.setOpcode(MI->getOpcode());
|
OutMI.setOpcode(MI->getOpcode());
|
||||||
|
|
||||||
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
||||||
@ -75,24 +76,23 @@ void ARMMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
|
|||||||
break;
|
break;
|
||||||
case MachineOperand::MO_MachineBasicBlock:
|
case MachineOperand::MO_MachineBasicBlock:
|
||||||
MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
|
MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
|
||||||
MO.getMBB()->getSymbol(), Ctx));
|
MO.getMBB()->getSymbol(), AP.OutContext));
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress:
|
||||||
MCOp = GetSymbolRef(MO, Printer.Mang->getSymbol(MO.getGlobal()));
|
MCOp = GetSymbolRef(MO, AP.Mang->getSymbol(MO.getGlobal()), AP);
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_ExternalSymbol:
|
case MachineOperand::MO_ExternalSymbol:
|
||||||
MCOp = GetSymbolRef(MO,
|
MCOp = GetSymbolRef(MO,
|
||||||
Printer.GetExternalSymbolSymbol(MO.getSymbolName()));
|
AP.GetExternalSymbolSymbol(MO.getSymbolName()), AP);
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_JumpTableIndex:
|
case MachineOperand::MO_JumpTableIndex:
|
||||||
MCOp = GetSymbolRef(MO, Printer.GetJTISymbol(MO.getIndex()));
|
MCOp = GetSymbolRef(MO, AP.GetJTISymbol(MO.getIndex()), AP);
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_ConstantPoolIndex:
|
case MachineOperand::MO_ConstantPoolIndex:
|
||||||
MCOp = GetSymbolRef(MO, Printer.GetCPISymbol(MO.getIndex()));
|
MCOp = GetSymbolRef(MO, AP.GetCPISymbol(MO.getIndex()), AP);
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_BlockAddress:
|
case MachineOperand::MO_BlockAddress:
|
||||||
MCOp = GetSymbolRef(MO,
|
MCOp = GetSymbolRef(MO,AP.GetBlockAddressSymbol(MO.getBlockAddress()),AP);
|
||||||
Printer.GetBlockAddressSymbol(MO.getBlockAddress()));
|
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_FPImmediate:
|
case MachineOperand::MO_FPImmediate:
|
||||||
APFloat Val = MO.getFPImm()->getValueAPF();
|
APFloat Val = MO.getFPImm()->getValueAPF();
|
||||||
@ -104,5 +104,4 @@ void ARMMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
|
|||||||
|
|
||||||
OutMI.addOperand(MCOp);
|
OutMI.addOperand(MCOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
//===-- ARMMCInstLower.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 ARM_MCINSTLOWER_H
|
|
||||||
#define ARM_MCINSTLOWER_H
|
|
||||||
|
|
||||||
#include "llvm/Support/Compiler.h"
|
|
||||||
|
|
||||||
namespace llvm {
|
|
||||||
class AsmPrinter;
|
|
||||||
class MCAsmInfo;
|
|
||||||
class MCContext;
|
|
||||||
class MCInst;
|
|
||||||
class MCOperand;
|
|
||||||
class MCSymbol;
|
|
||||||
class MachineInstr;
|
|
||||||
class MachineOperand;
|
|
||||||
class Mangler;
|
|
||||||
|
|
||||||
/// ARMMCInstLower - This class is used to lower an MachineInstr into an MCInst.
|
|
||||||
class LLVM_LIBRARY_VISIBILITY ARMMCInstLower {
|
|
||||||
MCContext &Ctx;
|
|
||||||
Mangler &Mang;
|
|
||||||
AsmPrinter &Printer;
|
|
||||||
public:
|
|
||||||
ARMMCInstLower(MCContext &ctx, Mangler &mang, AsmPrinter &printer)
|
|
||||||
: Ctx(ctx), Mang(mang), Printer(printer) {}
|
|
||||||
|
|
||||||
void Lower(const MachineInstr *MI, MCInst &OutMI) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Sym) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace llvm
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
x
Reference in New Issue
Block a user