Browse Source

case statiment insteed of ifs

Kirill Kranz 10 months ago
parent
commit
8e6a8a36cd
1 changed files with 25 additions and 15 deletions
  1. 25 15
      compiler/mips/aasmcpu.pas

+ 25 - 15
compiler/mips/aasmcpu.pas

@@ -717,21 +717,31 @@ begin
 
             if taicpu(pp).ops > 0 then begin
 
-              if taicpu(pp).ops = 1 then
-                if (taicpu(pp).oper[0]^.typ = top_reg) and (firstReg = taicpu(pp).oper[0]^.reg) then
-                  list.insertAfter(taicpu.op_none(A_NOP), l);
-
-              if taicpu(pp).ops = 2 then
-                if ((taicpu(pp).oper[0]^.typ = top_reg) and (firstReg = taicpu(pp).oper[0]^.reg)) or 
-                   ((taicpu(pp).oper[1]^.typ = top_reg) and (firstReg = taicpu(pp).oper[1]^.reg)) or 
-                   ((taicpu(pp).oper[1]^.typ = top_ref) and (firstReg = taicpu(pp).oper[1]^.ref^.base)) then
-                  list.insertAfter(taicpu.op_none(A_NOP), l);
-
-              if taicpu(pp).ops = 3 then
-                if ((taicpu(pp).oper[0]^.typ = top_reg) and (firstReg = taicpu(pp).oper[0]^.reg)) or 
-                   ((taicpu(pp).oper[1]^.typ = top_reg) and (firstReg = taicpu(pp).oper[1]^.reg)) or
-                   ((taicpu(pp).oper[2]^.typ = top_reg) and (firstReg = taicpu(pp).oper[2]^.reg)) then
-                  list.insertAfter(taicpu.op_none(A_NOP), l);
+              case taicpu(pp).ops of
+
+                0 : {noting to do};
+
+                1 : 
+                    if (taicpu(pp).oper[0]^.typ = top_reg) and (firstReg = taicpu(pp).oper[0]^.reg) then
+                          list.insertAfter(taicpu.op_none(A_NOP), l);
+
+                2 :
+                    if ((taicpu(pp).oper[0]^.typ = top_reg) and (firstReg = taicpu(pp).oper[0]^.reg)) or 
+                       ((taicpu(pp).oper[1]^.typ = top_reg) and (firstReg = taicpu(pp).oper[1]^.reg)) or 
+                       ((taicpu(pp).oper[1]^.typ = top_ref) and (firstReg = taicpu(pp).oper[1]^.ref^.base)) then
+                          list.insertAfter(taicpu.op_none(A_NOP), l);
+
+                3 :
+                    if ((taicpu(pp).oper[0]^.typ = top_reg) and (firstReg = taicpu(pp).oper[0]^.reg)) or 
+                       ((taicpu(pp).oper[1]^.typ = top_reg) and (firstReg = taicpu(pp).oper[1]^.reg)) or
+                       ((taicpu(pp).oper[2]^.typ = top_reg) and (firstReg = taicpu(pp).oper[2]^.reg)) then
+                          list.insertAfter(taicpu.op_none(A_NOP), l);
+                
+                else
+
+                    internalerror(2024092501);
+
+              end;
 
             end;