Commit Graph

277 Commits

Author SHA1 Message Date
florian
a5cdc0cdde * changed check introduced in r19193 into the same method as other locations in nadd.pas do
git-svn-id: trunk@19197 -
2011-09-23 20:34:10 +00:00
florian
bba726ae78 * don't do x*x -> sqr(x) optmization for arm softfloat
git-svn-id: trunk@19193 -
2011-09-23 17:23:35 +00:00
paul
005795495d merge r17552 from cpstrnew branch by inoussa:
*In normal procedure "var" and "out" RawByteString parameters does not accept other string types. Procedures with
"compilerproc" directive or the newly added "rtlproc" directive accept that. Please note that it is up to the
procedure coder to ensure the correctness of the code page in that case. The new directive is needed to handle 
the RTL procedures/functions that are not marked as "compilerproc" such as "UniqueString", "Insert" and "Delete".

*Correct "fpc_ansistr_concat" to handle code page correctly.

*Default "ansitring" type is now created with code page set to "0" instead of "65535". Before that change it was 
impossible to distinguish a "RawByteString" with the default "ansistring". At runtime "ansistring" variable'code
page is set to DefaultSystemCodePage

*UniqueString flavor of "SetLength" has been updated to release memory when shrinked to at least 50%, like ansitring
does.

git-svn-id: trunk@19118 -
2011-09-17 13:52:09 +00:00
paul
4b24a58871 compiler: remove/hide few unused variables
git-svn-id: trunk@18912 -
2011-08-30 01:32:23 +00:00
florian
c855c7a0aa * unified handling of comparison of constant and expression with disjunct ranges of values
* warn if such an expression is encountered
* don't optimize the expression if it has side effects, resolves #17838

git-svn-id: trunk@18275 -
2011-08-19 18:47:37 +00:00
florian
4f6a803c29 + might_have_sideeffects, make use of it when optimizing x*x into sqr(x)
git-svn-id: trunk@18271 -
2011-08-19 09:26:40 +00:00
Jonas Maebe
8c7f1e1013 * only transform multiplication nodes to sqr, not any kind of addnode
(fix for 18252)

git-svn-id: trunk@18263 -
2011-08-18 12:47:41 +00:00
Jonas Maebe
b5fc32750b * check whether both left and right are reals rather than twice whether left
is real before transforming a multiply into an sqr operation (fixes make
    cycle after r18252, don't know where or even how it caused a wrong
    optimization)

git-svn-id: trunk@18257 -
2011-08-18 09:12:13 +00:00
florian
e796a878ca * convert <real x>*<real x> into sqr(<real x>), it might reduces register
pressure and/or memory accesses without a drawback

git-svn-id: trunk@18252 -
2011-08-17 16:00:16 +00:00
pierre
9ec1213be1 * Reorganize code to avoid warnings about unreachable code
git-svn-id: trunk@17868 -
2011-06-29 09:59:06 +00:00
florian
d35d1ed357 + initial support for pascal booleans with sizes 2, 4 and 8
git-svn-id: branches/pasboolxx@17836 -
2011-06-26 15:02:37 +00:00
florian
6e1d5e0aa0 * handle pointer+type param. correctly, resolves #19548
* convert exit(x) into result:=x; exit;, enables further optimizations in the future

git-svn-id: trunk@17829 -
2011-06-25 18:05:49 +00:00
paul
d21bbc4548 compiler: reduce amount of hints and warnings
git-svn-id: trunk@17350 -
2011-04-20 02:58:52 +00:00
florian
cb003b631b * use helper for dword*dword if needed
git-svn-id: branches/avr@17026 -
2011-02-26 20:59:41 +00:00
florian
d5455cf6ac + software multiplication support for OS_16,OS_S16,OS_32,OS_S32
git-svn-id: branches/avr@17020 -
2011-02-26 20:33:01 +00:00
paul
906ca89f4e compiler:
- allow pointermath for pchar, pwidechar, array[] of char and array[] of widechar without pointermath directive, 
  - don't check tpointerdef().has_pointer_math if this is not a tpointerdef

This fixes testsuite regression (tbs/tb0439.pp)

git-svn-id: trunk@16679 -
2011-01-02 04:35:05 +00:00
Jonas Maebe
2222f2c44b * renamed is_class_or_interface_or_dispinterface_or_objc() into
is_implicit_pointer_object_type() to better indicate the purpose of
    that routine, and to avoid having to change its name every time
    a new object type with this property is added

git-svn-id: trunk@16664 -
2010-12-30 15:19:54 +00:00
paul
86d3e41442 compiler: replace MODESWTICH POINTERARITHMETICS with $POINTERMATH directive, disable pointer arithmetic in delphi mode by default (compatible with delphi), enable pointer arithmetic in fpc/objfpc modes as they had it enabled by default before, add has_pointer_math field to tpointerdef to allow pointer arithmetic with such pointer even if pointer math mode is off (delphi compatible) + tests
git-svn-id: trunk@16651 -
2010-12-29 03:24:28 +00:00
Jonas Maebe
769eb3f604 * moved the initialisation of the nodetree and tai class reference constants
from the unit initialisation sections to the variable declaration sections
    to prevent the base units from overriding derived classes (based on patch
    by Hans-Peter Dietrich, mantis #17516)

git-svn-id: trunk@16118 -
2010-10-09 18:52:22 +00:00
Jonas Maebe
94d976bc87 * when simplifying ordinal expressions during inlining, keep the resultdef
that was set during the typecheck pass because typeconversion nodes
    may have been optimised away previously and sometimes the resultdef is
    important (e.g. for the value of callparanodes) (mantis #17458)

git-svn-id: trunk@16101 -
2010-10-07 15:08:52 +00:00
florian
8b1889d033 * now compilation on i386 was broken, fixed
git-svn-id: trunk@15757 -
2010-08-09 20:00:19 +00:00
florian
33c67c7972 * compilation fixed on x86-64
git-svn-id: trunk@15756 -
2010-08-09 19:51:28 +00:00
florian
66571ee4c8 * use extended as default real type in calculations only if fputype=x87
git-svn-id: trunk@15750 -
2010-08-08 16:17:43 +00:00
Jonas Maebe
025ec34e4d + "CExtended" type that is the same as "extended", but conforming to the
properties/behaviour of the equivalent of Extended in C (i.e., to
    "long double" on i386 and x86_64 platforms that support a 10 byte
    long double, and to "double" elsewhere)

git-svn-id: trunk@14912 -
2010-02-14 13:45:58 +00:00
Jonas Maebe
38b1271a21 * fixed wrong range check errors for "qword and constant" after
r14892

git-svn-id: trunk@14904 -
2010-02-13 20:44:03 +00:00
Jonas Maebe
5e1a09f817 * fixed getting the "original" def in taddnode.simplify by stopping at
type conversions for absolute variables (fixes test/tprec13 on, a.o.,
    ppc64 after r14892)

git-svn-id: trunk@14896 -
2010-02-13 11:30:43 +00:00
Jonas Maebe
85984c2d8f * insert proper type conversions when optimising logical operations and
compares by avoiding unnecessary sign extensions (fixes bug reported in
    http://lists.freepascal.org/lists/fpc-pascal/2010-January/023907.html )
  * never throw away int2int type conversions on bitpacked loads, because
    in these cases the proper bits still need to be selected

git-svn-id: trunk@14892 -
2010-02-12 18:13:08 +00:00
paul
009ef9184d compiler: add dispinterfaces to most of places where something is comparing to usual interfaces since they are not very different things
git-svn-id: trunk@14751 -
2010-01-19 15:24:39 +00:00
florian
a58e07df38 * optimize <expr> and/or <expr> if they are equal and boolean
git-svn-id: trunk@14714 -
2010-01-17 14:39:58 +00:00
paul
74cc1e0bab compiler: allow 'as' for dispinterface, allow comparisons of dispinterface and pointers (issue #0015530, issue #0015529)
git-svn-id: trunk@14663 -
2010-01-16 11:37:25 +00:00
florian
c1f3d8dcaa * unified names of system_*/systems_* sets
git-svn-id: trunk@14566 -
2010-01-07 18:16:20 +00:00
Jonas Maebe
335e159c11 Merged revisions 13351-13373,13376-13457 via svnmerge from
svn+ssh://jonas@svn.freepascal.org/FPC/svn/fpc/trunk

git-svn-id: branches/objc@13458 -
2009-07-26 14:31:50 +00:00
Jonas Maebe
63ce04fd00 * set addn resultdef when evaluating constant string concatenation
instead of letting the resulting stringconstn decide for itself
    (mantis #14174)

git-svn-id: trunk@13419 -
2009-07-22 16:16:11 +00:00
Jonas Maebe
5a2ccfff52 --WARNING: start build process with FPC 2.2.4; won't work when
starting with a previous 2.3.1 or compiler built from the objc branch
  + added basic objcprotocol support (only for external protocols
    currently)
     o use in type declaration: "type xp = objcprotocol ... end;"
     o when defining a root class that implements it:
       "type yc = objcclass(xp) ... end" (note: no support yet
       for something like "objcclass(id,xp)" or so)
     o when defining a non-root class that implements a protocol:
       "type zc = objcclass(nsobject,xp) ... end"
     o includes support for "required" and "optional" sections
     o no support yet for the objcprotocol(<protocol>) expression
       that enables getting a class instance representing the
       protocol (e.g., for use with "conformsToProtocol:")
     o message names have to specified in protocol declarations,
       but if an objcclass implements a protocol, the message names do
       not have to be repeated (but if they are, they have to match;
       the same goes when overriding inherited methods)
  + allow specifying the external name of Objective-C classes and
    protocols, since classes and protocols can have the same name
    (and you cannot use the same Pascal identifier in such caseq)
  + added NSObject protocol, and make the NSObject class use it
  + added missing NSObject class methods that have the same name
    as instance methods (added "class" name prefix to avoid clashes)
  * fixed several cases where the compiler did not treat Objective-C
    classes/protocols the same as Object Pascal classes/interfaces
    (a.o., forward declarations, alignment, regvars, several type
     conversions, ...)
  * allow "override" directive in objcclass declarations, and print
    a hint if it's forgotten in an external declaration (because it
    doesn't really matter there, and may make automated header
    conversion harder than necessary) and an error if will be used in
    a non-external declaration (because it is not possible to start
    a new vmt entry-tree in Objective-C, you can only override parent
    methods)
  * reject objcclasses/protocols as parameters to typeof()
  * don't try to test VMT validity of objcclasses/protocols

git-svn-id: branches/objc@13375 -
2009-07-09 20:48:28 +00:00
Jonas Maebe
7e908cb1e3 * forbid "nil +/- ordinal" expressions (Delphi-compatible, and the
expression is meaningless since nil is not a valid address)

git-svn-id: trunk@13205 -
2009-05-27 17:50:55 +00:00
Jonas Maebe
17a7903e60 * fixed evaluating "nil +/- int_const" expressions (mantis #13815)
git-svn-id: trunk@13194 -
2009-05-25 18:34:04 +00:00
Jonas Maebe
79c70c52a7 * store/restore taddnode.resultrealdef to/from the ppufiles, and also
copy/compare it when copying/comparing taddnodes (necessary for inlined
    procedures, mantis #13596)

git-svn-id: trunk@13054 -
2009-04-27 21:03:11 +00:00
Jonas Maebe
626a723f8c * in {$h+} mode, always treat string constants as if they were ansistrings
when determining the result of string concatenations (mantis #13456)

git-svn-id: trunk@13004 -
2009-04-05 17:26:38 +00:00
Jonas Maebe
a00df1033f * changed "Mixing signed expressions and longwords gives a 64bit result"
from warning into a hint (it's not a potential error, but potential
    optimisation advice)

git-svn-id: trunk@12075 -
2008-11-13 19:49:46 +00:00
peter
af437d5beb * refactor the forward type declaration handling, remove
global typecanbeforward and move 'class of ..' parsing
    to ptype

git-svn-id: trunk@12045 -
2008-11-09 22:07:36 +00:00
florian
2e89b30e86 * fixed wrongly written system.$unicodetype type definition
* improved code generation for unicodestrings

git-svn-id: trunk@11776 -
2008-09-14 15:22:32 +00:00
florian
b178b08ba7 Merged revisions 11665-11738 via svnmerge from
http://svn.freepascal.org/svn/fpc/branches/unicodestring

........
  r11665 | florian | 2008-08-30 13:30:17 +0200 (Sat, 30 Aug 2008) | 1 line
  
  * continued to work on unicodestring type support
........
  r11666 | florian | 2008-08-30 19:02:26 +0200 (Sat, 30 Aug 2008) | 2 lines
  
  * expectloc for wide/ansi/unicode strings is LOC_CONSTANT or LOC_REGISTER now
........
  r11667 | florian | 2008-08-30 20:42:37 +0200 (Sat, 30 Aug 2008) | 1 line
  
  * more unicodestring stuff fixed, test results on win32 are already good
........
  r11670 | florian | 2008-08-30 23:21:48 +0200 (Sat, 30 Aug 2008) | 2 lines
  
  * first fixes for unix bootstrapping
........
  r11683 | ivost | 2008-09-01 12:46:39 +0200 (Mon, 01 Sep 2008) | 2 lines
  
      * fixed 64bit bug in iconvenc.pas
........
  r11689 | florian | 2008-09-01 23:12:34 +0200 (Mon, 01 Sep 2008) | 1 line
  
  * fixed several errors when building on unix
........
  r11694 | florian | 2008-09-03 20:32:43 +0200 (Wed, 03 Sep 2008) | 1 line
  
  * fixed unix compilation
........
  r11695 | florian | 2008-09-03 21:01:04 +0200 (Wed, 03 Sep 2008) | 1 line
  
  * bootstrapping fix
........
  r11696 | florian | 2008-09-03 21:07:18 +0200 (Wed, 03 Sep 2008) | 1 line
  
  * more bootstrapping fixed
........
  r11698 | florian | 2008-09-03 22:47:54 +0200 (Wed, 03 Sep 2008) | 1 line
  
  + two missing compiler procs exported
........
  r11701 | florian | 2008-09-04 16:42:34 +0200 (Thu, 04 Sep 2008) | 2 lines
  
  + lazarus project for the linux rtl
........
  r11702 | florian | 2008-09-04 16:43:27 +0200 (Thu, 04 Sep 2008) | 2 lines
  
  + set unicode string procedures
........
  r11707 | florian | 2008-09-04 23:23:02 +0200 (Thu, 04 Sep 2008) | 2 lines
  
  * fixed several type casting stuff
........
  r11712 | florian | 2008-09-05 22:46:03 +0200 (Fri, 05 Sep 2008) | 1 line
  
  * fixed unicodestring compilation on windows after recent unix changes
........
  r11713 | florian | 2008-09-05 23:35:12 +0200 (Fri, 05 Sep 2008) | 1 line
  
  + UnicodeString support for Variants
........
  r11715 | florian | 2008-09-06 20:59:54 +0200 (Sat, 06 Sep 2008) | 1 line
  
  * patch by Martin Schreiber for UnicodeString streaming
........
  r11716 | florian | 2008-09-06 22:22:55 +0200 (Sat, 06 Sep 2008) | 2 lines
  
  * fixed test
........
  r11717 | florian | 2008-09-07 10:25:51 +0200 (Sun, 07 Sep 2008) | 1 line
  
  * fixed typo when converting tunicodestring to punicodechar
........
  r11718 | florian | 2008-09-07 11:29:52 +0200 (Sun, 07 Sep 2008) | 3 lines
  
  * fixed writing of UnicodeString properties
  * moved some helper routines to unicode headers
........
  r11734 | florian | 2008-09-09 22:38:55 +0200 (Tue, 09 Sep 2008) | 1 line
  
  * fixed bootstrapping
........
  r11735 | florian | 2008-09-10 11:25:28 +0200 (Wed, 10 Sep 2008) | 2 lines
  
  * first fixes for persisten unicodestrings
........
  r11736 | florian | 2008-09-10 14:31:00 +0200 (Wed, 10 Sep 2008) | 3 lines
  
  Initialized merge tracking via "svnmerge" with revisions "1-11663" from 
  http://svn.freepascal.org/svn/fpc/trunk
........
  r11737 | florian | 2008-09-10 21:06:57 +0200 (Wed, 10 Sep 2008) | 3 lines
  
  * fixed unicodestring <-> variant handling
  * fixed unicodestring property reading
........

git-svn-id: trunk@11739 -
2008-09-10 20:14:31 +00:00
yury
491f0fa1d8 * Replaced all user defined warnings by TODO comments to reduce compiler noise.
git-svn-id: trunk@11443 -
2008-07-23 11:00:03 +00:00
yury
fcceb9cfa1 * Removed/ifdefed/commented unused local variables.
git-svn-id: trunk@11430 -
2008-07-20 23:00:31 +00:00
florian
37372fb7ce * fixed copy&paste errors in cpunodefaultint
git-svn-id: trunk@11379 -
2008-07-13 18:15:17 +00:00
florian
0a4314206f * range check error checking for floats refactored
* never throw range/overflow check errors for floats in delphi mode, resolves #7584

git-svn-id: trunk@10940 -
2008-05-11 09:09:21 +00:00
peter
8f239d04b6 * cleanup and simplify the set type handling
git-svn-id: trunk@10432 -
2008-03-02 17:48:27 +00:00
Jonas Maebe
97f4c0a130 * call taddnode.simplify at the very end of taddnode.pass_typecheck, so
it doesn't have to duplicate any type checking code, and so constant
    expressions get the same resultdefs as non-constant expressions
  * properly fixed resultdef determination of "set + setelementn" (follows
    same rules now as "set + set")
  * also convert "longint or/xor cardinal" to int64 (needed for correct
    results with negative numbers and Delphi-compatible) + test
  * extended 64-to-32 type conversion simplification to also handle
    or/xor nodes (so if the result is typecasted back to 32 bit, the
    evaluation can still be done entirely in 32 bit). These changes also
    enable that optimization in some extra cases (not just anymore for
    expressions containing only uint32)

git-svn-id: trunk@10418 -
2008-03-01 20:48:50 +00:00
florian
5826b9bdad + define cpunodefaultint
git-svn-id: trunk@10415 -
2008-03-01 20:31:56 +00:00
Jonas Maebe
59ca0153e7 * moved transformation of "mul by power-of-2" to shl from type check
pass to pass 1 (where most optimizing transformations are located,
    and because the way it's written it goes wrong if left and right are
    a constant, and I'm working on moving the simplify code after the
    typechecking code so the resulttype for constant and non-constant
    expressions can be the same)

git-svn-id: trunk@10396 -
2008-02-27 15:56:40 +00:00