|
@@ -101,19 +101,23 @@ implementation
|
|
|
end;
|
|
|
|
|
|
begin
|
|
|
- if not(jumptable_no_range) then
|
|
|
- begin
|
|
|
- { case expr less than min_ => goto elselabel }
|
|
|
- cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_lt,aint(min_),hregister,elselabel);
|
|
|
- { case expr greater than max_ => goto elselabel }
|
|
|
- cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_gt,aint(max_),hregister,elselabel);
|
|
|
- end;
|
|
|
- current_asmdata.getjumplabel(table);
|
|
|
+ last:=min_;
|
|
|
{ make it a 32bit register }
|
|
|
// allocate base and index registers register
|
|
|
indexreg:= cg.makeregsize(current_asmdata.CurrAsmList, hregister, OS_INT);
|
|
|
{ indexreg := hregister; }
|
|
|
cg.a_load_reg_reg(current_asmdata.CurrAsmList, opsize, OS_INT, hregister, indexreg);
|
|
|
+ if not(jumptable_no_range) then
|
|
|
+ begin
|
|
|
+ { use aword(value-min)<aword(max-min) instead of two comparisons }
|
|
|
+ { case expr outside min_ .. max_ => goto elselabel }
|
|
|
+ cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SUB,OS_INT,aint(min_),indexreg);
|
|
|
+ { this trick requires an unsigned comparison in all cases }
|
|
|
+ cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_A,aint(max_)-aint(min_),indexreg,elselabel);
|
|
|
+ { already taken into account now }
|
|
|
+ min_:=0;
|
|
|
+ end;
|
|
|
+ current_asmdata.getjumplabel(table);
|
|
|
{ create reference, indexreg := indexreg * sizeof(OS_ADDR) }
|
|
|
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_MUL, OS_INT, tcgsize2size[OS_ADDR], indexreg);
|
|
|
reference_reset_symbol(href, table, (-aint(min_)) * tcgsize2size[OS_ADDR]);
|
|
@@ -127,7 +131,6 @@ implementation
|
|
|
{ generate jump table }
|
|
|
new_section(current_procinfo.aktlocaldata,sec_rodata,current_procinfo.procdef.mangledname,sizeof(aint));
|
|
|
current_procinfo.aktlocaldata.concat(Tai_label.Create(table));
|
|
|
- last:=min_;
|
|
|
genitem(current_procinfo.aktlocaldata,hp);
|
|
|
end;
|
|
|
|