Преглед изворни кода

Fix shift operations on 32bit operands.

git-svn-id: branches/laksen/riscv_new@39489 -
Jeppe Johansen пре 7 година
родитељ
комит
c6b27bc225
1 измењених фајлова са 46 додато и 2 уклоњено
  1. 46 2
      compiler/riscv/cgrv.pas

+ 46 - 2
compiler/riscv/cgrv.pas

@@ -201,6 +201,27 @@ unit cgrv;
             a:=-a;
             a:=-a;
           end;
           end;
 
 
+{$ifdef RISCV64}
+        if (op=OP_SHL) and
+           (size in [OS_32,OS_S32]) then
+          begin
+            list.concat(taicpu.op_reg_reg_const(A_SLLIW,dst,src,a));
+            maybeadjustresult(list,op,size,dst);
+          end
+        else if (op=OP_SHR) and
+           (size in [OS_32,OS_S32]) then
+          begin
+            list.concat(taicpu.op_reg_reg_const(A_SRLIW,dst,src,a));
+            maybeadjustresult(list,op,size,dst);
+          end
+        else if (op=OP_SAR) and
+           (size in [OS_32,OS_S32]) then
+          begin
+            list.concat(taicpu.op_reg_reg_const(A_SRAIW,dst,src,a));
+            maybeadjustresult(list,op,size,dst);
+          end
+        else
+{$endif RISCV64}
         if (TOpCG2AsmConstOp[op]<>A_None) and
         if (TOpCG2AsmConstOp[op]<>A_None) and
            is_imm12(a) then
            is_imm12(a) then
           begin
           begin
@@ -232,8 +253,31 @@ unit cgrv;
           OP_MOVE:
           OP_MOVE:
             a_load_reg_reg(list,size,size,src1,dst);
             a_load_reg_reg(list,size,size,src1,dst);
         else
         else
-          list.concat(taicpu.op_reg_reg_reg(TOpCG2AsmOp[op],dst,src2,src1));
-          maybeadjustresult(list,op,size,dst);
+{$ifdef RISCV64}
+          if (op=OP_SHL) and
+             (size in [OS_32,OS_S32]) then
+            begin
+              list.concat(taicpu.op_reg_reg_reg(A_SLLW,dst,src2,src1));
+              maybeadjustresult(list,op,size,dst);
+            end
+          else if (op=OP_SHR) and
+             (size in [OS_32,OS_S32]) then
+            begin
+              list.concat(taicpu.op_reg_reg_reg(A_SRLW,dst,src2,src1));
+              maybeadjustresult(list,op,size,dst);
+            end
+          else if (op=OP_SAR) and
+             (size in [OS_32,OS_S32]) then
+            begin
+              list.concat(taicpu.op_reg_reg_reg(A_SRAW,dst,src2,src1));
+              maybeadjustresult(list,op,size,dst);
+            end
+          else
+{$endif RISCV64}
+            begin
+              list.concat(taicpu.op_reg_reg_reg(TOpCG2AsmOp[op],dst,src2,src1));
+              maybeadjustresult(list,op,size,dst);
+            end;
         end;
         end;
       end;
       end;