void CodeGeneratorMIPS64::visitOutOfLineTableSwitch(OutOfLineTableSwitch* ool) { MTableSwitch* mir = ool->mir(); masm.haltingAlign(sizeof(void*)); masm.bind(ool->jumpLabel()->target()); masm.addCodeLabel(*ool->jumpLabel()); for (size_t i = 0; i < mir->numCases(); i++) { LBlock* caseblock = skipTrivialBlocks(mir->getCase(i))->lir(); Label* caseheader = caseblock->label(); uint32_t caseoffset = caseheader->offset(); // The entries of the jump table need to be absolute addresses and thus // must be patched after codegen is finished. Each table entry uses 8 // instructions (4 for load address, 2 for branch, and 2 padding). CodeLabel cl; masm.ma_li(ScratchRegister, cl.patchAt()); masm.branch(ScratchRegister); masm.as_nop(); masm.as_nop(); cl.target()->bind(caseoffset); masm.addCodeLabel(cl); } }
void CodeGeneratorX86Shared::emitBranch(Assembler::Condition cond, MBasicBlock *mirTrue, MBasicBlock *mirFalse, Assembler::NaNCond ifNaN) { LBlock *ifTrue = mirTrue->lir(); LBlock *ifFalse = mirFalse->lir(); if (ifNaN == Assembler::NaN_IsFalse) masm.j(Assembler::Parity, ifFalse->label()); else if (ifNaN == Assembler::NaN_IsTrue) masm.j(Assembler::Parity, ifTrue->label()); if (isNextBlock(ifFalse)) { masm.j(cond, ifTrue->label()); } else { masm.j(Assembler::InvertCondition(cond), ifFalse->label()); if (!isNextBlock(ifTrue)) masm.jmp(ifTrue->label()); } }