diff --git a/compiler/aasmtai.pas b/compiler/aasmtai.pas index 67d84f7288..07774f3da2 100644 --- a/compiler/aasmtai.pas +++ b/compiler/aasmtai.pas @@ -85,7 +85,10 @@ interface {$endif m68k} {$ifdef arm} ait_thumb_func, + ait_thumb_set, {$endif arm} + ait_set, + ait_weak, { used to split into tiny assembler files } ait_cutobject, ait_regalloc, @@ -94,11 +97,13 @@ interface ait_marker, { used to describe a new location of a variable } ait_varloc, - { SEH directives used in ARM,MIPS and x86_64 COFF targets } - ait_seh_directive, +{$ifdef JVM} { JVM only } ait_jvar, { debug information for a local variable } - ait_jcatch { exception catch clause } + ait_jcatch, { exception catch clause } +{$endif JVM} + { SEH directives used in ARM,MIPS and x86_64 COFF targets } + ait_seh_directive ); taiconst_type = ( @@ -187,15 +192,20 @@ interface {$endif m68k} {$ifdef arm} 'thumb_func', + 'thumb_set', {$endif arm} + 'set', + 'weak', 'cut', 'regalloc', 'tempalloc', 'marker', 'varloc', - 'seh_directive', +{$ifdef JVM} 'jvar', - 'jcatch' + 'jcatch', +{$endif JVM} + 'seh_directive' ); type @@ -275,8 +285,11 @@ interface ,ait_stab, ait_function_name, ait_force_line ,ait_regalloc, ait_tempalloc, ait_symbol_end ,ait_ent, ait_ent_end, ait_directive - ,ait_varloc,ait_seh_directive - ,ait_jvar, ait_jcatch]; + ,ait_varloc, +{$ifdef JVM} + ait_jvar, ait_jcatch, +{$endif JVM} + ait_seh_directive]; { ait_* types which do not have line information (and hence which are of type tai, otherwise, they are of type tailineinfo } @@ -288,11 +301,15 @@ interface ait_ent, ait_ent_end, {$ifdef arm} ait_thumb_func, + ait_thumb_set, {$endif arm} + ait_set,ait_weak, ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_real_128bit, ait_symbol, - ait_seh_directive, - ait_jvar,ait_jcatch +{$ifdef JVM} + ait_jvar, ait_jcatch, +{$endif JVM} + ait_seh_directive ]; @@ -790,6 +807,7 @@ interface end; tai_seh_directive_class=class of tai_seh_directive; +{$ifdef JVM} { JVM variable live range description } tai_jvar = class(tai) stackslot: longint; @@ -814,6 +832,30 @@ interface procedure ppuwrite(ppufile:tcompilerppufile);override; end; tai_jcatch_class = class of tai_jcatch; +{$endif JVM} + + tai_set = class(tai) + sym, + value: pshortstring; + constructor create(const asym, avalue: string); + destructor destroy;override; + constructor ppuload(t:taitype;ppufile:tcompilerppufile);override; + procedure ppuwrite(ppufile:tcompilerppufile);override; + end; + +{$ifdef arm} + tai_thumb_set = class(tai_set) + constructor create(const asym, avalue: string); + end; +{$endif arm} + + tai_weak = class(tai) + sym: pshortstring; + constructor create(const asym: string); + destructor destroy;override; + constructor ppuload(t:taitype;ppufile:tcompilerppufile);override; + procedure ppuwrite(ppufile:tcompilerppufile);override; + end; var { array with all class types for tais } @@ -927,6 +969,69 @@ implementation end; + constructor tai_weak.create(const asym: string); + begin + inherited create; + typ:=ait_weak; + sym:=stringdup(asym); + end; + + destructor tai_weak.destroy; + begin + stringdispose(sym); + inherited destroy; + end; + + constructor tai_weak.ppuload(t: taitype; ppufile: tcompilerppufile); + begin + inherited ppuload(t,ppufile); + sym:=stringdup(ppufile.getstring); + end; + + procedure tai_weak.ppuwrite(ppufile: tcompilerppufile); + begin + inherited ppuwrite(ppufile); + ppufile.putstring(sym^); + end; + +{$ifdef arm} + constructor tai_thumb_set.create(const asym, avalue: string); + begin + inherited create(asym, avalue); + typ:=ait_thumb_set; + end; +{$endif arm} + + constructor tai_set.create(const asym, avalue: string); + begin + inherited create; + typ:=ait_set; + sym:=stringdup(asym); + value:=stringdup(avalue); + end; + + destructor tai_set.destroy; + begin + stringdispose(sym); + stringdispose(value); + inherited destroy; + end; + + constructor tai_set.ppuload(t: taitype; ppufile: tcompilerppufile); + begin + inherited ppuload(t,ppufile); + sym:=stringdup(ppufile.getstring); + value:=stringdup(ppufile.getstring); + end; + + procedure tai_set.ppuwrite(ppufile: tcompilerppufile); + begin + inherited ppuwrite(ppufile); + ppufile.putstring(sym^); + ppufile.putstring(value^); + end; + + constructor tai_varloc.create(sym: tsym; loc: tregister); begin inherited Create; @@ -2823,6 +2928,7 @@ implementation begin end; +{$ifdef JVM} {**************************************************************************** tai_jvar @@ -2913,6 +3019,7 @@ implementation ppufile.putasmsymbol(handlerlab); end; +{$endif JVM} begin {$push}{$warnings off} diff --git a/compiler/aggas.pas b/compiler/aggas.pas index c93be5b5a3..3f3bbc3344 100644 --- a/compiler/aggas.pas +++ b/compiler/aggas.pas @@ -1287,7 +1287,19 @@ implementation begin AsmWriteLn(#9'.thumb_func'); end; + ait_thumb_set: + begin + AsmWriteLn(#9'.thumb_set '+tai_thumb_set(hp).sym^+', '+tai_thumb_set(hp).value^); + end; {$endif arm} + ait_set: + begin + AsmWriteLn(#9'.set '+tai_set(hp).sym^+', '+tai_set(hp).value^); + end; + ait_weak: + begin + AsmWriteLn(#9'.weak '+tai_weak(hp).sym^); + end; ait_ent: begin AsmWrite(#9'.ent'#9); diff --git a/compiler/arm/raarmgas.pas b/compiler/arm/raarmgas.pas index 7a9d17d7da..3858bc4ba5 100644 --- a/compiler/arm/raarmgas.pas +++ b/compiler/arm/raarmgas.pas @@ -35,6 +35,7 @@ Unit raarmgas; actwideformat : boolean; function is_asmopcode(const s: string):boolean;override; function is_register(const s:string):boolean;override; + function is_targetdirective(const s: string): boolean; override; procedure handleopcode;override; procedure BuildReference(oper : tarmoperand); procedure BuildOperand(oper : tarmoperand); @@ -43,6 +44,7 @@ Unit raarmgas; procedure BuildOpCode(instr : tarminstruction); procedure ReadSym(oper : tarmoperand); procedure ConvertCalljmp(instr : tarminstruction); + procedure HandleTargetDirective; override; end; @@ -119,6 +121,16 @@ Unit raarmgas; end; end; + function tarmattreader.is_targetdirective(const s: string): boolean; + begin + if s = '.thumb_func' then + result:=true + else if s='.thumb_set' then + result:=true + else + Result:=inherited is_targetdirective(s); + end; + procedure tarmattreader.ReadSym(oper : tarmoperand); var @@ -1205,6 +1217,31 @@ Unit raarmgas; end; end; + procedure tarmattreader.HandleTargetDirective; + var + symname, + symval : String; + val : aint; + symtyp : TAsmsymtype; + begin + if actasmpattern='.thumb_set' then + begin + consume(AS_TARGET_DIRECTIVE); + BuildConstSymbolExpression(true,false,false, val,symname,symtyp); + Consume(AS_COMMA); + BuildConstSymbolExpression(true,false,false, val,symval,symtyp); + + curList.concat(tai_thumb_set.create(symname,symval)); + end + else if actasmpattern='.thumb_func' then + begin + consume(AS_TARGET_DIRECTIVE); + curList.concat(tai_thumb_func.create); + end + else + inherited HandleTargetDirective; + end; + procedure tarmattreader.handleopcode; var diff --git a/compiler/psystem.pas b/compiler/psystem.pas index 1d1e46bf54..d415408b6a 100644 --- a/compiler/psystem.pas +++ b/compiler/psystem.pas @@ -629,14 +629,19 @@ implementation {$endif SPARC} {$ifdef arm} aiclass[ait_thumb_func]:=tai_thumb_func; + aiclass[ait_thumb_set]:=tai_thumb_set; {$endif arm} + aiclass[ait_set]:=tai_set; + aiclass[ait_weak]:=tai_weak; aiclass[ait_cutobject]:=tai_cutobject; aiclass[ait_regalloc]:=tai_regalloc; aiclass[ait_tempalloc]:=tai_tempalloc; aiclass[ait_marker]:=tai_marker; aiclass[ait_seh_directive]:=tai_seh_directive; +{$ifdef JVM} aiclass[ait_jvar]:=tai_jvar; aiclass[ait_jcatch]:=tai_jcatch; +{$endif JVM} end; end. diff --git a/compiler/raatt.pas b/compiler/raatt.pas index c460d4feb0..f167ea873b 100644 --- a/compiler/raatt.pas +++ b/compiler/raatt.pas @@ -53,6 +53,7 @@ unit raatt; AS_ALIGN,AS_BALIGN,AS_P2ALIGN,AS_ASCII, AS_ASCIIZ,AS_LCOMM,AS_COMM,AS_SINGLE,AS_DOUBLE,AS_EXTENDED,AS_CEXTENDED, AS_DATA,AS_TEXT,AS_INIT,AS_FINI,AS_RVA,AS_END, + AS_SET,AS_WEAK,AS_SECTION, {------------------ 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, @@ -66,7 +67,7 @@ unit raatt; { These tokens should be modified accordingly to the modifications } { in the different enumerations. } firstdirective = AS_DB; - lastdirective = AS_END; + lastdirective = AS_SECTION; token2str : array[tasmtoken] of tasmkeyword=( '','Label','LLabel','string','integer', @@ -78,6 +79,7 @@ unit raatt; '.align','.balign','.p2align','.ascii', '.asciz','.lcomm','.comm','.single','.double','.tfloat','.tcfloat', '.data','.text','.init','.fini','.rva','END', + '.set','.weak','.section', 'TYPE','SIZEOF','VMTOFFSET','%','<<','>>','!','&','|','^','~','@','lo','hi', 'directive'); @@ -972,9 +974,13 @@ unit raatt; Function tattreader.Assemble: tlinkedlist; Var hl : tasmlabel; - commname : string; + commname, + symname, + symval : string; lasTSec : TAsmSectiontype; l1,l2 : longint; + symofs : aint; + symtyp : TAsmsymtype; Begin Message1(asmr_d_start_reading,'GNU AS'); firsttoken:=TRUE; @@ -1200,6 +1206,31 @@ unit raatt; BuildRva; end; + AS_SET: + begin + Consume(AS_SET); + BuildConstSymbolExpression(true,false,false, symofs,symname,symtyp); + Consume(AS_COMMA); + BuildConstSymbolExpression(true,false,false, symofs,symval,symtyp); + + curList.concat(tai_set.create(symname,symval)); + end; + + AS_WEAK: + begin + Consume(AS_WEAK); + BuildConstSymbolExpression(true,false,false, l1,symname,symtyp); + curList.concat(tai_weak.create(symname)); + end; + + AS_SECTION: + begin + Consume(AS_SECTION); + new_section(curlist, sec_user, actasmpattern, 0); + //curList.concat(tai_section.create(sec_user, actasmpattern, 0)); + consume(AS_STRING); + end; + AS_TARGET_DIRECTIVE: HandleTargetDirective;