Commit Graph

123 Commits

Author SHA1 Message Date
nickysn
d86a8ebc99 * defutil.get_int_result_type_from_pointer_subtraction moved to a virtual
method tpointerdef.pointer_subtraction_result_type

git-svn-id: trunk@28219 -
2014-07-14 23:30:29 +00:00
nickysn
99c555cea8 + implemented huge pointer subtraction
* the result of far pointer subtraction changed to word (for TP7 compatibility)

git-svn-id: trunk@28218 -
2014-07-13 23:40:43 +00:00
nickysn
89db1e4118 + add proper int type conversions for huge pointer arithmetic in pass_typecheck
of the add node

git-svn-id: trunk@28094 -
2014-06-27 23:37:08 +00:00
Jonas Maebe
24f4adf657 * set the rangedef of open arrays to ptrsinttype (instead of s32inttype),
so that it's the same as the def returned by the low/high nodes
    (mantis #25703)

git-svn-id: trunk@27970 -
2014-06-15 15:26:47 +00:00
Jonas Maebe
338c064beb * moved x86-specific tpointerdef functionality to architecture-specific
descendants

git-svn-id: trunk@27397 -
2014-03-30 21:04:36 +00:00
sergei
1744988962 * Modified behavior of CExtended type in overload selection: it is made more compatible to Extended than to Double and Single. Also an Extended parameter selects a CExtended overload (if available) instead of Double.
+ Test.

git-svn-id: trunk@27366 -
2014-03-30 07:31:58 +00:00
nickysn
f6b18e9b8d * i8086 far data memory model fixes in defutil.def_cgsize
git-svn-id: trunk@27247 -
2014-03-23 22:14:09 +00:00
nickysn
894d400a7b + added is_farpointer(tdef) and is_hugepointer(tdef) helper functions to defutil
git-svn-id: trunk@24865 -
2013-06-10 20:50:05 +00:00
nickysn
bfd65ea550 * use tprocvardef(def).size (which takes into account far code/data) to determine cgsize for procvars in def_cgsize
git-svn-id: trunk@24844 -
2013-06-09 17:51:56 +00:00
sergei
4e873d0561 + Determine early (before pass 2) whether managed parameters/locals/temps will cause the procedure to reference RTTI labels and, therefore, need GOT.
+ trttinode also sets pi_needs_got flag.

git-svn-id: trunk@24767 -
2013-06-02 13:09:47 +00:00
Jonas Maebe
7d9f98e516 + def_cgmmsize() that returns a vector tcgsize for arraydefs (as generated
for certain parameter locations in the x86-64 parameter manager)
  * full support for vector types in the high level code generator by
    translating arraydefs passed to a_*mm*() methods into vector tcgsizes

git-svn-id: trunk@24762 -
2013-06-02 10:24:08 +00:00
Jonas Maebe
53ba7fbb8b * support formaldef in def_cgsize (-> OS_ADDR)
git-svn-id: trunk@24760 -
2013-06-02 10:23:54 +00:00
Jonas Maebe
2dd75e707e * renamed thlcgobj.tcgsize2orddef to defutil.cgsize_orddef
git-svn-id: trunk@24743 -
2013-06-01 18:28:15 +00:00
nickysn
42b2228dc7 + far pointer support in defutil.def_cgsize
git-svn-id: trunk@24552 -
2013-05-22 12:30:34 +00:00
nickysn
2486009d37 + support u64bit as well in defutil.range_to_basetype
git-svn-id: branches/i8086@24173 -
2013-04-07 10:57:27 +00:00
nickysn
d88855566a + added defutil.is_nativesint and is_nativeuint
git-svn-id: branches/i8086@24167 -
2013-04-06 23:03:12 +00:00
nickysn
70d02e6942 + added defutil.is_nativeint and is_nativeord
git-svn-id: branches/i8086@24166 -
2013-04-06 22:58:04 +00:00
nickysn
7bce3c5208 * reverse the order of checks for determining the native int type (e.g. 8086 in large memory model would have 32-bit addresses, but a 16-bit native int)
git-svn-id: branches/i8086@24165 -
2013-04-06 22:44:07 +00:00
nickysn
848eeceded * use min and max in defutil.get_common_intdef
git-svn-id: branches/i8086@24120 -
2013-04-01 20:25:42 +00:00
nickysn
a8d72cc11a * bug fix in defutil.get_common_intdef
git-svn-id: branches/i8086@24115 -
2013-04-01 19:25:11 +00:00
nickysn
9c435a0bcb + added is_8/16bit and is_oversizedint/is_oversizedord helper functions in defutil.pas
git-svn-id: branches/i8086@24091 -
2013-03-31 16:25:22 +00:00
nickysn
a68dfed450 * defutil.is_smallset updated for 8/16-bit CPUs
git-svn-id: branches/i8086@23894 -
2013-03-17 15:31:57 +00:00
nickysn
a274e62724 + added defutil.is_32bit helper function, similar to is_64bit
git-svn-id: branches/i8086@23869 -
2013-03-16 17:54:52 +00:00
nickysn
f048e3fd3b + support 16-bit pointers (i8086 near pointers) in defutil.def_cgsize
git-svn-id: branches/i8086@23816 -
2013-03-13 17:19:21 +00:00
florian
761fcca4ec + is_dynamicstring
+ implement low/high for dynamic strings, resolves #15244 and #22936
+ basic support for $zerobasedstrings directive

git-svn-id: trunk@22933 -
2012-11-04 21:48:53 +00:00
florian
ca5fabda6d * cleanup some unused units from uses clauses
git-svn-id: trunk@22433 -
2012-09-21 18:53:46 +00:00
florian
7901662eb3 + mark method pointers as regable
git-svn-id: trunk@22337 -
2012-09-06 15:11:42 +00:00
Jonas Maebe
cf4a2bd392 * fixed java.lang.String and Pascal string comparisons after operator
overloading rewrite (consider java_jlstring to be "stringlike")

git-svn-id: trunk@22127 -
2012-08-19 13:57:48 +00:00
svenbarth
b0458b55a3 Loosen the restriction regarding operator overloads by applying a (modified) patch from JC Chu. This fixes Mantis #22359.
The changes are built up in a way that all operators on two given types are not allowed if a default implementation for that operator exists. This implies that there is a possibility to have a overload work for (in this order) type A and B, but not for B and A. This is for example the case for Set + Enum (which seems to have a default implementation) where Enum + Set is allowed. The added tests try to detect as many default implementations as feasible, but can't cover everything...

git-svn-id: trunk@21975 -
2012-07-26 18:02:01 +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
3589f90cf8 * also show the valid bounds in most cases when signalling a range check
warning/error while evaluating constants (mantis #21299)

git-svn-id: trunk@20507 -
2012-03-10 21:53:36 +00:00
Jonas Maebe
930883edf6 * also report currency as automatable on non-x87 platforms
(may fix mantis #20986)

git-svn-id: trunk@19924 -
2011-12-30 12:30:12 +00:00
florian
61eb25ea30 * qwordbool is obviously a 64 bit type, resolves #20889
git-svn-id: trunk@19911 -
2011-12-29 16:46:50 +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
Jonas Maebe
88df6573a0 * moved de2regtyp() from defutil to hlcgobj, so it can be overridden
(and override for the JVM, making the register type for records
     R_ADDRESSREGISTER instead of R_INTREGISTER there)

git-svn-id: branches/jvmbackend@18448 -
2011-08-20 08:00:31 +00:00
Jonas Maebe
8439e1472e * moved def2regtyp() from jvm/hlcgcpu to defutil, and extended it to
handle vectorfpu (floatdef->MMREG) and softfloat (floatdef->INTREG)
  + thlcg.getregisterfordef(), which uses def2regtyp() to allocate a register
    appropriate to hold values of that tdef type
  + generic thlcg.location_force_reg() implementation. Note that for
    low-level code generator targets it may be slightly less efficient than
    the implementation in hlcg2ll (from ncgutil) because it does not play
    any tricks with the register or location size, or with reference offsets,
    to truncate values

git-svn-id: branches/jvmbackend@18315 -
2011-08-20 07:38: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
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
sergei
b4ac714201 * defutil.pas: added UnicodeString to automatable types, fixes compilation of webtbs/tw2649.pp after r16360. However it requires RTL support similar to one for AnsiString to be complete.
* ncal.pas, translate_disp_call(): fixed parameter alignment once more, this time it should be correct for both 32 and 64 bit platforms.

git-svn-id: trunk@16394 -
2010-11-21 18:10:11 +00:00
sergei
ba700ad2ff * Improvements to Dispatch call handling:
o All signed and unsigned ordinal types are made automatable.
  o Non-automatable types are rejected when parsing dispinterface declarations.
  o Simplified translate_disp_call() a bit.
  o translate_disp_call() now supports non-automatable parameters which can be typecasted to automatable ones. UnicodeString is not yet there, though.
  o Partially fixes #17904: parameters of Variant Dispatch calls are passed by reference when they can be mapped to a variable.

git-svn-id: trunk@16360 -
2010-11-18 16:17:50 +00:00
Jonas Maebe
14b95b3b9b * always force range checking for the upper and lower bounds of for-loops if
they are constants (instead of only on 32 bit systems), and always use the
    actual upper/lower bound of the loop variable instead of hardcoding the
    bounds of longint (mantis #17646)

git-svn-id: trunk@16213 -
2010-10-24 14:55:48 +00:00
Jonas Maebe
4ef0601906 * let def_cgsize() also recognise unicodestrings (avoid calling tdef.size)
git-svn-id: trunk@15741 -
2010-08-08 12:37:07 +00:00
Jonas Maebe
57bd6d2685 + merged nestedprocvars branch
+ support for nested procedural variables:
    o activate using {$modeswitch nestedprocvars} (compatible with all
      regular syntax modes, enabled by default for MacPas mode)
    o activating this mode switch changes the way the frame pointer is
      passed to nested routines into the same way that Delphi uses (always
      passed via the stack, and if necessary removed from the stack by
      the caller) -- Todo: possibly also allow using this parameter
      passing convention without enabling nested procvars, maybe even
      by default in Delphi mode, see mantis #9432
    o both global and nested routines can be passed to/assigned to a
      nested procvar (and called via them). Note that converting global
      *procvars* to nested procvars is intentionally not supported, so
      that this functionality can also be implemented via compile-time
      generated trampolines if necessary (e.g. for LLVM or CIL backends
      as long as they don't support the aforementioned parameter passing
      convention)
    o a nested procvar can both be declared using a Mac/ISO Pascal style
      "inline" type declaration as a parameter type, or as a stand-alone
      type (in the latter case, add "is nested" at the end in analogy to
      "of object" for method pointers -- note that using variables of
      such a type is dangerous, because if you call them once the enclosing
      stack frame no longer exists on the stack, the results are
      undefined; this is however allowed for Metaware Pascal compatibility)

git-svn-id: trunk@15694 -
2010-08-02 22:20:36 +00:00
Jonas Maebe
f5c52b25cd * removed "and not is_class()" condition from is_managed_type(), because
tobjectdef.needs_inittable returns false for classes nowadays (and already
    since quite some time)
  * nevertheless replaced all usages in the compiler of x.needs_inittable with
    is_managed_type(x) (in case some other condition is added again in the
    future) and removed all remaining accompanying "and not is_class(x)"
    checks

git-svn-id: trunk@15320 -
2010-05-22 21:28:24 +00:00
Jonas Maebe
40705a085f * renamed is_refcounted_type() into is_managed_type(), because it also
returns true for variants and those aren't refcounted
  * also allow tempnodes for pointers to managed types to be put in
    registers (not sure why it was disabled, and there are no
    testsuite regressions by enabling it)

git-svn-id: trunk@15319 -
2010-05-22 20:51:50 +00:00
Jonas Maebe
734f9de2a0 + support for array of widechar typed constants (based on patch by
Blaise Thorn, mantis #16004)

git-svn-id: trunk@15096 -
2010-03-30 19:45:50 +00:00
Jonas Maebe
0cfc6e1cac + support for "univ" in macpas mode: a parameter modifier that allows
passing any value to that parameter which has the same size as the
    parameter (it basically acts as if there is an explicit type conversion
    to the parameter type around the value at the caller side). If a procvar
    has an univ parameter, all procvars whose corresponding parameter
    has the same size as that univ parameter are similarly compatible.

    This transparent compatibility can however cause crashes in case of
    of the procvars when one of the types is passed on the stack and the
    other isn't (because then the called routine will a) load the parameter
    from a wrong location and b) pop the wrong amount off of the stack at
    then end). Therefore FPC will warn in most cases where this can happen.
    (mantis #15777)

git-svn-id: trunk@15010 -
2010-03-13 22:13:20 +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
f530de8da6 * also honor keep_sign_equal in get_common_intdef() for signed types
(r14892)

git-svn-id: trunk@14909 -
2010-02-13 20:50:18 +00:00