Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Unified Diff: lib/Target/Mips/MipsMCInstLower.cpp

Issue 27690005: [MIPS] Modify LongBranch expansion to work with sandboxing (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« lib/Target/Mips/MipsLongBranch.cpp ('K') | « lib/Target/Mips/MipsMCInstLower.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« lib/Target/Mips/MipsLongBranch.cpp ('K') | « lib/Target/Mips/MipsMCInstLower.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698