}
ALU2_BRA(IF)
+ ALU2_BRA(ELSE)
ALU2_BRA(ENDIF)
ALU2_BRA(BRD)
ALU2_BRA(BRC)
insn.header.opcode == GEN_OPCODE_BRD ||
insn.header.opcode == GEN_OPCODE_ENDIF ||
insn.header.opcode == GEN_OPCODE_IF ||
- insn.header.opcode == GEN_OPCODE_BRC);
+ insn.header.opcode == GEN_OPCODE_BRC ||
+ insn.header.opcode == GEN_OPCODE_ELSE);
if (insn.header.opcode != GEN_OPCODE_JMPI || (jumpDistance > -32769 && jumpDistance < 32768)) {
if (insn.header.opcode == GEN_OPCODE_IF) {
else if (insn.header.opcode == GEN_OPCODE_JMPI) {
jumpDistance = jumpDistance - 2;
}
+ else if(insn.header.opcode == GEN_OPCODE_ENDIF)
+ jumpDistance += 2;
this->setSrc1(&insn, GenRegister::immd(jumpDistance));
} else if ( insn.header.predicate_control == GEN_PREDICATE_NONE ) {
virtual void JMPI(GenRegister src, bool longjmp = false);
/*! IF indexed instruction */
void IF(GenRegister src);
+ /*! ELSE indexed instruction */
+ void ELSE(GenRegister src);
/*! ENDIF indexed instruction */
void ENDIF(GenRegister src);
/*! BRC indexed instruction */
int JMPI(Reg src, ir::LabelIndex target, ir::LabelIndex origin);
/*! IF indexed instruction */
void IF(Reg src, ir::LabelIndex jip, ir::LabelIndex uip);
+ /*! ELSE indexed instruction */
+ void ELSE(Reg src, ir::LabelIndex jip, ir::LabelIndex elseLabel);
/*! ENDIF indexed instruction */
- void ENDIF(Reg src, ir::LabelIndex jip);
+ void ENDIF(Reg src, ir::LabelIndex jip, ir::LabelIndex endifLabel = ir::LabelIndex(0));
/*! BRD indexed instruction */
void BRD(Reg src, ir::LabelIndex jip);
/*! BRC indexed instruction */
insn->index1 = uint16_t(uip);
}
- void Selection::Opaque::ENDIF(Reg src, ir::LabelIndex jip) {
- this->block->endifLabel = this->newAuxLabel();
+ void Selection::Opaque::ELSE(Reg src, ir::LabelIndex jip, ir::LabelIndex elseLabel) {
+
+ SelectionInstruction *insn = this->appendInsn(SEL_OP_ELSE, 0, 1);
+ insn->src(0) = src;
+ insn->index = uint16_t(jip);
+ this->LABEL(elseLabel);
+ }
+
+ void Selection::Opaque::ENDIF(Reg src, ir::LabelIndex jip, ir::LabelIndex endifLabel) {
+ if(endifLabel == 0)
+ this->block->endifLabel = this->newAuxLabel();
+ else
+ this->block->endifLabel = endifLabel;
this->LABEL(this->block->endifLabel);
SelectionInstruction *insn = this->appendInsn(SEL_OP_ENDIF, 0, 1);
insn->src(0) = src;