+ AVR: avr_des intrinsic

git-svn-id: trunk@49353 -
This commit is contained in:
florian 2021-05-13 09:26:53 +00:00
parent da3eb5c178
commit 022a9b210f
10 changed files with 58 additions and 5 deletions

2
.gitattributes vendored
View File

@ -15011,6 +15011,8 @@ tests/test/tdefault8.pp svneol=native#text/pascal
tests/test/tdefault9.pp svneol=native#text/pascal
tests/test/tdel1.pp svneol=native#text/plain
tests/test/tdel2.pp svneol=native#text/plain
tests/test/tdes1.pp svneol=native#text/pascal
tests/test/tdes2.pp svneol=native#text/pascal
tests/test/tdispinterface1a.pp svneol=native#text/pascal
tests/test/tdispinterface1b.pp svneol=native#text/pascal
tests/test/tdispinterface2.pp svneol=native#text/plain

View File

@ -18,5 +18,6 @@
in_avr_sleep = in_cpu_first+3,
in_avr_nop = in_cpu_first+4,
in_avr_save = in_cpu_first+5,
in_avr_restore = in_cpu_first+6
in_avr_restore = in_cpu_first+6,
in_avr_des = in_cpu_first+7

View File

@ -53,7 +53,8 @@ unit cpubase;
A_LSL,A_LSR,A_ROL,A_ROR,A_ASR,A_SWAP,A_BSET,A_BCLR,A_SBI,A_CBI,
A_SEC,A_SEH,A_SEI,A_SEN,A_SER,A_SES,A_SET,A_SEV,A_SEZ,
A_CLC,A_CLH,A_CLI,A_CLN,A_CLR,A_CLS,A_CLT,A_CLV,A_CLZ,
A_BST,A_BLD,A_BREAK,A_NOP,A_SLEEP,A_WDR,A_XCH);
A_BST,A_BLD,A_BREAK,A_NOP,A_SLEEP,A_WDR,A_XCH,
A_DES);
{ This should define the array of instructions as string }

View File

@ -44,7 +44,8 @@ interface
'lsl','lsr','rol','ror','asr','swap','bset','bclr','sbi','cbi',
'sec','seh','sei','sen','ser','ses','set','sev','sez',
'clc','clh','cli','cln','clr','cls','clt','clv','clz',
'bst','bld','break','nop','sleep','wdr','xch');
'bst','bld','break','nop','sleep','wdr','xch',
'des');
function gas_regnum_search(const s:string):Tregister;
function gas_regname(r:Tregister):string;

View File

@ -40,6 +40,8 @@ unit navrinl;
implementation
uses
verbose,
constexp,
compinnr,
aasmdata,
aasmcpu,
@ -48,6 +50,7 @@ unit navrinl;
hlcgobj,
pass_2,
cgbase, cgobj, cgutils,
ncon,ncal,
cpubase;
procedure tavrinlinenode.second_abs_long;
@ -94,6 +97,18 @@ unit navrinl;
CheckParameters(1);
resultdef:=voidtype;
end;
in_avr_des:
begin
CheckParameters(2);
resultdef:=voidtype;
if not(is_constintnode(tcallparanode(left).paravalue)) then
MessagePos(tcallparanode(left).paravalue.fileinfo,type_e_constant_expr_expected);
if not(is_constboolnode(tcallparanode(tcallparanode(left).nextpara).paravalue)) then
MessagePos(tcallparanode(tcallparanode(left).nextpara).paravalue.fileinfo,type_e_constant_expr_expected);
if (tordconstnode(tcallparanode(left).paravalue).value<0) or
(tordconstnode(tcallparanode(left).paravalue).value>15) then
MessagePos(tcallparanode(left).paravalue.fileinfo,parser_e_range_check_error);
end;
else
Result:=inherited pass_typecheck_cpu;
end;
@ -109,7 +124,8 @@ unit navrinl;
in_avr_sei,
in_avr_wdr,
in_avr_cli,
in_avr_restore:
in_avr_restore,
in_avr_des:
begin
expectloc:=LOC_VOID;
resultdef:=voidtype;
@ -152,6 +168,14 @@ unit navrinl;
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
current_asmdata.CurrAsmList.concat(taicpu.op_const_reg(A_OUT, NIO_SREG, left.location.register));
end;
in_avr_des:
begin
if tordconstnode(tcallparanode(tcallparanode(left).nextpara).paravalue).value=0 then
current_asmdata.CurrAsmList.concat(taicpu.op_none(A_CLH))
else
current_asmdata.CurrAsmList.concat(taicpu.op_none(A_SEH));
current_asmdata.CurrAsmList.concat(taicpu.op_const(A_DES,int64(tordconstnode(tcallparanode(left).paravalue).value)));
end;
else
inherited pass_generate_code_cpu;
end;

View File

@ -256,7 +256,9 @@ unit raavr;
// A_WDR
(numOperands: (1 shl 0); Operands: ((typ: top_none), (typ: top_none))),
// A_XCH
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_Z), (typ: top_reg; rt: rt_all)))
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_Z), (typ: top_reg; rt: rt_all))),
// A_DES
(numOperands: (1 shl 1); Operands: ((typ: top_const; max: 15; min: 0), (typ: top_none)))
);
{$POP}

View File

@ -19,3 +19,4 @@
in_avr_nop = fpc_in_cpu_first+4;
in_avr_save = fpc_in_cpu_first+5;
in_avr_restore = fpc_in_cpu_first+6;
in_avr_des = fpc_in_cpu_first+7;

View File

@ -29,6 +29,8 @@ unit intrinsics;
{ Restores SREG }
procedure avr_restore(old_sreg: byte); [INTERNPROC: in_avr_restore];
procedure avr_des(decrypt: boolean;round: byte);[INTERNPROC: in_avr_des];
implementation
end.

9
tests/test/tdes1.pp Normal file
View File

@ -0,0 +1,9 @@
{ %cpu=avr }
{ %norun }
uses
intrinsics;
begin
avr_des(true,1);
end.

10
tests/test/tdes2.pp Normal file
View File

@ -0,0 +1,10 @@
{ %fail }
{ %cpu=avr }
{ %norun }
uses
intrinsics;
begin
avr_des(true,100);
end.