MipsMCInstLower.cpp revision ce1a538ab5b7ae7e0ed48d18c02571280fe105aa
117a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka//===-- MipsMCInstLower.cpp - Convert Mips MachineInstr to MCInst ---------===//
217a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka//
317a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka//                     The LLVM Compiler Infrastructure
417a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka//
517a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka// This file is distributed under the University of Illinois Open Source
617a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka// License. See LICENSE.TXT for details.
717a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka//
817a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka//===----------------------------------------------------------------------===//
917a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka//
1017a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka// This file contains code to lower Mips MachineInstrs to their corresponding
1117a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka// MCInst records.
1217a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka//
1317a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka//===----------------------------------------------------------------------===//
1417a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
1517a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka#include "MipsAsmPrinter.h"
1617a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka#include "MipsInstrInfo.h"
17ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes#include "MipsMCInstLower.h"
1817a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka#include "llvm/CodeGen/MachineFunction.h"
1917a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka#include "llvm/CodeGen/MachineInstr.h"
2017a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka#include "llvm/CodeGen/MachineOperand.h"
2117a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka#include "llvm/MC/MCContext.h"
22ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes#include "llvm/MC/MCExpr.h"
2317a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka#include "llvm/MC/MCInst.h"
2417a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka#include "llvm/Target/Mangler.h"
2517a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanakausing namespace llvm;
2617a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
2717a2f8e551dd4a772d389d1a193235ae56f8a399Akira HatanakaMipsMCInstLower::MipsMCInstLower(Mangler *mang, const MachineFunction &mf,
2817a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka                                 MipsAsmPrinter &asmprinter)
2917a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka  : Ctx(mf.getContext()), Mang(mang), AsmPrinter(asmprinter) {}
3017a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
3117a2f8e551dd4a772d389d1a193235ae56f8a399Akira HatanakaMCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO,
3278d1b11aa57e5a2683e4be3baaaa9576ac04eea2Akira Hatanaka                                              MachineOperandType MOTy,
3378d1b11aa57e5a2683e4be3baaaa9576ac04eea2Akira Hatanaka                                              unsigned Offset) const {
34ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  MCSymbolRefExpr::VariantKind Kind;
3517a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka  const MCSymbol *Symbol;
3617a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
3717a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka  switch(MO.getTargetFlags()) {
3801843361953463519db42e8098dc8b31b45407c8Akira Hatanaka  default:                  assert(0 && "Invalid target flag!");
39ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_NO_FLAG:  Kind = MCSymbolRefExpr::VK_None; break;
40ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_GPREL:    Kind = MCSymbolRefExpr::VK_Mips_GPREL; break;
41ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_GOT_CALL: Kind = MCSymbolRefExpr::VK_Mips_GOT_CALL; break;
42ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_GOT:      Kind = MCSymbolRefExpr::VK_Mips_GOT; break;
43ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_ABS_HI:   Kind = MCSymbolRefExpr::VK_Mips_ABS_HI; break;
44ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_ABS_LO:   Kind = MCSymbolRefExpr::VK_Mips_ABS_LO; break;
45ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_TLSGD:    Kind = MCSymbolRefExpr::VK_Mips_TLSGD; break;
46ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_GOTTPREL: Kind = MCSymbolRefExpr::VK_Mips_GOTTPREL; break;
47ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_TPREL_HI: Kind = MCSymbolRefExpr::VK_Mips_TPREL_HI; break;
48ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_TPREL_LO: Kind = MCSymbolRefExpr::VK_Mips_TPREL_LO; break;
49ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_GPOFF_HI: Kind = MCSymbolRefExpr::VK_Mips_GPOFF_HI; break;
50ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_GPOFF_LO: Kind = MCSymbolRefExpr::VK_Mips_GPOFF_LO; break;
51ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_GOT_DISP: Kind = MCSymbolRefExpr::VK_Mips_GOT_DISP; break;
52ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_GOT_PAGE: Kind = MCSymbolRefExpr::VK_Mips_GOT_PAGE; break;
53ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  case MipsII::MO_GOT_OFST: Kind = MCSymbolRefExpr::VK_Mips_GOT_OFST; break;
5417a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka  }
5517a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
5617a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka  switch (MOTy) {
5717a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka    case MachineOperand::MO_MachineBasicBlock:
5817a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka      Symbol = MO.getMBB()->getSymbol();
5917a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka      break;
6017a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
6117a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka    case MachineOperand::MO_GlobalAddress:
6217a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka      Symbol = Mang->getSymbol(MO.getGlobal());
6317a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka      break;
6417a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
6517a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka    case MachineOperand::MO_BlockAddress:
6617a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka      Symbol = AsmPrinter.GetBlockAddressSymbol(MO.getBlockAddress());
6717a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka      break;
6817a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
6917a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka    case MachineOperand::MO_ExternalSymbol:
7017a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka      Symbol = AsmPrinter.GetExternalSymbolSymbol(MO.getSymbolName());
7117a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka      break;
7217a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
7317a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka    case MachineOperand::MO_JumpTableIndex:
7417a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka      Symbol = AsmPrinter.GetJTISymbol(MO.getIndex());
7517a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka      break;
7617a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
7717a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka    case MachineOperand::MO_ConstantPoolIndex:
7817a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka      Symbol = AsmPrinter.GetCPISymbol(MO.getIndex());
7917a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka      if (MO.getOffset())
8078d1b11aa57e5a2683e4be3baaaa9576ac04eea2Akira Hatanaka        Offset += MO.getOffset();
8117a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka      break;
8217a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
8317a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka    default:
8417a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka      llvm_unreachable("<unknown operand type>");
8517a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka  }
8617a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
87ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  const MCSymbolRefExpr *MCSym = MCSymbolRefExpr::Create(Symbol, Kind, Ctx);
88ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes
89ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  if (!Offset)
90ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes    return MCOperand::CreateExpr(MCSym);
91ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes
92ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  // Assume offset is never negative.
93ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  assert(Offset > 0);
94ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes
95ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  const MCConstantExpr *OffsetExpr =  MCConstantExpr::Create(Offset, Ctx);
96ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  const MCBinaryExpr *AddExpr = MCBinaryExpr::CreateAdd(MCSym, OffsetExpr, Ctx);
97ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  return MCOperand::CreateExpr(AddExpr);
98ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes}
99ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes
100ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes// Lower ".cpload $reg" to
101ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes//  "lui   $gp, %hi(_gp_disp)"
102ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes//  "addiu $gp, $gp, %lo(_gp_disp)"
103ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes//  "addu  $gp. $gp, $reg"
104ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopesvoid MipsMCInstLower::LowerCPLOAD(const MachineInstr *MI,
105ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes                                  SmallVector<MCInst, 4>& MCInsts) {
106ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  MCInst Lui, Addiu, Addu;
107ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  StringRef SymName("_gp_disp");
108ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  const MCSymbol *Symbol = Ctx.GetOrCreateSymbol(SymName);
109ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  const MCSymbolRefExpr *MCSym;
110ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes
111ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  // lui   $gp, %hi(_gp_disp)
112ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  Lui.setOpcode(Mips::LUi);
113ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  Lui.addOperand(MCOperand::CreateReg(Mips::GP));
114ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  MCSym = MCSymbolRefExpr::Create(Symbol, MCSymbolRefExpr::VK_Mips_ABS_HI, Ctx);
115ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  Lui.addOperand(MCOperand::CreateExpr(MCSym));
116ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  MCInsts.push_back(Lui);
117ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes
118ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  // addiu $gp, $gp, %lo(_gp_disp)
119ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  Addiu.setOpcode(Mips::ADDiu);
120ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  Addiu.addOperand(MCOperand::CreateReg(Mips::GP));
121ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  Addiu.addOperand(MCOperand::CreateReg(Mips::GP));
122ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  MCSym = MCSymbolRefExpr::Create(Symbol, MCSymbolRefExpr::VK_Mips_ABS_LO, Ctx);
123ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  Addiu.addOperand(MCOperand::CreateExpr(MCSym));
124ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  MCInsts.push_back(Addiu);
125ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes
126ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  // addu  $gp. $gp, $reg
127ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  Addu.setOpcode(Mips::ADDu);
128ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  Addu.addOperand(MCOperand::CreateReg(Mips::GP));
129ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  Addu.addOperand(MCOperand::CreateReg(Mips::GP));
130ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  const MachineOperand &MO = MI->getOperand(0);
131ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  assert(MO.isReg() && "CPLOAD's operand must be a register.");
132ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  Addu.addOperand(MCOperand::CreateReg(MO.getReg()));
133ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  MCInsts.push_back(Addu);
13417a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka}
13517a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
136ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes// Lower ".cprestore offset" to "sw $gp, offset($sp)".
137ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopesvoid MipsMCInstLower::LowerCPRESTORE(const MachineInstr *MI, MCInst &OutMI) {
138ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  OutMI.clear();
139ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  OutMI.setOpcode(Mips::SW);
140ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  OutMI.addOperand(MCOperand::CreateReg(Mips::GP));
141ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  OutMI.addOperand(MCOperand::CreateReg(Mips::SP));
142ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  const MachineOperand &MO = MI->getOperand(0);
143ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  assert(MO.isImm() && "CPRESTORE's operand must be an immediate.");
144ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes  OutMI.addOperand(MCOperand::CreateImm(MO.getImm()));
145ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes}
146ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes
147ce1a538ab5b7ae7e0ed48d18c02571280fe105aaBruno Cardoso Lopes
1488957481e6a3a4217499f739bae24401576ade078Akira HatanakaMCOperand MipsMCInstLower::LowerOperand(const MachineOperand& MO) const {
1498957481e6a3a4217499f739bae24401576ade078Akira Hatanaka  MachineOperandType MOTy = MO.getType();
1508957481e6a3a4217499f739bae24401576ade078Akira Hatanaka
1518957481e6a3a4217499f739bae24401576ade078Akira Hatanaka  switch (MOTy) {
1528957481e6a3a4217499f739bae24401576ade078Akira Hatanaka  default:
1538957481e6a3a4217499f739bae24401576ade078Akira Hatanaka    assert(0 && "unknown operand type");
1548957481e6a3a4217499f739bae24401576ade078Akira Hatanaka    break;
1558957481e6a3a4217499f739bae24401576ade078Akira Hatanaka  case MachineOperand::MO_Register:
1568957481e6a3a4217499f739bae24401576ade078Akira Hatanaka    // Ignore all implicit register operands.
1578957481e6a3a4217499f739bae24401576ade078Akira Hatanaka    if (MO.isImplicit()) break;
1588957481e6a3a4217499f739bae24401576ade078Akira Hatanaka    return MCOperand::CreateReg(MO.getReg());
1598957481e6a3a4217499f739bae24401576ade078Akira Hatanaka  case MachineOperand::MO_Immediate:
1608957481e6a3a4217499f739bae24401576ade078Akira Hatanaka    return MCOperand::CreateImm(MO.getImm());
1618957481e6a3a4217499f739bae24401576ade078Akira Hatanaka  case MachineOperand::MO_MachineBasicBlock:
1628957481e6a3a4217499f739bae24401576ade078Akira Hatanaka  case MachineOperand::MO_GlobalAddress:
1638957481e6a3a4217499f739bae24401576ade078Akira Hatanaka  case MachineOperand::MO_ExternalSymbol:
1648957481e6a3a4217499f739bae24401576ade078Akira Hatanaka  case MachineOperand::MO_JumpTableIndex:
1658957481e6a3a4217499f739bae24401576ade078Akira Hatanaka  case MachineOperand::MO_ConstantPoolIndex:
1668957481e6a3a4217499f739bae24401576ade078Akira Hatanaka  case MachineOperand::MO_BlockAddress:
1678957481e6a3a4217499f739bae24401576ade078Akira Hatanaka    return LowerSymbolOperand(MO, MOTy, 0);
1688957481e6a3a4217499f739bae24401576ade078Akira Hatanaka }
1698957481e6a3a4217499f739bae24401576ade078Akira Hatanaka
1708957481e6a3a4217499f739bae24401576ade078Akira Hatanaka  return MCOperand();
1718957481e6a3a4217499f739bae24401576ade078Akira Hatanaka}
1728957481e6a3a4217499f739bae24401576ade078Akira Hatanaka
17317a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanakavoid MipsMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
17417a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka  OutMI.setOpcode(MI->getOpcode());
17517a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
17617a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka  for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
17717a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka    const MachineOperand &MO = MI->getOperand(i);
1788957481e6a3a4217499f739bae24401576ade078Akira Hatanaka    MCOperand MCOp = LowerOperand(MO);
17917a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka
1808957481e6a3a4217499f739bae24401576ade078Akira Hatanaka    if (MCOp.isValid())
1818957481e6a3a4217499f739bae24401576ade078Akira Hatanaka      OutMI.addOperand(MCOp);
18217a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka  }
18317a2f8e551dd4a772d389d1a193235ae56f8a399Akira Hatanaka}
184