Commit Graph

400 Commits

Author SHA1 Message Date
florian
0bc1e7e23b * "inherit" the nf_internal flag in tinlinenode.getaddsub_for_incdec
git-svn-id: trunk@34802 -
2016-11-05 23:06:06 +00:00
florian
64e2c2b914 + simplify succ/pred(<const>/x+/-x<const>)
git-svn-id: trunk@34798 -
2016-11-05 23:06:00 +00:00
florian
000cffa8e3 * make more use of nf_internal to avoid range check errors
git-svn-id: trunk@34793 -
2016-11-05 23:05:51 +00:00
florian
e4d60b2048 * factored out tinlinenode.getaddsub_for_incdec from first_IncDec so it can be used independently
* get varstate right of inc/dec nodes which are converted into add/sub nodes

git-svn-id: trunk@34792 -
2016-11-05 23:05:49 +00:00
florian
9c81e90e08 + extension to iso mode: reset/rewrite can take a file name as a second parameter
git-svn-id: trunk@34726 -
2016-10-16 07:55:08 +00:00
nickysn
d6007d650a * use tpointerdef.pointer_arithmetic_int/uint_type in tinlinenode.pass_typecheck
for handling inc/dec(pointer, int)

git-svn-id: trunk@34655 -
2016-10-08 12:06:57 +00:00
nickysn
e847971477 * use the actual ValSInt type from the system unit, instead of ptrsinttype when
handling the code parameter of val()

git-svn-id: trunk@34608 -
2016-10-03 21:45:08 +00:00
svenbarth
26a2ddd3d6 + extend Delete() intrinsics with Delphi compatible support for dynamic arrays. Also fixes Mantis #30306
git-svn-id: trunk@34455 -
2016-09-08 17:15:10 +00:00
svenbarth
17bb29ddc3 Check for tf_winlikewidestring in the target's flags instead of relying on the target being a Windows system when determining whether the system as the WideString type that's separate from UnicodeString
git-svn-id: trunk@33900 -
2016-06-04 08:45:22 +00:00
svenbarth
aaff6d0b97 Allow Delete() and Insert() to be used with generic types as arguments.
+ added test

git-svn-id: trunk@33897 -
2016-06-03 21:45:23 +00:00
svenbarth
a2c9c75e97 Convert Insert() and Delete() to intrinsics in preparation for dynamic array support for these two procedures.
Since overloading compilerprocs does not work each procedure got its own unique name, but they are using the new compilerproc extension to map them to the Insert and Delete symbol so that error messages can be shown with the respective name for the procedure declarations instead of fpc_shortstr_delete for example.

git-svn-id: trunk@33895 -
2016-06-03 21:25:49 +00:00
svenbarth
8c96fbed8f Fix for Mantis #28832
ninl.pas, tinlinenode:
  * pass_typecheck: let code pass on to simplify() for undefineddefs in Low() and High()
  * simplify: create a constant 0 as fallback

+ added test

git-svn-id: trunk@33884 -
2016-06-03 12:14:30 +00:00
Jonas Maebe
abe8d44f37 * changed allocating a temp with type sinttype and size sinttype*dims for
with a ctemprefnode.create_offset() hack into a proper array, because
    the old way does not work at all with LLVM (and is ugly)

git-svn-id: trunk@33724 -
2016-05-20 20:51:38 +00:00
svenbarth
8287773b16 Reverted revision 33036. This feature is too controverse to be left in.
git-svn-id: trunk@33048 -
2016-02-04 19:26:51 +00:00
svenbarth
ed94ca4b24 Add support for IfThen() instrinsic that works like the if-statement in that it evaluates only the expression that is indeed executed.
The result type of the intrinsic is determined by the Then-expression to provide a bit of control. There might however be some situations in which this fails, for this exceptions need to be added (e.g. a constant string needs to be converted to a normal string).

compinnr.inc:
  + add new constant in_ifthen_x_y_z for the IfThen() intrinsic
psystem.pas: 
  + create_intern_symbols: add symbol for IfThen() intrinsic
pexpr.pas:
  * statement_syssym: parse parameters of IfThen() intrinsic and return corresponding inline node
ninl.pas, tinlinenode:
  + new method handle_ifthen() which converts the inline node to an if-node which assigns the expressions to a temp node that is returned
  * pass_typecheck: handle in_ifthen_x_y_z using handle_ifthen()
  * pass_1: in_ifthen_x_y_z does not need a first pass as it's already converted after the typecheck pass

+ added tests

git-svn-id: trunk@33036 -
2016-01-31 14:29:12 +00:00
Jonas Maebe
8917633199 * implement sizeof/typeof completely at the node level, based on
loadvmtaddr and vmt_def
   o give an error when trying to use sizeof on a class/object when
     targeting the JVM (can't get/load the data size there)

git-svn-id: trunk@32764 -
2015-12-27 14:22:06 +00:00
svenbarth
74c79803f7 Extend tlocalvarsym with the ability to not register it if needed.
git-svn-id: trunk@32375 -
2015-11-20 11:29:21 +00:00
florian
70b8789262 o basic extended pascal support:
+ automatically loaded helper unit
  * Makefiles adapted
  * mode switch
  * mode switches reorganized
+ TimeStamp support

git-svn-id: trunk@32330 -
2015-11-15 15:13:36 +00:00
Jonas Maebe
2778bf55c7 * add "doregister" parameter to torddef.create, and don't register temporary
defs created in the scanner for evaluating compile time expressions, or in
    the code generator for range checking

git-svn-id: trunk@32046 -
2015-10-13 15:59:06 +00:00
florian
f00a55ae08 + tinlinenode.createintern
* do not do range checking on constants created by pred/succ if these nodes are created internally

git-svn-id: trunk@31471 -
2015-08-31 20:03:51 +00:00
Jonas Maebe
67b8aceaee * synchronized with privatetrunk till r30095
git-svn-id: branches/hlcgllvm@30101 -
2015-03-05 20:32:15 +00:00
Jonas Maebe
68303b8df1 * add explicit check that argument of sizeof(x) is a simple load node (this
was already assumed later on)

git-svn-id: trunk@29816 -
2015-02-23 22:47:35 +00:00
florian
0dfbba86f3 * properly firstpass nodes when inc(...) is converted into ...:=...+x, resolves #27471
git-svn-id: trunk@29742 -
2015-02-17 21:14:45 +00:00
florian
c9ba9665dd * set nf_internal for if nodes generated by assert, prevent warning for assert(true); resolves #26467
git-svn-id: trunk@29293 -
2014-12-14 19:41:22 +00:00
nickysn
a9e1419ee3 * extracted the pass 1 handling of inc/dec to a virtual method first_IncDec
git-svn-id: trunk@29210 -
2014-12-06 21:14:31 +00:00
pierre
a77735d7af Fix bug in in_const_swap_qword handling
git-svn-id: trunk@29067 -
2014-11-13 10:59:00 +00:00
Jonas Maebe
e8026ad8d3 * fixed the resultdef of length() intrinsic: it's ossinttype rather than
sinttype (they're the same on most platforms, except on 8 bit ones where
    ossinttype is still 16 bit)
  * simplified and documented second_length(), and fixed some (harmless)
    errors in the used tcgsize for the resultdef (it had to be OS_SINT
    rather than OS_INT -- now it's just def_cgsize(resultdef) so it's
    always correct)

git-svn-id: branches/hlcgllvm@28387 -
2014-08-12 18:59:13 +00:00
sergei
04d8e8a5dc * On 64-bit targets, handle abs(int64) internally, using the same code as for abs(longint), i.e. without branching. Both generic and x86-specific pass 2 code is already suitable for different operand sizes, only type checking needs removal of excessive conversions to 32 bits.
git-svn-id: trunk@27989 -
2014-06-17 18:45:11 +00:00
svenbarth
34394d6925 Fix for Mantis #26180. Accept undefineddef as first parameter type of an Assert if it is used inside a generic.
ninl.pas, tinlinenode.pass_typecheck:
  * if the first parameter of an Assert is a undefineddef node then accept it as well if the node is part of a generic function/method

+ added test

git-svn-id: trunk@27875 -
2014-06-06 14:39:27 +00:00
sergei
274c2fc82f * handle_ln_const: if/else branches were swapped, correct values are: ln(0)=-Inf and ln(-#)=NaN.
* handle_ln_const and handle_sqrt_const handle all arguments, not just invalid ones, so calling code can be simplified.

git-svn-id: trunk@27837 -
2014-06-01 01:20:06 +00:00
sergei
743326dc70 * abs(): when translated to generic fpc_abs_real() helper, typecast result back to original precision, similar to how it is done for sqr and sqrt. Fixes compilation on m68k after r27808 (m86k looks like the only target still needing this generic handling).
git-svn-id: trunk@27818 -
2014-05-25 11:55:55 +00:00
sergei
37625211f5 * Fixed sqrt procedure selection on arm-wince after r27809.
git-svn-id: trunk@27815 -
2014-05-23 21:58:23 +00:00
sergei
22e099d000 * sqrt(real): for targets with emulated floating point, invoke float64_sqrt or float32_sqrt from softfpu code. Testing on ARM CPU shows that float64_sqrt executes about twice faster and offers better accuracy than fpc_sqrt_real from genmath.inc.
* softfpu.pp: changed float64_sqrt into a function, so it is consistent with other compiler-invoked routines.

git-svn-id: trunk@27809 -
2014-05-21 15:07:13 +00:00
sergei
fc5f45f65c * sqr(real) and sqrt(real): remove typeconv node inserted by initial call processing (see explanation in comments), allowing these functions to be evaluated using precision of argument. In particular, sqrt(single) and sqrt(double) now emit 'sqrtss' and 'sqrtsd' instructions on x86 targets with -Cfsse3. Non-x86 targets already have the necessary support in code generators.
* abs(real): handle the same way as sqrt and sqr, i.e. without casting to bestreal and back.

git-svn-id: trunk@27808 -
2014-05-21 14:53:47 +00:00
florian
d88d644925 + support for FMA intrinsic: if there is no hardware support, the compiler throws an error.
Currently it is implemented only for x86-CPUs supporting the FMA extension. While it would
  be possible to implement it in software or simulate fma(<single>,<single>,<single>) using
  double operations, it makes no sense in my opinion to do so.

git-svn-id: trunk@27564 -
2014-04-13 19:21:54 +00:00
svenbarth
256c852631 Fix for Mantis #23776.
ninl.pas, tinlinenode.pass_typecheck:
  * don't generate a type error if Length() is used inside generics with a generic argument

+ added test

git-svn-id: trunk@27533 -
2014-04-11 15:57:21 +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
Jonas Maebe
0edb7b2288 * fixed r27320 for darwin, as its mangled names get prefixed with '_'
and hence the generated mangled name did not start with a '$' as
    expected

git-svn-id: trunk@27357 -
2014-03-29 22:31:36 +00:00
svenbarth
a08e8ff982 Fix for Mantis #25929
* ninl.pas, tinlinenode.handle_default.getdefaultvarsym:
    prefix the default variable's name with a "$zero" instead of a "zero" and use only the string from the second character on for comparisons so that findwithhash() and checkduplicates() generate consistent results

+ added test

git-svn-id: trunk@27320 -
2014-03-28 14:45:18 +00:00
florian
ab3f5744e0 * skip dec/inc type checking in unspecialized generic methods, resolves #25603
git-svn-id: trunk@26830 -
2014-02-22 09:20:57 +00:00
florian
e841027a48 * fixes handling of typed files in iso mode
git-svn-id: trunk@26436 -
2014-01-12 20:17:48 +00:00
nickysn
e1332304ef * when converting Hi() to a shr node, convert the right shr const parameter to
sinttype, instead of u32inttype. This:
  1) is consistent with what type conversion tshlshrnode.pass_typecheck inserts
     on the right side
  2) avoids the expensive conversion to 32-bit and the even more expensive
     performing the operation in 32-bit on i8086

git-svn-id: trunk@26352 -
2014-01-01 23:57:42 +00:00
Jonas Maebe
d2b8275b99 + support for arbitrary encodings in readstr/writestr
o set the code page of the temporary "text" file to utf-8 for writestr with
     unicodestring/widestring as destination, so that no data loss can occur
     (+ properly deal with cases whereby part of an utf-8 character is
      written to the textbuf in this case)
   o explicitly pass the code page of the destination ansistring for writestr
     with ansistring as destination and set it for the temporary "text" file
   o set the code page of the text file for readstr

git-svn-id: trunk@26317 -
2013-12-29 19:18:49 +00:00
sergei
8ecad469a6 * Reverted r26256 since it produced wrong results if argument of inc/dec is actually unaligned. Added description of the issue and slightly increased node complexity at which address is cached, so operations on record/class fields do not take address.
git-svn-id: trunk@26258 -
2013-12-21 10:33:38 +00:00
sergei
b376f56bf3 * Use typed pointer to store address of x when processing inc(x)/dec(x) with range checking enabled. This preserves alignment of x and prevents generating unaligned code on alignment-sensitive targets.
git-svn-id: trunk@26256 -
2013-12-20 17:13:41 +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
412dc6586f * the writestr helper initializes the target string, so mark it as being written
before the call to the helper to get proper life information

git-svn-id: trunk@26017 -
2013-11-10 20:20:40 +00:00
sergei
9ad98a2c4d * Handle "SarInt64" always as internal procedure, introduced virtual method tinlinenode.first_sar that by default converts it into call to "fpc_sarint64" unless target CPU is 64-bit. This provides a point to insert target-specific optimizations.
git-svn-id: trunk@25876 -
2013-10-28 14:31:36 +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