+ support for the .code directive in arm inline assembler

git-svn-id: trunk@32840 -
This commit is contained in:
florian 2016-01-03 22:08:25 +00:00
parent c3a293b727
commit 37cb35d780
8 changed files with 360 additions and 314 deletions

1
.gitattributes vendored
View File

@ -10832,6 +10832,7 @@ tests/tbs/tb0612.pp svneol=native#text/pascal
tests/tbs/tb0613.pp svneol=native#text/pascal
tests/tbs/tb0614.pp svneol=native#text/pascal
tests/tbs/tb0615.pp svneol=native#text/pascal
tests/tbs/tb0616.pp svneol=native#text/pascal
tests/tbs/tb205.pp svneol=native#text/plain
tests/tbs/tb610.pp svneol=native#text/pascal
tests/tbs/tb613.pp svneol=native#text/plain

View File

@ -347,8 +347,8 @@ interface
asd_ent,asd_ent_end,
{ supported by recent clang-based assemblers for data-in-code }
asd_data_region, asd_end_data_region,
{ .thumb_func for ARM }
asd_thumb_func
{ ARM }
asd_thumb_func,asd_code
);
TAsmSehDirective=(
@ -382,8 +382,9 @@ interface
'ent','end',
{ supported by recent clang-based assemblers for data-in-code }
'data_region','end_data_region',
{ .thumb_func for ARM }
'thumb_func'
{ ARM }
'thumb_func',
'code'
);
sehdirectivestr : array[TAsmSehDirective] of string[16]=(
'.seh_proc','.seh_endproc',

View File

@ -62,7 +62,7 @@ Unit raarmgas;
{ helpers }
cutils,
{ global }
globtype,verbose,
globtype,globals,verbose,
systems,aasmbase,aasmtai,aasmdata,aasmcpu,
{ symtable }
symconst,symsym,
@ -149,12 +149,14 @@ Unit raarmgas;
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);
case s of
'.thumb_func',
'.code',
'.thumb_set':
result:=true
else
Result:=inherited is_targetdirective(s);
end;
end;
@ -1426,6 +1428,7 @@ Unit raarmgas;
end;
end;
procedure tarmattreader.HandleTargetDirective;
var
symname,
@ -1433,24 +1436,35 @@ Unit raarmgas;
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);
case actasmpattern of
'.thumb_set':
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_symbolpair.create(spk_thumb_set,symname,symval));
end
else if actasmpattern='.thumb_func' then
begin
consume(AS_TARGET_DIRECTIVE);
curList.concat(tai_directive.create(asd_thumb_func,''));
end
else
inherited HandleTargetDirective;
curList.concat(tai_symbolpair.create(spk_thumb_set,symname,symval));
end;
'.code':
begin
consume(AS_TARGET_DIRECTIVE);
val:=BuildConstExpression(false,false);
if not(val in [16,32]) then
Message(asmr_e_invalid_code_value);
curList.concat(tai_directive.create(asd_code,tostr(val)));
end;
'.thumb_func':
begin
consume(AS_TARGET_DIRECTIVE);
curList.concat(tai_directive.create(asd_thumb_func,''));
end
else
inherited HandleTargetDirective;
end;
end;
function tarmattreader.is_unified: boolean;
begin
result:=false;

View File

@ -1557,6 +1557,9 @@ Implementation
{$ifdef ARM}
asd_thumb_func:
ObjData.ThumbFunc:=true;
asd_code:
{ ai_directive(hp).name can be only 16 or 32, this is checked by the reader }
ObjData.ThumbFunc:=tai_directive(hp).name='16';
{$endif ARM}
else
internalerror(2010011101);
@ -1700,6 +1703,9 @@ Implementation
asd_thumb_func:
{ ignore for now, but should be added}
;
asd_code:
{ ignore for now, but should be added}
;
else
internalerror(2010011102);
end;

View File

@ -2457,7 +2457,7 @@ cg_f_max_units_reached=06057_F_Maximum number of units ($1) reached for the curr
#
# Assembler reader
#
# 07128 is the last used one
# 07129 is the last used one
#
asmr_d_start_reading=07000_DL_Starting $1 styled assembler parsing
% This informs you that an assembler block is being parsed
@ -2767,7 +2767,8 @@ asmr_e_const16bit_for_segment=07128_E_Not enough space (16 bits required) for th
% Specifying a segment constant for a symbol via the SEG operator requires at
% least 16 bits of space for the segment. This error occurs, if you specify
% less, for example, if you use 'DB SEG symbol' instead of 'DW SEG symbol'.
asmr_e_invalid_code_value=07129_E_Invalid value of .code directive constant
% The ARM assembler only allows the values 16 and 32 to be used as arguments to the .code directive
#
# Assembler/binary writers
#

View File

@ -801,6 +801,7 @@ const
asmr_e_seg_without_identifier=07126;
asmr_e_CODE_or_DATA_without_SEG=07127;
asmr_e_const16bit_for_segment=07128;
asmr_e_invalid_code_value=07129;
asmw_f_too_many_asm_files=08000;
asmw_f_assembler_output_not_supported=08001;
asmw_f_comp_not_supported=08002;
@ -1023,9 +1024,9 @@ const
option_info=11024;
option_help_pages=11025;
MsgTxtSize = 76521;
MsgTxtSize = 76571;
MsgIdxMax : array[1..20] of longint=(
27,99,344,124,96,58,129,32,208,64,
27,99,344,124,96,58,130,32,208,64,
58,20,1,1,1,1,1,1,1,1
);

File diff suppressed because it is too large Load Diff

17
tests/tbs/tb0616.pp Normal file
View File

@ -0,0 +1,17 @@
{ %CPU=arm}
{ %norun }
{ %OPT=-Cparmv5te }
procedure p;
begin
asm
.code 16
bx lr
.code 32
bx lr
end;
end;
begin
end.