* improve hadlign %hi and %lo operators

This commit is contained in:
mazen 2003-12-10 13:16:35 +00:00
parent b718d900c7
commit 23f1b2c49e
2 changed files with 51 additions and 47 deletions

View File

@ -65,6 +65,7 @@ uses
function is_move:boolean;override; function is_move:boolean;override;
{ register spilling code } { register spilling code }
function spilling_get_operation_type(opnr: longint): topertype;override;
function spilling_decode_loadstore(op: tasmop; var counterpart: tasmop; var wasload: boolean): boolean;override; function spilling_decode_loadstore(op: tasmop; var counterpart: tasmop; var wasload: boolean): boolean;override;
function spilling_create_loadstore(op: tasmop; r:tregister; const ref:treference): tai;override; function spilling_create_loadstore(op: tasmop; r:tregister; const ref:treference): tai;override;
function spilling_create_load(const ref:treference;r:tregister): tai;override; function spilling_create_load(const ref:treference;r:tregister): tai;override;
@ -235,6 +236,24 @@ implementation
(oper[1]^.typ=top_reg); (oper[1]^.typ=top_reg);
end; end;
function taicpu.spilling_get_operation_type(opnr: longint): topertype;
{$WARNING ******Check taicpu.spilling_get_operation_type******}
begin
result := operand_read;
case opcode of
A_STB..A_STDA:
begin
if opnr = 1 then
result := operand_write;
end;
else
if opnr = 0 then
result := operand_write;
end;
end;
function taicpu.spilling_decode_loadstore(op: tasmop; var counterpart: tasmop; var wasload: boolean): boolean; function taicpu.spilling_decode_loadstore(op: tasmop; var counterpart: tasmop; var wasload: boolean): boolean;
begin begin
@ -335,7 +354,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.36 2003-10-30 15:03:18 mazen Revision 1.37 2003-12-10 13:16:35 mazen
* improve hadlign %hi and %lo operators
Revision 1.36 2003/10/30 15:03:18 mazen
* now uses standard routines in rgHelper unit to search registers by number and by name * now uses standard routines in rgHelper unit to search registers by number and by name
Revision 1.35 2003/10/24 07:00:17 mazen Revision 1.35 2003/10/24 07:00:17 mazen

View File

@ -36,7 +36,7 @@ Interface
procedure BuildReference(oper : tSparcoperand); procedure BuildReference(oper : tSparcoperand);
procedure BuildOperand(oper : tSparcoperand); procedure BuildOperand(oper : tSparcoperand);
procedure BuildOpCode(instr : tSparcinstruction); procedure BuildOpCode(instr : tSparcinstruction);
procedure ReadAt(oper : tSparcoperand); procedure ReadPercent(oper : tSparcoperand);
procedure ReadSym(oper : tSparcoperand); procedure ReadSym(oper : tSparcoperand);
procedure ConvertCalljmp(instr : tSparcinstruction); procedure ConvertCalljmp(instr : tSparcinstruction);
procedure handlepercent;override; procedure handlepercent;override;
@ -93,7 +93,7 @@ Interface
end; end;
procedure tSparcReader.ReadAt(oper : tSparcoperand); procedure tSparcReader.ReadPercent(oper : tSparcoperand);
begin begin
{ check for ...@ } { check for ...@ }
if actasmtoken=AS_AT then if actasmtoken=AS_AT then
@ -104,9 +104,9 @@ Interface
Consume(AS_AT); Consume(AS_AT);
if actasmtoken=AS_ID then if actasmtoken=AS_ID then
begin begin
if upper(actasmpattern)='L' then if upper(actasmpattern)='LO' then
oper.opr.ref.symaddr:=refs_lo oper.opr.ref.symaddr:=refs_lo
else if upper(actasmpattern)='HA' then else if upper(actasmpattern)='HI' then
oper.opr.ref.symaddr:=refs_hi oper.opr.ref.symaddr:=refs_hi
else else
Message(asmr_e_invalid_reference_syntax); Message(asmr_e_invalid_reference_syntax);
@ -158,8 +158,8 @@ Interface
Begin Begin
oper.opr.Ref.Offset:=BuildConstExpression(false,true); oper.opr.Ref.Offset:=BuildConstExpression(false,true);
Consume(AS_RPAREN); Consume(AS_RPAREN);
if actasmtoken=AS_AT then if actasmtoken=AS_MOD then
ReadAt(oper); ReadPercent(oper);
end; end;
exit; exit;
End; End;
@ -211,8 +211,8 @@ Interface
end; end;
end; end;
Consume(AS_RPAREN); Consume(AS_RPAREN);
if actasmtoken=AS_AT then if actasmtoken=AS_MOD then
ReadAt(oper); ReadPercent(oper);
End; End;
AS_COMMA: { (, ... can either be scaling, or index } AS_COMMA: { (, ... can either be scaling, or index }
Begin Begin
@ -247,42 +247,20 @@ Interface
actasmpattern[len]:='%'; actasmpattern[len]:='%';
c:=current_scanner.asmgetchar; c:=current_scanner.asmgetchar;
{ to be a register there must be a letter and not a number } { to be a register there must be a letter and not a number }
if c in ['0'..'9'] then while c in ['a'..'z','A'..'Z','0'..'9'] do
begin Begin
actasmtoken:=AS_MOD; inc(len);
end actasmpattern[len]:=c;
else c:=current_scanner.asmgetchar;
begin end;
while c in ['a'..'z','A'..'Z','0'..'9'] do actasmpattern[0]:=chr(len);
Begin uppervar(actasmpattern);
inc(len); if is_register(actasmpattern) then
actasmpattern[len]:=c; exit;
c:=current_scanner.asmgetchar; if(actasmpattern='%HI')or(actasmpattern='%LO')then
end; actasmtoken:=AS_MOD
actasmpattern[0]:=chr(len); else
uppervar(actasmpattern);
if (actasmpattern = '%ST') and (c='(') then
Begin
actasmpattern:=actasmpattern+c;
c:=current_scanner.asmgetchar;
if c in ['0'..'9'] then
actasmpattern:=actasmpattern + c
else
Message(asmr_e_invalid_fpu_register);
c:=current_scanner.asmgetchar;
if c <> ')' then
Message(asmr_e_invalid_fpu_register)
else
Begin
actasmpattern:=actasmpattern + c;
c:=current_scanner.asmgetchar; { let us point to next character. }
end;
end;
if is_register(actasmpattern) then
exit;
Message(asmr_e_invalid_register); Message(asmr_e_invalid_register);
actasmtoken:=raatt.AS_NONE;
end;
end; end;
Procedure tSparcReader.BuildOperand(oper : tSparcoperand); Procedure tSparcReader.BuildOperand(oper : tSparcoperand);
@ -406,7 +384,8 @@ Interface
AS_INTNUM, AS_INTNUM,
AS_MINUS, AS_MINUS,
AS_PLUS: AS_PLUS,
AS_MOD:
Begin Begin
{ Constant memory offset } { Constant memory offset }
{ This must absolutely be followed by ( } { This must absolutely be followed by ( }
@ -467,7 +446,7 @@ Interface
else else
begin begin
if oper.SetupVar(expr,false) then if oper.SetupVar(expr,false) then
ReadAt(oper) ReadPercent(oper)
else else
Begin Begin
{ look for special symbols ... } { look for special symbols ... }
@ -715,7 +694,10 @@ initialization
end. end.
{ {
$Log$ $Log$
Revision 1.1 2003-12-08 13:02:21 mazen Revision 1.2 2003-12-10 13:16:36 mazen
* improve hadlign %hi and %lo operators
Revision 1.1 2003/12/08 13:02:21 mazen
+ support for native sparc assembler reader + support for native sparc assembler reader
} }