OSDN Git Service

stub out PPCMCInstLowering, add a new option that uses it and the new
[android-x86/external-llvm.git] / lib / Target / PowerPC / PPCMCInstLower.cpp
1 //===-- PPCMCInstLower.cpp - Convert PPC MachineInstr to an MCInst --------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains code to lower PPC MachineInstrs to their corresponding
11 // MCInst records.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "PPCMCInstLower.h"
16 #include "llvm/CodeGen/AsmPrinter.h"
17 #include "llvm/CodeGen/MachineBasicBlock.h"
18 #include "llvm/MC/MCExpr.h"
19 #include "llvm/MC/MCInst.h"
20
21 using namespace llvm;
22
23 void PPCMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
24   OutMI.setOpcode(MI->getOpcode());
25   
26   for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
27     const MachineOperand &MO = MI->getOperand(i);
28     
29     MCOperand MCOp;
30     switch (MO.getType()) {
31     default:
32       MI->dump();
33       assert(0 && "unknown operand type");
34     case MachineOperand::MO_Register:
35       assert(!MO.getSubReg() && "Subregs should be eliminated!");
36       MCOp = MCOperand::CreateReg(MO.getReg());
37       break;
38     case MachineOperand::MO_Immediate:
39       MCOp = MCOperand::CreateImm(MO.getImm());
40       break;
41     case MachineOperand::MO_MachineBasicBlock:
42       MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
43                                               MO.getMBB()->getSymbol(), Ctx));
44       break;
45 #if 0
46     case MachineOperand::MO_GlobalAddress:
47       MCOp = LowerSymbolRefOperand(MO, GetSymbolRef(MO));
48       break;
49     case MachineOperand::MO_ExternalSymbol:
50       MCOp = LowerSymbolRefOperand(MO, GetExternalSymbolSymbol(MO));
51       break;
52     case MachineOperand::MO_JumpTableIndex:
53       MCOp = LowerSymbolOperand(MO, GetJumpTableSymbol(MO));
54       break;
55     case MachineOperand::MO_ConstantPoolIndex:
56       MCOp = LowerSymbolOperand(MO, GetConstantPoolIndexSymbol(MO));
57       break;
58     case MachineOperand::MO_BlockAddress:
59       MCOp = LowerSymbolOperand(MO, Printer.GetBlockAddressSymbol(
60                                                        MO.getBlockAddress()));
61       break;
62 #endif
63 #if 0
64     case MachineOperand::MO_FPImmediate:
65       APFloat Val = MO.getFPImm()->getValueAPF();
66       bool ignored;
67       Val.convert(APFloat::IEEEdouble, APFloat::rmTowardZero, &ignored);
68       MCOp = MCOperand::CreateFPImm(Val.convertToDouble());
69       break;
70 #endif
71     }
72     
73     OutMI.addOperand(MCOp);
74   }
75 }