Commit Graph

208 Commits

Author SHA1 Message Date
yury
5405a4727a * Removed unused vars.
git-svn-id: trunk@35535 -
2017-03-07 08:56:07 +00:00
florian
5aa32a1bbe * align more jump targets
git-svn-id: trunk@35223 -
2017-01-03 16:43:24 +00:00
florian
2e16628db1 * warning fixed
git-svn-id: trunk@35168 -
2016-12-18 20:27:13 +00:00
Jonas Maebe
746de569d5 - removed unused local variable
git-svn-id: trunk@35159 -
2016-12-18 13:57:36 +00:00
Jonas Maebe
b14c037533 * record in the flowcontrol flags whether we are currently in a block whose
exceptions are caught in the current routine (fc_catching_exceptions),
    so that for LLVM we will be able to use "invoke" instead of "call" in that
    case

git-svn-id: trunk@35158 -
2016-12-18 13:57:33 +00:00
Jonas Maebe
6a1c4f9b75 * replaced cg.a_label/a_jmp_always with hlcg.* calls (only for consistency,
does not change anything in practice)

git-svn-id: trunk@35157 -
2016-12-18 13:57:29 +00:00
Jonas Maebe
3ae1f6664a * extracted exception state handling helpers into a utility class so
they can be overridden

git-svn-id: trunk@35156 -
2016-12-18 13:57:25 +00:00
Jonas Maebe
c0f4e4db34 * group emitting a label of a try-block and restoring the control flow flags
in a single routine, so that both happen at the same time (needed for LLVM
    where inside a try-block all calls need to be performed using "invoke"
    and refer to the current try-block/catching label)

git-svn-id: trunk@35144 -
2016-12-16 22:41:30 +00:00
Jonas Maebe
a1c0d1a1ff * moved exception handling helpers from ncgutil to ncgflw as they are only
used there (could be turned into protected methods if they are ever needed
    by child classes)

git-svn-id: trunk@35143 -
2016-12-16 22:41:28 +00:00
Jonas Maebe
d6ccd54da5 - removed unused doexceptlabel
git-svn-id: trunk@35139 -
2016-12-16 22:38:07 +00:00
Jonas Maebe
a25ebbba3e + added volatility information to all memory references
o separate information for reading and writing, because e.g. in a
     try-block, only the writes to local variables and parameters are
     volatile (they have to be committed immediately in case the next
     instruction causes an exception)
   o for now, only references to absolute memory addresses are marked
     as volatile
   o the volatily information is (should be) properly maintained throughout
     all code generators for all archictures with this patch
   o no optimizers or other compiler infrastructure uses the volatility
     information yet
   o this functionality is not (yet) exposed at the language level, it
     is only for internal code generator use right now

git-svn-id: trunk@34996 -
2016-11-27 18:17:37 +00:00
Jonas Maebe
48ef33a8b3 * fixed interprocedural gotos for llvm
o ensure that the label's local "jumpbuf" variable gets moved to the
     parentfpstruct soon enough
   o don't generate global symbols for interprocedural labels: they're not
     necessary if they are only used via setjmp/longjmp (all references are
     local in that case), and if they are referenced via an assembler block
     then we'll have to handle them by passing a blockaddress() expression
     as parameter to that assembler block (which does not require a global
     symbol, but which is not yet implemented)

git-svn-id: trunk@34946 -
2016-11-21 07:39:13 +00:00
florian
834d58f54c * better execution weighting for while loops: the condition must be evaluated with an increased execution weight as well
* ensure that the weight is always increased

git-svn-id: trunk@34799 -
2016-11-05 23:06:01 +00:00
florian
0610187878 + transform for loop into equivalent while loop during pass 1 to simplify code generation
git-svn-id: trunk@34788 -
2016-11-05 23:05:43 +00:00
svenbarth
70fbe50bac * reference the extern assembler symbol of the VMT when catching an exception if it's from another unit
git-svn-id: trunk@34336 -
2016-08-19 12:41:06 +00:00
svenbarth
7dadd44ba7 Merged revision(s) 32500 from branches/svenbarth/packages:
Use indirect references for "on".

ncgflw.pas, tcgonnode:
  * pass_generate_code: if the target supports packages then we need to load the VMT using an indirect symbol

........

git-svn-id: trunk@34228 -
2016-07-29 14:58:40 +00:00
Károly Balogh
56fea8d047 * have regvars in address registers for defs which are address types. improves code with reference bases in regvars on m68k. and also reduces data register pressure.
git-svn-id: trunk@33591 -
2016-05-01 11:33:37 +00:00
Jonas Maebe
118f3c8049 * fixed type of stored exception class instance in on-node
git-svn-id: trunk@32421 -
2015-11-21 12:37:33 +00:00
Jonas Maebe
f0c6d40336 * converted loading for fpc_catches parameter to hlcg
git-svn-id: trunk@32300 -
2015-11-12 22:00:31 +00:00
sergei
e542800ea9 * Win64 SEH: Track control flow out of unwind-protected regions in a more precise way and don't generate expensive calls to __fpc_local_unwind when not necessary.
git-svn-id: trunk@31582 -
2015-09-09 18:43:46 +00:00
Jonas Maebe
0fc1fd6ac1 * replaced current_procinfo.currtrue/falselabel with storing the true/false
labels of LOC_JUMP in the node's location. This generates some extra jumps
    for short circuit boolean and/or-expressions if optimizations are off, but
    with optimisations enabled the generated code is the same (except for JVM
    because the jump threading optimisation isn't enabled there yet).

git-svn-id: trunk@31431 -
2015-08-27 18:28:57 +00:00
Jeppe Johansen
c5b24c5ce3 Changed cast to allow more loop iterations than the native bit-ness of the architecture.
git-svn-id: trunk@31029 -
2015-06-13 12:20:12 +00:00
Jonas Maebe
61e4a1b811 + added tasmlist parameter to getintparaloc() (needed for llvm)
git-svn-id: trunk@30429 -
2015-04-04 14:29:16 +00:00
Jonas Maebe
8064adec38 * converted tcgtryexceptnode.pass_generate_code() and
tcgtryfinallynode.pass_generate_code() to thlcg

git-svn-id: branches/hlcgllvm@28482 -
2014-08-19 20:22:27 +00:00
Jonas Maebe
a637fbe596 * moved all g_exception_*() methods to hlcgobj and cleaned them up (no more
hardcoded registers for the most part)
  + added extra g_exception_discard_reason() that can be called when we only
    want to get rid of the currently pushed exception reason, and don't have
    to load it (so it can do nothing on platforms that don't use push/pop)

git-svn-id: branches/hlcgllvm@28481 -
2014-08-19 20:22:24 +00:00
Jonas Maebe
bacd303208 * synchronized with trunk up to r27758
git-svn-id: branches/hlcgllvm@27779 -
2014-05-12 16:12:34 +00:00
nickysn
a79a891940 * handle the result of FPC_CATCHES via the high level code generator (which makes it i8086 far pointer safe)
git-svn-id: trunk@27451 -
2014-04-02 14:25:19 +00:00
Jonas Maebe
73a3f5ced4 * moved ncgutil.maybechangeloadnodereg() to hlcg.maybe_change_load_node_reg()
and moved ifdef'd jvm code to overridden method

git-svn-id: trunk@27153 -
2014-03-16 11:24:40 +00:00
sergei
e26ce9e442 * Fix code generation of for-loops. Keeping a copy of to-value in register during pass 2 is basically a hack, because register may be destroyed if an exception is raised and handled in loop body. This went unnoticed because generic setjmp-based exception handling is restoring registers to the state at entry to try block, and Win64 SEH also has some register-preserving features. However, for Win32 SEH it is not true.
Instead, to-value is now copied to a temp during pass 1, and this temp is forced into memory if loop body contains try..finally or try..except block.

git-svn-id: trunk@26192 -
2013-12-07 09:18:18 +00:00
sergei
563b74b16a * Cleanup code generation for try..finally nodes.
git-svn-id: trunk@26191 -
2013-12-07 07:31:59 +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
bf07fc077b * specify AT_DATA in all references to the tobjectdef.vmt_mangledname symbol.
This fixes a lot of bugs, related to objects and classes in the i8086 medium
  memory model

git-svn-id: trunk@25794 -
2013-10-15 18:56:27 +00:00
sergei
4a9fe5d07d * Fixed register live range in for-loops:
o Loop counter node is "left", not "right",
  o End-value register needs explicit sync.

Without these changes, allocating registers in hlcg.a_cmp_reg_loc_label (at the end of loop) could reuse counter or end-value register, resulting in invalid code.

git-svn-id: trunk@24924 -
2013-06-21 15:26:14 +00:00
florian
a07af824ea * properly fix raise node handling on x86-64 after r24288
git-svn-id: trunk@24334 -
2013-04-26 20:17:54 +00:00
pierre
4f8fcb7f15 Revert commit 24324 for ncgflow.pas unit to fix win64 cycle
git-svn-id: trunk@24328 -
2013-04-26 09:38:57 +00:00
florian
709ba5e053 + introduce cnf_call_never_returns to signal the dfa if a call node never returns
* get rid of  tcgraisenode.pass_generate_code, it is replaced by compiler proc. call nodes generated in pass_1

git-svn-id: branches/i8086@24288 -
2013-04-21 16:53:25 +00:00
nickysn
a5c5b05362 * initial support for system procs that use calling conventions that push left to right on i8086 or i386
git-svn-id: branches/i8086@24282 -
2013-04-21 13:26:12 +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
pierre
18698bc93d Fix safecall for cpus for which NR_FUNCTION_RESULT_REG is different from NR_FUNCTION_RETURN_REG
git-svn-id: trunk@22489 -
2012-09-27 15:59:31 +00:00
florian
ca5fabda6d * cleanup some unused units from uses clauses
git-svn-id: trunk@22433 -
2012-09-21 18:53:46 +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
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
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
sergei
fa98e0523d * Safecall handling: forgot to free cgpara before doing the call, fixed.
git-svn-id: trunk@19976 -
2012-01-05 19:12:56 +00:00
sergei
f6761d7939 * Handle safecall exceptions entirely in tcgtryfinallynode pass2. This simplifies things and removes the need in hidden safe_result variable.
git-svn-id: trunk@19950 -
2012-01-02 14:23:31 +00:00
sergei
8c9ad67682 + tcgexitnode,tcgbreaknode,tcgcontinuenode: added possibility to generate specialized code for leaving unwind-protected regions.
git-svn-id: trunk@19636 -
2011-11-14 22:47:37 +00:00
sergei
e2d43fcb30 - tcgonnode: don't store exception object in temp if it is not used.
- tcgtryexceptnode: don't generate code to decrease/compare exception reason if not necessary.

git-svn-id: trunk@19517 -
2011-10-19 20:28:41 +00:00
sergei
a32fdc3ae6 + Added a simple helper tcg.g_call, intended to replace allocallcpuregisters+a_call_name+deallocallcpuregisters sequence which is used all over the place.
* Refactored code generation for tcgonnonde and tcgtryexceptnode, simplifying both compiler and generated code. Merged compilerprocs called in sequence into larger ones (fpc_popobjectstack+fpc_destroyexception -> fpc_doneexception, fpc_popsecondobjectstack+fpc_destroyexception+fpc_reraise -> fpc_raise_nested).

git-svn-id: trunk@19506 -
2011-10-18 15:46:15 +00:00
sergei
9ed2fa6f7b - Exception handling: calling FPC_CATCHES(-1) is obsolete, it does not change any state and its return value is not used. Removed.
- Don't generate guard frame around 'except' block if it contains no code (tryexceptnode.t1 is an empty blocknode in this case).

git-svn-id: trunk@19415 -
2011-10-08 12:57:58 +00:00
Jonas Maebe
0a3a62811b + try/except and try/finally support for JVM target:
o always create exceptvarsym entry for on-nodes (on all targets) to remove
     some special cases when an unnamed exception was caught
   o the JVM tryfinally node generates the finally code twice: once for the
     case where no exception occurs, and once when it does occur. The reason
     is that the JVM's static bytecode verification otherwise cannot prove
     that we will only reraise the caught exception when we caught one in
     the first place (the old "jsr" opcode to de-duplicate finally code
     is no longer used in JDK 1.6 because it suffered from the same problem,
     see Sun Java bug
     http://webcache.googleusercontent.com/search?q=cache:ZJFtvxuyhfMJ:bugs.sun.com/bugdatabase/view_bug.do%3Fbug_id%3D6491544 )

git-svn-id: branches/jvmbackend@18387 -
2011-08-20 07:55:21 +00:00