Parcourir la source

* generate jumpless code for the IN node for WebAssembly. TODO: this needs to be
refactored, so the WebAssembly-specific code generation code goes in the wasm
in node descendant class.

git-svn-id: branches/wasm@48178 -

nickysn il y a 4 ans
Parent
commit
c4e8f091ec
1 fichiers modifiés avec 24 ajouts et 1 suppressions
  1. 24 1
      compiler/ncgset.pas

+ 24 - 1
compiler/ncgset.pas

@@ -96,6 +96,9 @@ implementation
       symconst,symdef,symsym,defutil,
       pass_2,tgobj,
       nbas,ncon,ncgflw,
+{$ifdef WASM}
+      hlcgcpu,aasmcpu,
+{$endif WASM}
       ncgutil,hlcgobj;
 
 
@@ -491,6 +494,18 @@ implementation
                          ((tenumdef(left.resultdef).min < aint(tsetdef(right.resultdef).setbase)) or
                           (tenumdef(left.resultdef).max > aint(tsetdef(right.resultdef).setmax)))) then
                        begin
+{$ifdef WASM}
+                         needslabel := True;
+
+                         thlcgwasm(hlcg).a_cmp_const_reg_stack(current_asmdata.CurrAsmList, opdef, OC_A, tsetdef(right.resultdef).setmax-tsetdef(right.resultdef).setbase, pleftreg);
+
+                         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
+                         thlcgwasm(hlcg).incblock;
+                         thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
+
+                         hlcg.a_load_const_reg(current_asmdata.CurrAsmList, uopdef, 0, location.register);
+                         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_else));
+{$else WASM}
                          current_asmdata.getjumplabel(l);
                          current_asmdata.getjumplabel(l2);
                          needslabel := True;
@@ -501,13 +516,21 @@ implementation
                          hlcg.a_jmp_always(current_asmdata.CurrAsmList, l2);
 
                          hlcg.a_label(current_asmdata.CurrAsmList, l);
+{$endif WASM}
                        end;
 
                      hlcg.a_bit_test_reg_loc_reg(current_asmdata.CurrAsmList,opdef,right.resultdef,uopdef,
                        pleftreg,right.location,location.register);
 
                      if needslabel then
-                       hlcg.a_label(current_asmdata.CurrAsmList, l2);
+                       begin
+{$ifdef WASM}
+                         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
+                         thlcgwasm(hlcg).decblock;
+{$else WASM}
+                         hlcg.a_label(current_asmdata.CurrAsmList, l2);
+{$endif WASM}
+                       end
                    end;
 {$ifndef cpuhighleveltarget}
                  location.size := def_cgsize(resultdef);