Commit Graph

186 Commits

Author SHA1 Message Date
nickysn
c9d2028ebd * handle LOC_(C)SUBSETREG/REF in second_NegNot_assign
* changed the way OP_NEG and OP_NOT are handled in op_reg_ref, in order to be
  consistent with op_reg_reg
* introduced op_reg,op_ref,op_subsetreg,op_subsetref and op_loc for the unary
  operations only (OP_NEG,OP_NOT)

git-svn-id: trunk@45302 -
(cherry picked from commit 0f6ab0de17)

# Conflicts:
#	compiler/cgobj.pas
2021-10-24 12:40:38 +02:00
Károly Balogh
bbbaa39d79 ncginl: another approach to fix the same issue #39184 supposed to address. keep left.resultdef, but try to make the target def always ordinal of an equal size, so it ends up in a data register on m68k
git-svn-id: trunk@39188 -
2018-06-07 06:43:02 +00:00
Károly Balogh
3286623c3c ncginl: revert the previous commit, it seems to cause some issues on other CPUs
git-svn-id: trunk@39186 -
2018-06-07 06:21:46 +00:00
Károly Balogh
42efddc481 ncginl: in inc/dec, do not use left.resultdef as the dest to force a register location, because if left is a pointer, then an ordinal value might get forced into an address register on m68k, which results in a lot of unnecessary register shuffling to complete the operation
git-svn-id: trunk@39184 -
2018-06-07 06:04:19 +00:00
Jonas Maebe
4686f61002 * keep track of the temp position separately from the offset in references,
so that they can still be freed after the reference has been changed
    (e.g. in case of array indexing or record field accesses) (mantis #33628)

git-svn-id: trunk@38814 -
2018-04-22 17:03:16 +00:00
florian
4752b0ef96 + tinlinenode calls cpu specific routines for unknown inline numbers
git-svn-id: trunk@37543 -
2017-11-01 16:33:32 +00:00
florian
8eec29b139 + enable support for a processor specific frac function
* implemented inlined frac support for CPUs with SSE4.1+

git-svn-id: trunk@36281 -
2017-05-21 11:12:59 +00:00
nickysn
efc5e339d0 * use an enum instead of integer constants to represent inline numbers
* compinnr.inc include file converted to a unit
* inline number field size stored in ppu increased from byte to longint
* inlines in the parse tree (when written with the -vp option) now printed with
  their enum name, instead of number

git-svn-id: trunk@36174 -
2017-05-10 14:41:43 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
nickysn
d8ec0eff8e + implemented inline code generation for 64-bit sar (the SarInt64 intrinsic) on
less-than-64-bit CPUs that have a 64-bit OP_SHR/OP_SHL/OP_SAR implementation
  in their cg64 backend code generator. This is enabled only for i386 for now.

git-svn-id: trunk@36022 -
2017-04-30 16:06:34 +00:00
nickysn
ec11864272 * use a native sized int register for the shift count in in_sar_assign_x_y,
in_shl_assign_x_y,in_shr_assign_x_y,in_rol_assign_x_y,in_ror_assign_x_y

git-svn-id: trunk@35857 -
2017-04-20 12:38:54 +00:00
nickysn
599b9e73de * determine correctly whether operand size is 32 or 64 bits for
sar/shl/shr/rol/ror in tcginlinenode.second_AndOrXorShiftRot_assign

git-svn-id: trunk@35783 -
2017-04-12 13:36:42 +00:00
nickysn
f514657e45 + implemented the sar/shl/shr/rol/ror inline modify-in-place nodes; the actual
optimization of "i:=i shl/shr k", etc statements is not performed yet

git-svn-id: trunk@35780 -
2017-04-12 00:41:15 +00:00
nickysn
c6680a32d7 * also support LOC_CREGISTER and LOC_CREFERENCE in in_not_assign_x and in_neg_assign_x
git-svn-id: trunk@35751 -
2017-04-07 21:33:56 +00:00
nickysn
6b43705437 * fixed compiler internal error when the in_not_assign_x/in_neg_assign_x are
applied to a LOC_REGISTER variable

git-svn-id: trunk@35750 -
2017-04-07 19:16:00 +00:00
nickysn
256dc546ac + implemented the in_neg_assign_x and in_not_assign_x inline nodes, which will
be used (TBD in a future commit) for optimizing x:=-x and x:=not x on CPUs
  that support performing these operations directly in memory (such as x86)

git-svn-id: trunk@35749 -
2017-04-07 16:02:40 +00:00
florian
4504648ec1 * initialize maskvalue to fix compilation with -O3+
git-svn-id: trunk@35707 -
2017-04-01 19:03:35 +00:00
nickysn
f19ebe2acf * fixed compiler internal error in the in_[and/or/xor]_assign_x_y inline nodes
when their second parameter is a large 64-bit unsigned constant

git-svn-id: trunk@35684 -
2017-03-29 14:55:07 +00:00
nickysn
fc59649a98 + added inline nodes for handling and/or/xor in place (i.e. x:=x op y, where
op=and/or/xor). They generate more optimal code on certain architectures
  (including x86). The new inline nodes aren't generated by the compiler yet,
  but will be used in the future, at certain optimization levels, whenever the
  pattern x:=x op y is detected by the compiler.

git-svn-id: trunk@35666 -
2017-03-26 23:16:53 +00:00
Jonas Maebe
a25ebbba3e + added volatility information to all memory references
o separate information for reading and writing, because e.g. in a
     try-block, only the writes to local variables and parameters are
     volatile (they have to be committed immediately in case the next
     instruction causes an exception)
   o for now, only references to absolute memory addresses are marked
     as volatile
   o the volatily information is (should be) properly maintained throughout
     all code generators for all archictures with this patch
   o no optimizers or other compiler infrastructure uses the volatility
     information yet
   o this functionality is not (yet) exposed at the language level, it
     is only for internal code generator use right now

git-svn-id: trunk@34996 -
2016-11-27 18:17:37 +00:00
Károly Balogh
c3e68d6b2d inline: implemented the second pass stub calls for inl_int_real nodes
git-svn-id: trunk@34992 -
2016-11-27 17:48:36 +00:00
Jonas Maebe
de465e056b * set the alignment resulting from an aligned() call to the actual natural
alignment of the resultdef rather than to 0 (required for llvm, and
    cleaner since then the code generator knows the actual alignment)

git-svn-id: trunk@34296 -
2016-08-13 14:47:26 +00:00
Jonas Maebe
8917633199 * implement sizeof/typeof completely at the node level, based on
loadvmtaddr and vmt_def
   o give an error when trying to use sizeof on a class/object when
     targeting the JVM (can't get/load the data size there)

git-svn-id: trunk@32764 -
2015-12-27 14:22:06 +00:00
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