Commit Graph

308 Commits

Author SHA1 Message Date
nickysn
949210e808 + added min and max functions for Tconstexprint
git-svn-id: branches/i8086@24119 -
2013-04-01 20:23:14 +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
Jeppe Johansen
a8f9b0dac4 Added initial support for the Cortex-M4F FPv4_S16 FPU
git-svn-id: branches/laksen/arm-embedded@22597 -
2012-10-08 20:10:45 +00:00
Jonas Maebe
33f5de990d * fixed indentation
git-svn-id: trunk@22255 -
2012-08-26 21:04:51 +00:00
Jonas Maebe
a2426178dc * don't insert type conversions in add nodes if both arguments are constant
and if the result does not depend on the types of the arguments (to
    prevent "qwordconst>int64const" being turned into
    "int64(qwordconst)>int64const" and thereby potentially change the outcome)
    (mantis #19622)

git-svn-id: trunk@21395 -
2012-05-26 14:14:59 +00:00
Jonas Maebe
06b17111da * also recognize scurrency as an "originally was a 64 bit value" in
try_make_mul32to64()
  * when inserting a 32x32->64 multiplication, change the typeconversions
    of the original nodes into internal type conversions, because they
    may have been currency (e.g., in case of an integer-to-currency
    conversion, which is performed via integer*currency(10000)) and
    since r21097 implicit conversions from currency to ordinal are no
    longer allowed

git-svn-id: trunk@21112 -
2012-04-29 13:13:22 +00:00
Jonas Maebe
834026bfb5 * synchronised with trunk up to r21067
git-svn-id: branches/jvmbackend@21068 -
2012-04-26 21:24:20 +00:00
paul
a26bc50ca6 compiler: change ShortString->(Some)String and AnsiString->(Some)String overload precedence both for variables and string constants, change unicode constant type from widestring to unicodestring (Delphi compatibility)
new ShortString->(Some)String precedence: ShortString, UTF8String, AnsiString, AnsiString(CodePage) and RawByteString, UnicodeString, WideString and other string types
new AnsiString->(Some)String precedence: RawByteString, UTF8String, AnsiString, AnsiString(CodePage), UnicodeString, WideString, ShortString and other string types

The new logic makes UTF8String more preferrable than other AnsiString types, AnsiString more preferrable than other  AnsiStrings(codepage) and also makes UnicodeString more preferrable than WideString.

git-svn-id: trunk@21057 -
2012-04-26 02:33:57 +00:00
Jonas Maebe
8e3d7fe8d3 * fixed genmultistringadd() optimization for jvm and enabled it
* created separate version of fpc_AnsiStr_Concat_multi() after all
    because it contains a punicodechar(unicodestring) typecast, which
    can't be supported on the JVM target (and splitting it out in the
    generic code seems like a bit overkill), and restored original
    generic version of fpc_AnsiStr_Concat_multi() (slightly faster
    than version partially adapted for jvm)

git-svn-id: branches/jvmbackend@20903 -
2012-04-16 20:51:51 +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
Jonas Maebe
d1acb76df8 * don't replace "expr1 or expr1" or "expr1 and expr1" with just "expr1"
if expr1 has sideeffects. This can't be done safely even in case of
    short boolean evaluation, because expr1 may return the inverse the
    second time its called (and "0 or 1" is not the same as "0", and
    neither is "1 and 0"), based on comment by Michael Karcher
  * perform a full string compare when comparing stringconstnodes
    before the string constant labels have been generated (patch by
    Michael Karcher, mantis #21255)

git-svn-id: trunk@20485 -
2012-03-09 20:26:32 +00:00
sergei
eda5511ef9 * Don't widen boolean operands of taddnode if they will be converted to pasbool8 immediately thereafter, doing so only causes generation of useless code. Mantis #20843.
git-svn-id: trunk@20376 -
2012-02-19 18:49:50 +00:00
Jonas Maebe
e2b5ba756d * when comparing two boolean values, convert both to pasbool8 so
that in case of byte/word/long/qwordbool, different "true"
    values all get mapped to true (mantis #20257)

git-svn-id: trunk@19737 -
2011-12-03 22:31:21 +00:00
florian
c12a4989d0 + use cpurox define in the compiler for CPUs having internal ror/rol support
+ optimize (i shl x) or (i shr (bitsizeof(i)-x)) and friends into rol/ror(x,i)

git-svn-id: trunk@19635 -
2011-11-13 18:40:34 +00:00
paul
c1866d5c17 compiler:
- don't pass CP_NONE encoding to internal functions. They handled it as 0 encoding. This will optimize the generated code a bit.
  - convert all king of string/char/pchar constants to local ansistring def if they needs to be passed to rawbytestring type. They should not get a CP_NONE codepage (delphi compatible)
  - don't convert left and right arguments of string concatenation to ansistring type if they are already ansistrings but with different codepage - RTL already handles different codepages in concat routine
  - fix resultdef for ansistring concatenations inside assignments - return def of left assignment operand if it is already ansistring - this reduces amount of unneeded condepage conversions since concat functions can return result in any desired codepage
rtl: remove CP_NONE comparisions from most of RTL functions, replace 0 constant with CP_ACP
tests: add test to check various conversions to RawByteString type

git-svn-id: trunk@19519 -
2011-10-20 09:25:51 +00:00
paul
c6ca9e5091 compiler:
- add helper function getansistringcodepage which returns explicitly set codepage or 0 in other case
  - add helper function getansistringdef which return a def with explicitly set codepage or cansistringtype in other case
  - change tstoreddef.createnai constructor to allow set codepage in constructor
  - don't convert string constants to rawbytestring. if string constant already has a codepage - preserve it or convert to ansistring codepage (delphi compatible)
  - don't perform string conversion from ansistring to strings with explicitly set codepage (by directive or by compiler switch) and vice versa (delphi compatible)
  + test which covers most of the cases

git-svn-id: trunk@19510 -
2011-10-19 02:45:52 +00:00
paul
a99ffb3097 compiler: apply patches from Inoussa and Jonas:
defcmp: Address code paged' string type comparison taking care of the code page
  ncnv: Remove un-needed code page comparison to CP_UTF8, some fixes regarding shortstrings and wide char/string 
  ncon: For the case of tstringconstnode.changestringtype (ncon.pas) where the code page are of CP_NONE or 0 no translation is done as :
    * CP_NONE is compatible to all
    * For 0 the raw bytes are just copied.
 My changes:
  - change ascii2unicode to allow pass source codepage, 
  - convert in both cases when source or destination is UTF8

git-svn-id: trunk@19457 -
2011-10-11 01:21:07 +00:00
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
Jonas Maebe
1fbd8750f2 * preparations to use generic string concatentation/comparison code for JVM
targets:
   o initialize managed temps that are passed as var-parameters to the
     dests-parameter of the concat routines, because they will be read and
     stored in the var-parameter array (they are finalized and hence work
     fine on native targets, but finalization is a nop on the JVM target)
   o do not take the shortcut of comparing with nil when checking for an
     empty ansi/unicodestring on managed VM targets

git-svn-id: branches/jvmbackend@18909 -
2011-08-29 22:59:19 +00:00
Jonas Maebe
b570ddf010 * fixed comparing pointers on the JVM target: typecast both to JLObject rather
than to pchar, since all pointers are compatible with the former but not with
    the latter

git-svn-id: branches/jvmbackend@18908 -
2011-08-29 22:59:15 +00:00
Jonas Maebe
28c20cfc5e * the default string type for the JVM target is no longer automatically
unicodestring = java.lang.String. The reason this was the default in
    the past is that this was the first string type that was implemented,
    and without it being the default most code involving string operations
    would fail. Now the default strings types are the same as for other
    targets
  + new {$modeswitch unicodestrings} directive, that when activated
    *together* with {$h+},
   1) changes char into an alias for widechar
   2) changes string into an alias for unicodestring
   3) changes the preferred string evaluation type (in case of uncertainty)
      to unicodestring
    {$modeswitch unicodestrings} with {$h-} does not change anything at all
    regarding the string type (it still changes the char type)
  + new uuchar unit that redefines char as widechar, and which is automatically
    included by the compiler if {$modeswitch unicodestrings} is enabled

git-svn-id: branches/jvmbackend@18781 -
2011-08-20 08:35:47 +00:00
Jonas Maebe
37aa2d8443 + full support for sets on the JVM target
o sets of enums are handled as JUEnumSet instances, others as JUBitSet
     derivatives (both smallsets and varsets, to make interoperability with
     Java easier)
   o special handling of set constants: these have to be constructed at run
     time. In case of constants in the code, create an internal constsym to
     represent them. These and regular constsyms are then aliased by an
     another internal staticvarsym that is used to initialise them in the
     unit initialisation code.
   o until they are constructed at run time, set constants are encoded as
     constant Java strings (with the characters containing the set bits)
   o hlcgobj conversion of tcginnode.pass_generate_code() for the genjumps
     part (that's the only part of the generic code that's used by the JVM
     target)
   o as far as explicit typecasting support is concerned, currently the
     following ones are supported (both from/to setdefs): ordinal types,
     enums, any other set types (whose size is the same on native targets)
   o enum setdefs also emit signatures
   o overloading routines for different ordinal set types, or for different
     enum set types, is not supported on the JVM target

git-svn-id: branches/jvmbackend@18662 -
2011-08-20 08:22:22 +00:00
Jonas Maebe
466f6751c8 + getpointerdef() function that returns a pointerdef for the passed def.
Multiple calls to getpointerdef() for the same def in a single module
    return the same pointerdef

git-svn-id: branches/jvmbackend@18644 -
2011-08-20 08:20:51 +00:00
Jonas Maebe
b60e50b2b0 - reverted 679f3968901f0d565644d59e046eb25d5402f027, because it requires
support for concat_multi for ansistrings to prevent compilation
    problems there

git-svn-id: branches/jvmbackend@18545 -
2011-08-20 08:09:10 +00:00
Jonas Maebe
e403ddca0c * enabled generic multi-string concatenation optimization now that var
parameters for strings work (although they're not as efficient as
    function results for the JVM target)

git-svn-id: branches/jvmbackend@18535 -
2011-08-20 08:08:05 +00:00
Jonas Maebe
3e5b70d80d * cpu64bitaddr -> cpu64bitalu check to determine whether we need special
handling for 64 add-nodes
  * call the generic ordinal handler for 64 add nodes on the JVM

git-svn-id: branches/jvmbackend@18518 -
2011-08-20 08:06:35 +00:00
Jonas Maebe
d1a1d30e04 * unless compiled with -dnounsupported, the compiler will now accept not
only JVM constructs that are already implemented, but also ones that
    will be supported in the future but that aren't implemented yet (to
    make it easier to already adapt code to the future changes)

git-svn-id: branches/jvmbackend@18498 -
2011-08-20 08:04:51 +00:00
Jonas Maebe
990a4ccb64 - disabled genmultistringadd() for the JVM target for now
git-svn-id: branches/jvmbackend@18479 -
2011-08-20 08:03:19 +00:00
Jonas Maebe
7200245337 + cs_unicodestrings global switch to indicate that the default string type
is unicodestring (does *not* change the type of "char" to "unicodechar"
    (yet)). Not yet (un)selectable via a directive.
  + systems_default_unicodestring set containing systems on which the
    default string type is unicodestring

git-svn-id: branches/jvmbackend@18415 -
2011-08-20 07:57:45 +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