|
@@ -96,32 +96,36 @@ implementation
|
|
|
var
|
|
|
ai: taicpu;
|
|
|
begin
|
|
|
- if (fromsize=tosize) or
|
|
|
- ((tcgsize2unsigned[fromsize]=tcgsize2unsigned[tosize]) and
|
|
|
- (tcgsize2unsigned[fromsize]=OS_64)) then
|
|
|
+ if (tcgsize2size[fromsize] > tcgsize2size[tosize]) or
|
|
|
+ ((tcgsize2size[fromsize] = tcgsize2size[tosize]) and (fromsize <> tosize)) or
|
|
|
+ { do we need to mask out the sign when loading from smaller signed to larger unsigned type? }
|
|
|
+ ((tcgsize2unsigned[fromsize]<>fromsize) and ((tcgsize2unsigned[tosize]=tosize)) and
|
|
|
+ (tcgsize2size[fromsize] < tcgsize2size[tosize]) and (tcgsize2size[tosize] <> sizeof(pint)) ) then
|
|
|
begin
|
|
|
- ai:=taicpu.op_reg_reg_const(A_ADDI,reg2,reg1,0);
|
|
|
- list.concat(ai);
|
|
|
- rg[R_INTREGISTER].add_move_instruction(ai);
|
|
|
- end
|
|
|
- {else if (fromsize=OS_S32) then
|
|
|
- list.Concat(taicpu.op_reg_reg_const(A_ADDIW,reg2,reg1,0))
|
|
|
- else if (fromsize=OS_8) then
|
|
|
- list.Concat(taicpu.op_reg_reg_const(A_ANDI,reg2,reg1,$FF))}
|
|
|
- else
|
|
|
- begin
|
|
|
- if tcgsize2size[tosize]<tcgsize2size[fromsize] then
|
|
|
- fromsize:=tosize;
|
|
|
+ if tcgsize2size[fromsize]<tcgsize2size[tosize] then
|
|
|
+ begin
|
|
|
+ list.Concat(taicpu.op_reg_reg_const(A_SLLI,reg2,reg1,8*(8-tcgsize2size[fromsize])));
|
|
|
|
|
|
- if tcgsize2unsigned[fromsize]<>OS_64 then
|
|
|
- list.Concat(taicpu.op_reg_reg_const(A_SLLI,reg2,reg1,8*(8-tcgsize2size[fromsize])))
|
|
|
+ if tcgsize2unsigned[fromsize]<>fromsize then
|
|
|
+ list.Concat(taicpu.op_reg_reg_const(A_SRAI,reg2,reg2,8*(tcgsize2size[tosize]-tcgsize2size[fromsize])))
|
|
|
+ else
|
|
|
+ list.Concat(taicpu.op_reg_reg_const(A_SRLI,reg2,reg2,8*(tcgsize2size[tosize]-tcgsize2size[fromsize])));
|
|
|
+ end
|
|
|
+ else if tcgsize2unsigned[tosize]<>OS_64 then
|
|
|
+ list.Concat(taicpu.op_reg_reg_const(A_SLLI,reg2,reg1,8*(8-tcgsize2size[tosize])))
|
|
|
else
|
|
|
- a_load_reg_reg(list,fromsize,fromsize,reg1,reg2);
|
|
|
+ a_load_reg_reg(list,tosize,tosize,reg1,reg2);
|
|
|
|
|
|
- if tcgsize2unsigned[fromsize]=fromsize then
|
|
|
- list.Concat(taicpu.op_reg_reg_const(A_SRLI,reg2,reg2,8*(8-tcgsize2size[fromsize])))
|
|
|
+ if tcgsize2unsigned[tosize]=tosize then
|
|
|
+ list.Concat(taicpu.op_reg_reg_const(A_SRLI,reg2,reg2,8*(8-tcgsize2size[tosize])))
|
|
|
else
|
|
|
- list.Concat(taicpu.op_reg_reg_const(A_SRAI,reg2,reg2,8*(8-tcgsize2size[fromsize])));
|
|
|
+ list.Concat(taicpu.op_reg_reg_const(A_SRAI,reg2,reg2,8*(8-tcgsize2size[tosize])));
|
|
|
+ end
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ ai:=taicpu.op_reg_reg_const(A_ADDI,reg2,reg1,0);
|
|
|
+ list.concat(ai);
|
|
|
+ rg[R_INTREGISTER].add_move_instruction(ai);
|
|
|
end;
|
|
|
end;
|
|
|
|