blob: b839ac5d5d018acd429d822eeab3eb5c49d9debe [file] [log] [blame]
Anton Korobeynikov1c7ceed2009-10-21 00:11:08 +00001//===-- MSP430MCInstLower.cpp - Convert MSP430 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 MSP430 MachineInstrs to their corresponding
11// MCInst records.
12//
13//===----------------------------------------------------------------------===//
14
15#include "MSP430MCInstLower.h"
16#include "llvm/CodeGen/MachineInstr.h"
17#include "llvm/MC/MCAsmInfo.h"
18#include "llvm/MC/MCContext.h"
19#include "llvm/MC/MCExpr.h"
20#include "llvm/MC/MCInst.h"
21#include "llvm/Support/raw_ostream.h"
22#include "llvm/Support/Mangler.h"
23#include "llvm/ADT/SmallString.h"
24using namespace llvm;
25
26void MSP430MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
27 OutMI.setOpcode(MI->getOpcode());
28
29 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
30 const MachineOperand &MO = MI->getOperand(i);
31
32 MCOperand MCOp;
33 switch (MO.getType()) {
34 default:
35 MI->dump();
36 assert(0 && "unknown operand type");
37 case MachineOperand::MO_Register:
38 MCOp = MCOperand::CreateReg(MO.getReg());
39 break;
40 case MachineOperand::MO_Immediate:
41 MCOp = MCOperand::CreateImm(MO.getImm());
42 break;
43#if 0
44 case MachineOperand::MO_MachineBasicBlock:
45 MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
46 AsmPrinter.GetMBBSymbol(MO.getMBB()->getNumber()), Ctx));
47 break;
48 case MachineOperand::MO_GlobalAddress:
49 MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
50 break;
51 case MachineOperand::MO_ExternalSymbol:
52 MCOp = LowerSymbolOperand(MO, GetExternalSymbolSymbol(MO));
53 break;
54 case MachineOperand::MO_JumpTableIndex:
55 MCOp = LowerSymbolOperand(MO, GetJumpTableSymbol(MO));
56 break;
57 case MachineOperand::MO_ConstantPoolIndex:
58 MCOp = LowerSymbolOperand(MO, GetConstantPoolIndexSymbol(MO));
59 break;
60#endif
61 }
62
63 OutMI.addOperand(MCOp);
64 }
65
66}