Commit Graph

431 Commits

Author SHA1 Message Date
svenbarth
0e5a598b6a * don't use a vecnode to convert a dynamic array or an array constructor to a pointer as that will lead to problems with range checking if the array should be empty; fixes run of tarray12 with -Cr
git-svn-id: trunk@38368 -
2018-02-27 21:43:21 +00:00
svenbarth
916ff0b92c + extend Concat() with support for dynamic arrays
+ added test

git-svn-id: trunk@37723 -
2017-12-12 19:54:08 +00:00
florian
194c0c7073 * compilation fixed
git-svn-id: trunk@37546 -
2017-11-01 16:54:08 +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
svenbarth
f6a867ef04 * move handling of Concat to tinlinenode so that it can be easily extended for dynamic arrays
+ added test

git-svn-id: trunk@37429 -
2017-10-08 10:39:34 +00:00
svenbarth
b3ee9339b8 * also report the dynamic array "overloads" for the Insert() intrinsics
git-svn-id: trunk@37343 -
2017-09-27 21:18:04 +00:00
svenbarth
c5b33f51f9 * fix for Mantis #32412: correctly handle an incorrect parameter count for Delete() and Insert() intrinsics
+ added tests

git-svn-id: trunk@37342 -
2017-09-27 21:15:00 +00:00
svenbarth
0b02dab684 + new Delphi-compatible intrinsic GetTypeKind() which returns the TTypeKind of a type as a constant value (and thus can be optimized away in If- and Case-statements)
+ added test

git-svn-id: trunk@36875 -
2017-08-11 22:12:53 +00:00
svenbarth
29d9beb40c * initialize datatemp
git-svn-id: trunk@36308 -
2017-05-23 19:27:08 +00:00
svenbarth
72c595eefe + implement support for Insert() for dynamic arrays; the parameter that is inserted can be a dynamic or static array of the same type, an array constructor or a single element of the arrays type; all that is determined based on the second type
+ added test

git-svn-id: trunk@36307 -
2017-05-23 19:11:49 +00:00
nickysn
a7ca75a4b6 * use current node's localswitches field for checking whether range and overflow
checking is on, when handling the inc/dec inline nodes, instead of using
  current_settings.localswitches
* when creating inline nodes in the optloadmodifystore optimization pass, copy
  localswitches from the node, that is being replaced, because otherwise,
  localswitches is copied from current_settings.localswitches at the time the
  new node is created, and that can already be in a different state, since
  optloadmodifystore is performed in a separate pass, after the current
  procedure has already been parsed and in this moment, it reflects the state
  of localswitches after the end of the procedure.
* these two fixes fix a bug, where an internalerror 2017032701 can happen, when
  compiling with -O3 code that turns on and off range/overflow checking in the
  middle of a procedure.

git-svn-id: trunk@36195 -
2017-05-12 14:07:13 +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
987cf2a9cf * fixed a bug in the maxqword check in the Rol/RorQWord(maxqword,x)->maxqword
optimization, which prevented the optimization from ever being performed. This
  should also fix the test failure of tbs/tb0627b.pp on all 64-bit platforms.

git-svn-id: trunk@36071 -
2017-05-03 15:32:48 +00:00
nickysn
f65f0b125a + optimize sar(0,x) to 0 and sar(-1,x) to -1
git-svn-id: trunk@36044 -
2017-05-01 19:12:04 +00:00
nickysn
c028362f31 * added the missing pop directive after the push directive in handle_const_rox
git-svn-id: trunk@36043 -
2017-05-01 18:25:01 +00:00
nickysn
855cd616f0 + optimize rol(0, x) and ror(0, x) to 0; also optimize the case with all ones,
e.g. rol32(ffffffff, x) = ffffffff, etc.

git-svn-id: trunk@36042 -
2017-05-01 18:19:49 +00:00
nickysn
29429cca3c + mask the shift/rotate count value in the rol/ror/sar inline nodes, before
checking for 0, so that things like sar(int32,32) can be optimized to int32,
  just like sar(int32,0)

git-svn-id: trunk@36031 -
2017-05-01 11:45:23 +00:00
nickysn
b17d97050f + also simplify rol(x,0) and ror(x,0) to x
git-svn-id: trunk@36024 -
2017-04-30 20:45:51 +00:00
nickysn
8ac84ce43a + simplify sar(x,0) to x
git-svn-id: trunk@36023 -
2017-04-30 20:24:44 +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
5393daa994 + added compile time const evaluation for Bsf/Bsr(const) as well
git-svn-id: trunk@35941 -
2017-04-24 20:35:08 +00:00
nickysn
32395bbcbb + added compile time const evaluation optimization for PopCnt(const)
git-svn-id: trunk@35937 -
2017-04-24 16:11:43 +00:00
nickysn
d7c8a081a1 + enable using the cg64 ops OP_SHR/OP_SHL/OP_SAR on i386 for implementing the
64-bit in_sar/shl/shr_assign_x_y inline nodes

git-svn-id: trunk@35835 -
2017-04-18 14:36:41 +00:00
nickysn
b14f277e8f + use rtl helpers for 64-bit shl/shr/sar/rol/ror modify in place operations, on
platforms that don't have native 64-bit implementation of the corresponding
  64-bit shift/rotate operation

git-svn-id: trunk@35787 -
2017-04-13 15:24:32 +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
8d885ffde6 + write the inlinenumber of inline nodes in the node tree
git-svn-id: trunk@35764 -
2017-04-10 14:54:50 +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
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
florian
6d6a45c034 * add/sub nodes with nf_internal set should not do overflow checking, resolves #30889
* do not convert succ/pred into add/sub nodes if nf_internal is set

git-svn-id: trunk@34896 -
2016-11-13 21:18:39 +00:00
florian
a705525e9b * allow prec/succ on non-consecutive enums if pred/succ are generated internally
git-svn-id: trunk@34813 -
2016-11-06 15:22:39 +00:00
florian
0bc1e7e23b * "inherit" the nf_internal flag in tinlinenode.getaddsub_for_incdec
git-svn-id: trunk@34802 -
2016-11-05 23:06:06 +00:00
florian
64e2c2b914 + simplify succ/pred(<const>/x+/-x<const>)
git-svn-id: trunk@34798 -
2016-11-05 23:06:00 +00:00
florian
000cffa8e3 * make more use of nf_internal to avoid range check errors
git-svn-id: trunk@34793 -
2016-11-05 23:05:51 +00:00
florian
e4d60b2048 * factored out tinlinenode.getaddsub_for_incdec from first_IncDec so it can be used independently
* get varstate right of inc/dec nodes which are converted into add/sub nodes

git-svn-id: trunk@34792 -
2016-11-05 23:05:49 +00:00
florian
9c81e90e08 + extension to iso mode: reset/rewrite can take a file name as a second parameter
git-svn-id: trunk@34726 -
2016-10-16 07:55:08 +00:00
nickysn
d6007d650a * use tpointerdef.pointer_arithmetic_int/uint_type in tinlinenode.pass_typecheck
for handling inc/dec(pointer, int)

git-svn-id: trunk@34655 -
2016-10-08 12:06:57 +00:00
nickysn
e847971477 * use the actual ValSInt type from the system unit, instead of ptrsinttype when
handling the code parameter of val()

git-svn-id: trunk@34608 -
2016-10-03 21:45:08 +00:00
svenbarth
26a2ddd3d6 + extend Delete() intrinsics with Delphi compatible support for dynamic arrays. Also fixes Mantis #30306
git-svn-id: trunk@34455 -
2016-09-08 17:15:10 +00:00
svenbarth
17bb29ddc3 Check for tf_winlikewidestring in the target's flags instead of relying on the target being a Windows system when determining whether the system as the WideString type that's separate from UnicodeString
git-svn-id: trunk@33900 -
2016-06-04 08:45:22 +00:00
svenbarth
aaff6d0b97 Allow Delete() and Insert() to be used with generic types as arguments.
+ added test

git-svn-id: trunk@33897 -
2016-06-03 21:45:23 +00:00
svenbarth
a2c9c75e97 Convert Insert() and Delete() to intrinsics in preparation for dynamic array support for these two procedures.
Since overloading compilerprocs does not work each procedure got its own unique name, but they are using the new compilerproc extension to map them to the Insert and Delete symbol so that error messages can be shown with the respective name for the procedure declarations instead of fpc_shortstr_delete for example.

git-svn-id: trunk@33895 -
2016-06-03 21:25:49 +00:00
svenbarth
8c96fbed8f Fix for Mantis #28832
ninl.pas, tinlinenode:
  * pass_typecheck: let code pass on to simplify() for undefineddefs in Low() and High()
  * simplify: create a constant 0 as fallback

+ added test

git-svn-id: trunk@33884 -
2016-06-03 12:14:30 +00:00
Jonas Maebe
abe8d44f37 * changed allocating a temp with type sinttype and size sinttype*dims for
with a ctemprefnode.create_offset() hack into a proper array, because
    the old way does not work at all with LLVM (and is ugly)

git-svn-id: trunk@33724 -
2016-05-20 20:51:38 +00:00
svenbarth
8287773b16 Reverted revision 33036. This feature is too controverse to be left in.
git-svn-id: trunk@33048 -
2016-02-04 19:26:51 +00:00
svenbarth
ed94ca4b24 Add support for IfThen() instrinsic that works like the if-statement in that it evaluates only the expression that is indeed executed.
The result type of the intrinsic is determined by the Then-expression to provide a bit of control. There might however be some situations in which this fails, for this exceptions need to be added (e.g. a constant string needs to be converted to a normal string).

compinnr.inc:
  + add new constant in_ifthen_x_y_z for the IfThen() intrinsic
psystem.pas: 
  + create_intern_symbols: add symbol for IfThen() intrinsic
pexpr.pas:
  * statement_syssym: parse parameters of IfThen() intrinsic and return corresponding inline node
ninl.pas, tinlinenode:
  + new method handle_ifthen() which converts the inline node to an if-node which assigns the expressions to a temp node that is returned
  * pass_typecheck: handle in_ifthen_x_y_z using handle_ifthen()
  * pass_1: in_ifthen_x_y_z does not need a first pass as it's already converted after the typecheck pass

+ added tests

git-svn-id: trunk@33036 -
2016-01-31 14:29:12 +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
svenbarth
74c79803f7 Extend tlocalvarsym with the ability to not register it if needed.
git-svn-id: trunk@32375 -
2015-11-20 11:29:21 +00:00
florian
70b8789262 o basic extended pascal support:
+ automatically loaded helper unit
  * Makefiles adapted
  * mode switch
  * mode switches reorganized
+ TimeStamp support

git-svn-id: trunk@32330 -
2015-11-15 15:13:36 +00:00
Jonas Maebe
2778bf55c7 * add "doregister" parameter to torddef.create, and don't register temporary
defs created in the scanner for evaluating compile time expressions, or in
    the code generator for range checking

git-svn-id: trunk@32046 -
2015-10-13 15:59:06 +00:00