diff options
Diffstat (limited to 'lib/Target/Mips/MipsMCInstLower.cpp')
-rw-r--r-- | lib/Target/Mips/MipsMCInstLower.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/Target/Mips/MipsMCInstLower.cpp b/lib/Target/Mips/MipsMCInstLower.cpp index 5fa6339338..1d108ab192 100644 --- a/lib/Target/Mips/MipsMCInstLower.cpp +++ b/lib/Target/Mips/MipsMCInstLower.cpp @@ -160,3 +160,48 @@ void MipsMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const { } } + + MCInst Instr4, Mask1, Mask2; // @LOCALMOD + // @LOCALMOD-START + MCOperand MaskReg = MCOperand::CreateReg(Mips::LoadStoreStackMaskReg); + // @LOCALMOD-END + + // @LOCALMOD-START + if (AsmPrinter.TM.getSubtarget<MipsSubtarget>().isTargetNaCl()) { + Mask1.setOpcode(Mips::SFI_GUARD_LOADSTORE); + Mask1.addOperand(Base); + Mask1.addOperand(Base); + Mask1.addOperand(MaskReg); + + Mask2.setOpcode(Mips::SFI_GUARD_LOADSTORE); + Mask2.addOperand(Base); + Mask2.addOperand(Base); + Mask2.addOperand(MaskReg); + if (Opc == Mips::ULW || Opc == Mips::USW || Opc == Mips::ULHu) { + // FIXME: ULHu should be rewritten because it uses mips32r2 instr. INS + MCInsts.push_back(Mask1); + MCInsts.push_back(Instr1); + MCInsts.push_back(Mask2); + MCInsts.push_back(Instr2); + if (!TwoInstructions) MCInsts.push_back(Instr3); + return; + } else if (Opc == Mips::ULH) { + MCInsts.push_back(Mask1); + MCInsts.push_back(Instr1); + MCInsts.push_back(Mask2); + MCInsts.push_back(Instr2); + MCInsts.push_back(Instr3); + MCInsts.push_back(Instr4); + return; + } else if (Opc == Mips::USH) { + MCInsts.push_back(Mask1); + MCInsts.push_back(Instr1); + MCInsts.push_back(Instr2); + MCInsts.push_back(Mask2); + MCInsts.push_back(Instr3); + return; + } else { + llvm_unreachable("unaligned instruction not sandboxed"); + } + } + // @LOCALMOD-END
\ No newline at end of file |