Commit Graph

477 Commits

Author SHA1 Message Date
Jonas Maebe
5abf6d0aa4 + thlcgobj support of the managed open array initialization fixes of
svn r17068,17071,17081,17136
  * changed all init_paras code in both thlcgobj and ncgutil to use
    location_get_data_ref() instead of direct a_load_loc_reg()/
    ref.base:=reg so it also works with the JVM target
  * changed all init_paras code so it works with targets that do
    not pass an implicit high parameter for open array (and a similar
    fix in ncgcal)
  + added support for initializing array (both regular and open)
    "out" parameters of reference counted types on the JVM target
    (the arrays will be initialised with nil rather than an empty
     array for implementation reasons, see comments in compproc.inc)
  * factored out calling of functions in the system unit directly
    from hlcgobj

git-svn-id: branches/jvmbackend@18421 -
2011-08-20 07:58:14 +00:00
Jonas Maebe
b42731ff84 * disable SSA for the JVM target
git-svn-id: branches/jvmbackend@18414 -
2011-08-20 07:57:40 +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
ab5b1fb686 * turned call_fail_node, initialize_data_node, and finalize_data_node from
nutils.pas into virtual class methods of a new tnodeutils class defined
    in ngenutil (global factory: cnodeutils), so they can be overridden by
    architecture-specific implementations (required by the JVM backend)

git-svn-id: branches/jvmbackend@18364 -
2011-08-20 07:52:11 +00:00
Jonas Maebe
13a459c2d7 * replaced all calls to cg.g_incr/decrrefcount/g_initialize/g_finalize with
calls to hlcg.*

git-svn-id: branches/jvmbackend@18361 -
2011-08-20 07:51:37 +00:00
Jonas Maebe
28740dce2d - removed extra "fordefinition" parameter again from tprocdef.mangledname(),
since the definition-specific adorning of JVM mangled names is Jasmin-
    specific, and such code has no place in symdef
  * moved code to adorn JVM mangled names for Jasmin definitions to agjasmin

git-svn-id: branches/jvmbackend@18346 -
2011-08-20 07:49:31 +00:00
Jonas Maebe
71deda6f50 + added interface to ncgutil.gen_load_loc_cgpara() to hlcgobj + generic
implementation (without loc_©mmregister support)
  * moved ncgutil.gen_load_return_value() to hlcgobj, and factored out
    architecture-specific behaviour to load an uninitialised function result
    into a virtual method (+ JVM-specific implementation of that method),
    gen_load_uninitialized_function_result()
  + added hlcgx86 unit and thlcgx86 type to override the
    thlcgobj.gen_load_uninitialized_function_result() method for x87
    function results; the i386 and x86_64 units now instantiate thlcgx86
    instead of thlcg2ll
  * moved calling of ncgutil.gen_load_loc_cgpara() from ncgcal also to hlcgobj
  -> returning function results works for JVM

git-svn-id: branches/jvmbackend@18317 -
2011-08-20 07:38:16 +00:00
Jonas Maebe
a19220f106 * cpu64bitaddr -> cpu64bitalu in location.free (whether or not
64 bit registers are represented as a pair of 32 bit registers
    in a register64 struct depends on whether or not the ALU can
    perform 64 bit operations -- if it can, assume there are 64
    bit registers)

git-svn-id: branches/jvmbackend@18295 -
2011-08-20 07:35:59 +00:00
Jonas Maebe
0ee702b3a2 * tprocdef.mangledname now gets an extra boolean parameter indicating
whether the mangled name is for defining a symbol, or for referencing
    it later (e.g. for a call or load of its address). The reason is that
    on the JVM both cases are different.
  + jvmdef unit to encode types according to the JVM rules
  + tprocdef.jvmmangledname() to encode a procdef's JVM mangled name
    (the common part of defining/referencing it; tprocdef.mangledname
     afterwards adorns it as required)

git-svn-id: branches/jvmbackend@18288 -
2011-08-20 07:22:00 +00:00
Jonas Maebe
0e16369906 * moved gen_proc_symbol() and gen_proc_symbol_end() from ncgutil to hlcgobj
git-svn-id: branches/jvmbackend@18287 -
2011-08-20 07:21:52 +00:00
Jonas Maebe
72e9cfee24 * create/destroy also the high level code generator for all architectures,
so it can be used in generic code

git-svn-id: branches/jvmbackend@18280 -
2011-08-20 07:21:16 +00:00
sergei
fec5dde5b6 * Fix handling of Windows WideString typed constants, resolves #15842 and completes the related #14308:
* Do not initialize unused symbols, because finalization code is not generated for them either.
  * Always initialize/finalize such constants, even if they are declared in {$J-} state and cannot be modified by user code.

git-svn-id: trunk@18121 -
2011-08-06 18:11:39 +00:00
Jonas Maebe
da3fb5de0f * prevent double freeing temps containing int64-sized parameters
(mantis #19700)

git-svn-id: trunk@18053 -
2011-08-01 17:12:45 +00:00
pierre
e6b5ce8557 * Use vo_has_section to test for user name section in insertbssdata
git-svn-id: trunk@17899 -
2011-07-01 14:24:56 +00:00
florian
449c20ce63 * moved pic helpers into system unit, resolves #8119
git-svn-id: trunk@17669 -
2011-06-05 21:16:11 +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
fb84cb865b * rebase to trunk@17295
git-svn-id: branches/avr@17296 -
2011-04-10 19:20:48 +00:00
florian
c97869bd89 * merge user sections support branch
git-svn-id: trunk@17285 -
2011-04-10 18:08:59 +00:00
florian
7f995c093e * moved some code from pmodules to ncgutil to get rid of cpubase in pmodules
git-svn-id: trunk@17280 -
2011-04-10 16:27:49 +00:00
florian
f328b6d635 + user section type
+ parsing of section directive for variables
  + section test
  + write section names in the assembler/binary writers correctly
  * allow section only after ; and for embedded targets

git-svn-id: branches/usersections@17154 -
2011-03-20 15:42:28 +00:00
sergei
1fcd40ee64 Continue fixing open array handling:
* Unified fpc_initialize_array,fpc_finalize_array with fpc_decref_array and fpc_addref_array by removing 'size' parameter from the former two. Element size is easily calculated from RTTI, so omitting it simplifies code generation. All four helpers are now callable by tcg.g_array_rtti_helper().
* ncgutil.pas: initialization of open array out-parameters is now done properly (using fpc_initialize_array).
+ Test

git-svn-id: trunk@17081 -
2011-03-05 18:45:44 +00:00
sergei
54bc8efa0b * Fixed reference counting of open array parameters passed by value. RTTI of the array itself is useless in this case, as it does not provide correct element count. Now using dedicated helpers which take RTTI of array element and the element count. Resolves #18859.
git-svn-id: trunk@17068 -
2011-03-03 18:38:46 +00:00
florian
88b0db90a6 * use correct sizes when getting additional registers for 64 bit values
git-svn-id: branches/avr@17044 -
2011-02-27 21:09:11 +00:00
florian
4bb9407f72 * remove usage of makeregsize on avr
git-svn-id: branches/avr@17027 -
2011-02-26 21:00:43 +00:00
florian
5abdfb6f7e * aint -> asizeint changes
git-svn-id: trunk@17018 -
2011-02-26 20:16:14 +00:00
florian
26fbfaf5a7 + introduce the usage of asizeint/asizeuint for cpus with sizeof("alu")<>sizeof(pointer)
git-svn-id: trunk@17011 -
2011-02-26 20:10:03 +00:00
paul
0f35da07f1 compiler: call gen_intf_wrappers not only for unit symtables but also for syntables of records and object types because they can contain nested classes (bug #0018610)
git-svn-id: trunk@16818 -
2011-01-26 13:50:36 +00:00
daniel
3307d98c40 - Revert micro-exe mode for now.
git-svn-id: trunk@16170 -
2010-10-15 16:49:48 +00:00
daniel
2139a229d3 + If no unit is used, no symbol inside the system unit is used,
and no language features requiring initialization are used,
    do not initialize units, but just configure the fpu and
    signal handlers.

git-svn-id: trunk@16124 -
2010-10-10 17:40:39 +00:00
Jonas Maebe
d5bc1c972f * don't generate init/fini sections in the al_procedures list, because the
compiler assumes it remains a sec_code (fixes linking problems with the
    iOS SDK 3.2 simulator tool chain when using debug info)

git-svn-id: trunk@16119 -
2010-10-09 21:27:07 +00:00
mazen
b127fc154a * Fixed spell error revealed by lintian.
git-svn-id: trunk@16094 -
2010-10-06 20:33:57 +00:00
Jonas Maebe
f13f6627c4 * moved use_fixed_stack from cgutils to a method in paramgr so it can
be used outside the code generator
  * renamed tabstractprocdef.requiredargarea into callerargareasize,
    and also added calleeargareasize field; added init_paraloc_info(side)
    method to init the parameter locations and init those size fields and
    replaced all "if not procdef.has_paraloc_info then ..." blocks with
    procdef.init_paraloc_info(callersize)"
  * moved detection of stack tainting parameters from psub to
    symdef/tabstractprocdef
  + added tcallparanode.contains_stack_tainting_call(), which detects
    whether a parameter contains a call that makes use of stack paramters
  * record for each parameter whether or not any following parameter
    contains a call with stack parameters; if not, in case the current
    parameter itself is a stack parameter immediately place it in its
    final location also for use_fixed_stack platforms rather than
    first putting it in a temporary location (part of mantis #17442)
  * on use_fixed_stack platforms, always first evaluate parameters
    containing a stack tainting call, since those force any preceding
    stack parameters of the current call to be stored in a temp location
    and copied to the final location afterwards

git-svn-id: trunk@16050 -
2010-09-26 21:24:14 +00:00
joost
65ab1e820b * Safecall on linux/i386 now behaves like cdecl plus hidden exception support.
* Adapted tests because safecall on linux/i386 now does not include high() 
   support anymore

git-svn-id: trunk@15913 -
2010-08-27 19:07:22 +00:00
florian
ad23569cf1 * renamed pi_has_goto into pi_has_label because the problematic thing is if a procedure has a label as target and not if it has some goto
* moved inclusion of pi_has_label to tlabelnode.pass_1

git-svn-id: trunk@15712 -
2010-08-05 19:22:12 +00:00
florian
0712dbe25d * white space fixes
git-svn-id: trunk@15709 -
2010-08-05 19:11:25 +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
florian
67416e958b * initialize file variables in iso mode
git-svn-id: trunk@15681 -
2010-07-31 20:43:37 +00:00
Jonas Maebe
356026f849 * use new_section() instead of tai_section.create() everywhere
- sort of reverted r14134, which is no longer required after the above
    change (new_section() inserts the alignment itself)
  * made the tai_section.create() constructor private so it cannot be
    called directly anymore

git-svn-id: trunk@15482 -
2010-06-26 10:50:14 +00:00
Jonas Maebe
7321f9a87a * fixed register allocation info when initialising parameters, both in
case they are refcounted out-parameters and when using -gt (mantis #16757)

git-svn-id: trunk@15479 -
2010-06-26 09:59:04 +00:00
Jonas Maebe
9ee74432b6 * fixed internalerror on ARM with 64 bit softfloats after r15416
git-svn-id: trunk@15437 -
2010-06-14 12:25:11 +00:00
Jonas Maebe
ea4bb9d752 * don't treat variant records with one element as "records with one element"
(the ABIs that prescribe special treatment for aggregates with one
     scalar element don't either, since a "union containing a single scalar"
     is not the same as a scalar)
  * fixed passing record with a single float field on PowerPC/AIX abi's
  * several changes to cgobj and ncgutil to correctly deal with transfering
    such records between integer and floating point registers

git-svn-id: trunk@15416 -
2010-06-13 09:57:58 +00:00
Jonas Maebe
7c372ede44 * fixed initialising 32 resp. 64 bit regvars with -g-t if the compiler is
an i386 resp. x86-64 binary (mantis #16668)

git-svn-id: trunk@15398 -
2010-06-09 15:58:39 +00:00
Jonas Maebe
15e9c54b44 * fixed ABI compliance for parameter passing and function returning on all
x86-64 platforms (except for win64, which uses another ABI and which
    already complied to it) + test
  * fixed returning records containing 1 single or double field on darwin/i386,
    these have to be returned via ST0 instead of as a regular record
  * added support for LOC_FPUREGISTER and LOC_MMREGISTER in several places
    where they can now occur due to the previous two changes
  * made a few internalerrors unique

git-svn-id: trunk@15368 -
2010-06-03 20:08:50 +00:00
Jonas Maebe
283018a3bf * changed tprocdef.funcretloc[] from a tlocation into a tcgpara so it can
represent complex locations (required for full x86-64 ABI support,
    which is not yet implemented) -> lots of special result handling
    code has been removed and replaced by the parameter handling
    routines
  + added support for composite parameters (and hence function
    results) to tcg.a_load_ref_cgpara() (so it can be used for
    handling, e.g., 64 bit parameters on 32 bit platforms)
  * the above fixed writing past the end of allocated memory when
    handling records returned in registers on x86-64 whose size is
    not a multiple of 8 bytes (mantis #16357)
  - removed the x86-64 and PPC specific versions of a_load_ref_cgpara(),
    as they are now handled correctly by the generic version
  * moved the responsibility of allocating tcgpara cpu registers
    (using paramanager.allocparaloc()) from the callers of
    cg.a_load*_cgpara() to the cg.a_load*_cgpara() methods
    themselves (so the register allocation can be done efficiently
    when dealing with function results)
  * for the above, renamed paramanager.alloc/freeparaloc() to
    paramanager.alloc/freecgpara(), and use paramanager.allocparaloc()
    to allocate individual pcgparalocations instead
  * fixed the register size of SSE2 function result registers for
    x86-64 (when used for floating point), which results in removing
    a few superfluous "movs? %xmm0,%xmm0" instructions
  * fixed compilation of paramanagers of avr, m68k and mips after r13695
    and also updated them for these new changes

git-svn-id: trunk@15350 -
2010-05-30 21:12:57 +00:00
Jonas Maebe
46ff0c4fc4 * extracted gen_load_cgpara_loc()
* unified previously introduced helpers into a single gen_load_loc_cgpara()
    with the same interface as gen_load_cgpara_loc()

git-svn-id: trunk@15327 -
2010-05-26 19:57:11 +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
e9b62c1294 * refactored general loc->cgpara loading code in ncgcal into helpers in
ncgutil it can be used elsewhere too
  - removed the code that checks for 64 bit integer types in the float
    para loading code, since is_64bit() can never return true for a
    floatdef

git-svn-id: trunk@15318 -
2010-05-22 16:05:04 +00:00
Jonas Maebe
9bc15a5f61 * renamed a_param_* to a_load_*_cgpara
git-svn-id: trunk@15305 -
2010-05-22 09:07:21 +00:00
Jonas Maebe
4945d419d3 * moved some paraloc->tlocation loading helpers from ncgutil to cgobj
* fixed an {$ifdef cpu64bitaddr} that should be {$ifdef cpu64bitalu}

git-svn-id: trunk@15276 -
2010-05-15 12:02:17 +00:00
Jonas Maebe
ca660d409c - removed unnecessary dependencies on tprocdef.funcretloc being a tlocation
(has to be changed into a tcgpara to fix the x86-64 abi bugs)

git-svn-id: trunk@15272 -
2010-05-13 18:29:01 +00:00