Commit Graph

708 Commits

Author SHA1 Message Date
Jonas Maebe
60c95032fa llvm: removed Xcode 10.0/10.1 as supported versions
These already did not work because they predate clang 7
2022-06-06 23:12:53 +02:00
Jonas Maebe
25e832940c llvmdbg: support for generating debug information for local/para varsyms
Note that not all symbols are covered yet, because absolutevarsyms are not
yet supported and those are e.g. used for function result aliases.
Additionally, not all types are fully supported yet.
2022-06-04 22:26:40 +02:00
Jonas Maebe
e7ec91eca8 dbgllvm: rename hastable for staticvarsym declarations 2022-06-04 22:26:40 +02:00
Jonas Maebe
a76038e1d1 hlcgobj: new getlocal and recordnewsymloc methods
Call hlcg.getlocal instead of tg.getlocal when used for actual parameters/local
variables. Has an extra tsym parameter, which will enable the LLVM backend to
insert debug information.

Call hlcg.recordnewsymloc when the location of a (local/para) symbol changes,
so debug info tracking can be updated (only done for LLVM currently)
2022-06-04 22:26:40 +02:00
Jonas Maebe
a76085e463 tllvmcallpara: record whether it's passed to metadata
Sometimes we need the def to store a the original def of the passed parameter,
e.g. for the first argument to llvm.dbg.addr
2022-06-04 22:26:40 +02:00
Jonas Maebe
41a6c5e967 agllvm: support specialised metadata with field names
Necessary for DIExpression
2022-06-04 22:26:40 +02:00
Jonas Maebe
c92a035614 agllvm: support nested constants in parameters
Needed for metadata support
2022-06-04 22:26:40 +02:00
Jonas Maebe
dc1e0a6bb3 tllvmcallpara: turned into object and added convenience methods 2022-06-04 22:26:40 +02:00
Jonas Maebe
fe0048bcec llvm: changed llvm_metadatatype from untyped pointer to undefineddef
That matches its meaning better, as it should not result in type conversions.
E.g. some kinds of metadata parameters expect a "type register" parameter such
as "metadata i32* %reg.3"
2022-06-04 22:26:40 +02:00
Jonas Maebe
aa43441ac9 llvm: replaced boolean fields in tllvmcallpara with a set 2022-06-04 22:26:40 +02:00
Jonas Maebe
573b2554f4 llvminfo: fix copy/paste error in llvm 14 comment
Spotted by @Alexey-T1
2022-06-04 22:26:40 +02:00
Jonas Maebe
a45e5e7ab6 llvm: version 14.0 support 2022-06-04 13:34:09 +02:00
Jonas Maebe
591c1b0177 llvm: added support for newer Xcode toolchains
Based on https://en.wikipedia.org/wiki/Xcode#Xcode_11.x_-_13.x_(since_SwiftUI_framework)_2
2022-06-04 09:43:39 +02:00
Jonas Maebe
dcf6063dc3 llvm: version 13.0 support 2022-06-03 21:46:23 +02:00
Jonas Maebe
1b06599e82 llvm: version 12.0 support 2022-06-03 21:46:23 +02:00
Jonas Maebe
a19deace45 llvmdbg: fix overflows for aggregates > 2^61 bytes
LLVM does not support aggregates larger than that at all, because internally
it stores all sizes in bits in an uint64. Their rationale for not having
special support for that is that there is no hardware with full 64 bit VM
address space anyway. So truncate our size emissions in debug info also to
that.
2022-05-29 13:33:27 +02:00
Jonas Maebe
70908b1449 llvm: support for adding/subtracting constants to pointers in typed constants
Fixes webtbs/tw34027 for llvm
2022-05-29 13:33:27 +02:00
Sven/Sarah Barth
088c746d45 * reset written source lines once a section is encountered 2022-05-26 21:43:35 +02:00
Jonas Maebe
ccc843f983 llvmdbg: emit uppercase symbol names unless C++-style debug info is selected
Otherwise gdb won't find the symbols unless you use the exact case
2022-05-21 22:32:35 +02:00
Jonas Maebe
9a7a97175e llvmdbg: emit debug information for global variables 2022-05-21 22:32:35 +02:00
Jonas Maebe
1b393c80aa llvmdbg: fix missing initialisation when there are no procedures 2022-05-21 22:32:35 +02:00
Jonas Maebe
d0bf7acc18 llvmdbg: build hashtable to lookup llvmdecl belonging to a global variable
We need to attach the debug info to it
2022-05-21 22:32:35 +02:00
Jonas Maebe
e865ab4c3a llvmdbg: handle nil in more places
"void" is represented as "null" in LLVM debug information, which we represent
by nil
2022-05-21 22:32:35 +02:00
Jonas Maebe
a33e6230a0 llvm metadata: add DIGlobalVariableExpression enum
Only documented as of LLVM 9.0, but existed already in 7.0.
Also fixed DIGlobalVariable not being marked as unique
2022-05-21 22:32:35 +02:00
Jonas Maebe
f896766837 agllvm: fix writing metadata operands for variable declarations 2022-05-21 22:32:35 +02:00
Jonas Maebe
16cb409fbf LLVM: separate as_clang_llvm_darwin
The Darwin local label prefix ('L') is different from that on most other
platforms ('.L). While LLVM generally handles that for us, for inline
assembly it's still FPC's job to adhere to the target conventions.
2022-05-14 22:38:49 +02:00
Jonas Maebe
481741c65b llvmdbg: remove some commented dbgdwarf code
Also adjusted some hashtable sizes
2022-05-14 22:38:49 +02:00
Pierre Muller
9b87fb4a34 Use '.L' as labelprefix for LLVM compiler variant 2022-05-14 21:26:13 +02:00
Pierre Muller
a0d4cccd87 Fix syntax error for isLocal field for function/procedure type LLVM debug information 2022-05-14 21:05:54 +02:00
Jonas Maebe
cddffbed58 llvmdbg: disable open array data location
Since we don't generate full debug info for parameters yet, this internalerrors
2022-05-14 08:34:38 +02:00
Jonas Maebe
fd125b506e LLVM debug info: LLVM 7.0 support
Also defined some llvm flags in a negative way so they can be removed from
later versions rather than added
2022-05-13 22:49:02 +02:00
Jonas Maebe
edbddec98a llvmdbg: diflags/dispflags fixes
Fix MainSubprogram flag for older LLVM versions, as it was a plain flag rather
than a subprogram flag there.

Added visibility flags for procdefs (public/private/protected)

Write flags as enum rather than integer to avoid issues with changing values
across different LLVM versions
2022-05-13 22:49:02 +02:00
Jonas Maebe
816ab7ffcc llvm metadata: counter per unit rather than globally
Results in less high numbers, and reproducible results when partially
rebuilding
2022-05-13 22:49:02 +02:00
Jonas Maebe
9b280db2b1 dbgllvm: add scopeLine attribute for function debug info
Ensures that breaking on the function correctly sets the breakpoint on the
first source line of the function (rather than potentially in the prologue
without line information)
2022-05-13 22:49:02 +02:00
Jonas Maebe
d1aaeff832 dbgllvm: fix crash for files without procedures/functions 2022-05-13 22:49:02 +02:00
Jonas Maebe
067d96242c dbgllvm: fix crash when generating debug info for procdef of imported struct 2022-05-13 22:49:02 +02:00
Jonas Maebe
cf6a97c8ed LLVM: fix fileinfo of temp allocations 2022-05-13 22:49:02 +02:00
Jonas Maebe
8d2d91d505 dbgllvm: fix infinite loop when writing multi-dimensional array info 2022-05-13 22:49:02 +02:00
Jonas Maebe
a7e19e9f06 llvm metadata: use cardinal instead of tsuperregister for unnamed metadata numbers
We're not putting these into registers, so no need to limit ourselves
2022-05-13 22:49:02 +02:00
Jonas Maebe
a75adf542d dbgllvm: handle empty spFlags 2022-05-13 22:49:02 +02:00
Jonas Maebe
91563115c4 dbgllvm: handle array of const (stub) 2022-05-13 22:49:02 +02:00
Jonas Maebe
aec7aefdd5 dbgllvm: create dummy line info for instructions that shouldn't have any
Use line 0 for that, like clang does
2022-05-13 22:49:02 +02:00
Jonas Maebe
20674089bd llvmdbg: add declaration for all DISPFlags 2022-05-13 22:49:02 +02:00
Jonas Maebe
13055bb58a llvmtype: ensure all processed defs get recorded
This is necessary so they get reset as well, as they may be reprocessed while
compiling other units (both by llvmtype and dbgllvm)
2022-05-13 22:49:02 +02:00
Jonas Maebe
f832444eaa LLVM lineinfo: fix nolineinfo generation
LLVM requires line info metadata for all call instructions that may potentially
be inlined. So attach one to all call instructions in nolineinfo regions, but
set their line number to 0 (same as what clang does)
2022-05-13 22:49:02 +02:00
Jonas Maebe
40418f5b3d dbgllvm: remove restriction to only write struct procdef in context of struct
Does not make a difference for LLVM since all debug info for procdefs is
assigned to the definition instructions for the procdef anyway, and avoids
issues when only generating line info (in that case the structs will never
be processed, but we still have to generate the basic debug info for their
procdefs to provide a scope for their line info)
2022-05-13 22:49:02 +02:00
Jonas Maebe
6cacd9c824 llvmdbg: initial version based on dbgdwarf
Line information is mostly functional, type information not yet (except
for basic procdef info, as that's required for line info)
2022-05-13 22:49:02 +02:00
Jonas Maebe
f1bcd02aaf Typed const builder: store tsym
Useful for LLVM debug info generation
2022-05-13 22:49:02 +02:00
Jonas Maebe
b7b495a679 LLVM: assign procdef.procstarttai, like in the regular code generator 2022-05-13 22:49:02 +02:00
Jonas Maebe
229eb93e72 tnodeuitls: merge GenerateObjCImageInfo into InsertObjectInfo
LLVM needs to insert the Objective-C image info into the general object info
metadata. This way we don't need to store a reference to that metadata so
as to add extra data to it later (tnodeutils is never instantiated, it only
contains class methods)
2022-05-13 22:49:02 +02:00
Jonas Maebe
78535bbcd8 agllvm: support for writing specialised metadata nodes 2022-05-13 22:49:02 +02:00
Jonas Maebe
d294731542 LLVM: enable DWARF debug info generation 2022-05-13 22:49:02 +02:00
Jonas Maebe
527c68b6c3 agllvm: remove useless code 2022-05-13 22:49:02 +02:00
Jonas Maebe
a8cb061a50 LLVM: support for attaching metadata to instructions 2022-05-13 22:49:02 +02:00
Jonas Maebe
4293d4455c LLVM: factor out writing operands in agllvm 2022-05-13 22:49:02 +02:00
Jonas Maebe
411fa298ae LLVM: data location debug info support
This was added to LLVM for Fortran arrays, but can also be used for Pascal
dynamic arrays
2022-05-13 22:49:02 +02:00
Jonas Maebe
1d010d918b LLVM metadata: specialised metadata fleshing out 2022-05-13 22:49:02 +02:00
Pierre Muller
69d40dd17a Use round to convert float constant into s64comp type for LLVM compiler as is done in general case 2022-05-12 22:32:26 +02:00
pierre
04ebdf8df8 Fix compilation for x86_64 llvm variant
git-svn-id: trunk@49477 -
2021-06-05 06:47:46 +00:00
pierre
aadcb00977 Add -march option to clang call for llvm target
git-svn-id: trunk@49475 -
2021-06-04 21:14:34 +00:00
florian
fe57cd3536 * fix LLVM after r48828
* global gotos really use the return type of fpc_setjmp to test where we come from

git-svn-id: trunk@48835 -
2021-02-27 22:07:58 +00:00
Jonas Maebe
80282d6eff * llvm: only set custom parameter alignments for byval parameters, the rest
is handled automatically by llvm (and since llvm 11.0 you get an error if
    you specify an alignment for them anyway)

git-svn-id: trunk@48100 -
2021-01-06 22:35:40 +00:00
Jonas Maebe
c3e2285c45 * when getting an llvm temporary recorddef, recurse into arrays rather than
treating them as opaque defs. This is required to ensure that the temporary
    recorddef for all x86-64 function results are the same on the caller and
    callee side, as we allocate new arrays when generating them

git-svn-id: trunk@47584 -
2020-11-25 18:44:44 +00:00
pierre
96f2e683e7 Also accept s80bit real constants when FPC_SOFT_FPUX80 macro is defined
git-svn-id: trunk@47557 -
2020-11-24 15:31:26 +00:00
Jonas Maebe
6d0ce1c4b6 * LLVM: ensure that the parameter types are processed of procdefs that are
declared when they get first called
   o fixes compilation of several tests/test/tobjc* tests after r46675

git-svn-id: trunk@47160 -
2020-10-23 15:09:34 +00:00
Jonas Maebe
080d8c28f7 * LLVM 11.0 support
git-svn-id: trunk@47121 -
2020-10-17 14:59:04 +00:00
florian
637976e83f * patch by Marģers to unify internal error numbers, resolves #37888
git-svn-id: trunk@47103 -
2020-10-13 19:59:01 +00:00
Jonas Maebe
3208929e17 * add Xcode-11.0 as LLVM target version versin
git-svn-id: trunk@46676 -
2020-08-23 21:11:13 +00:00
Jonas Maebe
453bfcd370 * emit the correct declaration for procdefs used to force a procname in LLVM
o fixes lazarus startup on macOS/AArch64 when compiled with the LLVM cg

git-svn-id: trunk@46675 -
2020-08-23 21:11:09 +00:00
yury
6e777d8967 * ait_comment,ait_regalloc,ait_tempalloc,ait_varloc instructions produce only comments in the external assembler output. Moved handling of these instructions to TExternalAssembler.WriteComments().
This eliminates code duplication and improves maintainability.

git-svn-id: trunk@46550 -
2020-08-22 19:53:39 +00:00
yury
5ec489c018 * ait_varloc instructions are handled and removed by Trgobj.translate_registers() and never left for an assembler.
git-svn-id: trunk@46541 -
2020-08-22 10:58:21 +00:00
yury
764227193a * Added on option to implement library based smartlinking of the dead stripable vectorized lists (e.g. resource strings index). By default smartlinking of such lists only supported when the section based smartlinking (tf_smartlink_sections) is enabled for a target.
git-svn-id: trunk@46479 -
2020-08-18 11:31:39 +00:00
Jonas Maebe
86d55055df * made internalerror unique
git-svn-id: trunk@46236 -
2020-08-04 21:12:06 +00:00
Jonas Maebe
3047ce71bc * fixed LLVM register allocator after r46199
git-svn-id: trunk@46212 -
2020-08-03 20:36:02 +00:00
Jonas Maebe
a5bad32b7c - removed no longer used -target $TARGET parameter (triplet is used instead)
git-svn-id: trunk@45853 -
2020-07-25 16:11:54 +00:00
Jonas Maebe
eb7ba1690e * mark all external assemblers using an LLVM tool using af_llvm
+ added support for constructing target triplets
  * pass "-target triplet" when using an LLVM assembler
   o removed no longer needed $DARWINVERSION and $ARCH parameters
  * consistently use as_clang_gas when clang is used to assembler GAS-style
    assembly, and rename as_llcm_clang to as_clang_llvm (for consistency)
  * support pipe assembling when using clang on *nix in all cases

git-svn-id: trunk@45807 -
2020-07-19 14:30:35 +00:00
Jonas Maebe
e7d1a77f9a * rename the ARM/AArch64-Darwin targets to ARM/AArch64-iOS
* rename the m68k/PowerPC-MacOS targets to m68k/PowerPC-MacOSClassic
  * repurpose the AArch64/Darwin target for AArch64/macOS
   o make AArch64-Darwin default target for a hosted AArch64-Darwin compiler

git-svn-id: trunk@45758 -
2020-07-10 21:52:24 +00:00
Jonas Maebe
4caa471a24 * implemented a_load_undefined_cgpara for LLVM, fixes LLVM code generator
after the changes to optimize unused parentfp parameters

git-svn-id: trunk@45456 -
2020-05-21 10:56:39 +00:00
yury
627fcb4354 * Do not use the LOC_VOID location to indicate unused parameters.
* Added the tprocdef.parentfpsym property. Set parentfpsym.varstate to vs_read instead of using the pio_needs_parentfp flag.
* Replaced tcgcallparanode.push_zero_sized_value_para by tparamanager.has_strict_proc_signature.

git-svn-id: trunk@45454 -
2020-05-21 09:36:40 +00:00
marcus
589b2b956f Fixed LLVM compilation after r45143
git-svn-id: trunk@45155 -
2020-04-28 18:41:45 +00:00
nickysn
3d81dd0b00 * ReplaceForbiddenAsmSymbolChars renamed ApplyAsmSymbolRestrictions, because now it also applies the
label length limit

git-svn-id: branches/z80@45085 -
2020-04-26 10:42:07 +00:00
nickysn
a8fe46c0f5 + introduced labelmaxlen in tasminfo and added code in ReplaceForbiddenAsmSymbolChars that limits the
output label to that length

git-svn-id: branches/z80@45066 -
2020-04-25 12:59:25 +00:00
Jonas Maebe
d5de84c6c5 * use typenames in more cases in the generated LLVM IR (results in smaller
IR in textual form)

git-svn-id: trunk@44518 -
2020-04-02 21:21:44 +00:00
Jonas Maebe
afd0ae44ee * use tprocvardef.getreusableprocaddr also for non-address-only copies of
proc(var)defs

git-svn-id: trunk@44517 -
2020-04-02 21:21:40 +00:00
Jonas Maebe
4ba19f5418 * add support for creating non-address-only procvars to
cprocvar.getreusableprocaddr()

git-svn-id: trunk@44516 -
2020-04-02 21:21:36 +00:00
Jonas Maebe
79974a9671 + -XlS<x> option to specify a suffix for externally called LLVM utilities,
e.g. -XlS-7 to call clang-7 instead of clang)
  * IMPORTANT: changed the -CL llvm code generation options to -Cl, for
    consistency with the new -Xl option (-XL was already taken)

git-svn-id: trunk@44436 -
2020-03-30 19:58:49 +00:00
Jonas Maebe
523ebb42cf * fix LLVM backend compilation (mantis #36833)
git-svn-id: trunk@44374 -
2020-03-27 21:26:39 +00:00
Jonas Maebe
3188dc18d4 * fixed tdel1/2 tests again for AArch64/LLVM
git-svn-id: trunk@44195 -
2020-02-16 16:58:25 +00:00
Jonas Maebe
254b85c352 + new pio_inline_forbidden flag to indicate that while parsing the
implementation the compiler determined the routine must never be
    inlined
   o difference with po_noinline: can also be set in the implementation
   o difference with pio_inline_not_possible: it indicates that e.g.
     LLVM must not inline the routine either

git-svn-id: trunk@44065 -
2020-01-29 22:21:17 +00:00
Jonas Maebe
08f9ec98e5 * use same Windows platform name as clang
git-svn-id: trunk@44063 -
2020-01-29 22:21:10 +00:00
Jonas Maebe
df6516c29f * fix internalerror if adding the object info for LLVM requires creating new defs
git-svn-id: trunk@44061 -
2020-01-29 22:21:03 +00:00
Jonas Maebe
31ef82b9c6 * constrained sitofp is not yet supported in LLVM for all targets
git-svn-id: trunk@43885 -
2020-01-07 20:22:17 +00:00
Jonas Maebe
9462d6b1ea * handle non-smallset sets in registers in LLVM like arrays and records
git-svn-id: trunk@43884 -
2020-01-07 20:22:13 +00:00
Jonas Maebe
32be078ab8 * fixed for targets where currency is implemented via int64 after r43829
git-svn-id: trunk@43882 -
2020-01-07 20:22:06 +00:00
Jonas Maebe
f659e91a95 * fixed LLVM compilation after r43860
git-svn-id: trunk@43862 -
2020-01-05 13:15:10 +00:00
Jonas Maebe
044d946782 * fixed missing sign extension when adding a signed integer variable with
size < sizeof(pointer) to a pointer for LLVM (fixes tfmtbcd)

git-svn-id: trunk@43833 -
2020-01-01 19:19:12 +00:00
Jonas Maebe
ec0d98156c * use maytrap instead of strict FP exception behaviour in LLVM, so constant
propagation is still allowed

git-svn-id: trunk@43832 -
2020-01-01 19:19:08 +00:00
Jonas Maebe
1f5efe2a95 * support for constrained sitofp/uitofp with (the upcoming) LLVM 10.0
(fixes most of test/units/math/troundm, although there's still an LLVM
     optimizer/code generation bug that breaks some qword -> double
     conversions)

git-svn-id: trunk@43829 -
2019-12-31 18:05:54 +00:00
Jonas Maebe
9b53ed53e3 * the llvm.experimental.constrained.fpext intrinsic doesn't have a rounding
mode parameter

git-svn-id: trunk@43828 -
2019-12-31 18:05:50 +00:00
Jonas Maebe
3885ce98ac * fix LLVM code generator after r43808
o share the high/length code for LLVM rather than duplicating it, since
      LLVM will optimize away the minor inefficiencies
    o removed temp reference in the old code, as it was useless (it doesn't
      prevent spilling to get to an SSA representation since the same
      register is written at least twice in all cases)

git-svn-id: trunk@43821 -
2019-12-30 15:05:17 +00:00