#define DEBUG_TYPE "mips-mc-nacl"
#include "Mips.h"
+#include "MipsELFStreamer.h"
#include "MipsMCNaCl.h"
#include "llvm/MC/MCELFStreamer.h"
/// Extend the generic MCELFStreamer class so that it can mask dangerous
/// instructions.
-class MipsNaClELFStreamer : public MCELFStreamer {
+class MipsNaClELFStreamer : public MipsELFStreamer {
public:
MipsNaClELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
- MCCodeEmitter *Emitter)
- : MCELFStreamer(Context, TAB, OS, Emitter), PendingCall(false) {}
+ MCCodeEmitter *Emitter, const MCSubtargetInfo &STI)
+ : MipsELFStreamer(Context, TAB, OS, Emitter, STI), PendingCall(false) {}
~MipsNaClELFStreamer() {}
MaskInst.addOperand(MCOperand::CreateReg(AddrReg));
MaskInst.addOperand(MCOperand::CreateReg(AddrReg));
MaskInst.addOperand(MCOperand::CreateReg(MaskReg));
- MCELFStreamer::EmitInstruction(MaskInst, STI);
+ MipsELFStreamer::EmitInstruction(MaskInst, STI);
}
// Sandbox indirect branch or return instruction by inserting mask operation
EmitBundleLock(false);
emitMask(AddrReg, IndirectBranchMaskReg, STI);
- MCELFStreamer::EmitInstruction(MI, STI);
+ MipsELFStreamer::EmitInstruction(MI, STI);
EmitBundleUnlock();
}
unsigned BaseReg = MI.getOperand(AddrIdx).getReg();
emitMask(BaseReg, LoadStoreStackMaskReg, STI);
}
- MCELFStreamer::EmitInstruction(MI, STI);
+ MipsELFStreamer::EmitInstruction(MI, STI);
if (MaskAfter) {
// Sandbox SP change.
unsigned SPReg = MI.getOperand(0).getReg();
if (MaskBefore || MaskAfter)
sandboxLoadStoreStackChange(Inst, AddrIdx, STI, MaskBefore, MaskAfter);
else
- MCELFStreamer::EmitInstruction(Inst, STI);
+ MipsELFStreamer::EmitInstruction(Inst, STI);
return;
}
unsigned TargetReg = Inst.getOperand(1).getReg();
emitMask(TargetReg, IndirectBranchMaskReg, STI);
}
- MCELFStreamer::EmitInstruction(Inst, STI);
+ MipsELFStreamer::EmitInstruction(Inst, STI);
PendingCall = true;
return;
}
if (PendingCall) {
// Finish the sandboxing sequence by emitting branch delay.
- MCELFStreamer::EmitInstruction(Inst, STI);
+ MipsELFStreamer::EmitInstruction(Inst, STI);
EmitBundleUnlock();
PendingCall = false;
return;
}
// None of the sandboxing applies, just emit the instruction.
- MCELFStreamer::EmitInstruction(Inst, STI);
+ MipsELFStreamer::EmitInstruction(Inst, STI);
}
};
MCELFStreamer *createMipsNaClELFStreamer(MCContext &Context, MCAsmBackend &TAB,
raw_ostream &OS,
- MCCodeEmitter *Emitter, bool RelaxAll,
- bool NoExecStack) {
- MipsNaClELFStreamer *S = new MipsNaClELFStreamer(Context, TAB, OS, Emitter);
+ MCCodeEmitter *Emitter,
+ const MCSubtargetInfo &STI,
+ bool RelaxAll, bool NoExecStack) {
+ MipsNaClELFStreamer *S = new MipsNaClELFStreamer(Context, TAB, OS, Emitter,
+ STI);
if (RelaxAll)
S->getAssembler().setRelaxAll(true);
if (NoExecStack)