Commit Graph

172 Commits

Author SHA1 Message Date
nickysn
85dd9e5789 + added a size parameter to optimize_op_const and do a sign extension of the 'a' parameter up from the specified size, so that things like (i and $ffffffff) get optimized away the same way as (i and -1)
git-svn-id: trunk@26561 -
2014-01-22 15:00:34 +00:00
sergei
4168388235 + SPARC: support 8 and 16-bit arithmetic shifts.
git-svn-id: trunk@26330 -
2013-12-30 23:37:21 +00:00
sergei
63c1a05718 * SPARC: Removed hacks with g1_used that were used for g_intf_wrapper to be operational without initialized reg.allocator, and replaced them with a proper solution (which is basically a clone from MIPS cg).
git-svn-id: trunk@26321 -
2013-12-30 13:08:51 +00:00
sergei
05489d6e05 * SPARC: fixed g_intf_wrapper for non-virtual methods once again, my initial assumption was not correct: a wrapper does not necessarily reference methods from the class that implements the interface, it may be methods from parent classes, which can be located arbitrarily far away in address space.
Now using code from g_external_wrapper, which has no distance limit and is only one instruction longer.

git-svn-id: trunk@26319 -
2013-12-30 11:51:57 +00:00
sergei
bf94257310 * SPARC: simplified and fixed a_load_const_reg method, was generating redundant instructions for constants with non-zero bits 10..12.
git-svn-id: trunk@26318 -
2013-12-30 09:59:41 +00:00
sergei
f8a60522d4 - SPARC: removed 3 code generator methods, they provide no difference in generated code from generic code generator.
git-svn-id: trunk@26307 -
2013-12-29 10:00:09 +00:00
sergei
176d8434e4 * SPARC: completely rewrote PIC-related code, got it twice shorter in source lines and much less instructions in generated code.
+ Enable registers %i0..%i5 and %o7 for use by reg.allocator.

Some notable properties of this implementation are:
  o pi_needs_got flag can be safely set during pass 2, so not setting it occasionally in pass 1 does not result in internal error.
  o Reg.allocator configuration is independent from PIC. If procedure requires GOT, register %l7 is allocated at the prologue, making it unavailable to RA.
  o GOT is stored in fixed %l7 register, but it is trivial to switch over to virtual register.

git-svn-id: trunk@26293 -
2013-12-27 19:53:38 +00:00
sergei
eaba90dda7 * SPARC: since peephole optimizer recognizes only one conditional branching instruction, generate all branches using A_Bxx opcode, and change it to A_FBxx if necessary when writing assembler. This enables optimization of floating-point branches.
* Assembler reader: rewrote branch condition matching part, don't try to match integer suffixes to floating-point branches and vice versa.

git-svn-id: trunk@26290 -
2013-12-27 06:45:49 +00:00
sergei
890d757573 + SPARC: override g_external_wrapper method and emit PIC-safe jump without distance limit. Mantis #25455.
git-svn-id: trunk@26286 -
2013-12-26 07:37:22 +00:00
sergei
e6a9bfdc1d * SPARC, g_concatcopy and g_concatcopy_unaligned: removed strange (probably long outdated) comments and unnecessary operations.
* g_concatcopy: avoid taking address of references if possible.

git-svn-id: trunk@26281 -
2013-12-25 10:45:25 +00:00
sergei
03fb83cc01 * SPARC: fixed PIC interface wrappers for non-virtual methods. The fix uses branching with 8 MB distance limit, but in particular case of interface wrappers this limit applies to code size of a single unit, not to entire program, and is therefore hard enough to reach.
git-svn-id: trunk@26279 -
2013-12-25 08:13:10 +00:00
sergei
65d24e000f * SPARC: generate PIC prologue as recommended by ABI, it does not require FPC_GETGOT helper.
git-svn-id: trunk@26264 -
2013-12-22 14:20:18 +00:00
sergei
5ccdfcf106 * SPARC: optimized a_op_const_reg and a_op_const_reg_reg, take advantage of optimize_op_const functionality.
git-svn-id: trunk@26261 -
2013-12-22 13:54:49 +00:00
sergei
c3fe0c7379 * On SPARC, using shifts for zero-extending to OS_16 is more efficient than ANDing with 65535 (two instructions and no temp registers vs. three instructions and a temp register).
git-svn-id: trunk@26257 -
2013-12-20 19:00:44 +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
paul
51825b6f2e compiler: change ret_in_param to accept tabstractprocdef instead of tproccalloption to allow check more options (required for record constructor implementation)
git-svn-id: trunk@23394 -
2013-01-16 01:14:23 +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
pierre
b145028f35 Allow testing of delayed pi_needs_got by internal error generated if compiler compiled with -dCHECK_PIC
git-svn-id: trunk@22547 -
2012-10-05 14:59:18 +00:00
pierre
d88ef103bb Fix IInterface virtual method helper code for PIC mode (no L7 needed)
git-svn-id: trunk@22500 -
2012-09-28 22:20:32 +00:00
pierre
5bbd9597e0 + Add handling of PIC mode with unlimited GOT size
git-svn-id: trunk@22477 -
2012-09-27 15:45:00 +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
pierre
44f8bb35b7 Override abstract method to abvoid warning at compilation time
git-svn-id: trunk@19579 -
2011-11-03 10:08:37 +00:00
florian
3323f1b3ea * use sra instead of srl when doing overflow checking on sparc, resolves #20396
git-svn-id: trunk@19498 -
2011-10-15 20:26:59 +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
sergei
9608c4eabe * Interface wrappers must be global when linking smart, Mantis #19462. Other targets already have this condition in place.
git-svn-id: trunk@17631 -
2011-06-02 10:49:28 +00:00
florian
bf32e47132 * hopefully fixes broken sparc-solaris building due to r17459
git-svn-id: trunk@17522 -
2011-05-22 08:17:03 +00:00
florian
77f2d6cc0d * introduce usage of TCGInt in the code generator units
git-svn-id: trunk@17459 -
2011-05-14 17:58:23 +00:00
svenbarth
96116a6c3a Several adjustments because virtual methods in helpers are just normal methods and a VMT isn't generated for them either.
* $CPU/cgcpu.pas: disable the generation of VMT loading code
* dbgstabs.pas, dbgdwarf.pas: treat virtual methods of helpers as normal methods
* ncgcal.pas: don't register virtual helper methods for WPO 
* ncgrtti.pas: write virtual helper methods as normal methods to RTTI
* nobj.pas: correctly handle final and override cases in helpers
* pdecvar.pas: property getters
* rautils.pas: no VMT offset in records

git-svn-id: branches/svenbarth/classhelpers@17150 -
2011-03-20 10:41:45 +00:00
paul
b317139006 compiler: fix compilation problems caused by tprocdef._class -> tprocdef.struct rename which was found by make fullcycle
git-svn-id: branches/paul/extended_records@16530 -
2010-12-10 06:50:58 +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
pierre
ca6eabd55d * fi for tw10831 test failure on sparc solaris
git-svn-id: trunk@14453 -
2009-12-20 09:17:36 +00:00
Jonas Maebe
b30b7ee6b1 * fixed alignment initialisation of temprary dst reference in
g_concatcopy_unaligned()

git-svn-id: trunk@14287 -
2009-11-29 15:14:56 +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
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
Jonas Maebe
718694d1d6 * always specify an explicit alignment for tgobj.gettemp (so e.g.
shortstring temps don't get maximum alignment)
  * changed some gettemptyed() calls into gettemp() calls (gettemptyped
    means that this temp can only be used for temps of that type,
    which is necessary for refcounted types but not for floats)

git-svn-id: trunk@12036 -
2008-11-08 22:20:47 +00:00
Jonas Maebe
a23630260b + "weakexternal" support for imported procedures and variables.
the syntax is exactly the same as for "external", except for
    the keyword. It is currently only active for Darwin targets.
    It should also work at least for Linux targets, but only with
    the GNU assembler (which is why it is not activated there)
  + test for this functionality

git-svn-id: trunk@12009 -
2008-11-01 18:38:32 +00:00
florian
1afb1aa9cc + ror/rol functions
+ internal compiler support for ror/rol on i386

git-svn-id: trunk@11466 -
2008-07-27 17:12:32 +00:00
florian
5c18145632 * fix interface wrappers on sparc
git-svn-id: trunk@10999 -
2008-05-18 11:11:30 +00:00
florian
77e5e0525c * experimental sparc interface wrapper patch
git-svn-id: trunk@10991 -
2008-05-17 20:10:35 +00:00
mazen
dec0ba97b0 * Applied patch to fix issue with far call for sparc (bug #11312).
git-svn-id: trunk@10988 -
2008-05-17 19:31:08 +00:00
Jonas Maebe
263984f874 * fixed a_load_ref_reg for OS_S8->OS_16 for ppc32, ppc64 and sparc
(and on ppc64 also for OS_S8->OS_32 and OS_S16->OS_32)
  * adapted tcnvint6 to check for ppc64 OS_S16->OS_32 conversion
    (the old comparison was performed using a 32 bit compare and
     therefore did not notice the wrong result)

git-svn-id: trunk@10705 -
2008-04-18 20:04:55 +00:00
Jonas Maebe
8349cde7db * changed byte/word/longbool to be Delphi-compatible (+ similar changes
for qwordbool) + test:
    o assigning true to such a variable now sets them to $ff/$ffff/$ffffffff
    o these types are now all signed
    o converting an integer type to a byte/word/long/qwordbool using an
      explicit type cast keeps the integer's original value stored in the
      bool, instead of forcing it to ord(true)/ord(false)
    (mantis #10233 and #10613, implemented for all architectures, testsuite
     tested for ppc32, sparc and x86)
  * fixed some places where the rtl depended on longbool(true) having the
    value 1
  * extended several boolean tests (and adapted some to no longer assume
    that byte/word/long/qwordbool(true)=1)
  + support for converting to qwordbool in second_int_to_bool for x86, ppc
    and sparc

git-svn-id: trunk@9898 -
2008-01-24 21:30:55 +00:00
Jonas Maebe
ad5ce1adf4 * fixed a_load_reg_ref: the store size has to depend on the tosize,
not on the fromsize (fixes webtbs/tw10072, and hopefully also
    resolves mantis #8121)

git-svn-id: trunk@9037 -
2007-11-01 13:31:23 +00:00
florian
00d6a03b2c + default code now preserves mm registers
* save|restore_standard_registers => save|restore_registers

git-svn-id: trunk@8954 -
2007-10-27 12:02:28 +00:00
Jonas Maebe
20dbda751a * fixed sparc compilation after addr_lo/hi changes
git-svn-id: trunk@8107 -
2007-07-20 12:30:16 +00:00
Jonas Maebe
085689af60 + support for unaligned stores
* avoid some unnecessary unaligned load sequences

git-svn-id: trunk@7427 -
2007-05-23 12:03:42 +00:00
Jonas Maebe
2b0c01b903 * simplified and fixed a_load_reg_reg()
git-svn-id: trunk@7121 -
2007-04-17 13:35:42 +00:00
peter
d810064e48 * fix shift for 16bit from mazen
git-svn-id: trunk@7091 -
2007-04-12 09:58:21 +00:00
peter
1f7cde0306 * patch from mazen to fix zero extending of register moves where the destination
size is larger than the source size

git-svn-id: trunk@7090 -
2007-04-12 07:11:24 +00:00