Commit Graph

707 Commits

Author SHA1 Message Date
Jonas Maebe
797077855e * use constrained LLVM fp intrinsics for add/sub/mul/slash/fma/sqrt
operations when fastmath is not enabled

git-svn-id: trunk@43819 -
2019-12-30 15:05:09 +00:00
Jonas Maebe
b355ba3d39 * record whether a function uses fastmath, and define the function as
strictfp if it doesn't (so LLVM doesn't perform transformations that can
    change the fp/exception behaviour)

git-svn-id: trunk@43818 -
2019-12-30 15:05:06 +00:00
Jonas Maebe
67dbd0cdb3 * support nf_internal to ignore currency conversion adjustments also on
platforms that implement currency using a floating point type

git-svn-id: trunk@43817 -
2019-12-30 15:05:02 +00:00
Jonas Maebe
9bd33f7a45 + support for LLVM metadata constant string parameters
o they are implemented as a new metadata register class, whereby the
     subregister indicates the metadata type (currently always a string)
     and the superregister is an index in the metadata array (which
     contains the strings). LLVM metadata can only be passed as parameters
     to intrinsics in bitcode, so moves of metadata into other registers
     triggers internal errors and when moving them into parameters, we
     replace the parameter's register with the metadata register (and look
     up the corresponding string when writing out the bitcode)

git-svn-id: trunk@43816 -
2019-12-30 15:04:57 +00:00
Jonas Maebe
6d51c69dbe * fixed writing of calling convention for function declarations/definitions
in LLVM

git-svn-id: trunk@43785 -
2019-12-24 22:12:40 +00:00
Jonas Maebe
96dfe3d03a * LLVM support for writing vector types
git-svn-id: trunk@43783 -
2019-12-24 22:12:34 +00:00
Jonas Maebe
1e3f72403e * renamed getintparaloc to getcgtempparaloc
o it can be used for more than integer parameters

git-svn-id: trunk@43781 -
2019-12-24 22:12:25 +00:00
Jonas Maebe
0f57151d36 + recognise LLVM 9.0 (no changes needed compared to LLVM 8.0)
git-svn-id: trunk@43686 -
2019-12-14 17:15:27 +00:00
Jonas Maebe
c477816100 - removed LLVM support for clang < 7.0 and Xcode < 10.0: those versions
contain various bugs and can't even complete "make all", so there is no
    point in keeping them
   o changed default LLVM target version to 7.0

git-svn-id: trunk@43682 -
2019-12-14 14:59:05 +00:00
Jonas Maebe
a352a12bb4 * use value_real rather than value_curency when writing currency
realconstnodes (fixes tcurrency1, tw33439 and tw36179 with LLVM)
   o we need to load the fpu representation of the currency values,
     not the scaled currency value

git-svn-id: trunk@43681 -
2019-12-14 14:11:12 +00:00
Jonas Maebe
e775ecdc43 * cleaned up safecall support: use a hidden localvarsym instead of result
register hacking
   o this also allowed fixing/adding safecall support for LLVM

git-svn-id: trunk@43578 -
2019-11-24 20:23:22 +00:00
Jonas Maebe
49026e1261 * add "readonly" attribute for constant pointer parameters on LLVM
git-svn-id: trunk@43089 -
2019-09-29 10:29:57 +00:00
Jonas Maebe
b99323bb19 * fix LLVM compilation after r43076
git-svn-id: trunk@43088 -
2019-09-29 10:29:54 +00:00
Jonas Maebe
9678542ba6 + add "thunk" attribute for stubs/thunks and emit it for LLVM
- also removed wrong "noreturn" attribute for interface thunks generated
     for high level code generator targets

git-svn-id: trunk@43018 -
2019-09-15 20:43:12 +00:00
Jonas Maebe
ff2d718699 * fixed occasional rounding error with currency constants on the LLVM targets
(fixes test/tcustomattr13.pp)

git-svn-id: trunk@43017 -
2019-09-15 20:43:09 +00:00
Jonas Maebe
cdafe680c2 * different definitions for the same Objective-C class (can happen with
external class declarations) need a type conversion in LLVM (because
    they're represented by different LLVM types)

git-svn-id: trunk@42970 -
2019-09-09 18:33:37 +00:00
Jonas Maebe
dcf4e4cb2c * support taking the address of labels defined in assembler blocks in the
LLVM code genrator (for the rtti unit's thunk hacking)

git-svn-id: trunk@42969 -
2019-09-09 18:33:33 +00:00
Jonas Maebe
e7fbebfef5 * fixed field alignment when reusing an anonymous recorddef for LLVM and
the LLVM layout of an instance does not match the original one
    (e.g. because it contains procdefs of procedures with different
     signatures)

git-svn-id: trunk@42477 -
2019-07-21 11:06:54 +00:00
Jonas Maebe
145f4299b4 * search dynamic string data record in correct symtable in
tllvmtai_typedconstbuilder.emit_string_offset
   o fixes LLVM internalerror 2014080406 for test/tcustomattr14

git-svn-id: trunk@42464 -
2019-07-20 12:08:59 +00:00
Jonas Maebe
d8903ce6b3 - removed maxcrecordalign parameter/field from recordsymtables, as this value
cannot be modified in the settings (so we can directly use the one from
    current_settings)

git-svn-id: trunk@42447 -
2019-07-14 19:24:32 +00:00
Jonas Maebe
3fee990218 * on Mach-O, PECOFF and ELF platforms, write local symbols as hidden/
private_extern (or plain global in case of PECOFF, as the effect is
    the same there): visible across object files, but they become local
    when linked into a binary/library. This enables cross-unit inlining
    of functions accessig implementation-only symbols.

git-svn-id: trunk@42340 -
2019-07-07 21:33:43 +00:00
Jonas Maebe
789f13eb24 * LLVM-specific support for popcnt
git-svn-id: trunk@42311 -
2019-06-30 15:23:36 +00:00
Jonas Maebe
0a91fcb44f * LLVM-specific support for bsr*/bsf*
git-svn-id: trunk@42309 -
2019-06-29 16:27:18 +00:00
Jonas Maebe
c425c51963 * simplify and optimize generated LLVM code for case statements
git-svn-id: trunk@42305 -
2019-06-29 12:17:49 +00:00
Jonas Maebe
f1b66a9741 * fixed LLVM type checking of typed files in ISO mode (fixes webtbs/tw34848)
git-svn-id: branches/debug_eh@42205 -
2019-06-10 13:36:57 +00:00
Jonas Maebe
3f2578a3e3 * don't quote LLVM calling convention name (that will cause it to be ignored)
o fixes tasm10a and tx64ccnv.ll with LLVM

git-svn-id: branches/debug_eh@42193 -
2019-06-08 17:11:20 +00:00
Jonas Maebe
faf75095cd * synchronised with trunk till r42189
git-svn-id: branches/debug_eh@42190 -
2019-06-07 18:24:38 +00:00
Jonas Maebe
1dee4c41dd - removed "cmp 0/1, pasbool1" optimization for llvm because this discards
the upper 7 bits of the boolean, while other platforms take it into
    account (even though they're technically always required to be 0, and
    the value is undefined if they're not)

git-svn-id: trunk@42189 -
2019-06-07 18:17:55 +00:00
Jonas Maebe
5473f4fc44 + LLVM support for library init/fini routines
git-svn-id: branches/debug_eh@42108 -
2019-05-19 19:26:59 +00:00
Jonas Maebe
9f18cbf5d6 * support writing aggregate LLVM constants that are not packed
git-svn-id: branches/debug_eh@42107 -
2019-05-19 19:26:55 +00:00
Jonas Maebe
0cd0e1614b * synchronised with trunk till r42105
git-svn-id: branches/debug_eh@42106 -
2019-05-19 19:24:25 +00:00
Jonas Maebe
a418dc6c91 * made the fields array parameter of llvmgettemprecorddef "const", as it
doesn't get modified and hence doesn't need to be copied

git-svn-id: trunk@42103 -
2019-05-19 19:20:42 +00:00
Jonas Maebe
3bee9ab9da * two different specialisations with the same types from different units
still need a type conversion with llvm, as their type identifiers will
    be different

git-svn-id: branches/debug_eh@42097 -
2019-05-18 18:49:05 +00:00
Jonas Maebe
d74b0843df * set null-pointer-is-valid attribute on functions, so that LLVM does not
optimise provable accesses to null as undefined behaviour (requires
    LLVM/Clang 7.0 or later)

git-svn-id: branches/debug_eh@42055 -
2019-05-12 21:09:44 +00:00
Jonas Maebe
853e622fb7 * fix case completeness warnings
git-svn-id: branches/debug_eh@42051 -
2019-05-12 18:46:47 +00:00
Jonas Maebe
1b6425176b * synchronised with trunk till r42049
git-svn-id: branches/debug_eh@42050 -
2019-05-12 18:44:05 +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
7dbbce157f * fixed Objective-C metadata generation for LLVM
git-svn-id: branches/debug_eh@41980 -
2019-05-02 19:45:34 +00:00
Jonas Maebe
024b38e1ff * fixed setting calling convention for calls (the callpd passed to the
taillvm constructors is not necessarily a proc(var)def)

git-svn-id: branches/debug_eh@41979 -
2019-05-02 19:45:30 +00:00
Jonas Maebe
3fa6838815 * basic llvm metadata support
git-svn-id: branches/debug_eh@41978 -
2019-05-02 19:45:26 +00:00
Jonas Maebe
3a1fb45315 * synchronised with trunk till r41976
git-svn-id: branches/debug_eh@41977 -
2019-05-02 19:44:41 +00:00
Jonas Maebe
079d616978 * fixed double free in LLVM code generator after r41963
git-svn-id: trunk@41976 -
2019-05-02 19:40:00 +00:00
Jonas Maebe
97a144ea6a - removed ttypedconstkind parameter from tai_simpletypedconst constructor,
as it always has to be tck_simple anyway

git-svn-id: trunk@41975 -
2019-05-02 19:39:56 +00:00
Jonas Maebe
cd3e4d26d4 * recognise extra llvm/Xcode versions
git-svn-id: branches/debug_eh@41912 -
2019-04-20 18:56:19 +00:00
Jonas Maebe
fc60ec2ea4 + support for LLVM LTO: compile units with -CLflto -> when compiling a main
program/library also with -Clflto, all units compiled with that option
    will be linked using their bitcode files and LTO
   o compiling with -CLflto will compile all units twice: once for normal
     (static or smart) linking, and once for LTO. So the result can be
     used both with and without LTO.

git-svn-id: branches/debug_eh@41910 -
2019-04-20 18:56:11 +00:00
Jonas Maebe
810d0ab2fe * use $DARWINVERSION functionality to pass Darwin/iOS version to clang when
assembling llvm bitcode

git-svn-id: branches/debug_eh@41909 -
2019-04-20 18:56:07 +00:00
Jonas Maebe
fcde89cb26 * support forcing to write the parameter alignment for parameters for LLVM,
even when it's the same as the stack alignment (it can also refer to the
    alignment of the data pointed to by pointer parameters)

git-svn-id: branches/debug_eh@41729 -
2019-03-17 15:28:27 +00:00
Jonas Maebe
3b254affb7 * support for the individual alignment flags for the memcpy intrinsic of
LLVM 7.0

git-svn-id: branches/debug_eh@41728 -
2019-03-17 15:28:23 +00:00
Jonas Maebe
cf65c55b72 * support specifying the target LLVM/Xcode version
git-svn-id: branches/debug_eh@41727 -
2019-03-17 15:28:20 +00:00
Jonas Maebe
16cde0da15 * create LLVM TAsmCFI wrapper that calls through to the original TASmCFI for
pure assembler routines and for generating the CFI tables, and does nothing
    for LLVM-handled routines (LLVM takes care of the CFI there)

git-svn-id: branches/debug_eh@41580 -
2019-03-03 17:15:09 +00:00
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