Commit Graph

149 Commits

Author SHA1 Message Date
sergei
5f2821ee5f * Moved handling of emulated floating point negation into new virtual method tcgunaryminusnode.second_float_emulated. Also changed it into simple flipping of the sign bit, which is how it is defined by IEEE 754, and already done for ARM targets. Relevant ARM-specific parts can now be removed, and m68k code gets significantly better without further efforts.
git-svn-id: trunk@28528 -
2014-08-27 21:16:30 +00:00
sergei
c184d9740c + Implemented target-independent optimization of signed "mod 2**N" as
"sign:=left sar sizeof(left)*8-1; result:=(((left xor sign)-sign) and 2**N-1) xor sign)-sign;"
  This solution yields larger code than one suggested by Mantis #21152, however its speed on i386 is approximately the same, and it is also suitable for all operand sizes, all powers of two and all targets.

git-svn-id: trunk@27891 -
2014-06-07 22:19:10 +00:00
nickysn
a47ab44ec8 * unified the 8-bit and 16-bit alu handling in tshlshrnode.pass_typecheck
git-svn-id: trunk@27642 -
2014-04-23 12:53:31 +00:00
nickysn
7d8fb1833f * 16-bit alu handling in tshlshrnode.pass_typecheck simplified via the use of
get_common_intdef

git-svn-id: trunk@27641 -
2014-04-23 12:43:48 +00:00
nickysn
a17797f3ca * tshlshrnode.simplify: in the case of 16-bit or 8-bit shl/shr, AND the right
side constant with 31 (instead of 15 or 7), because that's how the 16-bit and
  8-bit x86 shl/shr instructions behave (even on 16-bit CPUs like 286). The
  change does not affect 32-bit and 64-bit platforms, because there the shift
  is always done in at least 32 bits.

git-svn-id: trunk@27638 -
2014-04-23 00:23:27 +00:00
nickysn
aa3f450832 * 8/16-bit alu fixes in tnotnode.simplify
git-svn-id: trunk@27636 -
2014-04-22 22:04:31 +00:00
svenbarth
e85075de7f Fix for Mantis #25604.
nmat.pas:
  * correctly disable type checks if one of the arguments for MOD, DIV, SHR, SHL, NOT, -X and +X is a generic type parameter

+ added tests

git-svn-id: trunk@27535 -
2014-04-11 16:43:53 +00:00
florian
6e1bf4d040 * properly simplify not(<const. cbool>), resolves #25255
git-svn-id: trunk@26803 -
2014-02-16 20:20:58 +00:00
florian
cd235d8409 + simplify shl/shr x, if (x mod bitsizeof(left))=0
git-svn-id: trunk@26628 -
2014-01-30 17:34:33 +00:00
florian
27f6fd1c2c * use new shl/shr constant folding (of r26295) only if forinline is set
* explicitly simplify tree after constant propagation

git-svn-id: trunk@26311 -
2013-12-29 14:09:03 +00:00
florian
89663e499b * fold shifting of constants equally to cpus
* test adapted, e.g. 1 shl 63 needs now an explicit cast to qword for the one: qword(1) shl 63

git-svn-id: trunk@26295 -
2013-12-28 20:19:35 +00:00
sergei
6a08ca3f0b * tmoddivnode.firstoptimize improvements/fixes:
* Fixed misplaced parentheses, which were preventing optimization of "unsigned mod power_of_two" into "and" expressions.
  * Handling "signed div power_of_two": properly delete the temp node, removes warnings when compiled with "-dEXTDEBUG". This however requires another temp node for storing the result.
  * Replaced direct calls to "fpc_sarint64" with inline nodes (in_sar_x_y), allowing target-specific optimizations to take place.

git-svn-id: trunk@25877 -
2013-10-28 15:55:13 +00:00
nickysn
1312fd72f2 * tmoddivnode.pass_typecheck: in the case of unsigned div/mod positive_const, check also the upper bound of the const, so it doesn't get truncated
git-svn-id: branches/i8086@24247 -
2013-04-14 21:56:32 +00:00
nickysn
70a0d2989c * fixed tmoddivnode.pass_typecheck on 64-bit CPUs; I was wrong about uint64 div uint64 producing int64 on 64-bit CPUs; this fixes make cycle on e.g. x86_64
git-svn-id: branches/i8086@24226 -
2013-04-11 19:51:01 +00:00
nickysn
7a15fd0444 * in the case of (uint8 div/mod small_positive_const), convert the const to unsigned, so that we don't do a 16-bit division on 8-bit CPUs
git-svn-id: branches/i8086@24209 -
2013-04-08 18:08:10 +00:00
nickysn
3558766390 * first attempt to simplify tmoddivnode.pass_typecheck handling of all cpu native int sizes
git-svn-id: branches/i8086@24208 -
2013-04-08 17:11:33 +00:00
nickysn
0dcbb4f1cc * refactored tunaryplusnode.pass_typecheck as well
git-svn-id: branches/i8086@24185 -
2013-04-07 16:50:30 +00:00
nickysn
a3117beb12 * refactored tunaryminusnode.pass_typecheck to handle all native int sizes generically, without ifdefs
git-svn-id: branches/i8086@24184 -
2013-04-07 16:45:52 +00:00
nickysn
b79569ed2f * Borland Pascal compatibility for 16-bit CPUs: int16 shl int32 now produces int32; this fixes writeln(longint) on the i8086-msdos target
git-svn-id: branches/i8086@24011 -
2013-03-26 00:59:04 +00:00
nickysn
a9640ad9c6 + insert type conversion for the div result when cpuneedsdiv32helper is used
git-svn-id: branches/i8086@23879 -
2013-03-16 23:12:39 +00:00
nickysn
1dbca4c403 * 16-bit ALU fixes in tmoddivnode.pass_typecheck
git-svn-id: branches/i8086@23878 -
2013-03-16 22:50:09 +00:00
nickysn
edc382aa76 * 16-bit ALU fixes in tshlshrnode.pass_typecheck
git-svn-id: branches/i8086@23817 -
2013-03-13 18:00:28 +00:00
nickysn
4ac508a2b9 fixed bug in tunaryplusnode.pass_typecheck introduced in my previous commit r23737
git-svn-id: branches/i8086@23744 -
2013-03-09 14:05:09 +00:00
nickysn
63ac46c74c 16-bit ALU fixes in tunaryminusnode.pass_typecheck and tunaryplusnode.pass_typecheck
git-svn-id: branches/i8086@23743 -
2013-03-09 13:24:42 +00:00
florian
8e5bd14e3a * overleft newline fix
git-svn-id: trunk@23110 -
2012-12-03 21:56:01 +00:00
sergei
12ad6704f6 - Removed a number of unused variables, reduces noise at compilation.
git-svn-id: trunk@22880 -
2012-10-30 11:55:59 +00:00
florian
5e1e42ec2b * fixes support for cpus with cpunodefaultint for unary minus nodes
git-svn-id: trunk@22838 -
2012-10-23 20:27:07 +00:00
Jonas Maebe
9e0184884e * correctly change the signdness information of tordconstnodes that are
simplified via typeconvnode (corrects resultdef of "qword(1) shl 33",
    mantis #22133)
  * simplify shl/shr nodes after their resultdef has been set, so the
    resultdef used during simplify is set (fixes same expression as above
    when it is calculated by an inline function)

git-svn-id: trunk@21394 -
2012-05-26 13:31:23 +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
pierre
7101151b5c Avoid internal error 2002042430 and check overloading before calling simplify method
git-svn-id: trunk@20635 -
2012-03-26 15:44:47 +00:00
Jonas Maebe
3b8ae840c1 * avoid range check errors when inlining not-nodes (mantis #21029)
git-svn-id: trunk@20046 -
2012-01-10 22:23:25 +00:00
florian
4765728fc4 * use SarInt64 to optimize 64 bit divs on 32 bit platforms, resolves #20998
git-svn-id: trunk@19968 -
2012-01-04 22:58:25 +00:00
pierre
da62249d6b * Fix code to avoid use of unitialized rv local variable in tmoddivnode.simplify method
git-svn-id: trunk@19571 -
2011-11-02 11:22:45 +00:00
florian
6ec0f2549a * factored load node flags out of node flags to gain space
+ implemented iso mode mod, resolves #17685

git-svn-id: trunk@19558 -
2011-10-30 15:14:21 +00:00
Jonas Maebe
845f50448c + support for qword div/mod via helper (the JVM only supports signed
64 bit division natively)

git-svn-id: branches/jvmbackend@18523 -
2011-08-20 08:07:02 +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
sergei
2f7c779fa4 * tmoddivnode.simplify: made result definitely assigned and removed local var
* tshlshrnode.simplify: likewise

git-svn-id: trunk@17770 -
2011-06-19 21:48:18 +00:00
tom_at_work
e5fc169e57 * Call fpc_shl/r_qword for qword types for first_shlshr64bitint method
git-svn-id: trunk@17620 -
2011-06-01 06:25:00 +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
8d960cb608 + implementation of shifting operations for avr
* handle shl/shr operand size correctly

git-svn-id: branches/avr@17109 -
2011-03-09 19:48:01 +00:00
paul
a8da9e4bd1 compiler: set result value to dummy function to prevent compiler to generate a hint
git-svn-id: trunk@16649 -
2010-12-28 09:51:26 +00:00
paul
ee6fe6c4f5 compiler: add unary plus node, search for unary plus operator if a type cannot be handled by compiler, increase ppu version because of node types change
git-svn-id: trunk@16640 -
2010-12-26 12:19: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
c1f3d8dcaa * unified names of system_*/systems_* sets
git-svn-id: trunk@14566 -
2010-01-07 18:16:20 +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
Jonas Maebe
931aef4daa * make result of not(constant) (with constant type <= sinttype)
equal to sinttype (Delphi-compatible, fixes #10966)
  * changed not(cardinal_constant) into sinttype on 64 bit
    platforms for consistency with other similar rules (and with
    the above change)

git-svn-id: trunk@10455 -
2008-03-07 16:33:15 +00:00
Jonas Maebe
0ae33aeab0 * the result of not(dword(ordconst)) has to be dword as well for Delphi
compatibility (and to avoid range errors like in mantis #10931)

git-svn-id: trunk@10451 -
2008-03-06 21:36:32 +00:00
Jonas Maebe
761f2e5c93 * fixed constant evaluation of not(byte/word/long/quadbool) + test
git-svn-id: trunk@10450 -
2008-03-06 20:29:27 +00:00
Jonas Maebe
db34ed44e4 * fixed an {$ifndef cpu64bitalu} which had to be {$ifndef cpu64bitaddr}
git-svn-id: trunk@10371 -
2008-02-20 20:08:03 +00:00