comparison lwasm/insn_indexed.c @ 455:cad5937314cb

Add operandsizewarning pragma Add operandsizewarning pragma that will raise warnings for certain operands if the operand size could be smaller. (Long branch used instead of short branch, for instance.)
author William Astle <lost@l-w.ca>
date Fri, 16 Feb 2018 22:53:46 -0700
parents b20f14edda5a
children 3948c874901b
comparison
equal deleted inserted replaced
454:ffdef8994f13 455:cad5937314cb
707 { 707 {
708 lwasm_register_error(as, l, E_BYTE_OVERFLOW); 708 lwasm_register_error(as, l, E_BYTE_OVERFLOW);
709 } 709 }
710 } 710 }
711 711
712 if (l -> lint == 2 && CURPRAGMA(l, PRAGMA_OPERANDSIZE))
713 {
714 int offs;
715 e = lwasm_fetch_expr(l, 0);
716 if (lw_expr_istype(e, lw_expr_type_int))
717 {
718 offs = lw_expr_intval(e);
719 if ((offs >= -128 && offs <= 127) || offs >= 0xFF80)
720 {
721 lwasm_register_error(as, l, W_OPERAND_SIZE);
722 }
723 }
724 }
725
712 lwasm_emitop(l, instab[l -> insn].ops[0]); 726 lwasm_emitop(l, instab[l -> insn].ops[0]);
713 lwasm_emitop(l, l -> pb); 727 lwasm_emitop(l, l -> pb);
714 728
715 l -> cycle_adj = lwasm_cycle_calc_ind(l); 729 l -> cycle_adj = lwasm_cycle_calc_ind(l);
716 730