mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-19 01:34:32 +00:00
293ef9ae0f
instprinter when -enable-ppc-inst-printer is passed to llc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119061 91177308-0d34-0410-b5e6-96231b3b80d8
76 lines
2.5 KiB
C++
76 lines
2.5 KiB
C++
//===-- 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.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "PPCMCInstLower.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 {
|
|
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();
|
|
assert(0 && "unknown operand type");
|
|
case MachineOperand::MO_Register:
|
|
assert(!MO.getSubReg() && "Subregs should be eliminated!");
|
|
MCOp = MCOperand::CreateReg(MO.getReg());
|
|
break;
|
|
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);
|
|
}
|
|
}
|