mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-28 09:01:35 +01:00
* simplified and fixed a_load_reg_reg()
git-svn-id: trunk@7121 -
This commit is contained in:
parent
4e44015b8e
commit
2b0c01b903
@ -539,81 +539,47 @@ implementation
|
|||||||
var
|
var
|
||||||
instr : taicpu;
|
instr : taicpu;
|
||||||
begin
|
begin
|
||||||
if (tcgsize2size[tosize]<tcgsize2size[fromsize]) or
|
if (tcgsize2size[fromsize] > tcgsize2size[tosize]) or
|
||||||
(
|
((tcgsize2size[fromsize] = tcgsize2size[tosize]) and
|
||||||
(tcgsize2size[tosize] = tcgsize2size[fromsize]) and
|
(fromsize <> tosize)) or
|
||||||
(tosize <> fromsize) and
|
{ needs to mask out the sign in the top 16 bits }
|
||||||
not(fromsize in [OS_32,OS_S32])
|
((fromsize = OS_S8) and
|
||||||
) then
|
(tosize = OS_16)) then
|
||||||
begin
|
case tosize of
|
||||||
case tosize of
|
OS_8 :
|
||||||
OS_8 :
|
a_op_const_reg_reg(list,OP_AND,tosize,$ff,reg1,reg2);
|
||||||
a_op_const_reg_reg(list,OP_AND,tosize,$ff,reg1,reg2);
|
OS_16 :
|
||||||
OS_16 :
|
a_op_const_reg_reg(list,OP_AND,tosize,$ffff,reg1,reg2);
|
||||||
a_op_const_reg_reg(list,OP_AND,tosize,$ffff,reg1,reg2);
|
OS_32,
|
||||||
OS_32,
|
OS_S32 :
|
||||||
OS_S32 :
|
begin
|
||||||
begin
|
instr:=taicpu.op_reg_reg(A_MOV,reg1,reg2);
|
||||||
instr:=taicpu.op_reg_reg(A_MOV,reg1,reg2);
|
list.Concat(instr);
|
||||||
list.Concat(instr);
|
{ Notify the register allocator that we have written a move instruction so
|
||||||
{ Notify the register allocator that we have written a move instruction so
|
it can try to eliminate it. }
|
||||||
it can try to eliminate it. }
|
add_move_instruction(instr);
|
||||||
add_move_instruction(instr);
|
end;
|
||||||
end;
|
OS_S8 :
|
||||||
OS_S8 :
|
begin
|
||||||
begin
|
list.concat(taicpu.op_reg_const_reg(A_SLL,reg1,24,reg2));
|
||||||
list.concat(taicpu.op_reg_const_reg(A_SLL,reg1,24,reg2));
|
list.concat(taicpu.op_reg_const_reg(A_SRA,reg2,24,reg2));
|
||||||
list.concat(taicpu.op_reg_const_reg(A_SRA,reg2,24,reg2));
|
end;
|
||||||
end;
|
OS_S16 :
|
||||||
OS_S16 :
|
begin
|
||||||
begin
|
list.concat(taicpu.op_reg_const_reg(A_SLL,reg1,16,reg2));
|
||||||
list.concat(taicpu.op_reg_const_reg(A_SLL,reg1,16,reg2));
|
list.concat(taicpu.op_reg_const_reg(A_SRA,reg2,16,reg2));
|
||||||
list.concat(taicpu.op_reg_const_reg(A_SRA,reg2,16,reg2));
|
end;
|
||||||
end;
|
else
|
||||||
else
|
internalerror(2002090901);
|
||||||
internalerror(2002090901);
|
end
|
||||||
end;
|
else
|
||||||
end
|
begin
|
||||||
else
|
instr:=taicpu.op_reg_reg(A_MOV,reg1,reg2);
|
||||||
begin
|
list.Concat(instr);
|
||||||
if reg1<>reg2 then
|
{ Notify the register allocator that we have written a move instruction so
|
||||||
begin
|
it can try to eliminate it. }
|
||||||
if tcgsize2size[tosize] > tcgsize2size[fromsize] then
|
add_move_instruction(instr);
|
||||||
begin
|
end;
|
||||||
case fromsize of
|
|
||||||
OS_8:
|
|
||||||
begin
|
|
||||||
list.concat(taicpu.op_reg_const_reg(A_SLL,reg1,24,reg2));
|
|
||||||
list.concat(taicpu.op_reg_const_reg(A_SRL,reg2,24,reg2));
|
|
||||||
end;
|
|
||||||
OS_16 :
|
|
||||||
begin
|
|
||||||
list.concat(taicpu.op_reg_const_reg(A_SLL,reg1,16,reg2));
|
|
||||||
list.concat(taicpu.op_reg_const_reg(A_SRL,reg2,16,reg2));
|
|
||||||
end;
|
|
||||||
OS_S8:
|
|
||||||
begin
|
|
||||||
list.concat(taicpu.op_reg_const_reg(A_SLL,reg1,24,reg2));
|
|
||||||
list.concat(taicpu.op_reg_const_reg(A_SRA,reg2,24,reg2));
|
|
||||||
end;
|
|
||||||
OS_S16 :
|
|
||||||
begin
|
|
||||||
list.concat(taicpu.op_reg_const_reg(A_SLL,reg1,16,reg2));
|
|
||||||
list.concat(taicpu.op_reg_const_reg(A_SRA,reg2,16,reg2));
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
{ same size, only a register mov required }
|
|
||||||
instr:=taicpu.op_reg_reg(A_MOV,reg1,reg2);
|
|
||||||
list.Concat(instr);
|
|
||||||
{ Notify the register allocator that we have written a move instruction so
|
|
||||||
it can try to eliminate it. }
|
|
||||||
add_move_instruction(instr);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user