Commit Graph

353 Commits

Author SHA1 Message Date
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
Jonas Maebe
8d1090269e * synchronised with trunk r25259
git-svn-id: branches/cpstrrtl@25267 -
2013-08-16 11:33:44 +00:00
Jonas Maebe
fb8fb29574 * record/use the code page of string constants typecasted to an ansistring
type with a non-default code page
   TODO: ensure that string constants typecasted to ansistring become
     ansistrings rather than typeless string constants

git-svn-id: trunk@25207 -
2013-08-02 13:23:32 +00:00
Jonas Maebe
29132f45b7 * synchronised with trunk up to r25167 (fixes glib compilation via r25164,
and occasional crashes in executeprocess on libc platforms via r25167)

git-svn-id: branches/cpstrrtl@25169 -
2013-07-24 14:24:49 +00:00
Jonas Maebe
1a560e9875 * when concatenating ansistrings, do not map CP_NONE (rawbytestring) to
CP_ACP (defaultsystemcodepage), because if all input strings have the
    same code page then the result should also have that code page if it's
    assigned to a rawbytestring rather than getting defaultsystemcodepage
  * do not consider empty strings to determine the code page of the result
    in fpc_AnsiStr_Concat_multi(), because that will cause a different
    result than when using a sequence of fpc_AnsiStr_Concat() calls (it
    ignores empty strings to determine the result code page) and it's also
    slower
  * do not consider the run time code page of the destination string in
    fpc_AnsiStr_Concat(_multi)() because Delphi does not do so either. This
    was introduced in r19118, probably to hide another bug
  + test

git-svn-id: branches/cpstrrtl@25143 -
2013-07-19 16:33:14 +00:00
svenbarth
6b34c84704 nadd.pas, taddnode.create_internal:
* Fix formatting of parameters

git-svn-id: trunk@25070 -
2013-07-09 08:51:49 +00:00
svenbarth
fc79d47b09 Fix for Mantis #24651. Allow pointer comparison for internal expressions (in this case check for valid VMT).
nadd.pas, taddnode:
  + add new constructor "create_internal" which adds "nf_internal" to the node's "flags"
  * pass_typecheck_internal: allow pointer comparisons other than "=" and "<>" for nodes which have "nf_internal" set
psub.pas, generate_bodyentry_block:
  * create the addnode using "create_internal" instead of "create" to allow the pointer comparison

+ added test 

git-svn-id: trunk@25069 -
2013-07-09 08:04:11 +00:00
nickysn
d387182bd6 * when doing a pointer comparison on i8086, don't cast a far pointer to a near one (pchar), but use a far one instead
git-svn-id: trunk@24866 -
2013-06-10 20:53:11 +00:00
florian
0e41df598e * merge i8086 branch by Nikolay Nikolov
git-svn-id: trunk@24324 -
2013-04-25 20:23:51 +00:00
nickysn
0473cbf70f * refactored the add node type check pass to handle all native integer sizes with the same common code, without ifdefs
git-svn-id: branches/i8086@24174 -
2013-04-07 11:03:08 +00:00
nickysn
949210e808 + added min and max functions for Tconstexprint
git-svn-id: branches/i8086@24119 -
2013-04-01 20:23:14 +00:00
florian
364f170765 * cosmetic formatting changes
git-svn-id: trunk@24117 -
2013-04-01 19:52:43 +00:00
florian
88455bbb02 * 32 bit comparison normally result in LOC_FLAGS on 16 bit CPUs
git-svn-id: branches/i8086@23875 -
2013-03-16 20:02:36 +00:00
nickysn
d72d496478 * enable cpuneedsmulhelper for the 32-bit multiplication
git-svn-id: branches/i8086@23796 -
2013-03-11 23:43:00 +00:00
nickysn
ded6b87acc 16-bit and 8-bit ALU fixes for int types in taddnode.pass_typecheck_internal
git-svn-id: branches/i8086@23737 -
2013-03-09 01:12:48 +00:00
nickysn
e4d66dd95c i8086 fix for taddnode.pass_typecheck_internal and real types
git-svn-id: branches/i8086@23735 -
2013-03-08 22:56:50 +00:00