From e2272c8a7e23050a147e8c874cd6344abf09a675 Mon Sep 17 00:00:00 2001 From: Jeppe Johansen Date: Sat, 4 Apr 2015 10:29:11 +0000 Subject: [PATCH] Added aitconst_gs for AVR pointer references to Flash. git-svn-id: trunk@30419 - --- compiler/aasmtai.pas | 14 +++++++++++++- compiler/aggas.pas | 5 ++++- compiler/assemble.pas | 5 +++-- compiler/llvm/agllvm.pas | 3 ++- compiler/x86/agx86nsm.pas | 2 +- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/compiler/aasmtai.pas b/compiler/aasmtai.pas index a657a6c425..1e9c5c5a5a 100644 --- a/compiler/aasmtai.pas +++ b/compiler/aasmtai.pas @@ -133,6 +133,8 @@ interface aitconst_darwin_dwarf_delta32, { ARM Thumb-2 only } aitconst_half16bit, { used for table jumps. The actual value is the 16bit value shifted left once } + { AVR } + aitconst_gs, { Upper 16-bit of 17-bit constant } { for use by dwarf debugger information } aitconst_16bit_unaligned, aitconst_32bit_unaligned, @@ -1680,6 +1682,11 @@ implementation consttype:=aitconst_ptr; end; {$else i8086} +{$ifdef avr} + if assigned(_sym) and (_sym.typ=AT_FUNCTION) then + consttype:=aitconst_gs + else +{$endif avr} consttype:=aitconst_ptr; {$endif i8086} { sym is allowed to be nil, this is used to write nil pointers } @@ -1784,7 +1791,11 @@ implementation consttype:=aitconst_farptr else {$endif i8086} +{$ifdef avr} + consttype:=aitconst_gs; +{$else avr} consttype:=aitconst_ptr; +{$endif avr} sym:=nil; endsym:=nil; symofs:=0; @@ -1868,7 +1879,8 @@ implementation result:=LengthUleb128(qword(value)); aitconst_sleb128bit : result:=LengthSleb128(value); - aitconst_half16bit: + aitconst_half16bit, + aitconst_gs: result:=2; aitconst_got: result:=sizeof(pint); diff --git a/compiler/aggas.pas b/compiler/aggas.pas index 51f82d92ad..b6365642e4 100644 --- a/compiler/aggas.pas +++ b/compiler/aggas.pas @@ -127,7 +127,7 @@ implementation ait_const2str : array[aitconst_128bit..aitconst_64bit_unaligned] of string[20]=( #9'.fixme128'#9,#9'.quad'#9,#9'.long'#9,#9'.short'#9,#9'.byte'#9, #9'.sleb128'#9,#9'.uleb128'#9, - #9'.rva'#9,#9'.secrel32'#9,#9'.quad'#9,#9'.long'#9,#9'.short'#9, + #9'.rva'#9,#9'.secrel32'#9,#9'.quad'#9,#9'.long'#9,#9'.short'#9,#9'.short'#9, #9'.short'#9,#9'.long'#9,#9'.quad'#9 ); @@ -919,6 +919,7 @@ implementation aitconst_darwin_dwarf_delta32, aitconst_darwin_dwarf_delta64, aitconst_half16bit, + aitconst_gs, aitconst_16bit_unaligned, aitconst_32bit_unaligned, aitconst_64bit_unaligned: @@ -995,6 +996,8 @@ implementation {$endif cpu64bitaddr} if constdef = aitconst_half16bit then s:='('+s+')/2'; + if constdef = aitconst_gs then + s:='gs('+s+')'; AsmWrite(s); inc(l,length(s)); diff --git a/compiler/assemble.pas b/compiler/assemble.pas index 6cbb7055a6..25ebaffadd 100644 --- a/compiler/assemble.pas +++ b/compiler/assemble.pas @@ -1665,11 +1665,12 @@ Implementation aitconst_darwin_dwarf_delta32, aitconst_darwin_dwarf_delta64: ObjData.writebytes(Tai_const(hp).value,tai_const(hp).size); - aitconst_half16bit: + aitconst_half16bit, + aitconst_gs: begin tmp:=Tai_const(hp).value div 2; ObjData.writebytes(tmp,2); - end + end; else internalerror(200603254); end; diff --git a/compiler/llvm/agllvm.pas b/compiler/llvm/agllvm.pas index b04246c2fb..1ecb6514a7 100644 --- a/compiler/llvm/agllvm.pas +++ b/compiler/llvm/agllvm.pas @@ -623,7 +623,8 @@ implementation aitconst_secrel32_symbol, aitconst_darwin_dwarf_delta32, aitconst_darwin_dwarf_delta64, - aitconst_half16bit: + aitconst_half16bit, + aitconst_gs: internalerror(2014052901); aitconst_128bit, aitconst_64bit, diff --git a/compiler/x86/agx86nsm.pas b/compiler/x86/agx86nsm.pas index aaccfacc4e..c63f5c7672 100644 --- a/compiler/x86/agx86nsm.pas +++ b/compiler/x86/agx86nsm.pas @@ -451,7 +451,7 @@ interface #9'FIXME_128BIT'#9,#9'DQ'#9,#9'DD'#9,#9'DW'#9,#9'DB'#9, #9'FIXME_SLEB128BIT'#9,#9'FIXME_ULEB128BIT'#9, #9'RVA'#9,#9'SECREL32'#9,#9'FIXME_darwin_dwarf_delta64'#9, - #9'FIXME_darwin_dwarf_delta32'#9,#9'FIXME_half16bit'#9, + #9'FIXME_darwin_dwarf_delta32'#9,#9'FIXME_half16bit'#9,#9'FIXME_gs'#9, #9'DW'#9,#9'DD'#9,#9'FIXME_64BIT_UNALIGNED'#9 );