Index: lib/Target/Mips/MipsMCInstLower.cpp |
diff --git a/lib/Target/Mips/MipsMCInstLower.cpp b/lib/Target/Mips/MipsMCInstLower.cpp |
index d836975eb7d227a972350120aee3e0c5a6926d8a..af3cb07fb5cd6cc8ffdabb122bc97457adeb9bc1 100644 |
--- a/lib/Target/Mips/MipsMCInstLower.cpp |
+++ b/lib/Target/Mips/MipsMCInstLower.cpp |
@@ -152,7 +152,70 @@ MCOperand MipsMCInstLower::LowerOperand(const MachineOperand &MO, |
return MCOperand(); |
} |
+// @LOCALMOD-START |
+void MipsMCInstLower::LowerLongBranchLUi(const MachineInstr *MI, |
+ MCInst &OutMI) const { |
+ OutMI.setOpcode(Mips::LUi); |
+ |
+ // Lower register operand. |
+ MCOperand Reg = LowerOperand(MI->getOperand(0)); |
+ if (Reg.isValid()) |
+ OutMI.addOperand(Reg); |
+ |
+ // Lower branch target. |
+ const MCSymbol *Symbol = MI->getOperand(1).getMBB()->getSymbol(); |
+ const MCSymbolRefExpr *MCSym |
+ = MCSymbolRefExpr::Create(Symbol, |
+ MCSymbolRefExpr::VK_Mips_NACL_LONG_BRANCH_HI16, |
+ *Ctx); |
+ MCOperand Br = MCOperand::CreateExpr(MCSym); |
+ if (Br.isValid()) |
+ OutMI.addOperand(Br); |
+} |
+ |
+void MipsMCInstLower::LowerLongBranchADDiu(const MachineInstr *MI, |
+ MCInst &OutMI) const { |
+ OutMI.setOpcode(Mips::ADDiu); |
+ |
+ // Lower two register operands. |
+ for (unsigned i = 0, e = 2; i != e; ++i) { |
+ const MachineOperand &MO = MI->getOperand(i); |
+ MCOperand Reg = LowerOperand(MO); |
+ |
+ if (Reg.isValid()) |
+ OutMI.addOperand(Reg); |
+ } |
+ |
+ // Lower branch target. |
+ const MCSymbol *Symbol = MI->getOperand(2).getMBB()->getSymbol(); |
+ const MCSymbolRefExpr *MCSym |
+ = MCSymbolRefExpr::Create(Symbol, |
+ MCSymbolRefExpr::VK_Mips_NACL_LONG_BRANCH_LO16, |
+ *Ctx); |
+ MCOperand Br = MCOperand::CreateExpr(MCSym); |
+ if (Br.isValid()) |
+ OutMI.addOperand(Br); |
+} |
+// @LOCALMOD-END |
+ |
void MipsMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const { |
+ // @LOCALMOD-START |
+ if (AsmPrinter.Subtarget->isTargetNaCl()) { |
+ if (MI->getOpcode() == Mips::LUi |
+ && (MI->getOperand(1).getTargetFlags() |
+ == MipsII::MO_NACL_LONG_BRANCH)) { |
+ LowerLongBranchLUi(MI, OutMI); |
+ return; |
+ } |
+ if (MI->getOpcode() == Mips::ADDiu |
+ && (MI->getOperand(2).getTargetFlags() |
+ == MipsII::MO_NACL_LONG_BRANCH)) { |
+ LowerLongBranchADDiu(MI, OutMI); |
+ return; |
+ } |
+ } |
+ // @LOCALMOD-END |
+ |
OutMI.setOpcode(MI->getOpcode()); |
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { |