+ implemented some AVR specific intrinsics

git-svn-id: trunk@37544 -
This commit is contained in:
florian 2017-11-01 16:33:34 +00:00
parent 4752b0ef96
commit c7d5525b56
10 changed files with 203 additions and 0 deletions

4
.gitattributes vendored
View File

@ -109,6 +109,7 @@ compiler/avr/aoptcpu.pas svneol=native#text/plain
compiler/avr/aoptcpub.pas svneol=native#text/plain
compiler/avr/aoptcpud.pas svneol=native#text/plain
compiler/avr/avrreg.dat svneol=native#text/plain
compiler/avr/ccpuinnr.inc svneol=native#text/plain
compiler/avr/cgcpu.pas svneol=native#text/plain
compiler/avr/cpubase.pas svneol=native#text/plain
compiler/avr/cpuinfo.pas svneol=native#text/plain
@ -120,6 +121,7 @@ compiler/avr/hlcgcpu.pas svneol=native#text/plain
compiler/avr/itcpugas.pas svneol=native#text/plain
compiler/avr/navradd.pas svneol=native#text/plain
compiler/avr/navrcnv.pas svneol=native#text/plain
compiler/avr/navrinl.pas svneol=native#text/pascal
compiler/avr/navrmat.pas svneol=native#text/plain
compiler/avr/navrmem.pas svneol=native#text/pascal
compiler/avr/navrutil.pas svneol=native#text/pascal
@ -8676,7 +8678,9 @@ rtl/atari/tthread.inc svneol=native#text/plain
rtl/atari/xbios.inc svneol=native#text/plain
rtl/avr/avr.inc svneol=native#text/plain
rtl/avr/cpuh.inc svneol=native#text/plain
rtl/avr/cpuinnr.inc svneol=native#text/plain
rtl/avr/int64p.inc svneol=native#text/plain
rtl/avr/intrinsics.pp svneol=native#text/pascal
rtl/avr/makefile.cpu svneol=native#text/plain
rtl/avr/math.inc svneol=native#text/plain
rtl/avr/set.inc svneol=native#text/plain

19
compiler/avr/ccpuinnr.inc Normal file
View File

@ -0,0 +1,19 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2016 by the Free Pascal development team.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
in_avr_cli = fpc_in_cpu_first,
in_avr_sei = fpc_in_cpu_first+1,
in_avr_wdr = fpc_in_cpu_first+2,
in_avr_sleep = fpc_in_cpu_first+3,
in_avr_nop = fpc_in_cpu_first+4

View File

@ -37,6 +37,7 @@ unit cpunode;
,navradd
,navrmat
,navrcnv
,navrinl
,navrmem
,navrutil,
{ symtable }

106
compiler/avr/navrinl.pas Normal file
View File

@ -0,0 +1,106 @@
{
Copyright (c) 1998-2017 by Florian Klaempfl
Generates AVR inline nodes
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************
}
unit navrinl;
{$i fpcdefs.inc}
interface
uses
node,ninl,ncginl;
type
tavrinlinenode = class(tcginlinenode)
function pass_typecheck_cpu:tnode;override;
function first_cpu : tnode;override;
procedure pass_generate_code_cpu;override;
end;
implementation
uses
compinnr,
aasmdata,
aasmcpu,
symdef,
cgbase,
cpubase;
function tavrinlinenode.pass_typecheck_cpu : tnode;
begin
Result:=nil;
case inlinenumber of
in_avr_nop,
in_avr_sleep,
in_avr_sei,
in_avr_wdr,
in_avr_cli:
begin
CheckParameters(0);
resultdef:=voidtype;
end;
else
Result:=inherited pass_typecheck_cpu;
end;
end;
function tavrinlinenode.first_cpu : tnode;
begin
Result:=nil;
case inlinenumber of
in_avr_nop,
in_avr_sleep,
in_avr_sei,
in_avr_wdr,
in_avr_cli:
begin
expectloc:=LOC_VOID;
resultdef:=voidtype;
end;
else
Result:=inherited first_cpu;
end;
end;
procedure tavrinlinenode.pass_generate_code_cpu;
begin
case inlinenumber of
in_avr_nop:
current_asmdata.CurrAsmList.concat(taicpu.op_none(A_NOP));
in_avr_sleep:
current_asmdata.CurrAsmList.concat(taicpu.op_none(A_SLEEP));
in_avr_sei:
current_asmdata.CurrAsmList.concat(taicpu.op_none(A_SEI));
in_avr_wdr:
current_asmdata.CurrAsmList.concat(taicpu.op_none(A_WDR));
in_avr_cli:
current_asmdata.CurrAsmList.concat(taicpu.op_none(A_CLI));
else
inherited pass_generate_code_cpu;
end;
end;
begin
cinlinenode:=tavrinlinenode;
end.

View File

@ -20,6 +20,9 @@ unit compinnr;
interface
const
fpc_in_cpu_first = 10000;
type
tinlinenumber=(
in_none = -1,
@ -159,6 +162,11 @@ type
{ 3DNow }
{ SSE }
{$if defined(AVR)}
,
{$i ccpuinnr.inc}
{$endif }
);
implementation

19
rtl/avr/cpuinnr.inc Normal file
View File

@ -0,0 +1,19 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2016 by the Free Pascal development team.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
in_avr_cli = fpc_in_cpu_first;
in_avr_sei = fpc_in_cpu_first+1;
in_avr_wdr = fpc_in_cpu_first+2;
in_avr_sleep = fpc_in_cpu_first+3;
in_avr_nop = fpc_in_cpu_first+4;

30
rtl/avr/intrinsics.pp Normal file
View File

@ -0,0 +1,30 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2016 by the Free Pascal development team.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
unit intrinsics;
interface
const
{$i cpuinnr.inc}
procedure avr_cli;[INTERNPROC: in_avr_cli];
procedure avr_sei;[INTERNPROC: in_avr_sei];
procedure avr_wdr;[INTERNPROC: in_avr_wdr];
procedure avr_sleep;[INTERNPROC: in_avr_sleep];
procedure avr_nop;[INTERNPROC: in_avr_nop];
implementation
end.

View File

@ -384,6 +384,7 @@ $(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNIT
endif
endif
ifeq ($(ARCH),avr)
CPU_SPECIFIC_COMMON_UNITS=intrinsics
ifeq ($(SUBARCH),avr25)
CPU_UNITS=attiny44a attiny26 attiny48 attiny10 attiny84a attiny2313 attiny461 attiny43u \
attiny24a attiny88 attiny40 attiny861 attiny85 attiny20 attiny24 attiny9 \
@ -2759,7 +2760,11 @@ iso7185$(PPUEXT) : $(INC)/iso7185.pp $(SYSTEMUNIT)$(PPUEXT)
extpas$(PPUEXT) : $(INC)/extpas.pp dos$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(INC)/extpas.pp
define CPU_UNITS_RULE
ifeq ($(ARCH),avr)
$(1)$(PPUEXT): $(ARCH)/$(1).pp intrinsics$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
else
$(1)$(PPUEXT): $(ARCH)/$(1).pp $(SYSTEMUNIT)$(PPUEXT)
endif
endef
$(foreach unit,$(CPU_UNITS),$(eval $(call CPU_UNITS_RULE,$(unit))))
$(addsuffix $(PPUEXT),$(CPU_UNITS)):
@ -2778,3 +2783,5 @@ ctypes$(PPUEXT) : $(INC)/ctypes.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(INC)/ctypes.pp
fpcylix$(PPUEXT) : fpcylix.pp cthreads$(PPUEXT) cwstring$(PPUEXT) dynlibs$(PPUEXT) objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) fpcylix.pp
intrinsics$(PPUEXT) : $(PROCINC)/intrinsics.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(PROCINC)/intrinsics.pp

View File

@ -96,6 +96,7 @@ endif
endif
ifeq ($(ARCH),avr)
CPU_SPECIFIC_COMMON_UNITS=intrinsics
ifeq ($(SUBARCH),avr25)
CPU_UNITS=attiny44a attiny26 attiny48 attiny10 attiny84a attiny2313 attiny461 attiny43u \
attiny24a attiny88 attiny40 attiny861 attiny85 attiny20 attiny24 attiny9 \
@ -328,7 +329,11 @@ extpas$(PPUEXT) : $(INC)/extpas.pp dos$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
#
define CPU_UNITS_RULE
ifeq ($(ARCH),avr)
$(1)$(PPUEXT): $(ARCH)/$(1).pp intrinsics$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
else
$(1)$(PPUEXT): $(ARCH)/$(1).pp $(SYSTEMUNIT)$(PPUEXT)
endif
endef
$(foreach unit,$(CPU_UNITS),$(eval $(call CPU_UNITS_RULE,$(unit))))
@ -360,3 +365,6 @@ ctypes$(PPUEXT) : $(INC)/ctypes.pp $(SYSTEMUNIT)$(PPUEXT)
fpcylix$(PPUEXT) : fpcylix.pp cthreads$(PPUEXT) cwstring$(PPUEXT) dynlibs$(PPUEXT) objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) fpcylix.pp
intrinsics$(PPUEXT) : $(PROCINC)/intrinsics.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(PROCINC)/intrinsics.pp

View File

@ -151,3 +151,4 @@ const
{ SSE }
fpc_in_cpu_first = 10000;