Commit Graph

128 Commits

Author SHA1 Message Date
florian
0882c13cb7 * do not move dest to a new register if not needed in tcgavr.g_concatcopy
git-svn-id: trunk@34935 -
2016-11-20 16:07:53 +00:00
Jonas Maebe
0afbe85aab * various memory reference alignment fixes
git-svn-id: trunk@34544 -
2016-09-20 21:43:19 +00:00
Jonas Maebe
aa1be3276f - removed default value of _typ parameter of TAsmData.(Weak)RefAsmSymbol():
it was AT_NONE, which is invalid and should never be used
  * explicitly pass the correct value for all calls to those methods elsewhere
    in the compiler

git-svn-id: trunk@34250 -
2016-08-05 07:09:16 +00:00
Jeppe Johansen
159c28eca8 Fix AVR comparison with zero.
git-svn-id: trunk@32589 -
2015-12-05 15:25:33 +00:00
Jeppe Johansen
5ec4d38231 Add support for ram-less AVR chips and simultanously optimize flash/ram size the initfinal calling sequence.
git-svn-id: trunk@32448 -
2015-11-22 00:37:10 +00:00
Jeppe Johansen
14020b044c Fix bug in gen_load_cgpara_loc for 64bit registers on 8bit architectures.
Added a workaround in a_load_const_reg to allow compilation for AVR.

git-svn-id: trunk@32090 -
2015-10-18 11:36:58 +00:00
Jeppe Johansen
1a285a7d24 Fixed an off-by-one error in a_load_const_cgpara which caused some problems.
Added some minor CG optimizations.

git-svn-id: trunk@32088 -
2015-10-18 11:03:57 +00:00
Jeppe Johansen
7fc3ed2644 Fix a broken OpCp2Op optimization. It needed the added NR_DEFAULTFLAGS allocation to not break subsequent optimizations.
Updated the code for a_load_const_cgpara in case it needed stack parameters. This was completely broken before. Now it should allow things to compile at least.

git-svn-id: trunk@32086 -
2015-10-17 23:29:15 +00:00
florian
af6ffd751f + generate optimized code for shifts/rotates by constants
git-svn-id: trunk@31170 -
2015-06-28 20:28:51 +00:00
Jeppe Johansen
03880c2f74 Added some peephole optimizations, and fixed generic unconditional jump optimizations, for AVR.
Fixed multiplication code generation for AVR controllers without mul instructions.
Added handling of the old interrupt procedure directive such that procedures with that use RETI instead of RET.

git-svn-id: trunk@31030 -
2015-06-13 12:25:11 +00:00
florian
9a5b458d4e * allocate registers properly before icall
* use emit_mov to load registers before icall

git-svn-id: trunk@30758 -
2015-05-02 08:02:17 +00:00
florian
5c8d0d87cd o better code generation for avr:
* omit entry/exit code, if no frame pointer is used, partly fixes issue #27842
  * take advantage of adiw/sbiw
  * make more often use of ldd/std

git-svn-id: trunk@30732 -
2015-04-26 19:39:43 +00:00
florian
1969abec77 * improved code generation in a_op_const_reg_internal and a_op_const_reg_reg
git-svn-id: trunk@30662 -
2015-04-19 12:51:53 +00:00
florian
7f1585b99a * do not save registers for subroutines which never return
* do not generate any exit code for subroutines which never return

git-svn-id: trunk@30657 -
2015-04-19 08:11:28 +00:00
florian
9e51283ae0 + initial a_op_const_reg_reg and a_op_reg_reg_reg implementations to generate optimized 16 Bit multiplications on avr
git-svn-id: trunk@30648 -
2015-04-18 13:53:20 +00:00
florian
8b7a449cf1 * clear r1 after 8 Bit multiplication, resolves #27838
git-svn-id: trunk@30578 -
2015-04-13 20:15:30 +00:00
florian
4d01271944 * due to avr's harvard architecture, loads of code labels need to use the gs(...) macro
git-svn-id: trunk@30559 -
2015-04-12 20:29:13 +00:00
florian
bd803769b8 * fix compilation
git-svn-id: trunk@30554 -
2015-04-12 14:58:41 +00:00
florian
9559dabe51 * function result is in r24:r25
git-svn-id: trunk@30549 -
2015-04-11 21:25:05 +00:00
florian
1ef7e36f3c * some fixes for handling parameters passed on the stack
git-svn-id: trunk@30545 -
2015-04-11 13:56:21 +00:00
florian
03fa8336de o several avr fixes
* handle function result of FPC_MUL_WORD correctly
  * use mov ...,r1 to load a register with zero instead of clr ..., this might enable the register allocator to 
    coalesce these moves in the feature
  * use tst/dec instead of cpi/sub in the shifting loops, this reduces register pressure on r16 and higher

git-svn-id: trunk@30540 -
2015-04-11 11:08:01 +00:00
florian
6a032bee1b * improved code generation for a_load_const_reg and a_op_const_reg
git-svn-id: trunk@30519 -
2015-04-09 20:38:19 +00:00
florian
63bf17440c * use volatile registers first
* fix some range check errors

git-svn-id: trunk@30444 -
2015-04-05 19:17:24 +00:00
Jonas Maebe
61e4a1b811 + added tasmlist parameter to getintparaloc() (needed for llvm)
git-svn-id: trunk@30429 -
2015-04-04 14:29:16 +00:00
Jeppe Johansen
8c105d4c97 Fix off by 8 error.
git-svn-id: trunk@30393 -
2015-03-30 12:03:18 +00:00
florian
873d88ba57 * fix 8 Bit*8 Bit multiplication according to #27737 using modified code supplied by Georg Hieber
git-svn-id: trunk@30381 -
2015-03-29 19:58:30 +00:00
florian
ad995eb121 * use correctly CALL/RCALL and JMP/RJMP on avr, resolves #27738
git-svn-id: trunk@30372 -
2015-03-29 18:26:32 +00:00
Jonas Maebe
b745dcc64c * moved g_external_wrapper() to the hlcg, and also g_intf_wrapper() because
for some platforms it depends on that routine

git-svn-id: branches/hlcgllvm@28492 -
2014-08-19 20:22:54 +00:00
sergei
e4fea2ebc8 * Dummy implementations of a_bit_scan_reg_reg and g_stackpointer_alloc in tcg, removes the need to override these methods in every descendant code generator solely to avoid "constructing a class with abstract method" warning.
git-svn-id: trunk@28175 -
2014-07-06 11:34:04 +00:00
Jeppe Johansen
10522e9779 Disabled a_adjust_sp optimized steps for now.
Integrated proper stack frame calculation.
Changed rjmp to jmp in ATMEGA128 interrupt vectors.

git-svn-id: trunk@26964 -
2014-03-05 19:17:46 +00:00
Jeppe Johansen
2227045e23 Replace forbidden chars in more places in the GAS assembler writer.
Add support for .set and .weak on AVR.
Fix 64 bit negation on AVR.
Add cpu_capabilities to cpuinfo.pas and fixed some peephole optimizations.
Pass >4 byte parameters by reference.

git-svn-id: trunk@26943 -
2014-03-04 08:01:23 +00:00
Jeppe Johansen
e33550b67d Added support for X,Y,and Z register aliases plus low/high forms, and post-incrementation in AVR assembler reader.
Cleaned up parameter and funcretloc information generation in AVR paramanger, and made it closer to GCC's calling convention.
Fixed a number of codegenerator bugs generating invalid or broken instructions: CP operands were swapped, a number of instructions had immediate operands, and stack frame epilogue wasn't complete.
Added a bunch of peephole optimizations that clears the generated code up a lot.

git-svn-id: trunk@26925 -
2014-03-02 15:37:24 +00:00
sergei
9c1f917e3a * a_call_ref functionality cannot be implemented efficiently at code generator level, because references need specific preparations at earlier points. Moved this support to tcgcallnode and its x86 descendants, and got rid of all ifdef's around.
+ x86 targets now directly call procedure variables located in references.
- a_call_ref method removed from tcg and thlcgobj.

git-svn-id: trunk@26666 -
2014-02-03 13:28:56 +00:00
florian
cb48c2afca * some fixes for parameter handling on avr
git-svn-id: trunk@26425 -
2014-01-11 17:02:34 +00:00
florian
4d5119bf1c * fixes several issues which cause warnings by the dfa code when using it to detect uninitialized variables
git-svn-id: trunk@26161 -
2013-12-01 17:02:08 +00:00
Jonas Maebe
69c29a415f * pass the procdef to getintparaloc instead of only the proccalloption, so
that the type of the parameters can be determined automatically
   o added compilerproc declarations for all helpers called in the compiler
     via their assembler name, so we can look up the corresponding procdef

git-svn-id: trunk@23325 -
2013-01-06 15:05:40 +00:00
florian
a3dff44489 + support of 64 bit operations on avr
git-svn-id: trunk@22836 -
2012-10-23 20:15:47 +00:00
Jonas Maebe
7a0ae38700 + also specify the parameter def when allocating a parameter via
getintparaloc + adapted all call sites of getintparaloc. This
    led to a number of additional, related changes:
   o corrected the type information for some getintparaloc parameters
   o don't allocate some intparalocs in cases they aren't used
   o changed "const tvardata" parameter into "constref tvardata" for
     fpc_variant_copy_overwrite to make pass-by-reference semantics
     explicit
   o moved a number of routines that now have to call find_system_type()
     from cgobj to hlcgobj so that cgobj doesn't have to start depending
     on the symtable unit
   o added versions of the cpureg alloc/dealloc methods to hlcgobj that
     call through to their cgobj counter parts, so we can call save/restore
     the cpu registers before/after calling system helpers from hlcgobj
     (not implemented in hlcgobj itself, because all basic register
      allocator functionality is still part of cgobj/cgcpu)

git-svn-id: trunk@21696 -
2012-06-24 15:02:12 +00:00
florian
0e7e45d423 * avoid warnings in the avr code generator
git-svn-id: trunk@20015 -
2012-01-08 20:10:59 +00:00
florian
0066a12974 * makes a_jmp_cond working
git-svn-id: trunk@18969 -
2011-09-04 18:47:08 +00:00
florian
6005ec2c91 + a_jmp_cond implemented
git-svn-id: trunk@18840 -
2011-08-25 18:27:33 +00:00
florian
b0cef1693a * compilation of system unit was broken
git-svn-id: trunk@17972 -
2011-07-10 21:03:55 +00:00
florian
26850e3425 * fix full cycle after adding new boolean types
git-svn-id: branches/pasboolxx@17847 -
2011-06-27 20:11:08 +00:00
florian
5231d109ba * fullcycle fixed
git-svn-id: trunk@17475 -
2011-05-15 19:13:49 +00:00
florian
8cfbb70326 + generic a_cmp_const_reg_label
git-svn-id: branches/avr@17294 -
2011-04-10 18:52:37 +00:00
florian
ebe8078263 * compilation fixed
git-svn-id: branches/avr@17293 -
2011-04-10 18:43:44 +00:00
florian
7b8f3a61d3 + implemented tcgavr.g_flags2reg
git-svn-id: branches/avr@17290 -
2011-04-10 18:39:51 +00:00
florian
ed8d652398 + implemened a_cmp_reg_reg_label
git-svn-id: branches/avr@17289 -
2011-04-10 18:39:07 +00:00
florian
5fd4bb70de * started to implement ref.base parameter for normalize_ref
git-svn-id: branches/avr@17288 -
2011-04-10 18:38:06 +00:00
florian
a0b0b43d0c + implemented tcgavr.a_jmp_name
* updated todos

git-svn-id: branches/avr@17287 -
2011-04-10 18:37:26 +00:00
florian
8d960cb608 + implementation of shifting operations for avr
* handle shl/shr operand size correctly

git-svn-id: branches/avr@17109 -
2011-03-09 19:48:01 +00:00
florian
d4ff3b2eb6 * forgotten file in previous commit
git-svn-id: branches/avr@17107 -
2011-03-09 19:46:42 +00:00
florian
c7e6d07ff0 * fix tavraddnode.second_cmp
* optimized register usage
+ implemented concatcopy for len<16

git-svn-id: branches/avr@17106 -
2011-03-09 19:46:05 +00:00
florian
8f343078fa * optimize moves into movw if possible
* use ldd instruction if possible

git-svn-id: branches/avr@17105 -
2011-03-09 19:42:15 +00:00
florian
de2d504f15 + dedicated getaddressregister so address registers are allocated with size OS_ADDR
* allocate volatile register first
* start with R8 so allocation might be pair wise

git-svn-id: branches/avr@17103 -
2011-03-09 19:40:57 +00:00
florian
a6464c36e3 * push reads the register
* concatcopy for len>=16 implemented

git-svn-id: branches/avr@17102 -
2011-03-09 19:40:07 +00:00
florian
1cc956afc8 + implements tcgavr.a_loadaddr_ref_reg
git-svn-id: branches/avr@17101 -
2011-03-09 19:38:59 +00:00
florian
0302c7181e * AVR: use LDS/LD and STS/ST depending on the reference
git-svn-id: branches/avr@17052 -
2011-02-27 21:13:25 +00:00
florian
93e72b7e8a * fixed normalize_ref
git-svn-id: branches/avr@17045 -
2011-02-27 21:09:41 +00:00
florian
b870a6eff5 * started to fix parameter passing
* fixed entry/exit code generation

git-svn-id: branches/avr@17041 -
2011-02-27 21:05:53 +00:00
florian
7b9276ae8a + implementation of avr rtl helpers
+ avr: fixed writing of constants in assembler
* avr: fixed reading of constants in assembler
* avr: determine used registers at procedure exit properly
* changed project name to ppavr

git-svn-id: branches/avr@17032 -
2011-02-26 21:04:56 +00:00
florian
acac3ce37c * dummy fix for concatcopy
git-svn-id: branches/avr@17028 -
2011-02-26 21:00:58 +00:00
florian
27f1abb58b * clean up and nicer todos
git-svn-id: branches/avr@17023 -
2011-02-26 20:58:13 +00:00
florian
d5455cf6ac + software multiplication support for OS_16,OS_S16,OS_32,OS_S32
git-svn-id: branches/avr@17020 -
2011-02-26 20:33:01 +00:00
florian
ef699b1864 + avr flag and condition handling
git-svn-id: trunk@17016 -
2011-02-26 20:15:03 +00:00
florian
db2600d40b + first primitive concatcopy implementation
+ implemented op_const_reg and load_const_reg
+ implemented op_reg_reg
* set register info values correctly

git-svn-id: trunk@17014 -
2011-02-26 20:13:19 +00:00
florian
fd97ce0109 * removed some arm overlefts
git-svn-id: trunk@17010 -
2011-02-26 20:09:21 +00:00
florian
26ce3cef00 * compilation fixes
* completed a_load_ref_reg
+ implemented procedure entry/exit code generation
+ implemented a_load_reg_ref

git-svn-id: trunk@17009 -
2011-02-26 20:08:23 +00:00
florian
8b245369e1 + implemented normalize_ref
git-svn-id: trunk@17008 -
2011-02-26 20:03:39 +00:00
florian
4cfc5693c5 * fix compilation for avr
* some ideas for avr register management
+ initial implementation of a_load_reg_reg

git-svn-id: trunk@17007 -
2011-02-26 20:02:45 +00:00
Jonas Maebe
283018a3bf * changed tprocdef.funcretloc[] from a tlocation into a tcgpara so it can
represent complex locations (required for full x86-64 ABI support,
    which is not yet implemented) -> lots of special result handling
    code has been removed and replaced by the parameter handling
    routines
  + added support for composite parameters (and hence function
    results) to tcg.a_load_ref_cgpara() (so it can be used for
    handling, e.g., 64 bit parameters on 32 bit platforms)
  * the above fixed writing past the end of allocated memory when
    handling records returned in registers on x86-64 whose size is
    not a multiple of 8 bytes (mantis #16357)
  - removed the x86-64 and PPC specific versions of a_load_ref_cgpara(),
    as they are now handled correctly by the generic version
  * moved the responsibility of allocating tcgpara cpu registers
    (using paramanager.allocparaloc()) from the callers of
    cg.a_load*_cgpara() to the cg.a_load*_cgpara() methods
    themselves (so the register allocation can be done efficiently
    when dealing with function results)
  * for the above, renamed paramanager.alloc/freeparaloc() to
    paramanager.alloc/freecgpara(), and use paramanager.allocparaloc()
    to allocate individual pcgparalocations instead
  * fixed the register size of SSE2 function result registers for
    x86-64 (when used for floating point), which results in removing
    a few superfluous "movs? %xmm0,%xmm0" instructions
  * fixed compilation of paramanagers of avr, m68k and mips after r13695
    and also updated them for these new changes

git-svn-id: trunk@15350 -
2010-05-30 21:12:57 +00:00
Jonas Maebe
9bc15a5f61 * renamed a_param_* to a_load_*_cgpara
git-svn-id: trunk@15305 -
2010-05-22 09:07:21 +00:00
florian
515774b864 * merged armthum branch
-- Zusammenführen der Unterschiede zwischen Projektarchiv-URLs in ».«:
U    rtl/arm/setjump.inc
A    rtl/arm/thumb2.inc
U    rtl/arm/divide.inc
A    rtl/embedded/arm/stm32f103.pp
U    rtl/inc/system.inc
U    compiler/alpha/cgcpu.pas
U    compiler/sparc/cgcpu.pas
U    compiler/i386/cgcpu.pas
U    compiler/ncgld.pas
U    compiler/powerpc/cgcpu.pas
U    compiler/avr/cgcpu.pas
U    compiler/aggas.pas
U    compiler/powerpc64/cgcpu.pas
U    compiler/x86_64/cgcpu.pas
U    compiler/cgobj.pas
U    compiler/psystem.pas
U    compiler/aasmtai.pas
U    compiler/m68k/cgcpu.pas
U    compiler/ncgutil.pas
U    compiler/rautils.pas
U    compiler/arm/raarmgas.pas
U    compiler/arm/armatts.inc
U    compiler/arm/cgcpu.pas
U    compiler/arm/armins.dat
U    compiler/arm/rgcpu.pas
U    compiler/arm/cpubase.pas
U    compiler/arm/agarmgas.pas
U    compiler/arm/cpuinfo.pas
U    compiler/arm/armop.inc
U    compiler/arm/narmadd.pas
U    compiler/arm/aoptcpu.pas
U    compiler/arm/armatt.inc
U    compiler/arm/aasmcpu.pas
U    compiler/systems/t_embed.pas
U    compiler/psub.pas
U    compiler/options.pas

git-svn-id: trunk@13801 -
2009-10-04 09:03:44 +00:00
florian
9856e548ed * avr stuff, work in progress
git-svn-id: trunk@13444 -
2009-07-25 19:31:06 +00:00
florian
60169d34dc * fixed compilation of AVR compiler
git-svn-id: trunk@13342 -
2009-06-27 19:31:24 +00:00
Jonas Maebe
7d459cf12a * the compiler now explicitly keeps track of the minimally guaranteed
alignment for each memory reference (mantis #12137, and
    test/packages/fcl-registry/tregistry1.pp on sparc). This also
    enables better code generation for packed records in many cases.
  o several changes were made to the compiler to minimise the chances
    of accidentally forgetting to set the alignment of memory references
    in the future:
    - reference_reset*() now has an extra alignment parameter
    - location_reset() can now only be used for non LOC_(C)REFERENCE,
      use location_reset_ref() for those (split the tloc enum so the
      compiler can catch errors using range checking)

git-svn-id: trunk@12719 -
2009-02-08 13:00:24 +00:00
florian
5b5895b8ff * small avr compilation fixes
git-svn-id: trunk@12198 -
2008-11-22 09:51:24 +00:00
florian
bc73f9021c Merged revisions 5891-10167,10169-10180 via svnmerge from
http://svn.freepascal.org/svn/fpc/branches/avr

........
  r5891 | florian | 2007-01-11 17:30:12 +0100 (Do, 11 Jan 2007) | 2 lines
  
  + some initial work
........
  r10170 | florian | 2008-02-03 11:02:04 +0100 (So, 03 Feb 2008) | 2 lines
  
  * continued to work on avr port
........
  r10180 | florian | 2008-02-03 15:29:30 +0100 (So, 03 Feb 2008) | 2 lines
  
  + a lot of skeleton code for avr added
........

git-svn-id: trunk@10186 -
2008-02-03 17:21:52 +00:00