|
@@ -803,9 +803,24 @@ end;
|
|
|
|
|
|
|
|
|
procedure TCGMIPS.a_op_reg_reg_reg(list: tasmlist; op: TOpCg; size: tcgsize; src1, src2, dst: tregister);
|
|
|
+var
|
|
|
+ hreg: tregister;
|
|
|
begin
|
|
|
if (TOpcg2AsmOp[op]=A_NONE) then
|
|
|
InternalError(2013070305);
|
|
|
+ if (op=OP_SAR) then
|
|
|
+ begin
|
|
|
+ if (size in [OS_S8,OS_S16]) then
|
|
|
+ begin
|
|
|
+ { Shift left by 16/24 bits and increase amount of right shift by same value }
|
|
|
+ list.concat(taicpu.op_reg_reg_const(A_SLL, dst, src2, 32-(tcgsize2size[size]*8)));
|
|
|
+ hreg:=GetIntRegister(list,OS_INT);
|
|
|
+ a_op_const_reg_reg(list,OP_ADD,OS_INT,32-(tcgsize2size[size]*8),src1,dst);
|
|
|
+ src1:=hreg;
|
|
|
+ end
|
|
|
+ else if not (size in [OS_32,OS_S32]) then
|
|
|
+ InternalError(2013070306);
|
|
|
+ end;
|
|
|
list.concat(taicpu.op_reg_reg_reg(TOpCG2AsmOp[op], dst, src2, src1));
|
|
|
maybeadjustresult(list,op,size,dst);
|
|
|
end;
|
|
@@ -885,8 +900,17 @@ begin
|
|
|
list.concat(taicpu.op_reg_reg_const(A_SRL,dst,src,a));
|
|
|
|
|
|
OP_SAR:
|
|
|
- list.concat(taicpu.op_reg_reg_const(A_SRA,dst,src,a));
|
|
|
-
|
|
|
+ begin
|
|
|
+ if (size in [OS_S8,OS_S16]) then
|
|
|
+ begin
|
|
|
+ list.concat(taicpu.op_reg_reg_const(A_SLL,dst,src,32-(tcgsize2size[size]*8)));
|
|
|
+ inc(a,32-tcgsize2size[size]*8);
|
|
|
+ src:=dst;
|
|
|
+ end
|
|
|
+ else if not (size in [OS_32,OS_S32]) then
|
|
|
+ InternalError(2013070303);
|
|
|
+ list.concat(taicpu.op_reg_reg_const(A_SRA,dst,src,a));
|
|
|
+ end;
|
|
|
else
|
|
|
internalerror(2007012601);
|
|
|
end;
|