Commit Graph

339 Commits

Author SHA1 Message Date
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
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