Переглянути джерело

+ AVR: avr_des intrinsic

git-svn-id: trunk@49353 -
florian 4 роки тому
батько
коміт
022a9b210f

+ 2 - 0
.gitattributes

@@ -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

+ 2 - 1
compiler/avr/ccpuinnr.inc

@@ -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
 

+ 2 - 1
compiler/avr/cpubase.pas

@@ -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 }

+ 2 - 1
compiler/avr/itcpugas.pas

@@ -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;

+ 25 - 1
compiler/avr/navrinl.pas

@@ -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;

+ 3 - 1
compiler/avr/raavr.pas

@@ -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}
 

+ 1 - 0
rtl/avr/cpuinnr.inc

@@ -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;

+ 2 - 0
rtl/avr/intrinsics.pp

@@ -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 - 0
tests/test/tdes1.pp

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

+ 10 - 0
tests/test/tdes2.pp

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