Commit Graph

281 Commits

Author SHA1 Message Date
nickysn
9eb4419ba3 * fixed the conversion and assignment to the 64-bit boolean types on the i8086
git-svn-id: trunk@26343 -
2013-12-31 17:18:20 +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
nickysn
b8de1370a0 * fixed assignment of i8086 method pointers, when the source is in a register
git-svn-id: trunk@25999 -
2013-11-09 16:50:56 +00:00
nickysn
7ff97d9b7d * specify AT_DATA when refering to the 'RESSTR' symbols; among other things,
this fixes resourcestring constants in the i8086 memory model.

git-svn-id: trunk@25796 -
2013-10-15 22:06:16 +00:00
nickysn
f2763b98fa + implemented absolute seg:ofs vars on i8086
git-svn-id: trunk@25666 -
2013-10-05 22:16:33 +00:00
florian
0a22199738 * always use the varrec size retrieved from the system unit when advancing to the next element
git-svn-id: trunk@25244 -
2013-08-11 20:13:57 +00:00
nickysn
91d7b2bc94 + added i8086 medium/compact model 6-byte (mixed near + far) method pointer support in tcgloadnode and tcgassignmentnode
git-svn-id: trunk@25149 -
2013-07-20 15:06:14 +00:00
florian
541d67771b * keep managed types in registers if possible. Under certain circumstances (if they don't require init/final code,
e.g. being a const parameter or immutable temp. values), managed types like dyn. arrays, new string types and interfaces can be kept in registers.

git-svn-id: trunk@24953 -
2013-06-23 15:16:30 +00:00
nickysn
57e84dc0b4 * set the proper size for far procsyms in tcgloadnode.pass_generate_code
git-svn-id: trunk@24858 -
2013-06-10 01:06:02 +00:00
sergei
4b820a1ca5 - Removed tcgloadnode.generate_picvaraccess, it is never used and is not necessary because PIC stuff is handled at lower levels.
git-svn-id: trunk@24764 -
2013-06-02 10:49:17 +00:00
Jonas Maebe
5051453806 + support for LOC_(C)MMREGISTER in hlcg
o migrated location_force_mmregister_scalar from ncgutil to hlcgobj

git-svn-id: trunk@24661 -
2013-05-31 12:05:14 +00:00
nickysn
35939ff0a9 + method pointer support for targets with a 16-bit address space in tcgloadnode.pass_generate_code
git-svn-id: trunk@24641 -
2013-05-30 13:22:59 +00:00
nickysn
c41d93214f * fixed passing a longint to an array of const parameter on i8086 (and other 8/16-bit cpus)
git-svn-id: trunk@24588 -
2013-05-25 10:14:39 +00:00
Jonas Maebe
5152c86932 * set the location size of load nodes of procsyms without methodpointer/
framepointer
  * fixed conversion of procedure of object/nested procedure into a procvar
    that only contains the code address

git-svn-id: trunk@23928 -
2013-03-19 12:27:57 +00:00
yury
0960ee2034 * Add missing checks for android target.
git-svn-id: branches/targetandroid@23477 -
2013-01-21 12:08:25 +00:00
sergei
bc4c1149c3 + Native threadvar implementation for Win32 and Win64 (most of it, but not yet complete).
git-svn-id: trunk@23359 -
2013-01-10 19:13:02 +00:00
Jonas Maebe
69c29a415f * pass the procdef to getintparaloc instead of only the proccalloption, so
that the type of the parameters can be determined automatically
   o added compilerproc declarations for all helpers called in the compiler
     via their assembler name, so we can look up the corresponding procdef

git-svn-id: trunk@23325 -
2013-01-06 15:05:40 +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
67744ef46e * fix methodpointers in registers on big endian targets
git-svn-id: trunk@22362 -
2012-09-09 17:54:35 +00:00
florian
d93cee995b * fix register method pointer for ppc64 and x86_64-linux
git-svn-id: trunk@22351 -
2012-09-07 15:15:10 +00:00
florian
7361e19799 + support for handling OS_128/OS_S128 on 64 Bit CPUs as far as needed for method pointers in registers
git-svn-id: trunk@22344 -
2012-09-06 15:12:12 +00:00
florian
370d42035a * when creating method pointers, put them into registers
git-svn-id: trunk@22341 -
2012-09-06 15:11:58 +00:00
florian
d8161c185c + track usage of flags by using a new register RS_/NR_DEFAULTFLAGS
git-svn-id: trunk@22179 -
2012-08-22 19:37:51 +00:00
Jonas Maebe
7a0ae38700 + also specify the parameter def when allocating a parameter via
getintparaloc + adapted all call sites of getintparaloc. This
    led to a number of additional, related changes:
   o corrected the type information for some getintparaloc parameters
   o don't allocate some intparalocs in cases they aren't used
   o changed "const tvardata" parameter into "constref tvardata" for
     fpc_variant_copy_overwrite to make pass-by-reference semantics
     explicit
   o moved a number of routines that now have to call find_system_type()
     from cgobj to hlcgobj so that cgobj doesn't have to start depending
     on the symtable unit
   o added versions of the cpureg alloc/dealloc methods to hlcgobj that
     call through to their cgobj counter parts, so we can call save/restore
     the cpu registers before/after calling system helpers from hlcgobj
     (not implemented in hlcgobj itself, because all basic register
      allocator functionality is still part of cgobj/cgcpu)

git-svn-id: trunk@21696 -
2012-06-24 15:02:12 +00:00
Jonas Maebe
78bb3e323a * fixed source type information for values loaded in arrayconstructor after
r21069

git-svn-id: trunk@21350 -
2012-05-20 20:34:14 +00:00
Jonas Maebe
edd42aa42a * moved subsetref/reg and bit_set/test support from cgobj to hlcgobj for
future use by high level code generator targets
   o this in turn required that all a_load*_loc* methods are called via
     hlcg rather than via cg, since a location can be a subsetref/reg and
     and those are no longer handled in tcg
   o that then required moving several force_location_* routines into
     thlcg because they use a_load_loc*, but did not take tdef size
     parameters (which are required by the thlcg a_load_loc* routines)
   o the only practical consequence is that from now on, you have to
     use hlcg.location_force_mem/reg() (fpureg not yet) and
     hlcg.gen_load_loc_cgpara() instead of the removed versions from ncgutil,
     and hlcg.a_load*loc*() instead of cg.a_load*loc* if a subsetref/reg
     might be involved

git-svn-id: trunk@21287 -
2012-05-13 12:33:10 +00:00
Jonas Maebe
41d86f2b26 * fixed (harmless) class cast error when checking whether an aggregate
has the same size as one of its members to determine whether we can
    exchange two temps rather than copying one to the other

git-svn-id: trunk@21259 -
2012-05-08 20:02:04 +00:00
sergei
78c0215447 Preparations to native threadvar support:
- i386/cgcpu.pas: removed segment check, rejecting references with segment here is too early. These references are passed to tcgx86.a_loadaddr_ref_reg, which can generate required code for them (or reject if they are not allowed for the target).
- ncgld.pas: removed "not tf_section_threadvars in target_info" condition, it is inverse to one on the following line, making non-generic branch impossible to execute.
+ Define FPC_SECTION_THREADVARS macro if corresponding flag is set for the target.

git-svn-id: trunk@21210 -
2012-05-03 16:26:44 +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
452414e1a7 - removed cg.g_indirect_sym_load() calls from pass_generate_code; this
routine is called from tcgppcgen.fixref()/tcgx86.make_simple_ref()
    when necessary

git-svn-id: trunk@20789 -
2012-04-11 18:00:21 +00:00
sergei
afb4992113 * Changed code generation for assignments of managed types, it now generates a single call to helper procedure (significantly reducing code size) and is handled entirely in firstpass.
git-svn-id: trunk@20118 -
2012-01-19 22:28:29 +00:00
florian
fd07f51f35 * handle LOC_JUMP correctly for 64 bit boolean assignments
git-svn-id: trunk@19967 -
2012-01-04 22:32:31 +00:00
Jonas Maebe
d0ba14ecab * fixed webtbs/tw20874b for non-x86 32 bit targets: tcgobj methods (by
default) cannot deal with 64 bit locations on 32 bit platforms

git-svn-id: trunk@19919 -
2011-12-30 11:58:49 +00:00
florian
c4a5499d2a * handle flag to reg./ref. conversion correctly for boolean64
git-svn-id: trunk@19914 -
2011-12-29 17:28:35 +00:00
florian
a59a37dddd * handle assignments of qword bools with LOC_FLAGS correctly, resolves #20874
git-svn-id: trunk@19912 -
2011-12-29 16:48:46 +00:00
Jonas Maebe
bd990d1173 * generate JVM bytecode that passes the stringent requirements of the Dalvik
verifier when -Cpjvmdalvik is used (including debug information). Using
    -Cpjvmdalvik changes the semantics at the language-level in one case:
    boolean(bytevar) will no longer return a boolean that contains the same
    value as bytevar did, but will map the value to 0/1 (that also means that
    such expressions cannot be passed to var-parameters in case of
    -Cpjvmdalvik). Code compiled with -Cpjvmdalvik will also work fine on
    the regular JVM, but it may be somewhat slower (it won't necessarily
    be slower on Dalvik, because the .class -> .dex transformation
    applies many optimizations itself)

git-svn-id: branches/jvmbackend@19743 -
2011-12-04 14:48:54 +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
florian
7bb1c642dd * fix division by zero in alignment code, should resolve #20265 an #20240
git-svn-id: trunk@19338 -
2011-10-03 16:53:42 +00:00
Jonas Maebe
27731e342c + support for array-of-const on the JVM target. Even though the
implementation is a bit different from that on native targets, the
    result is quite compatible

git-svn-id: branches/jvmbackend@18765 -
2011-08-20 08:34:00 +00:00
Jonas Maebe
979f55e1db + support for procedural variables for the JVM target
o every porocedural variable type is represented by a class with one
     public "invoke" method whose signature matches the signature of the
     procvar
   o internally, dispatching happens via java.lang.reflect.Method.invoke().
     WARNING: while this allows calling private/protected or other methods
     that are normally not accessible from another context, a security
     manger can override this. If such a security manager is installed,
     most procvars will cause security exceptions
   o such dispatching also requires that all arguments are wrapped, but
     that's done in the compiler-generated body of the invoke method,
     so that procvars can also be called conveniently from Java code
   o typecasting between a procedure of object and tmethod is supported,
     as well as Delphi-style replacing of only the method pointer via
     @procvar1=@procvar2.
   o nested procvars are not yet supported, but most of the basic
     infrastructure for them is already present
  * all units/programs now get an internal __FPC_JVM_Module_Class_Alias$
    type when compiled for the JVM target, which is an "external" class
    that maps to the unit name. This is required to look up the
    JLRMethod instances for regular functions/procedures
  + new tabstractprocdef.copyas() method that allows to create a procvar
    from a procdef and vice versa

git-svn-id: branches/jvmbackend@18690 -
2011-08-20 08:24:58 +00:00
Jonas Maebe
d6966e545b + support for formal var/out parameters on the JVM target:
o primitive types are first boxed
   o the parameter is passed inside an array of one class instance
   o changing the parameter inside the routine (by assigning a value to it
     like in Delphi.NET and different from regular Pascal code) will replace
     this class instance (again boxing the value if required)
   o on return, the class instance is extracted, unboxed if required, and
     assigned back to the original location
   o formal const parameters are handled without the extra array indirection,
     since they cannot be changed

  TODO: while writing tjvmcallparanode.handleformalcopyoutpara() I forgot that
    calling getcopy on ttemprefnodes whose ttempcreatenode hasn't been copied
    yet works fine, so that code is more complex than needed. Still have to
    fix.

git-svn-id: branches/jvmbackend@18675 -
2011-08-20 08:23:33 +00:00
Jonas Maebe
569228447d * converted all enum handling for the JVM target so that it uses the
JDK class-style enums rather than plain ordinals like in Pascal
   o for Pascal code, nothing changes, except that for the JVM target
     you can always typecast any enum into a class instance (to interface
     with the JDK)
   o to Java programs, FPC enums look exactly like Java enum types

git-svn-id: branches/jvmbackend@18620 -
2011-08-20 08:15:54 +00:00
Jonas Maebe
8fa42c206f + support for nested procedures for the JVM target
o since the JVM target has no stack/framepointer that can be passed
     on to nested routines, all local variables and parameters accessed
     from nested routines are grouped into a local record whose address
     is passed to nested routines. The same technique is also required
     for LLVM in the future

git-svn-id: branches/jvmbackend@18588 -
2011-08-20 08:12:59 +00:00
Jonas Maebe
63962043a5 * fixed fake nested procedures support
git-svn-id: branches/jvmbackend@18543 -
2011-08-20 08:09:00 +00:00
Jonas Maebe
c9537e3347 + support for non-array/record var parameter on the JVM target using
copy-in/out

git-svn-id: branches/jvmbackend@18527 -
2011-08-20 08:07:24 +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
bf21cd7a15 + support for (non-variant) arrayconstructornodes for the JVM target
o when allocating array temps for the JVM target, use the specified
     "forcesize" for the first dimension, since the arraydef size may
     be invalid (e.g., in case it's an array constructor)

git-svn-id: branches/jvmbackend@18468 -
2011-08-20 08:02:22 +00:00
Jonas Maebe
2c313e397e + support for regular arrays and open arrays
o support for copying value parameters at the callee side if they were
     passed by reference in hlcg
   o JVM g_concatcopy() implementation for arrays
   o moved code to get length of an array from njvminl to hlcgcpu so it can
     be reused elsewhere as well
   o export array copy helpers from system unit for use when assigning one
     array to another
   o some generic support for types that are normally not implicit pointers,
     but which are for the JVM target (such as normal arrays)
  * handle assigning nil to a dynamic array by generating a setlength(x,0)
    node instead of by hardcoding a call to fpc_dynarray_clear, so
    target-specific code can handle it if required
  * hook up gethltemp() for JVM ttgjvm so array temps are properly
    allocated

git-svn-id: branches/jvmbackend@18388 -
2011-08-20 07:55:27 +00:00
Jonas Maebe
0e87627218 + gethltemp() to allocate a temp specifying full type information even
for regular temps. This is required for targets that need special
    handling of the temps depending on the type
  * converted most gettemp() calls to gethltemp() calls

git-svn-id: branches/jvmbackend@18376 -
2011-08-20 07:54:04 +00:00