Commit Graph

368 Commits

Author SHA1 Message Date
Jonas Maebe
ec5dea1092 * don't perform the "/ const" to "* (1/const)" transformation for comp-typed
expressions, since comp cannot represent fractions (bug reported at
    http://lists.freepascal.org/pipermail/fpc-pascal/2016-June/048234.html )

git-svn-id: trunk@34035 -
2016-06-30 15:33:51 +00:00
Jonas Maebe
2bbab60c92 * when simplifying a constant string concatenation that gets assigned to a
rawbytestring, ensure the resulting constant string does not get CP_NONE
    as codepage, but the default system code page (mantis #30082)

git-svn-id: trunk@33597 -
2016-05-01 13:16:02 +00:00
yury
d4d70d3865 * Evaluate currency constant expressions when the currency type is 64-bit integer. Issue #28749.
git-svn-id: trunk@33334 -
2016-03-26 17:48:50 +00:00
Jonas Maebe
4ae8dcc91e * make the resultdef of left and right equal when comparing a dynarray
with nil (for llvm)

git-svn-id: trunk@32902 -
2016-01-10 14:01:39 +00:00
nickysn
a159ebdbad * fixed comparison of two procvars in the i8086 compact and medium memory models
git-svn-id: trunk@32166 -
2015-10-27 17:24:33 +00:00
nickysn
8eceb73dd4 * also use an 8-bit zero constant for string comparisons with the empty string.
This avoids the unnecessary 32-bit comparison on 16-bit and 8-bit CPUs

git-svn-id: trunk@32103 -
2015-10-20 15:50:02 +00:00
nickysn
a20428f246 * when doing a string comparison that calls an rtl helper, compare the function
result with an 8-bit zero constant (which will be expanded to the native
  integer size by the comparison node), instead of 32-bit zero. This avoids the
  unnecessary 32-bit comparison on 16-bit and 8-bit cpus.

git-svn-id: trunk@32099 -
2015-10-20 01:22:01 +00:00
Jonas Maebe
b22e2ef400 * add "doregister" parameter to tsetdef.create, and don't register temporary
defs created in the scanner for evaluating compile time expressions

git-svn-id: trunk@32048 -
2015-10-13 15:59:12 +00:00
Jonas Maebe
fbacf9682f * rename WinCE softfp compilerproc names to lowercase, needed since r31404
(mantis #28598)

git-svn-id: trunk@31478 -
2015-09-02 09:54:02 +00:00
Jonas Maebe
f402b0d7df * changed getpointerdef() into a tpointerdef.getreusable() class method
o allows removing the ugly x86 hacks

git-svn-id: trunk@31144 -
2015-06-22 08:17:49 +00:00
Jonas Maebe
e9800ad3f9 * make the resultdef of left and right equal when comparing a procvar
with nil (for llvm)

git-svn-id: trunk@30954 -
2015-05-31 16:50:59 +00:00
florian
cfa68be55b * do not use 16 Bit mul helper on avr, the code generator generates
muls and adds. For simple cases this might be cause longer code than a call to a well crafted assembler helper
  but inlining the muls/adds makes register allocation more flexible

git-svn-id: trunk@30739 -
2015-04-27 20:51:32 +00:00
florian
a8e001d4ad * do not warn about disjunct ranges for internally created cmp nodes
git-svn-id: trunk@30269 -
2015-03-21 22:56:30 +00:00
Jonas Maebe
dd2aa17de1 * also allow 64 bit platforms have have a 32x32->64 bit multiplication to
take advantage of this transormation (enables this optimization for
    AArch64)

git-svn-id: trunk@30035 -
2015-02-28 22:31:06 +00:00
florian
ccb01d6196 * allow subtraction/addition of internally generated nodes, resolves #27256
git-svn-id: trunk@29456 -
2015-01-12 20:56:17 +00:00
florian
5c67fcc43f + change always floating point divisions into multiplications if they are a power of two,
this is an exact operation so it is always allowed
* change only divisions by normal numbers into multiplications

git-svn-id: trunk@29085 -
2014-11-16 20:47:38 +00:00
florian
9fdfe4f474 + convert floating point division by a constant into a multiplication if fastmath is turned on
git-svn-id: trunk@29069 -
2014-11-13 21:13:12 +00:00
florian
499dd078e3 + automatically insert fma inlines into floating point code if possible and fastmath is activated
git-svn-id: trunk@28382 -
2014-08-11 20:50:21 +00:00
sergei
0d96963459 * Do not promote integer comparison operations to native size if one side is a constant and its value is within range of opposite side. Instead, cast the constant to type of the opposite side.
Comparisons are already not promoted if sides are equally signed, but this wasn't true for "unsigned vs constant" case, because constants are preferably parsed as signed.
The change considerably improves generated code for i386 and even more considerably for m68k. Tested on i386-win32.

git-svn-id: trunk@28266 -
2014-07-25 21:40:22 +00:00
nickysn
33dac14554 * defutil.get_int_type_for_pointer_arithmetic replaced with a virtual method
tpointerdef.pointer_arithmetic_int_type

git-svn-id: trunk@28258 -
2014-07-24 14:18:57 +00:00
nickysn
bb48761652 * taddnode.pass_typecheck_internal: always pass a tpointerdef to
get_int_type_for_pointer_arithmetic, even when adding a zero-based array with
  a number

git-svn-id: trunk@28257 -
2014-07-24 13:28:19 +00:00
nickysn
6d54046300 * output a proper error message in case number+nil is encountered (just like
it's already done for nil+number and nil-number)

git-svn-id: trunk@28225 -
2014-07-15 22:26:58 +00:00
nickysn
d86a8ebc99 * defutil.get_int_result_type_from_pointer_subtraction moved to a virtual
method tpointerdef.pointer_subtraction_result_type

git-svn-id: trunk@28219 -
2014-07-14 23:30:29 +00:00
nickysn
99c555cea8 + implemented huge pointer subtraction
* the result of far pointer subtraction changed to word (for TP7 compatibility)

git-svn-id: trunk@28218 -
2014-07-13 23:40:43 +00:00
nickysn
2b2224494b * call first_addpointer and first_cmppointer in pass_1 for pchars as well. Fixes
huge pointer arithmetic/comparison on huge pchars.

git-svn-id: trunk@28159 -
2014-07-04 23:58:26 +00:00
nickysn
c8130843b2 * fixed 'cannot convert type' error when comparing two voidhugepointers with
= or <>

git-svn-id: trunk@28158 -
2014-07-04 23:54:47 +00:00
nickysn
e80ecd4d5b + moved handling of pointer comparison in pass_1 to new virtual method
taddnode.first_cmppointer. To be overriden for i8086 huge pointer comparisons.

git-svn-id: trunk@28156 -
2014-07-04 22:47:21 +00:00
nickysn
da77535631 * the handling of pointer arithmetic in pass_1 moved to a new virtual method
taddnode.first_addpointer. This will be overridden in the i8086 code generator
  in order to implement huge pointer arithmetic.

git-svn-id: trunk@28138 -
2014-07-03 13:47:47 +00:00
nickysn
89db1e4118 + add proper int type conversions for huge pointer arithmetic in pass_typecheck
of the add node

git-svn-id: trunk@28094 -
2014-06-27 23:37:08 +00:00
sergei
4c3a4646ec * Fixed floating-point comparisons for softfloat targets (part of Mantis #9362).
git-svn-id: trunk@27584 -
2014-04-15 23:36:21 +00:00
nickysn
4563b2994d + handle constint+pointerconst in taddnode.simplify
git-svn-id: trunk@27491 -
2014-04-06 16:36:09 +00:00
Jonas Maebe
d452686c39 * moved pbestrealtype from symdef to symcpu
git-svn-id: trunk@27441 -
2014-04-01 21:41:37 +00:00
Jonas Maebe
b57c95043f + support overriding tdef/tsym methods with target-specific functionality:
o made all (non-abstract) tdef and tsym constructors virtual
   o added c*def/c*sym classref types for every (non-abstract) t*def/t*sym
     class
   o added cpusym unit for every architecture that derives a tcpu*def/tcpu*sym
     class from the base classes, and initialises the c*def/c*sym classes with
     them. This is done so that the llvm target will be able to derive from
     the tcpu*def/sym classes without umpteen ifdefs, and it also means that
     the WPO can devirtualise everything because the c* variables are only
     initialised with one class type
   o replaced all t*def/t*sym constructor calls with c*def/c*sym constructor
     calls

git-svn-id: trunk@27361 -
2014-03-29 22:31:55 +00:00
nickysn
71720533d7 * fixed the comparison of near pointers in i8086 far data memory models
+ added charfarpointertype and charnearpointertype to symdef
* the system unit compiles in the i8086 compact memory model now

git-svn-id: trunk@27251 -
2014-03-24 00:34:52 +00:00
nickysn
888ecdaee4 * fixed the type conversions of the 'and' operator to be Delphi compatible. Fixes Mantis #25179
git-svn-id: trunk@26882 -
2014-02-25 18:06:29 +00:00
nickysn
83dd2aed4a * refactored the pass_typecheck code for and/or/xor/comparisons, so that the logic is simpler, but still yields exactly the same result
git-svn-id: trunk@26823 -
2014-02-21 14:55:00 +00:00
nickysn
3c332bf276 * not(is_signed(ld) xor is_signed(rd)) changed to (is_signed(ld)=is_signed(rd)) for better readability
git-svn-id: trunk@26817 -
2014-02-19 16:49:03 +00:00
sergei
8b3217815b * When inlining currency (ordinal) multiplication, change resultdef to int64, in order to be consistent with behavior of generic handling. Fixes compilation faliure after r26500, Mantis #25565.
git-svn-id: trunk@26534 -
2014-01-20 17:16:11 +00:00
sergei
a3efd9e1df + Added method taddnode.use_generic_mul64bit, allowing it to inline full 64-bit multiplications, and fixed ARM to comply (it was not checking for possible 32x32 to 64 optimization after detecting a 64-bit operand, so recently added code for 32x32 to 64 bit optimization was inactive).
git-svn-id: trunk@26500 -
2014-01-18 09:59:59 +00:00
nickysn
aec73bce68 * pass the overflow check flag correctly to the 32 and 16-bit mul helpers (on
i8086 and AVR) according to whether overflow checking is enabled (instead of
  always passing 'false')

git-svn-id: trunk@26445 -
2014-01-13 00:45:12 +00:00
nickysn
372e9dfdf1 * improved the readability of the code of taddnode.try_make_mul32to64() even
more by factoring out some of the node tests to nested functions

git-svn-id: trunk@26414 -
2014-01-10 00:22:15 +00:00
nickysn
ac177a445e * use is_64bit() in taddnode.try_make_mul32to64() for better readability
git-svn-id: trunk@26413 -
2014-01-09 18:04:07 +00:00
nickysn
c2ba9ebfe5 + added different mul helpers for the 32 to 64-bit muls, since they can usually
be implemented more efficiently than the 64 to 64-bit ones.

git-svn-id: trunk@26386 -
2014-01-05 03:01:18 +00:00
nickysn
72e526b9b1 * taddnode.pass_1: set correctly expectloc to LOC_JUMP or LOC_FLAGS for compare
nodes on 16/8-bit targets. This fixes (among other things) the conversion of
  booleans to boolean16 or boolean32 on i8086.

git-svn-id: trunk@26341 -
2013-12-31 16:22:24 +00:00
nickysn
4917d8da39 - rm the special case handling of unsigned 32-bit ordinals in taddnode.pass_1,
since it performs exactly the same thing as the generic signed 32-bit handling
  in the else clause (regardless of whether cpuneedsmulhelper is defined or not)

git-svn-id: trunk@26340 -
2013-12-31 15:44:29 +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
florian
99eadb91b3 * run CheckAndWarn to get proper locations for warnings about uninitialized variables
* several fixes to liveness analysis
* get rid of old version defines
+ tests

git-svn-id: trunk@26159 -
2013-12-01 17:01:51 +00:00
florian
d39b9059d6 * improve simplification of arithmetic nodes, based on a patch by Jeppe Johansen
git-svn-id: trunk@25957 -
2013-11-06 21:10:13 +00:00
svenbarth
798bb91e90 Extract tdef.is_related plus its overrides in tobjectdef, trecorddef and tstringdef into a new function def_is_related in unit defcmp.
defcmp.pas:
  + add new function "def_is_related" which combines the "is_related" overloads of "tobjectdef", "trecorddef" and "tstringdef" (it returns "false" for other def types which is what "tdef.is_related" did)
  * compare_defs_ext & compatible_childmethod_resultdef: change call from "x.is_related" to "def_is_related(x,...)"
symtype.pas, tdef:
  - remove "is_related" method
symdef.pas:
  - remove "is_related" in "tobjectdef", "trecorddef" and "tstringdef"
  * tobjectdef.needs_inittable: for checking whether a Corba interface somehow inherits from a IInterface don't use "is_related" anymore (we want to avoid the dependency after all), but mimic the necessary functionality of "def_is_related"
htypechk.pas, nadd.pas, ncal.pas, ncnv.pas, ngtcon.pas, nld.pas, optvirt.pas, pdecobj.pas, pdecvar.pas, pexpr.pas, pgenutil.pas:
  * change call from "x.is_related" to "def_is_related(x,...)"
symtable.pas
  + use unit defcmp
  * change call from "x.is_related" to "def_is_related(x,...)"
jvm/njvmcnv.pas, jvm/njvmflw.pas:
  * change call from "x.is_related" to "def_is_related(x,...)"

git-svn-id: trunk@25847 -
2013-10-25 19:44: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