mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 13:29:27 +02:00
* Handle possible relocation types in assembler reader using a single AS_RELTYPE token, rather than with individual tokens for each case. Since possible relocations are target-dependent, this will allow to support any amount of them without modifying the base tattreader class.
git-svn-id: trunk@33117 -
This commit is contained in:
parent
4e7c0d0670
commit
cc3e09ee46
@ -26,11 +26,13 @@ Unit racpugas;
|
||||
Interface
|
||||
|
||||
uses
|
||||
cgbase,
|
||||
rautils,
|
||||
raatt;
|
||||
|
||||
type
|
||||
tMipsReader = class(tattreader)
|
||||
actrel: trefaddr;
|
||||
function is_asmopcode(const s: string):boolean;override;
|
||||
procedure BuildOperand(oper : TOperand);
|
||||
procedure BuildOpCode(instr : TInstruction);
|
||||
@ -58,7 +60,7 @@ Interface
|
||||
rabase,
|
||||
rgbase,
|
||||
itcpugas,
|
||||
cgbase,cgobj
|
||||
cgobj
|
||||
;
|
||||
|
||||
|
||||
@ -91,7 +93,6 @@ Interface
|
||||
len:=1;
|
||||
actasmpattern[len]:='%';
|
||||
c:=current_scanner.asmgetchar;
|
||||
{ to be a register there must be a letter and not a number }
|
||||
while c in ['a'..'z','A'..'Z','0'..'9'] do
|
||||
Begin
|
||||
inc(len);
|
||||
@ -100,12 +101,15 @@ Interface
|
||||
end;
|
||||
actasmpattern[0]:=chr(len);
|
||||
uppervar(actasmpattern);
|
||||
actrel:=addr_no;
|
||||
if (actasmpattern='%HI') then
|
||||
actasmtoken:=AS_HI
|
||||
actrel:=addr_high
|
||||
else if (actasmpattern='%LO')then
|
||||
actasmtoken:=AS_LO
|
||||
actrel:=addr_low
|
||||
else
|
||||
Message(asmr_e_invalid_reference_syntax);
|
||||
if actrel<>addr_no then
|
||||
actasmtoken:=AS_RELTYPE;
|
||||
end;
|
||||
|
||||
|
||||
@ -253,16 +257,12 @@ Interface
|
||||
gotplus:=false;
|
||||
end;
|
||||
|
||||
AS_HI,
|
||||
AS_LO:
|
||||
AS_RELTYPE:
|
||||
begin
|
||||
{ Low or High part of a constant (or constant
|
||||
memory location) }
|
||||
oper.InitRef;
|
||||
if actasmtoken=AS_LO then
|
||||
oper.opr.ref.refaddr:=addr_low
|
||||
else
|
||||
oper.opr.ref.refaddr:=addr_high;
|
||||
oper.opr.ref.refaddr:=actrel;
|
||||
Consume(actasmtoken);
|
||||
Consume(AS_LPAREN);
|
||||
BuildConstSymbolExpression(false, true,false,l,tempstr,tempsymtyp);
|
||||
|
@ -57,7 +57,7 @@ unit raatt;
|
||||
AS_SET,AS_WEAK,AS_SECTION,AS_END,
|
||||
{------------------ Assembler Operators --------------------}
|
||||
AS_TYPE,AS_SIZEOF,AS_VMTOFFSET,AS_MOD,AS_SHL,AS_SHR,AS_NOT,AS_AND,AS_OR,AS_XOR,AS_NOR,AS_AT,
|
||||
AS_LO,AS_HI,
|
||||
AS_RELTYPE, // common token for relocation types
|
||||
{------------------ Target-specific directive ---------------}
|
||||
AS_TARGET_DIRECTIVE
|
||||
);
|
||||
@ -82,7 +82,7 @@ unit raatt;
|
||||
'.asciz','.lcomm','.comm','.single','.double','.tfloat','.tcfloat',
|
||||
'.data','.text','.init','.fini','.rva',
|
||||
'.set','.weak','.section','END',
|
||||
'TYPE','SIZEOF','VMTOFFSET','%','<<','>>','!','&','|','^','~','@','lo','hi',
|
||||
'TYPE','SIZEOF','VMTOFFSET','%','<<','>>','!','&','|','^','~','@','reltype',
|
||||
'directive');
|
||||
|
||||
type
|
||||
|
@ -26,10 +26,11 @@ Unit racpugas;
|
||||
Interface
|
||||
|
||||
uses
|
||||
raatt,racpu;
|
||||
cgbase,raatt,racpu;
|
||||
|
||||
type
|
||||
tSparcReader = class(tattreader)
|
||||
actrel: trefaddr;
|
||||
function is_asmopcode(const s: string):boolean;override;
|
||||
procedure handleopcode;override;
|
||||
procedure BuildReference(oper : tSparcoperand);
|
||||
@ -56,7 +57,7 @@ Interface
|
||||
scanner,
|
||||
procinfo,
|
||||
rabase,rautils,
|
||||
cgbase,cgobj
|
||||
cgobj
|
||||
;
|
||||
|
||||
|
||||
@ -153,12 +154,15 @@ Interface
|
||||
uppervar(actasmpattern);
|
||||
if is_register(actasmpattern) then
|
||||
exit;
|
||||
actrel:=addr_no;
|
||||
if (actasmpattern='%HI') then
|
||||
actasmtoken:=AS_HI
|
||||
actrel:=addr_high
|
||||
else if (actasmpattern='%LO')then
|
||||
actasmtoken:=AS_LO
|
||||
actrel:=addr_low
|
||||
else
|
||||
Message(asmr_e_invalid_register);
|
||||
if (actrel<>addr_no) then
|
||||
actasmtoken:=AS_RELTYPE;
|
||||
end;
|
||||
|
||||
|
||||
@ -292,16 +296,12 @@ Interface
|
||||
gotplus:=false;
|
||||
end;
|
||||
|
||||
AS_HI,
|
||||
AS_LO:
|
||||
AS_RELTYPE:
|
||||
begin
|
||||
{ Low or High part of a constant (or constant
|
||||
memory location) }
|
||||
oper.InitRef;
|
||||
if actasmtoken=AS_LO then
|
||||
oper.opr.ref.refaddr:=addr_low
|
||||
else
|
||||
oper.opr.ref.refaddr:=addr_high;
|
||||
oper.opr.ref.refaddr:=actrel;
|
||||
Consume(actasmtoken);
|
||||
Consume(AS_LPAREN);
|
||||
BuildConstSymbolExpression(false, true,false,l,tempstr,tempsymtyp);
|
||||
|
Loading…
Reference in New Issue
Block a user