Commit Graph

151 Commits

Author SHA1 Message Date
J. Gareth "Curious Kit" Moreton
0e5da37533 * Flags specific to TAsmNode have been moved to their own field 2024-03-02 21:31:21 +01:00
Yuriy Sydorov
c78e9557f8 * Added support for the old Turbo Pascal INLINE(data/data/...) statement.
It is available only in the TP mode.
2021-08-16 00:40:34 +03:00
yury
8b7c5666a2 * Renamed fc_block_with_exit to fc_no_direct_exit to expand its usage.
* Set fc_no_direct_exit in case when a routine has an additional implicit exit code, such as calling FreeInstance in the destructor.

git-svn-id: trunk@47749 -
2020-12-10 17:38:37 +00:00
yury
d72566169e * The code generator of the exit statement must set the fc_gotolabel flag in flowcontrol for inlined routines/code blocks. It fixes the incorrect assumption that such exit statements terminate the main routine.
git-svn-id: trunk@47683 -
2020-12-04 12:33:47 +00:00
Jonas Maebe
a88288bab3 - reverted r46457, accidentally committed (breaks -Oooptcse)
git-svn-id: trunk@46459 -
2020-08-16 12:46:21 +00:00
Jonas Maebe
f26735fc77 * execute the tempinitcode whent the tempcreate node gets processed rather
than when the first temprefnode to it gets processed. Solves the issue
    the foreachnodestatic processes the tempinitcode when seeing the
    tempcreatenode and ignores it when seeing temprefnodes, even though
    it may actually be executed/generated for the temprefnode. It's
    impossible to easily process it for the "correct" temprefnode
    (since there may be multiple temprefnodes for the same tempcreatenode)
   o fixes tarray12 for Darwin/i386 and Linux/i386

git-svn-id: trunk@46457 -
2020-08-16 12:29:31 +00:00
nickysn
2f4390ac9b + added Z80 inline asm instruction validation
git-svn-id: trunk@45186 -
2020-04-29 23:51:23 +00:00
florian
f2a8b8ad6a * adapt register if the size of the paraloc and the register differ, resolves #34409
git-svn-id: trunk@43617 -
2019-11-30 20:37:55 +00:00
Jonas Maebe
281b3ad276 * fix case completeness and unreachable code warnings in compiler that would
be introduced by the next commit

git-svn-id: trunk@42046 -
2019-05-12 14:29:03 +00:00
Jonas Maebe
04d295f186 * first step towards supporting 32 bit targets with the LLVM code generator:
use the generic code in more cases when cpuhighleveltarget is defined

git-svn-id: trunk@41133 -
2019-01-29 21:39:09 +00:00
Jonas Maebe
3b9f5a5e96 * moved finalization of code generator temps to a node, so it can be getcopy'd
(needed for LLVM, where we need two copies of the finally code: one in case
     an exception occurs, and one in case none is raised)
   o also first finalize parameters and only then code generator temps, since
     in theory the former could create more of the latter

git-svn-id: trunk@40345 -
2018-11-17 22:38:36 +00:00
florian
800ce23499 * fixed some issues to get correct values of section_count, works better than before but it is still not perfect for unknown reasons
git-svn-id: trunk@39750 -
2018-09-12 20:33:18 +00:00
Jonas Maebe
4686f61002 * keep track of the temp position separately from the offset in references,
so that they can still be freed after the reference has been changed
    (e.g. in case of array indexing or record field accesses) (mantis #33628)

git-svn-id: trunk@38814 -
2018-04-22 17:03:16 +00:00
florian
1497b64804 * the temp. locations created by cse were not properly cleanup up, this patch fixes this
git-svn-id: trunk@38624 -
2018-03-25 15:55:34 +00:00
nickysn
c0b7aec2c4 * fix inline assembly of segment:localvar with the internal asm writer on x86
git-svn-id: trunk@38475 -
2018-03-09 15:36:59 +00:00
nickysn
2cee948b72 + support segment overrides in inline asm references to local variables or parameters on x86
git-svn-id: trunk@38392 -
2018-03-01 17:59:57 +00:00
Jeppe Johansen
e699be78ab Handle simple cases where a record member is passed in a register on AVR, and referenced from inline assembly.
git-svn-id: trunk@37864 -
2017-12-29 14:01:39 +00:00
nickysn
ddba821561 * GetNextReg(), used by 16-bit and 8-bit code generators (i8086 and avr) moved
from cpubase unit to a method in the tcg class. The reason for doing that is
  that this is now a standard part of the 16-bit and 8-bit code generators and
  moving to the tcg class allows doing extra checks (not done yet, but for
  example, in the future, we can keep track of whether there was an extra
  register allocated with getintregister and halt with an internalerror in case
  GetNextReg() is called for registers, which weren't allocated as a part of a
  sequence, therefore catching a certain class of 8-bit and 16-bit code
  generator bugs at compile time, instead of generating wrong code).
- removed GetLastReg() from avr's cpubase unit, because it isn't used for
  anything. It might be added to the tcg class, in case it's ever needed, but
  for now I've left it out.
* GetOffsetReg() and GetOffsetReg64() were also moved to the tcg unit.

git-svn-id: trunk@37180 -
2017-09-11 14:53:06 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
svenbarth
c6bfb0064f * keep track of the sections that are created in the asmlists
git-svn-id: trunk@35408 -
2017-02-10 14:38:53 +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
e730da9c1a * turned resolveref from a local procedure into a virtual method
git-svn-id: trunk@34856 -
2016-11-09 19:51:33 +00:00
florian
82e6e1eb34 + tempinfo flag ti_no_final_regsync which prevents that the final reg. sync. is emitted
git-svn-id: trunk@34787 -
2016-11-05 23:05:41 +00:00
Jonas Maebe
179c1ab328 * changed ttemp*node.tempinfo^.flags to a private field, and added setters
and getters for the ttemp*node classes instead
   o this will allow descendants to prevent certain flags from being added
     or removed. E.g. for LLVM, certain temps must never be put in registers
     because it cannot typecast a value in a register from a non-record/array
     type to an array type without forcing it to memory (so if that is done
     on an lvalue, the result will be written to the memory temp instead of
     to the register)

git-svn-id: trunk@34358 -
2016-08-21 14:23:09 +00:00
Jonas Maebe
18580d3069 * when assigning a value to a temp marked as ti_const, do not immediately
release the source location in case it was also a temp. Reason: we
    don't increase reference counts when assigning to a ti_const (they are
    like const parameters), so the original value must stay alive until
    the ti_const temp is freed
   o free the original data in the ttempdelete node for the ti_const temp
   o don't increase reference counts when assigning composite types to
     ti_const temps either

git-svn-id: trunk@34287 -
2016-08-12 13:35:51 +00:00
Jonas Maebe
46166c89cb - removed no longer used and unsafe ttemprefnode.create_offset()
functionality

git-svn-id: trunk@33733 -
2016-05-21 10:28:28 +00:00
nickysn
06b9789928 + implemented a new {$ASMCPU XXX} directive, allowing to specify a different
CPU target for inline assembler blocks. In addition to the different CPUs
  (as listed under 'Supported CPU instruction sets:' in the output of 'fpc -i'),
  it also supports the special values 'ANY' and 'CURRENT'. 'ANY' means no
  restrictions (i.e. all instructions are available). 'CURRENT' means the
  current CPU target (as specified with the '-Cp' command line option). For
  backward compatibility, the default value is 'ANY' for all CPU targets, except
  i8086, where it defaults to 'CURRENT'.

  This directive requires support for the new asd_cpu directive in the assembler
  writer. This is currently implemented only for NASM, but will be supported in
  some of the other assembler writers as well (incl. the x86 internal assembler
  writer).

git-svn-id: trunk@33138 -
2016-02-29 22:25:25 +00:00
Jonas Maebe
67b8aceaee * synchronized with privatetrunk till r30095
git-svn-id: branches/hlcgllvm@30101 -
2015-03-05 20:32:15 +00:00
sergei
657ac78304 * Improved handling of registers used in assembler blocks. Assembler nodes no longer have lists of used registers attached to them. Instead, each specified register creates an allocation/deallocation pair and an additional tai_regalloc.markused item directly in the asmlist. This way, register lists are no longer limited to integer registers, and parsing no longer depends on paramanager to know which registers are volatile.
If assembler block has no modified register list, it is still handled in pass2, by allocating all volatile registers (not only the integer ones as before).

git-svn-id: trunk@30011 -
2015-02-25 21:53:15 +00:00
Jonas Maebe
3b7f43ad77 * renamed (hl)gettemptyped() to (hl)gettempmanaged() to better indicate the
meaning

git-svn-id: branches/hlcgllvm@28484 -
2014-08-19 20:22:32 +00:00
nickysn
99770d367f * 16-bit and 8-bit ALU fixes in tcgtempdeletenode.pass_generate_code
git-svn-id: trunk@26272 -
2013-12-23 14:09:28 +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
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
Jonas Maebe
c37c039905 * report resolveref errors on the correct line number
git-svn-id: trunk@23153 -
2012-12-15 22:54:22 +00:00
Jonas Maebe
6ac8b4fbdf * give a proper error when an mmx/fpu/sse register is used inside a memory
reference (mantis #23441)

git-svn-id: trunk@23152 -
2012-12-15 22:47:16 +00:00
Jonas Maebe
288d1ec74a * support referencing "result" in nostackframe pure assembler routines if
the result location is a simple location (a single register/reference)
    (mantis #22490)
  * print an error when accessing "result" in a nostack pure assembler routine
    if the result location is not simple

git-svn-id: trunk@22166 -
2012-08-21 19:51:40 +00:00
Jonas Maebe
b50d0aa3d0 * only don't pre-finalize funcret temps that are passed by reference to the
called function, fixes webtbs/tw3742.pp after r21955 (looked at wrong
    testsuite results :/ )

git-svn-id: trunk@21963 -
2012-07-23 23:55:00 +00:00
Jonas Maebe
ccbcb36f98 * don't pre-finalize temp nodes that are passed by reference as hidden
function result parameter, because reference counted function results
    are not guaranteed to be initialized (we sometimes even pass the,
    non-finalized, left-hand side of an assignment as hidden function
    result parameter)

git-svn-id: trunk@21955 -
2012-07-23 14:22:36 +00:00
Jonas Maebe
cef61300ff + ttgobj.gethltemptyped() routine for allocating managed types with high level
code generator support
  * refactored some internal temp generator code

git-svn-id: branches/jvmbackend@18681 -
2011-08-20 08:24:07 +00:00
Jonas Maebe
b556c05b1a * properly deal with reference temps in tcgtempdeletenode.pass_generate_code
git-svn-id: branches/jvmbackend@18665 -
2011-08-20 08:22:38 +00:00
Jonas Maebe
a2a6b2fd1d + "reference" temps that sort of implement pointer-style functionality for
platforms that don't support pointers (by make a copy of all registers
    part of a reference)

git-svn-id: branches/jvmbackend@18377 -
2011-08-20 07:54:10 +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
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
mazen
b127fc154a * Fixed spell error revealed by lintian.
git-svn-id: trunk@16094 -
2010-10-06 20:33:57 +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
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
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
florian
7707e6a030 + tempcreate nodes can now take an init. value, this allows to initilialize temp. ref nodes on the fly
git-svn-id: trunk@14595 -
2010-01-10 13:19:16 +00:00
florian
40cea8d4d5 * handle mm register properly when used as top_local, resolves #14566
git-svn-id: trunk@14535 -
2010-01-03 20:33:01 +00:00
Jonas Maebe
09b4918cab * don't allocate persistent temps for classes (they are not refcounted)
git-svn-id: trunk@14372 -
2009-12-08 20:00:27 +00:00