Commit Graph

163 Commits

Author SHA1 Message Date
Jonas Maebe
da696057ab * converted register_maybe_adjust_setbase() to the high level code generator
git-svn-id: trunk@32591 -
2015-12-05 18:03:37 +00:00
Jonas Maebe
67b8aceaee * synchronized with privatetrunk till r30095
git-svn-id: branches/hlcgllvm@30101 -
2015-03-05 20:32:15 +00:00
Jonas Maebe
2ab7f5c35d * moved x86-specific requirements from the generic bsr/bsf code to the
x86 code generator (register size constraints)

git-svn-id: trunk@29984 -
2015-02-23 22:57:18 +00:00
Jonas Maebe
5e339e89e4 * source can also be a LOC_CREGISTER for bsr/bsf
git-svn-id: trunk@29980 -
2015-02-23 22:57:05 +00:00
Jonas Maebe
e8026ad8d3 * fixed the resultdef of length() intrinsic: it's ossinttype rather than
sinttype (they're the same on most platforms, except on 8 bit ones where
    ossinttype is still 16 bit)
  * simplified and documented second_length(), and fixed some (harmless)
    errors in the used tcgsize for the resultdef (it had to be OS_SINT
    rather than OS_INT -- now it's just def_cgsize(resultdef) so it's
    always correct)

git-svn-id: branches/hlcgllvm@28387 -
2014-08-12 18:59:13 +00:00
nickysn
214eaebf99 * fixed length(ansistring/widestring/dynarray) in i8086 far data memory models
git-svn-id: trunk@27673 -
2014-04-27 02:26:35 +00:00
florian
d88d644925 + support for FMA intrinsic: if there is no hardware support, the compiler throws an error.
Currently it is implemented only for x86-CPUs supporting the FMA extension. While it would
  be possible to implement it in software or simulate fma(<single>,<single>,<single>) using
  double operations, it makes no sense in my opinion to do so.

git-svn-id: trunk@27564 -
2014-04-13 19:21:54 +00:00
nickysn
81875346cf * fixed tcginlinenode.second_SizeOfTypeOf for i8086 far data memory models by
using the high level code generator for all operations, that involve pointers

git-svn-id: trunk@27310 -
2014-03-28 00:07:39 +00:00
nickysn
6e9083aa84 * fixed inc/dec with constant truncating the high parts of the constant on
16-bit and 8-bit CPUs

git-svn-id: trunk@26908 -
2014-03-01 10:33:14 +00:00
nickysn
5e0359d389 * 16/8-bit ALU fix for 64-bit pred/succ after r26580
git-svn-id: trunk@26590 -
2014-01-26 15:44:58 +00:00
florian
cb8100bccf * do not reuse registers in prec/succ
git-svn-id: trunk@26580 -
2014-01-25 09:40:48 +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
nickysn
bf07fc077b * specify AT_DATA in all references to the tobjectdef.vmt_mangledname symbol.
This fixes a lot of bugs, related to objects and classes in the i8086 medium
  memory model

git-svn-id: trunk@25794 -
2013-10-15 18:56:27 +00:00
sergei
dac8cbcefc * Handle assigned(x) expressions entirely in first pass by converting them to "x<>nil", indicate that procedure variables should not be called by setting nf_load_procvar flag (which is already used with typeconvnode for exactly the same purpose). This allows to generate better code when assigned(x) is used on right side of assigments. Mantis #24572.
git-svn-id: trunk@25499 -
2013-09-16 14:38:38 +00:00
masta
b81f746e05 Inline Length(DynamicArray)
Up until now a helperfunction was called at runtime. This change inlines
the whole code in the same way Length(AnsiString) works. As dynamic
arrays do not record their length but their highest index, an additional
"OP_ADD" is this case.

git-svn-id: trunk@25227 -
2013-08-07 22:07:08 +00:00
sergei
cc8772cf92 * sizeof(x), typeof(x): if "x" is typenode, request GOT for PIC because a global VMT label will be loaded.
* typeinfo(x): transform into rttinode (which does request GOT) during pass 1, so pass 2 is not needed. 

git-svn-id: trunk@24798 -
2013-06-03 18:07:32 +00:00
Jonas Maebe
2dd75e707e * renamed thlcgobj.tcgsize2orddef to defutil.cgsize_orddef
git-svn-id: trunk@24743 -
2013-06-01 18:28:15 +00:00
nickysn
4d8adbf5ff + implemented Seg() for i8086 (small/tiny memory model)
git-svn-id: branches/i8086@24071 -
2013-03-30 13:04:58 +00:00
florian
b43b4bb455 + pseudo procedure aligned: tells the compiler to assume that the given parameter is naturally aligned, counterpart of unaligned
git-svn-id: trunk@23310 -
2013-01-04 19:13:24 +00:00
florian
b782918434 * first draft to support the popcnt instruction, works so far for x86 with a real popcnt instruction
git-svn-id: trunk@22289 -
2012-09-02 20:59:39 +00:00
Jonas Maebe
89c230c035 * moved assert handling from second to first pass, so that the code generator
knows that the frame pointer needs to be available (and the code is also
    much simpler this way), fixes test/units/system/tassert7 after r21843

git-svn-id: trunk@21869 -
2012-07-11 11:49:47 +00:00
Jonas Maebe
aba6923187 * moved g_test_self() from cgobj to hlcgobj
git-svn-id: trunk@21861 -
2012-07-11 08:25:51 +00:00
masta
bba75a079c Better Code generation for SAR/ROR/ROL inline nodes
The old code forced dst and src to be the same, which is highly x86
specific and creates bad register utilization on other architectures
like arm.

The new version will use more imaginary registers, allowing the register
allocator to do a better job.

I've merged second_sar and second_rox into a single procedure
second_rox_sar because they were very similar.

git-svn-id: trunk@21809 -
2012-07-06 21:33:28 +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
Jonas Maebe
4a730bd053 * fixed source type for location_force_register() when loading second
parameter of inc/dec into a register

git-svn-id: trunk@21338 -
2012-05-19 14:39:29 +00:00
Jonas Maebe
edd42aa42a * moved subsetref/reg and bit_set/test support from cgobj to hlcgobj for
future use by high level code generator targets
   o this in turn required that all a_load*_loc* methods are called via
     hlcg rather than via cg, since a location can be a subsetref/reg and
     and those are no longer handled in tcg
   o that then required moving several force_location_* routines into
     thlcg because they use a_load_loc*, but did not take tdef size
     parameters (which are required by the thlcg a_load_loc* routines)
   o the only practical consequence is that from now on, you have to
     use hlcg.location_force_mem/reg() (fpureg not yet) and
     hlcg.gen_load_loc_cgpara() instead of the removed versions from ncgutil,
     and hlcg.a_load*loc*() instead of cg.a_load*loc* if a subsetref/reg
     might be involved

git-svn-id: trunk@21287 -
2012-05-13 12:33:10 +00:00
Jonas Maebe
aee5380ae0 * merged trunk up to r20882
o support for the new codepage-aware ansistrings in the jvm branch
   o empty ansistrings are now always represented by a nil pointer rather than
     by an empty string, because an empty string also has a code page which
     can confuse code (although this will make ansistrings harder to use
     in Java code)
   o more string helpers code shared between the general and jvm rtl
   o support for indexbyte/word in the jvm rtl (warning: first parameter
     is an open array rather than an untyped parameter there, so
     indexchar(pcharvar^,10,0) will be equivalent to
     indexchar[pcharvar^],10,0) there, which is different from what is
     intended; changing it to an untyped parameter wouldn't help though)
   o default() support is not yet complete
   o calling fpcres is currently broken due to limitations in
     sysutils.executeprocess() regarding handling unix quoting and
     the compiler using the same command lines for scripts and directly
     calling external programs
   o compiling the Java compiler currently requires adding ALLOW_WARNINGS=1
     to the make command line

git-svn-id: branches/jvmbackend@20887 -
2012-04-15 15:54:10 +00:00
paul
27538f21a4 merge r13489 from cpstrnew branch by florian:
* made tcpstr1 work

git-svn-id: trunk@19086 -
2011-09-17 11:21:00 +00:00
paul
8cc22972a0 merge r13488 from cpstrnew branch by florian except ncgcon.pas which has a difficult merge conflict (code moved to another unit which is not at the branch during the revision):
* first batch of patches to make tcpstr1.pp work

git-svn-id: trunk@19085 -
2011-09-17 11:16:45 +00:00
Jonas Maebe
1a23a7cd27 * removed all remaining nounsupported ifdefs (except for the one about
variants)

git-svn-id: branches/jvmbackend@18770 -
2011-08-20 08:34:26 +00:00
Jonas Maebe
1418faf854 * converted tcginlinenode.second_abs_long() to hlcgobj
git-svn-id: branches/jvmbackend@18745 -
2011-08-20 08:32:05 +00:00
Jonas Maebe
6a6ab5beac * converted SAR code to hlcgobj
git-svn-id: branches/jvmbackend@18520 -
2011-08-20 08:06:44 +00:00
Jonas Maebe
694ccf3df3 + dummy support for untyped var/const/out parameters on the JVM target
o includes basic "auto-boxing" infrastructure to support Delphi.NET-
     compatible untyped parameters as described at
     http://hallvards.blogspot.com/2007/10/dn4dp24-net-vs-win32-untyped-parameters.html

git-svn-id: branches/jvmbackend@18510 -
2011-08-20 08:05:54 +00:00
Jonas Maebe
d1a1d30e04 * unless compiled with -dnounsupported, the compiler will now accept not
only JVM constructs that are already implemented, but also ones that
    will be supported in the future but that aren't implemented yet (to
    make it easier to already adapt code to the future changes)

git-svn-id: branches/jvmbackend@18498 -
2011-08-20 08:04:51 +00:00
Jonas Maebe
761ff19c7f * initialise local dynamic array variables to empty arrays rather than
to "nil", so that returning them to Java code does not return a nil
    pointer

git-svn-id: branches/jvmbackend@18417 -
2011-08-20 07:57:55 +00:00
Jonas Maebe
f47689a5fe * enable intercepting passes on tinlinenode(in_new_x); these cannot be
generated from Pascal source code, but they will be generated by the
    JVM backend to construct new array instances

git-svn-id: branches/jvmbackend@18374 -
2011-08-20 07:53:51 +00:00
Jonas Maebe
15aaf36b82 + pred/succ, inc/dec and assigned converted to hlcg
git-svn-id: branches/jvmbackend@18363 -
2011-08-20 07:51:50 +00:00
florian
8e7f39f176 * constant evaluation of ror/rol if they are internally handled, resolves #6300
* renamed rox_x_x to rox_x_y

git-svn-id: trunk@17810 -
2011-06-23 20:54:08 +00:00
Jonas Maebe
04e26bfc85 * corrected version of r16812: code generation is still handled specially
for assigned(), but the type information is now correct so it doesn't
    have to be forced to OS_ADDR anymore

git-svn-id: trunk@16819 -
2011-01-26 14:50:18 +00:00
Jonas Maebe
ed1485c33e - reverted r16812 for now because it breaks building some packages
git-svn-id: trunk@16815 -
2011-01-25 21:46:25 +00:00
Jonas Maebe
b0f3fd2533 * completely handle assigned() in pass_1, replaced second_assigned with
internalerror

git-svn-id: trunk@16812 -
2011-01-25 08:01:14 +00:00
florian
5dae691c96 * implementation of bit scan intrinsics by Richard Vida, resolves #17592
git-svn-id: trunk@16174 -
2010-10-16 15:03:30 +00:00
Jonas Maebe
04a63ea278 * fixed range/overflow checking for succ/pred (mantis #16770)
git-svn-id: trunk@15474 -
2010-06-22 19:15:08 +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
Jonas Maebe
8a1f272c6b * de-tabbed
git-svn-id: trunk@14928 -
2010-02-19 17:19:50 +00:00
florian
dfc2652062 + support of compiler intrinsic sar* using a patch by Benjamin Rosseaux, resolves #15606
git-svn-id: trunk@14834 -
2010-01-31 16:47:01 +00:00
Jonas Maebe
2c3c6d27d3 * fixed range checking for inc/dec when mixing unsigned and signed types
(mantis #14841)
   -> this also makes it impossible now to use constructs such as
    inc(qword_var,-1) with range checking enabled, because that would require
    a conversion to 128 bit for proper evaluation

git-svn-id: trunk@14260 -
2009-11-23 20:01:07 +00:00
Jonas Maebe
0eec337a00 - removed SUPPORT_UNALIGNED, FPC_SUPPORTS_UNALIGNED and FPC_UNALIGNED_FIXED
defines and ifdefs (already all defined by 2.2.4)

git-svn-id: trunk@13581 -
2009-08-23 07:51:26 +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