Commit Graph

707 Commits

Author SHA1 Message Date
Jonas Maebe
332af0bc4e * completed license header
git-svn-id: branches/debug_eh@41575 -
2019-03-03 17:14:53 +00:00
Jonas Maebe
8f6820a9f1 * LLVM=: also merge varargs paralocs
git-svn-id: branches/debug_eh@41520 -
2019-02-27 21:13:49 +00:00
Jonas Maebe
e720a1f306 * moved tcgexceptionstatehandler to a new cgexcept unit
* fixed llvm cycle by overriding additional eh-related tcgprocinfo methods

git-svn-id: branches/debug_eh@41519 -
2019-02-27 21:13:45 +00:00
Jonas Maebe
a079e5fa80 * synchronised with trunk till r41449
git-svn-id: branches/debug_eh@41450 -
2019-02-24 20:01:53 +00:00
Jonas Maebe
08791712d7 * also specify the byval alignment at the callee side
git-svn-id: trunk@41448 -
2019-02-24 19:59:00 +00:00
Jonas Maebe
6071263469 * use ` instead of ^ as replacement character in LLVM asmnodes, as ^ can
appear in ARM inline assembly

git-svn-id: trunk@41446 -
2019-02-24 19:58:54 +00:00
Jonas Maebe
a87a7270d5 * remove double "nocapture" attributes
* also add "noalias nocapture" to sret parameters

git-svn-id: trunk@41445 -
2019-02-24 19:58:51 +00:00
Jonas Maebe
e829596750 * type left-over parts of parameters as arrays of "stack slot alignment" if
they're an exact multiple of the ialignment size on LLVM. This prevents
    both overalignment (e.g. remainder of 8 individual bytes on ARM
    would be aligned to 8 bytes instead of 4 if typed as int64) and
    underalignment (e.g. 32 bytes remainder of a record that needs to be
    aligned to 8 bytes would be aligned to 1 or 4 bytes if types as
    array of resp. bytes or longints)

git-svn-id: trunk@41444 -
2019-02-24 19:58:47 +00:00
Jonas Maebe
5cb5b10f8d * fixed LLVM and non-i386 compilation
git-svn-id: branches/debug_eh@41423 -
2019-02-23 17:03:42 +00:00
florian
65aebd22b0 + initial implementation of dwarf/eh_frame based exception handling for i386-linux, basic stuff works, open todos
* nested exception handling statments in one procedure need to be fixed
  * clean up, finally factor out tcgprocinfo from psub at least
  * extensive testing

git-svn-id: branches/debug_eh@41289 -
2019-02-10 18:07:33 +00:00
Jonas Maebe
a0831b058a * fixed LLVM para loading for byval paralocs that are preceded by other
paralocs

git-svn-id: branches/debug_eh@41217 -
2019-02-03 21:10:18 +00:00
Jonas Maebe
af098474f4 * keep track of the alignment requirements of parameters with LLVM, and emit
them when they are different from the default

git-svn-id: branches/debug_eh@41216 -
2019-02-03 21:10:14 +00:00
Jonas Maebe
8eb07ed7b1 * add support for custom calling conventions to LLVM function declarations
git-svn-id: branches/debug_eh@41211 -
2019-02-03 21:09:58 +00:00
Jonas Maebe
9d07e4948f * fix compilation of ARM compiler for LLVM
git-svn-id: branches/debug_eh@41210 -
2019-02-03 21:09:54 +00:00
Jonas Maebe
7aa6a2ec81 * only make a copy of the finally code in pass_1 instead of in pass_typecheck,
to avoid an internalerror in case the finally code contains a goto outside
    the finally code (tbf/tb0209.pp)

git-svn-id: branches/debug_eh@41209 -
2019-02-03 21:09:51 +00:00
Jonas Maebe
d93c05a90c * synchronised with trunk till r41207
git-svn-id: branches/debug_eh@41208 -
2019-02-03 21:05:37 +00:00
Jonas Maebe
f9668f8c03 * let de LLVM parameter manager merge multiple paralocs used to represent a
single ordinal, as such splitting is handled by LLVM itself (and handling
    such split locations is currently not supported by our LLVM code generator)

git-svn-id: trunk@41199 -
2019-02-03 21:00:28 +00:00
Jonas Maebe
503ea604f3 + nolinline modifier to specify that a routine must never be inlined
git-svn-id: trunk@41198 -
2019-02-03 21:00:17 +00:00
Jonas Maebe
a0d796e98d * synchronised with trunk till r41159
git-svn-id: branches/debug_eh@41160 -
2019-02-01 17:01:54 +00:00
Jonas Maebe
e52cf555ab * fix loading of constants in registers in the LLVM CG if the constant
does not fit in ptrsinttype

git-svn-id: trunk@41138 -
2019-01-29 21:39:26 +00:00
Jonas Maebe
14cc517f40 * synchronised with trunk till r40724
git-svn-id: branches/debug_eh@40737 -
2019-01-01 17:15:29 +00:00
Jonas Maebe
a72a12eef6 * don't emit 0-sized parameters for LLVM: clang doesn't either, and some
LLVM backends (like the AArch64 one) trigger internal errors when
    encountering them

git-svn-id: trunk@40736 -
2019-01-01 16:55:41 +00:00
Jonas Maebe
9f928b2805 * fix exception handling code generator memory leaks
git-svn-id: branches/debug_eh@40734 -
2019-01-01 16:24:42 +00:00
Jonas Maebe
473fef315d * synchronised with trunk till r40732
git-svn-id: branches/debug_eh@40733 -
2019-01-01 16:24:18 +00:00
Jonas Maebe
4d03f3a65e * fixed LLVM memory leaks
git-svn-id: trunk@40732 -
2019-01-01 16:22:31 +00:00
Jonas Maebe
882d676bc9 * synchronised with trunk till r40635
git-svn-id: branches/debug_eh@40636 -
2018-12-24 22:12:19 +00:00
Jonas Maebe
acf02ab64b * when creating wrappers, add a prefix to parameter names to prevent them
hiding the method name of the wrapped routine
   o also add a few more '&' prefixes to the generated wrapper code to
     prevent issues when keywords are used as identifiers

git-svn-id: trunk@40634 -
2018-12-24 22:10:06 +00:00
Jonas Maebe
f3d831b480 * fixed result cgsize of LLVM's second_nothing type conversion node (new
size instead of original size, which can be different in case of going
    from void to something else)

git-svn-id: trunk@40632 -
2018-12-24 22:09:58 +00:00
Jonas Maebe
eb769e3859 * force pointer-based self parameters of inlined routines in temps for LLVM
to ensure that their type gets updated

git-svn-id: trunk@40631 -
2018-12-24 22:09:55 +00:00
Jonas Maebe
dd29088430 * simplify all type conversions for formal constants even for LLVM and JVM
(since these happen at compile time and don't result in generated code,
     they never need extra type conversions in the code)

git-svn-id: trunk@40629 -
2018-12-24 22:09:48 +00:00
Jonas Maebe
31c047adf8 * synchronised with trunk till r40605
git-svn-id: branches/debug_eh@40606 -
2018-12-21 20:58:16 +00:00
Jonas Maebe
f87304f5ca * fixed LLVM code generator not taking into account constalignmin/max
settings for typed constants

git-svn-id: trunk@40605 -
2018-12-21 20:57:22 +00:00
Jonas Maebe
4f72edcdd5 + LLVM support for the FMA intrinsics
git-svn-id: trunk@40604 -
2018-12-21 20:57:19 +00:00
Jonas Maebe
1cc995b471 * use ccallnode.createintern() instead of
ccallcnode.createinternfromunit('SYSTEM')

git-svn-id: trunk@40603 -
2018-12-21 20:57:16 +00:00
Jonas Maebe
c55ffa8cc7 * fixed <> comparisons with NaNs (use LLVM "unordered" comparison: succeed
if either operand is a NaN)

git-svn-id: trunk@40602 -
2018-12-21 20:57:12 +00:00
Jonas Maebe
3b4011760a * cleaned up blockaddress instruction (add type rather than hardcoding it
in the assembler writer)
  * fixed taking the address of a label in a typed const for llvm (fixes
    tbs/tb0468a)

git-svn-id: trunk@40599 -
2018-12-20 21:22:44 +00:00
Jonas Maebe
1a0ffbc82b * fixed llvm compiler compilation with -O3/-Oodfa
git-svn-id: branches/debug_eh@40590 -
2018-12-18 21:13:56 +00:00
Jonas Maebe
752a28a41d * enabled more optimization flags for llvm
git-svn-id: branches/debug_eh@40589 -
2018-12-18 21:13:52 +00:00
Jonas Maebe
24c49301e3 * synchronised with trunk till r40578
git-svn-id: branches/debug_eh@40579 -
2018-12-16 21:00:49 +00:00
Jonas Maebe
7cc7268635 * fixed dynamic array constants for non-Darwin LLVM platforms
git-svn-id: trunk@40578 -
2018-12-16 20:59:58 +00:00
Jonas Maebe
f26ac9026e * enable LLVM support Linux/AArch64
o also put the regular function result before the partfpstruct parameter

git-svn-id: branches/debug_eh@40577 -
2018-12-16 20:46:44 +00:00
Jonas Maebe
b41cd1eb6a * synchronised with trunk till r40575
git-svn-id: branches/debug_eh@40576 -
2018-12-16 20:45:55 +00:00
Jonas Maebe
2330164ee2 + internal sqrt support for LLVM (faster on all platforms, necessary on
platforms that don't have RTL support for it, as the the generic
    fpc_sqrt_real just calls runerror)

git-svn-id: trunk@40575 -
2018-12-16 20:44:41 +00:00
Jonas Maebe
e69b4d2d9a * replaced some stray cpointerdef.create() calls with cpointerdef.getreusable()
git-svn-id: trunk@40572 -
2018-12-16 20:44:31 +00:00
Jonas Maebe
93e39fb0cd * only coerce the type of the leftover bytes of a record if the location
size doesn't match the number of remaining bytes
   o prevents a second "single" field of a record getting interpreted as a
     "cardinal"

git-svn-id: trunk@40569 -
2018-12-16 20:44:21 +00:00
Jonas Maebe
97bc58d248 * fixed bug that caused the "sret" argument attribute to never be used (and
a guaranteed internalerror on AArch64/llvm)

git-svn-id: trunk@40565 -
2018-12-16 20:44:09 +00:00
Jonas Maebe
440026bb25 * synchronised with trunk till r40503
git-svn-id: branches/debug_eh@40504 -
2018-12-08 15:33:36 +00:00
Jonas Maebe
32a51d7b62 * add nocapture and dereferenceable/dereferenceable_or_null decorators to
parameters for llvm where appropriate

git-svn-id: trunk@40503 -
2018-12-08 15:31:54 +00:00
Jonas Maebe
51502874af * emit temp lifetime information for llvm
o also allow freeing temps in the middle of a routine for llvm (we won't
     reuse them, but it results in better lifetime information)

git-svn-id: trunk@40502 -
2018-12-08 15:31:51 +00:00
Jonas Maebe
8a4947dba2 * don't do anything in thlcgllvm.allocallcpuregisters() like in
deallocallcpuregisters()

git-svn-id: trunk@40499 -
2018-12-08 15:31:41 +00:00
Jonas Maebe
9630eb7ce9 * synchronised with trunk till r40466
git-svn-id: branches/debug_eh@40467 -
2018-12-04 19:54:31 +00:00
Jonas Maebe
b7da7cd654 * ensure the generic version of tcgshlshrnode gets used for llvm
git-svn-id: trunk@40464 -
2018-12-04 19:53:16 +00:00
Jonas Maebe
cec839ab30 - removed the -(m)stack-alignment parameter, as it prevents stack-realignment
by llc (so avx code crashes on targets wich 16 byte stack alignment --
    which is all of them)

git-svn-id: branches/debug_eh@40445 -
2018-12-01 23:08:48 +00:00
Jonas Maebe
eb742bcacc * pass on the value of -CfXXX to llc/clang for x86-64
git-svn-id: branches/debug_eh@40438 -
2018-12-01 20:30:46 +00:00
Jonas Maebe
68ce5dc91f * register static symbols references from assembly code as "used" so that LLVM won't
remove them if there are no references from regular code

git-svn-id: branches/debug_eh@40432 -
2018-12-01 20:30:27 +00:00
Jonas Maebe
85702dd263 + added support for clang as an assembler for llvm IR
* adapted string used for macOS/iOS version in triple in llvm IR files to
    what clang expects (always a single digit patch version)

git-svn-id: branches/debug_eh@40431 -
2018-12-01 20:30:24 +00:00
Jonas Maebe
645a4da831 - removed "-enable-fp-mad" llc option, as it's not supported for all versions
git-svn-id: branches/debug_eh@40420 -
2018-11-29 21:50:18 +00:00
Jonas Maebe
df0a126064 * abstracted rest of the generic exception handling code through the
texceptionstatehandler class + llvm overrides
  + added FPC_DummyPotentialRaise routine that gets called at the begin and end
    of try-blocks to be able to catch hardware exceptions to a limited extent
    with LLVM

git-svn-id: branches/debug_eh@40418 -
2018-11-29 21:31:40 +00:00
Jonas Maebe
7ffd5fc90b * handle explicit reraise for llvm specifically, as it needs to unwind to
the parent exception frame (-> pop current exception label, invoke/call
    reraise, push current exception label again)

git-svn-id: branches/debug_eh@40417 -
2018-11-29 21:31:37 +00:00
Jonas Maebe
2f8fcf7819 + new tf_use_psabieh target flag to indicate a target uses PSABI/Dwarf EH
o use this flag to set the personality routine of a function if it uses
     exception handlinga
   o also define FPC_USE_PSABIEH if this target flag is set
   o set this target flag for darwin/x86-64 if the compiler is compiled with
     -dllvm

git-svn-id: branches/debug_eh@40415 -
2018-11-29 21:31:30 +00:00
Jonas Maebe
fceb34dbd5 * converted tllvmpara contents from tlocation to toper, so we can also
store tai in them
  + support for direct symbol parameters to llvm routines (without first
    loading them into register)
   o needed to pass such symbols to llvm intrinsics

git-svn-id: branches/debug_eh@40414 -
2018-11-29 21:31:27 +00:00
Jonas Maebe
d363acbe77 * when inserting a reference to an external procdef, also process its
parameter types in case it hasn't been called (because in that case
    the defs of those parameters won't have been used and hence they
    won't have been recorded for writing either)

git-svn-id: branches/debug_eh@40413 -
2018-11-29 21:31:24 +00:00
Jonas Maebe
ae65f88f62 * add support for la_catch in spilling_get_reg_type (it will never need
spilling, but we may need the type to insert bitcasts)
  * load the la_catch symbol operand with loadref instead of loadsymbol,
    as the latter sets refaddr_full and with llvm we use that to indicated
    symbol names of named registers rather than data symbols (which in turn
    prevents it from being processed for inserting bitcasts if necessary)

git-svn-id: branches/debug_eh@40412 -
2018-11-29 21:31:21 +00:00
Jonas Maebe
ce7579bd50 + added "cleanup" landing pad opcode
git-svn-id: branches/debug_eh@40411 -
2018-11-29 21:31:18 +00:00
Jonas Maebe
4cd6f59bc3 * changed create_hlcodegen into a procvar, so that we don't have to insert
hlcgllvm in the uses clause of every unit that calls create_hlcodegen
   o prevents dependency cycles that can cause llvm codegen units to init
     before the cpu variants, which is bad since the llvm versions have to
     override the cpu variants in their init code (+ added checks in the
     init code that they are in fact initialised later)

git-svn-id: branches/debug_eh@40410 -
2018-11-29 21:31:15 +00:00
Jonas Maebe
366bf4294b * constructor to create extractvalue/extractelement instructions
git-svn-id: branches/debug_eh@40409 -
2018-11-29 21:31:11 +00:00
Jonas Maebe
e6c89bbf0a + helper to add an extra clause to a landingpad instruction
git-svn-id: branches/debug_eh@40408 -
2018-11-29 21:31:08 +00:00
Jonas Maebe
ccb7231744 * generate invoke instead of call when calling a function in a block that
catches exceptions

git-svn-id: branches/debug_eh@40405 -
2018-11-29 21:30:59 +00:00
Jonas Maebe
8711069998 + constructors to create invoke instructions
git-svn-id: branches/debug_eh@40404 -
2018-11-29 21:30:56 +00:00
Jonas Maebe
077d7e8551 * fixed handling of LLVM invoke instruction in the assembler writer and
type inference

git-svn-id: branches/debug_eh@40403 -
2018-11-29 21:30:53 +00:00
Jonas Maebe
5b8f7224af * set the dummy exception handling personality function for functions using
exceptions for LLVM (except on Windows targets, since they (will) use
    their own kind of exception handling)
   o ensure we generate an external function symbol definition for such
     personality functions on LLVM

git-svn-id: branches/debug_eh@40402 -
2018-11-29 21:30:49 +00:00
Jonas Maebe
b6efcb9105 + tllvmexceptionstatehandler that emits LLVM landingpad instructions to be
referred by invoke instructions in exception catching blocks
   o for now we won't actually use ABI-compliant exception handling, but we
     need invoke/landingpad combinations for LLVM's control flow analyses to
     correctly handle code involving exception handling

git-svn-id: branches/debug_eh@40401 -
2018-11-29 21:30:46 +00:00
Jonas Maebe
50ab607676 + customint torddef type to create arbitraty bit-width integers
o use this to handle non-power-of-two-sized parameters for llvm
   o no general support in the parser/code generator, so don't expose

git-svn-id: trunk@40398 -
2018-11-29 20:57:08 +00:00
Jonas Maebe
97b40dc16d * fixed dynamic array constants for llvm
git-svn-id: trunk@40383 -
2018-11-28 19:23:25 +00:00
Jonas Maebe
413a3599c1 * thlcgobj.g_unreachable() dummy implementation + llvm override
git-svn-id: trunk@40382 -
2018-11-28 19:23:22 +00:00
Jonas Maebe
20fea3607c * pass volatility information to llvm.memcpy
git-svn-id: trunk@40376 -
2018-11-26 22:30:05 +00:00
pierre
23570bed33 Use same parameter type for update_reference_offset override
git-svn-id: trunk@40325 -
2018-11-16 13:26:56 +00:00
Jonas Maebe
0b246f3dbd * converted Boolean8 to an internal type, and mapped Boolean to the
new internal pasbool1(type) (part of mantis #34411)
   o apply the _Bool x86-64 parameter passing rules only to pasbool1

git-svn-id: trunk@39949 -
2018-10-16 21:14:18 +00:00
florian
c7a0022146 * fix building with LLVM=1, thanks to Karl-Michael Schindler for the hint
git-svn-id: trunk@39861 -
2018-10-05 20:56:56 +00:00
Jonas Maebe
807fcb3371 * support pasbool8 as type for a record field when a record is passed/
returned in multiple registers (llvm)

git-svn-id: trunk@38862 -
2018-04-28 16:17:37 +00:00
Jonas Maebe
d69ad8fa41 * removed temppos field again from parameter locations: they're not allocated
by the temp manager of the current procedure

git-svn-id: trunk@38858 -
2018-04-27 19:18:55 +00:00
Jonas Maebe
3da67019e5 * fixed llvm compiler compilation after r38814 (crashes in "make cycle", but
that was already the case before)

git-svn-id: trunk@38815 -
2018-04-22 20:40:19 +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
94de872927 * fix compilation for llvm as proposed by Karl-Michael Schindler, resolves #31969
git-svn-id: trunk@37842 -
2017-12-28 14:57:35 +00:00
Jonas Maebe
e4dbd24a49 + inline trunc() support for the LLVM backend when using -Oofastmath (because
the behaviour of LLVM's fptosi instruction is undefined in case of
    overflow)

git-svn-id: trunk@36275 -
2017-05-20 19:28:15 +00:00
Jonas Maebe
04ac44cd37 - removed dependency of hlcgllvm on llvmpara, so that cpupara no longer
indirectly depends on llvmpara and hence is initialised after instead
    of before it (since llvmpara should override cpupara in its init code)

git-svn-id: trunk@36264 -
2017-05-19 21:52:37 +00:00
svenbarth
c16238e8dd * fix for Mantis #31464: add an entry for the WebAssembly CPU (this is already the target name that LLVM uses)
git-svn-id: trunk@35507 -
2017-03-03 16:14:52 +00:00
Jonas Maebe
4b9179636b + support for creating and writing LLVM landingpad instructions
git-svn-id: trunk@35161 -
2016-12-18 13:57:42 +00:00
Jonas Maebe
28e5636daa + support for LLVM nil assembler symbols in instructions (write as "null")
+ support for LLVM nil tai operands (will be used for terminating a daisy
    chain of catch/filter clauses of landingpads): don't try to write it

git-svn-id: trunk@35160 -
2016-12-18 13:57:39 +00:00
Jonas Maebe
7503c2bd3e * changed llvmgettemprecorddef() to take an open array instead of a tfplist
as list of defs to be stored in the record, so we don't need to create and
    free a class instance every time we call this routine

git-svn-id: trunk@35155 -
2016-12-18 13:57:22 +00:00
Jonas Maebe
b936d8f012 * don't internalerror when performing an LLVM tc_equal conversion from one
TP-style object to another and the sizes differ, at least if they are
    related
  * restructured and commented the LLVM type conversion checks

git-svn-id: trunk@35137 -
2016-12-16 22:38:01 +00:00
Jonas Maebe
f55d962e40 * use system.round() instead of LLVM's fptosui operation for converting a
floating point type to currency, as fptosui is defined as always rounding
    to zero while on other platforms we use the FPU's current rounding mode
    (fixes webtbs/tw21449 for LLVM, and also webtbs/tw24197 because LLVM's
     code generated for fptosui temporarily changes the FPU control word so
     it rounds to zero and also to disable FPU exceptions)

git-svn-id: trunk@35061 -
2016-12-04 11:15:22 +00:00
Jonas Maebe
8b1c90124e * support encoding helper types for LLVM (encode the same type as the
extended class) (fixes webtbs/tw21457 for LLVM)

git-svn-id: trunk@35060 -
2016-12-04 11:15:19 +00:00
Jonas Maebe
a0b537bc7b * fixed typed constants that use an integer number to initialise a procvar or
pointer on LLVM (fixes webtbs/tw21267)

git-svn-id: trunk@35059 -
2016-12-04 11:15:15 +00:00
Jonas Maebe
a8e107bb4b * fix memory leak: free rg[R_MMREGISTER]
git-svn-id: trunk@35056 -
2016-12-04 11:15:05 +00:00
Jonas Maebe
8c167f4e40 * handle already quoted symbol names for LLVM (like for Objective-C)
git-svn-id: trunk@35045 -
2016-12-02 18:04:14 +00:00
Jonas Maebe
876e5eab56 * fixed "smart linking" parameters to llc
git-svn-id: trunk@35044 -
2016-12-02 17:45:12 +00:00
Jonas Maebe
02e4a27a35 * print internalerrors in case we still encounter stray constants not part of
a typed constants
  * don't print superfluous newlines in typed constant definitions

git-svn-id: trunk@35042 -
2016-12-02 12:33:09 +00:00
Jonas Maebe
db40e1575d + support for handling the tcalo_no_dead_strip flag when targeting LLVM:
add such symbols to the pseudo-arrays llvm.compiler.used or llvm.used
    depending on their nature (fixes compiling Objective-C programs with
    optimization, and keeps the FPC ident in the linked binary)

git-svn-id: trunk@35041 -
2016-12-02 12:33:05 +00:00
Jonas Maebe
e62cb7917e + support for setting the "appending" flag of declaration generated via an
LLVM typed constant builder through a new appendingdef property

git-svn-id: trunk@35040 -
2016-12-02 12:33:02 +00:00
Jonas Maebe
97d6f17cc8 + add support for marking an LLVM definition as using "appending" linkage
git-svn-id: trunk@35039 -
2016-12-02 12:32:58 +00:00
Jonas Maebe
d328d7d95d * don't write an alignment for symbols in internal llvm sections (sections
whose name starts with 'llvm.')

git-svn-id: trunk@35038 -
2016-12-02 12:32:54 +00:00
Jonas Maebe
d99d18e258 - removed useless empty asmwrite statement
git-svn-id: trunk@35037 -
2016-12-02 12:32:51 +00:00
Jonas Maebe
006c7e1ccf * apply localalignmin/max to local variables for LLVM (fixes webtbs/tw15582)
git-svn-id: trunk@35020 -
2016-11-29 21:54:30 +00:00
Jonas Maebe
8cd84bd8e8 * stop updating llvmnextfieldindex once we have established that the current
typed constant does not match the equivalent LLVM definition (it's only
    used to check whether any emitted data's type differs from the LLVM
    definition's field types)
   o fixed a potential out-of-bounds access related to this: the index of the
     equivalent LLVM field kept getting increased and at some point we checked
     whether the current emitted data's type was different from the LLVM field
     type without verifying first that the LLVM equivalent field index was not
     yet beyond the number of LLVM equivalent fields

git-svn-id: trunk@35018 -
2016-11-29 21:54:25 +00:00
Jonas Maebe
ee014fa4ff * fixed handling of typed files for LLVM when ISO-like I/O is active: encode
the buffer in the type, and support typecasting the typed file to a
    different size (needed to be able to pass it to the compiler helpers that
    expected a "TypedFile", whose buffer is 0 bytes and which hence will
    always have a smaller size than the original type) (fixes test/tisoext1)

git-svn-id: trunk@35017 -
2016-11-29 21:54:21 +00:00
svenbarth
ee466b9a28 * extend tdef.fullownerhierarchyname() with a parameter that skips the inclusion of a procdef's parameter declaration using the new pno_noparams option
git-svn-id: trunk@35009 -
2016-11-28 18:06:35 +00:00
Jonas Maebe
26f9dabf56 * write the volatile flag for LLVM load/store operations if set
git-svn-id: trunk@35004 -
2016-11-27 21:44:32 +00:00
Jonas Maebe
4d951780d1 + support for LLVM 3.8 and LLVM 3.9 IR to the llvm assembler writer
git-svn-id: trunk@35003 -
2016-11-27 21:44:29 +00:00
Jonas Maebe
3ea976fd2d * fixed compilation of llvm compiler after r34996
git-svn-id: trunk@35002 -
2016-11-27 21:44:26 +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
26a05518f8 * implement unary minus for floating point via -1.0*x instead of 0-x,
because otherwise -0.0 stays 0.0 (fixes webtbs/tw4534 for llvm)

git-svn-id: trunk@34990 -
2016-11-27 17:17:02 +00:00
Jonas Maebe
b2e99da3e6 * use tabstractprocdef.is_addressonly to determine whether a procvar is
stored in more than one register (has a self and a code pointer), instead
    of assuming it always occupies more than one register if the original
    procdef had a self pointer (can be different when getting the address
    of a static class procedure)

git-svn-id: trunk@34976 -
2016-11-26 21:51:18 +00:00
Jonas Maebe
ef90b46e52 * comment fix
git-svn-id: trunk@34958 -
2016-11-24 19:47:48 +00:00
Jonas Maebe
d39db60934 * initialise the llvmvalueloc field for LOC_VOID locations, so they don't
get randomly passed as either byval or not (while they don't contain any
    data and hence this can't cause bugs in the generated code, it can cause
    signature mismatches in llvm)

git-svn-id: trunk@34956 -
2016-11-24 08:57:09 +00:00
Jonas Maebe
280a6e15b7 * fixed invalid memory reads and potential double freeing when removing
superfluous temporary paralocs for llvm

git-svn-id: trunk@34955 -
2016-11-24 08:57:05 +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
Jonas Maebe
ade45eb31a + support for llvm load nodes of labelsym using blockaddress()
git-svn-id: trunk@34945 -
2016-11-21 07:39:09 +00:00
Jonas Maebe
3b7d9447ae * blockaddress creates a constant operand for another opcode, it's not an
independent operation
   o additionally, it does not take a "label" qualifier for its label argument

git-svn-id: trunk@34944 -
2016-11-21 07:39:05 +00:00
Jonas Maebe
e1e3ad15f0 * escape all occurrences of '$' in function-level inline assembly
o temporarily encode the uses of '$' for references to function-level inline
     assembly arguments as '^', because those have to remain/become a single
     '$'

git-svn-id: trunk@34898 -
2016-11-13 22:10:00 +00:00
Jonas Maebe
43e599d6be * fixed function-level inline assembly constraints in case there are no
parameters

git-svn-id: trunk@34897 -
2016-11-13 22:09:57 +00:00
Jonas Maebe
c3aa9e2890 * generate LLVM function-level inline assembly blocks, replacing
references to local variables and parameters with references to
    assembler block constraints/parameters

git-svn-id: trunk@34892 -
2016-11-13 16:06:32 +00:00
Jonas Maebe
c4ae040258 + support for writing LLVM function-level inline assembly blocks
git-svn-id: trunk@34891 -
2016-11-13 16:06:29 +00:00
Jonas Maebe
f3409b4c9d + new la_asm LLVM pseudo-instruction to represent function-level inline
assembly blocks

git-svn-id: trunk@34890 -
2016-11-13 16:06:26 +00:00
Jonas Maebe
d2873e433e + top_asmlist operand type for LLVM inline assembly "call" instructions
git-svn-id: trunk@34889 -
2016-11-13 16:06:23 +00:00
Jonas Maebe
1c23218375 * pass the parameter list directly to getparas()
git-svn-id: trunk@34888 -
2016-11-13 16:06:20 +00:00
Jonas Maebe
bdfd588b47 * free the temporary assembler writer created for writing the code of pure
assembler routines

git-svn-id: trunk@34887 -
2016-11-13 16:06:17 +00:00
Jonas Maebe
af297e849c + function-level LLVM inline assembly decorator
git-svn-id: trunk@34855 -
2016-11-09 19:51:30 +00:00
Jonas Maebe
646385e966 * support for overriding the line ending character in external assembler
writer decorators (for LLVM function-level inline assembly: there
    newline has to be replaced by the character sequence '\0A')

git-svn-id: trunk@34854 -
2016-11-09 19:51:27 +00:00
Jonas Maebe
74a49b5f91 * restructured the the TExternalAssembler constructors so that the
hack for the Jasmin descendent is no longer needed

git-svn-id: trunk@34852 -
2016-11-09 19:51:20 +00:00
Jonas Maebe
999cb7de6d + LLVM 3.7 support in the LLVM IR writer
git-svn-id: trunk@34550 -
2016-09-20 21:44:06 +00:00
Jonas Maebe
dfb20f3f6a * fixup the asmbind of aliases (an llvm alias can never refer to an
external symbol)

git-svn-id: trunk@34514 -
2016-09-11 17:12:00 +00:00
Jonas Maebe
702715a518 * generalised llvmgettemprecorddef() so it works for almost all types
git-svn-id: trunk@34513 -
2016-09-11 17:11:57 +00:00
Jonas Maebe
18a59dddb9 * use ctai_typedconstbuilder.get_dynstring_rec() to get the recorddef representing
string constants instead of giving an internal error if we can't find it in
    the current context (in most cases it will exist, but not when inlining a
    routine from another unit that accesses a locally declared string constant)

git-svn-id: trunk@34373 -
2016-08-24 16:41:04 +00:00
Jonas Maebe
4eea5d9651 * override ttempinfoaccessor.settempinfoflags() for llvm and filter out
ti_may_be_in_reg flag (see comments)

git-svn-id: trunk@34359 -
2016-08-21 14:23:13 +00:00
Jonas Maebe
8760a6fbf8 * set shiftval to 0 if we convert a reference to a register paraloc,
as the reference overlaid the shiftval field and hence it could
    have any value

git-svn-id: trunk@34303 -
2016-08-13 14:47:44 +00:00
Jonas Maebe
7ebbb744e9 * also specify sret attribute at the caller side
git-svn-id: trunk@34302 -
2016-08-13 14:47:42 +00:00
Jonas Maebe
819f0c39fa * specify the "byval" attribute also at the caller side
git-svn-id: trunk@34301 -
2016-08-13 14:47:39 +00:00
Jonas Maebe
f417ed6576 * internalerror in case a reference's alignment is not set in
thlcgllvm.make_simple_ref_ptr()

git-svn-id: trunk@34299 -
2016-08-13 14:47:34 +00:00
Jonas Maebe
2f0c3ce8cc * fixed updating the reference alignment in thlcgllvm.g_set_addr_nonbitpacked_field_ref()
git-svn-id: trunk@34298 -
2016-08-13 14:47:31 +00:00
Jonas Maebe
a83f3c1a45 * fix maximum common alignment calculation in g_concatcopy() (if the second
parameter of newalignment() is larger than the first, the result is always
    1)

git-svn-id: trunk@34295 -
2016-08-13 14:47:23 +00:00
Jonas Maebe
f4015f6ac9 * fixed wrong class cast in case arrays/records are passed to a_loadfpu*()
(fixes tests/webtbs/tw26993.pp for llvm)

git-svn-id: trunk@34280 -
2016-08-12 13:35:31 +00:00
Jonas Maebe
aa1be3276f - removed default value of _typ parameter of TAsmData.(Weak)RefAsmSymbol():
it was AT_NONE, which is invalid and should never be used
  * explicitly pass the correct value for all calls to those methods elsewhere
    in the compiler

git-svn-id: trunk@34250 -
2016-08-05 07:09:16 +00:00
Jonas Maebe
a0efde8167 * automatically generate necessary indirect symbols when a new assembler
symbol is defined
   o removed all places where AB_INDIRECT symbols were explicitly generated
   o only generate AB_INDIRECT symbols for AT_DATA on systems_indirect_var_imports
   o for some symbols an indirect symbol is always required (because they are
     dereferenced by code in RTL units) -> use new AT_DATA_FORCEINDIRECT type

git-svn-id: trunk@34165 -
2016-07-20 20:53:03 +00:00
Jonas Maebe
1cb8c0d00c * specify the def of assembler level symbols defined via
tasmdata.DefineAsmSymbol() and all routines that call it
   o will be used to automatically generate AB_INDIRECT sybols when
     necessary

git-svn-id: trunk@34164 -
2016-07-20 20:52:59 +00:00
Jonas Maebe
687adbefd7 + support for LOC_VOID parameters in llvm for empty records (fixes
tests/test/tnoext4.)

git-svn-id: trunk@34136 -
2016-07-15 14:35:17 +00:00
Jonas Maebe
c05fa52775 * call g_concatcopy() from a_load_ref_ref() if the size of the to be copied
data is big, because large load/store operations result in very slow code
    (and takes forever to generate by llc)

git-svn-id: trunk@34135 -
2016-07-15 14:34:43 +00:00
Jonas Maebe
88a736c95a * moved the code generated for library init/fini to the al_pure_assembler
list, so that the assembler directives generated for Darwin are emitted
    correctly for LLVM
   o extracted the library init code generation from hlcgobj to pmodules so
     we don't add things to another list than what's passed to
     gen_proc_symbol_end(), and so it's done where we generate the init
     routine for libraries (rather then checking for every routine whether
     it's the init routine for a library)
   o removed the llvm-specific gen_proc_symbol_end() because the regular one
     now does the same

git-svn-id: trunk@34134 -
2016-07-15 14:34:11 +00:00
Jonas Maebe
c7ea921066 * renamed thlcgobj.g_external_wrapper() into a_jmp_external_name(), and
moved the code to create the procedure start/end etc. that was at the
    call sites of g_external_wrapper() into the new g_external_wrapper()
    -> got rid of the x86-specific code in expunix, and fixed expunix for
    llvm (e.g. tests/test/tlib1{a,b})

git-svn-id: trunk@34131 -
2016-07-14 15:26:40 +00:00
Jonas Maebe
f5e4265b1e * "push" zero-sized value parameters for LLVM and JVM, because all parameters
are part of the signature on those platforms (fixes e.g. tbs/tb0408.pp for
    LLVM)

git-svn-id: trunk@34128 -
2016-07-14 15:24:50 +00:00
Jonas Maebe
c0ff55e95a * changed the abstract method wrapper generation from thlcgobj to synthetic
methods. Implementing a fully functional g_external_wrapper() for llvm is
    quite hard, and the regular wrapper method that calls FPC_ABSTRACTERROR can
    in principle be optimized to a plain jump by tail call optimisation on other
    targets (to the extent that this matters, because most of them will be
    smartlinked away, and the ones that are executed will trigger an exception)
   o this means that the synthetic method generation needs to be run for all
     objectdefs on all platforms now, rather than only for Java classes

git-svn-id: trunk@34127 -
2016-07-14 15:24:13 +00:00
Jonas Maebe
0311528502 * always write bitpacked typed constant arrays as a multiple of bytes rather
than of their loadsize, because otherwise if they are e.g. part of a record
    they would occupy more space than allowed
   o adapted llvm code to deal with the fact that bitpacked arrays are now
     always arrays of bytes rather than arrays of integers with the same size
     as their loadsize -- this also fixes several type inconsistencies
     detected by llvm

git-svn-id: trunk@34125 -
2016-07-14 15:23:07 +00:00
Jonas Maebe
9b7e7c5298 + support absolute addresses on llvm (fixes tests/webtbs/tw12685 for llvm)
git-svn-id: trunk@34124 -
2016-07-14 15:22:31 +00:00
Jonas Maebe
458ba2efac * unlike other architectures, llvm requires that both operands of shl/shr are
of the same size -> ensure that this is the case for the shifts in
    a_bit_test/set_reg_reg_reg() (fixes tests/tbs/tb0219.pp for llvm)

git-svn-id: trunk@34123 -
2016-07-14 15:21:37 +00:00
Jonas Maebe
31b70ecfd3 * don't perform the automatic insertion of typecasts in case register
allocation hasn't been performed, because then reused "registers"
    could have multiple types

git-svn-id: trunk@34121 -
2016-07-14 15:20:19 +00:00
Jonas Maebe
0cce590982 * encode the result type of functions returning a zero-sized value
using their actual type (array/record) rather than using the
    simplified type (void), so we can also return an actual value and
    assign it to something (void means that nothing is returned and
    cannot be assigned to anything) (completes fixing
    tests/test/tnoext4.pp for llvm)

git-svn-id: trunk@34120 -
2016-07-14 15:19:45 +00:00
Jonas Maebe
2148a20d6a * fixed returning results from functions that have a zero-sized result
(e.g. an empty record): return an "undefined" instance of the result
    type (since it's empty, its contents are irrelevant). Before, we
    returned "void", but that means returning nothing rather than returning
    something empty (part of fixing test/tnoext4 for llvm)

git-svn-id: trunk@34119 -
2016-07-14 15:19:09 +00:00
Jonas Maebe
5541fb3f6d * when converting a pointer-sized entity to a complex procvar in a typed
const builder, it can only initialise the function pointer part of the
    complex procvar -> convert the to-size to an address-only version of
    the complex procvar to avoid us trying to bitcast an address into a
    record containing both the function and self/nestedfp pointer
    (fixes test/tmaclocalprocparam4e for llvm)

git-svn-id: trunk@34118 -
2016-07-14 15:18:35 +00:00
Jonas Maebe
cdfe299f23 * encode extended in a dynamic array the same as in regular arrays and
records: as an array of 10 bytes. We handle indexing dynamic arrays
    the same as indexing other arrays, and hence that code expects extended
    to be encoded the same way.

git-svn-id: trunk@34116 -
2016-07-14 15:17:27 +00:00
Jonas Maebe
571d053a60 - removed tabstractnormalvarsym.currentregloc: the new location will
always be different from the old location, since we just allocated
    the registers for the new one above. Should the old registers ever
    be needed again for tai_varloc: rr.old/rr.oldhi contains it

git-svn-id: trunk@34086 -
2016-07-08 07:46:51 +00:00
Jonas Maebe
b5cb7a5d4f * factored out loading of integers from memory into structs in registers or
vice versa, and generalised for floating point and mm registers
    (webtbs/tw26993.pp)

git-svn-id: trunk@34031 -
2016-06-30 15:33:37 +00:00
Jonas Maebe
eeae34ea7d * simplified handling of loading a reference into a register of a
larger size in case of structured types
   o also fixes the logic for big endian

git-svn-id: trunk@34029 -
2016-06-30 15:33:31 +00:00
Jonas Maebe
f2c1e4234f * use g_ptrtypecast_ref() in a_load_ref_reg() when we have to typecast
references

git-svn-id: trunk@34028 -
2016-06-30 15:33:27 +00:00
Jonas Maebe
c421171461 * fixed handling of fpu/mm loads from "named registers" in case they involve
a typecast from a struct to a scalar type (webtbs/tw26993)

git-svn-id: trunk@34027 -
2016-06-30 15:33:24 +00:00
Jonas Maebe
542b6b604e * missing closing comment
git-svn-id: trunk@34025 -
2016-06-30 15:32:50 +00:00
Jonas Maebe
5313db710b * override gen_stack_check_size_para() and gen_stack_check_call()
for llvm and do nothing (see comments in the code)

git-svn-id: trunk@33991 -
2016-06-15 18:31:58 +00:00
Jonas Maebe
8c006f04e2 * don't check type size equality for conversions to formaldef either
git-svn-id: trunk@33987 -
2016-06-15 18:31:37 +00:00
Jonas Maebe
3f01efbee0 * adapted tcgtypeconvnode.second_int_to_int() to work with high level cpu
targets, and removed the (buggy) LLVM-specific version

git-svn-id: trunk@33980 -
2016-06-12 20:56:40 +00:00
Jonas Maebe
2d1023140a * don't try to check whether the size of from and to in type conversion nodes
are the same in case of open arrays (their size can't be determined at
    compile time) -- this is just a sanity check, which can't be performed in
    this case

git-svn-id: trunk@33979 -
2016-06-12 20:56:37 +00:00
Jonas Maebe
22c31ca004 * fixed LLVM vecn typed constant evaluation if the lower bound is <> 0
git-svn-id: trunk@33959 -
2016-06-12 09:21:00 +00:00
Jonas Maebe
8bc39ba7a3 * fixed bitpacked array index calculation for llvm: the element bitsize was
only used for masking out the bits of the loaded data, not for calculating
    the offset

git-svn-id: trunk@33957 -
2016-06-12 09:20:54 +00:00
Jonas Maebe
14ab43626f * don't write initialisation values for AB_EXTERNAL_INDIRECT
git-svn-id: trunk@33956 -
2016-06-12 09:20:51 +00:00
Jonas Maebe
b76539a049 * fixed handling of uninitialised complex function results
git-svn-id: trunk@33940 -
2016-06-09 22:00:05 +00:00
Jonas Maebe
ea54b6b2c5 * factored comp/currency-in-register handling out of a_loadfpu_reg_reg()
into llvmconvop() so it's also used by code using that routine

git-svn-id: trunk@33938 -
2016-06-09 21:59:58 +00:00
Jonas Maebe
7f2d970a1e * fixed type encoding of C-style blocks for LLVM
git-svn-id: trunk@33926 -
2016-06-05 21:34:47 +00:00
Jonas Maebe
9d2bba1917 * create a separate type and def for the LLVM "i1" type, because reusing
pasbool8type for this results in too much trouble (we mustn't use i1
    for parameters, because then LLVM will try to apply the ABI convention
    for passing "1 bit" values, or in records because then this may
    result in unwanted bitpacking). Downside: the new LLVMBool1 type is
    also exposed in the system unit, because we need it to define LLVM
    intrinsics...

git-svn-id: trunk@33726 -
2016-05-20 20:51:44 +00:00
Jonas Maebe
04c5d2ee6e * generate indirect symbols for LLVM too
git-svn-id: trunk@33722 -
2016-05-20 20:51:31 +00:00
Jonas Maebe
44839ba0c0 * handle AB_INDIRECT and AB_EXTERNAL_INDIRECT in the llvm assembler writer
git-svn-id: trunk@33721 -
2016-05-20 20:51:28 +00:00
Jonas Maebe
4fff9645af * use tasmbind for llvm aliases and derive llvm flags from that
git-svn-id: trunk@33720 -
2016-05-20 20:51:25 +00:00
nickysn
e1f21fb1e3 + handle the asd_cpu directive (commented out, but without producing an internal
error) on all the remaining external assemblers, so it is safe to emit on all
  platforms

git-svn-id: trunk@33122 -
2016-02-26 20:50:41 +00:00
Jonas Maebe
e4c8a2776b - removed empty "protected type" section
git-svn-id: trunk@32966 -
2016-01-18 22:20:05 +00:00
Jonas Maebe
4aba875c34 * add llvm "weak" flag for tcalo_weak
git-svn-id: trunk@32916 -
2016-01-10 17:22:17 +00:00
Jonas Maebe
e3f8f8c974 * fixed position of "weak" linkage flag
git-svn-id: trunk@32915 -
2016-01-10 17:22:14 +00:00
Jonas Maebe
90071e04c4 * encode objc classrefdefs as objc_idtype as that is how they are typed
elsewhere in the compiler as well

git-svn-id: trunk@32914 -
2016-01-10 17:22:11 +00:00
Jonas Maebe
5959f45694 * emit custom Objective-C names in the LLVM assembler writer
git-svn-id: trunk@32912 -
2016-01-10 17:22:06 +00:00
Jonas Maebe
d46fad1e7f * use provided name to a_call_name() instead of hardcoding pd.mangledname()
(so that Objective-C messaging and WPO procedure names are used)

git-svn-id: trunk@32910 -
2016-01-10 17:21:59 +00:00
Jonas Maebe
1c99adb411 * fix rol/ror for llvm
git-svn-id: trunk@32909 -
2016-01-10 14:02:06 +00:00
Jonas Maebe
0350369c6a * don't check for a simple result location when loading an uninitialised
function result: we always only use the first location's register

git-svn-id: trunk@32906 -
2016-01-10 14:01:54 +00:00
Jonas Maebe
ae7b17890a * support non-power-of-two records that have to be passed in MM registers
in a_load_ref_cgpara()

git-svn-id: trunk@32905 -
2016-01-10 14:01:50 +00:00
Jonas Maebe
49a83b2872 * allow targets to keep certain type conversions for equal types in
inserttypeconv()
   o keep typeconversions between structurally equivalent but semantically
     different procvardefs for LLVM and JVM, because they're different
     types there

git-svn-id: trunk@32904 -
2016-01-10 14:01:46 +00:00
Jonas Maebe
3f7169e250 * treat Objective-C metaclasses (classrefdefs) as voidpointertype at the
LLVM type level

git-svn-id: trunk@32884 -
2016-01-07 22:06:13 +00:00
Jonas Maebe
53bf43983a + support for emitting weak symbols with the high level typed constant builder
git-svn-id: trunk@32883 -
2016-01-07 22:06:06 +00:00
Jonas Maebe
58ae32e2d1 * factored out writing the LLVM linkage flags, take into account version
differences and also write them for procdefs

git-svn-id: trunk@32882 -
2016-01-07 22:06:00 +00:00
Jonas Maebe
3dbe97d9b6 + added some extra llvm versions and flags describing their features
git-svn-id: trunk@32880 -
2016-01-07 22:05:49 +00:00
Jonas Maebe
110a5642c0 - removed ait_weak/tai_weak, and replaced it with the previously existing
asd_weak_reference/asd_weak_definition directives

git-svn-id: trunk@32879 -
2016-01-07 22:05:38 +00:00
Jonas Maebe
81381cfbb4 + vectorized dead-strippable section support for LLVM
o individual elements are not (yet) dead-strippable on LLVM though,
     there doesn't seem to be a way to encode the necessary information
     in LLVM (so e.g. all resource strings from a unit are currently
     always linked in if at least one is referenced)

git-svn-id: trunk@32802 -
2015-12-30 21:55:29 +00:00
Jonas Maebe
015a864db1 * def.fullownerhierarchyname() already ends in a '.', so don't append another
one

git-svn-id: trunk@32783 -
2015-12-28 15:06:55 +00:00
Jonas Maebe
35a170ed8e * don't internalerror when asked to set the function result of a function
returning an empty record to "uninitialized"

git-svn-id: trunk@32778 -
2015-12-28 15:06:22 +00:00
Jonas Maebe
c452e70f74 + support for a reference without base or symbol, if the offset is 0
(for @ptrtype(0)^.field expressions)

git-svn-id: trunk@32777 -
2015-12-28 15:06:15 +00:00
Jonas Maebe
b4fe4789d6 + support for constant call parameters on LLVM
o reduces the size of the generated LLVM IR, but mainly important for LLVM
     intrinsics such as llvm.memcpy.*(), as llc complains if some of their
     parameters are not constants (you could work around it by first running
     opt or by using clang with optimizations so that the constants, which
     were loaded in registers until now, were propagated to the intrinsics
     by the time llc saw them)

git-svn-id: trunk@32776 -
2015-12-28 15:06:07 +00:00
Jonas Maebe
e3d2980c98 * don't load data in a register when converting from void to an integer
type (like with integer(pointer1^):=integer(pointer2^))

git-svn-id: trunk@32743 -
2015-12-26 20:01:44 +00:00
Jonas Maebe
205136f924 * fixed the size used for setting uninitialised function results if it
has to be zero/sign-extended for ABI reasons

git-svn-id: trunk@32742 -
2015-12-26 20:01:38 +00:00
Jonas Maebe
fad7c8f151 * fixed indexing dynamic arrays and strings with a constant index (the index
was ignored in this case)

git-svn-id: trunk@32741 -
2015-12-26 20:01:32 +00:00
Jonas Maebe
ea1e368328 + added div-by-zero and overflow checking support for mod/div
git-svn-id: trunk@32737 -
2015-12-26 20:00:57 +00:00
Jonas Maebe
4939c9a7b9 * implemented overflow checking for llvm
git-svn-id: trunk@32736 -
2015-12-26 20:00:44 +00:00
Jonas Maebe
cd5db0d186 * register the types for the cgparas instead of for the parameters of
procvardefs, as it's those types that we use in the LLVM IR

git-svn-id: trunk@32734 -
2015-12-26 20:00:18 +00:00
Jonas Maebe
99aaec5431 * handle typed constant definitions of variant records using different fields
than the one we use to construct the LLVM equivalent (which doesn't support
    variants), or in case the complete record is not defined in the source and
    has to be padded with zeroes
   o we do this by creating a new recorddef in this case with as elements the
     defs of the actually emitted constant data, and replacing the original
     def with this new def; note that this can also replace arrays in case of,
     e.g., an array of a variant record type
   o the pass in llvmtype takes care of inserting type conversions (bitcasts)
     when these constants are accessed using the original def

git-svn-id: trunk@32719 -
2015-12-25 21:05:45 +00:00
Jonas Maebe
f83f9168ee * emit all resource strings and internal dynamic string data using the
def representing that string type, instead of using p(wide)char
   o these string types are represented the same in llvm as p(wide)char,
     but this way we can check whether the emitted data type matches the
     expected one in the future

git-svn-id: trunk@32715 -
2015-12-25 21:05:26 +00:00
Jonas Maebe
787caf4dda * treat records with {$packrecords c} the same as other records for LLVM
o while in principle LLVM can layout those the same as we do, this would
     require special treatment in case some fields are not initialised in
     a typed record declaration (because then we have to emit padding only
     for the skipped fields, and not for any padding between them)
   o exception: records we create to represent parameters, as those have to
     match the ABI definitions exactly for them to be treated as expected

git-svn-id: trunk@32714 -
2015-12-25 21:05:22 +00:00
Jonas Maebe
f57a94b5aa * explicitly name the fields we add in llvmgettemprecorddef()
* use those field names when loading their addresses in
    thlcgllvm.a_load_ref_cgpara()/gen_load_cgpara_loc(), instead of
    assuming the field indices in the llvm representation of those
    records matches the parameter location order (it currently does
    because we let llvm lay out C-packed records, but that will
    change)

git-svn-id: trunk@32713 -
2015-12-25 21:05:17 +00:00
Jonas Maebe
698ca04d90 * reset shiftval when transforming a paraloc into an llvm paraloc
git-svn-id: trunk@32690 -
2015-12-20 21:08:56 +00:00
Jonas Maebe
1dcd312ca5 * don't handle Objective-C or dispinterfaces like Pascal interfaces (we
don't generated a vmtdef for those)

git-svn-id: trunk@32685 -
2015-12-20 20:56:02 +00:00
Jonas Maebe
477e087857 * only check the shiftval in llvmbyvalparaloc() if it's a register parameter
location (it's invalid for other locations)

git-svn-id: trunk@32600 -
2015-12-05 18:04:02 +00:00
Jonas Maebe
a9498b6735 * fixed the parameter order for thlcgobj.g_load_const_field_by_name()
git-svn-id: trunk@32595 -
2015-12-05 18:03:48 +00:00
Jonas Maebe
df9efdeb4c * fixed llvm types for loading the address of a nested routine
git-svn-id: trunk@32594 -
2015-12-05 18:03:45 +00:00
Jonas Maebe
b5c9a20d3f * fixed range of llvm definition of bitpacked arrays
git-svn-id: trunk@32572 -
2015-12-02 22:29:26 +00:00
Jonas Maebe
35714e5d50 * don't internallerror when encountering an "absolute" type conversion to
a differently sized def in LLVM

git-svn-id: trunk@32571 -
2015-12-02 22:29:23 +00:00
Jonas Maebe
86b02cf76e * handle bitpacked ordinal fields whose size is a multiple of 8 bits the same
other bitpacked ordinal fields, since they can also start on a non-byte-
    aligned boundary

git-svn-id: trunk@32570 -
2015-12-02 22:24:04 +00:00
Jonas Maebe
8df979e5e8 * take into account the fact that bitpacked ordinal fields are all encoded
as bytes in the LLVM type, so typecast them to the correct type (which is
    the size that will be used by hlcg.a_load*subsetref*)

git-svn-id: trunk@32565 -
2015-12-01 21:52:23 +00:00
Jonas Maebe
3ff265da88 * fixed rol/ror
git-svn-id: trunk@32556 -
2015-11-29 21:46:10 +00:00
Jonas Maebe
da8d276766 * correctly encode bitpacked arrays of elements that can't be bitpacked
git-svn-id: trunk@32555 -
2015-11-29 21:46:06 +00:00
Jonas Maebe
e144ba05c1 * fixed storing "self" (nestedfpstruct) when taking the address of a nested
routine

git-svn-id: trunk@32551 -
2015-11-29 21:45:54 +00:00
Jonas Maebe
4f4d4d9456 * also support non-pointerdefs as first argument for g_ptrtypecast_ref()
via internal restructuring of the llvm code generator (so we can
    typecast e.g. a procvardef to a pointerdef)

git-svn-id: trunk@32550 -
2015-11-29 21:45:50 +00:00
Jonas Maebe
f97192edf9 * support typecasts in a_loadmm_ref_reg()
git-svn-id: trunk@32545 -
2015-11-27 14:44:35 +00:00
Jonas Maebe
4c720b8ba2 * fixed parameter order of llvm.memcpy call
git-svn-id: trunk@32533 -
2015-11-25 22:25:51 +00:00
Jonas Maebe
eefcbaff69 * converted tnodeutils.InsertResourceInfo to the high level typed constant
builder and enabled it for llvm

git-svn-id: trunk@32532 -
2015-11-25 22:25:48 +00:00
Jonas Maebe
682d133e1e * enable generic tllvmnodeutils.InsertResourceTablesTable for llvm
git-svn-id: trunk@32531 -
2015-11-25 22:25:45 +00:00
Jonas Maebe
0c4edd2aa9 * fixed getting address of interface methods after r32414: interfaces are not
a pointer to a vmt, but a pointer to a pointer to vmt (mantis #29086)
   o also adjusted the llvm type for interfaces accordingly

git-svn-id: trunk@32530 -
2015-11-25 19:28:17 +00:00
Jonas Maebe
71e27e85c9 * fixed llvm unaryminus for comp/currency on platforms supporting extended
git-svn-id: trunk@32524 -
2015-11-24 20:10:48 +00:00
Jonas Maebe
6cf67b7ace * only convert left/right to the resultdef of an addnode involving pointers
if the it's an addn/subn. For comparisons, the resultdef is boolean, and
    left and right will already have the same type (with addn/subn, one could
    be a pointer and the other an integer)

git-svn-id: trunk@32523 -
2015-11-24 20:10:45 +00:00
Jonas Maebe
1d460eebc1 * ensure that necessary padding bytes in a non-anonymous aggregate are added
before any nested aggregate

git-svn-id: trunk@32521 -
2015-11-24 20:10:38 +00:00
Jonas Maebe
ef3bafd67c * fixed resetting defs after generating the llvm "type" instructions: the
dbg_state is not sufficient to determine whether or not a def has
    already been processed or not -> use stab_number (and reset it)
   o also record all defs we don't emit "type" instruction for, but which
     we still process to find other defs, so we reset those too

git-svn-id: trunk@32520 -
2015-11-24 20:10:35 +00:00
Jonas Maebe
2342ee467b * don't write the parameter names for external function declarations in llvm,
because the names we assign to parameter locations are no longer valid after
    a module has been compiled (they are tasmsymbols), and they're not necessary
    for declarations either; this also avoids generating calleeside parameter
    information for imported routines just to write the external declaration
    (the callerside information will already be available from when the routines
     were called)

git-svn-id: trunk@32518 -
2015-11-24 20:10:28 +00:00
Jonas Maebe
99c97c331a * keep the result type after a call as llvmretdef, because call nodes
afterwards use hlcg.gen_load_cgpara_loc() to convert it to the Pascal
    level tdef (and otherwise we try to do this twice). For non-Pascal
    level calls, the code generator will automatically convert the
    type if necessary when using the function result location, because
    its def is (now) set to llvmretdef

git-svn-id: trunk@32475 -
2015-11-22 11:49:51 +00:00
Jonas Maebe
7b89072d88 * fixed external wrapper generation on llvm
git-svn-id: trunk@32472 -
2015-11-22 11:49:40 +00:00
Jonas Maebe
e90af5d7c0 * fixed collection of types from tai_*typedconst
git-svn-id: trunk@32469 -
2015-11-22 11:49:28 +00:00
Jonas Maebe
c17458149c - removed accidentally committed debug code
git-svn-id: trunk@32468 -
2015-11-22 11:49:25 +00:00
Jonas Maebe
4f287207cd * initialise all register temps with "undef" for llvm, so that llvm knows
they exist even if we try to read them before writing to them (e.g.
    because they represent the uninitialised function result of an
    inlined function)

git-svn-id: trunk@32465 -
2015-11-22 11:49:15 +00:00
Jonas Maebe
13cf405f8c * fixed llvm second_int_to_real for comp
git-svn-id: trunk@32464 -
2015-11-22 11:49:11 +00:00
Jonas Maebe
72c7cb2770 * typecast second_proc_to_procvar() results for llvm if the generic code
performed a simple location_copy() from one complex procvar type to
    another

git-svn-id: trunk@32426 -
2015-11-21 12:37:50 +00:00
Jonas Maebe
8cebb76572 * corrected llvm level type of interfaces
git-svn-id: trunk@32425 -
2015-11-21 12:37:47 +00:00
Jonas Maebe
423eb7ddb6 * fixed int_to_real() conversion llvm destination type when the result is
currency

git-svn-id: trunk@32423 -
2015-11-21 12:37:40 +00:00
Jonas Maebe
cc52730147 * typecast function results if an explicit type is forced
git-svn-id: trunk@32420 -
2015-11-21 12:37:30 +00:00
Jonas Maebe
00a5dd87c9 * allow g_ptrtypecast_reg() to allocate a new register, because spilling
a bitcast that reads from and writes to the same register doesn't
    work well
  * changed pointerdef parameters of g_ptrtypecast_reg()/ref() to regular tdef
    so that these routines can also be used with procvardefs (which are pointers,
    but not pointerdefs), except for the fromdef of g_ptrtypecast_ref() as this
    one has to call a_loadaddr_ref_reg() (which needs the pointeddef, and getting
    that is not possible for non-pointerdefs)

git-svn-id: trunk@32417 -
2015-11-21 12:37:20 +00:00
Jonas Maebe
abd79d275f * always emit the procdef when calling a routine in llvm; this is
only required when calling a routine that returns a procvardef or
    if it's a C-style varargs routine, but it's always allowed and
    always doing it simplifies procvar handling

git-svn-id: trunk@32416 -
2015-11-21 12:37:17 +00:00
Jonas Maebe
fed94f56c8 * fixed spilling_get_operation_type and spilling_get_reg_type for
la_call and la_invoke (operand 1 is the destination register
    since r30776)

git-svn-id: trunk@32415 -
2015-11-21 12:37:14 +00:00
Jonas Maebe
eaeb9d8351 * renamed thlcgobj.g_set_addr_nonbitpacked_record_field_ref() to
thlcgobj.g_set_addr_nonbitpacked_field_ref() and adjusted it so that
    it also works for objects/classes (if the incoming reference points
    to the start of the class contents)
   o factored out the related code from tllvmsubscriptnode

git-svn-id: trunk@32411 -
2015-11-21 12:37:01 +00:00
Jonas Maebe
1284032765 + llvm blockaddress() intrinsic (supported as of LLVM 3.5.1)
git-svn-id: trunk@32409 -
2015-11-21 12:36:55 +00:00
Jonas Maebe
bd4787c716 * force complex procvars immediately to memory for llvm, so we don't have to
deal with the hacky register/registerhi complex locations

git-svn-id: trunk@32407 -
2015-11-21 12:36:48 +00:00
Jonas Maebe
7b93e40530 * fixed opcode in second_sqr_real
git-svn-id: trunk@32404 -
2015-11-21 12:36:39 +00:00