Commit Graph

55 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
91e8f4c439 + custom section name support for llvm
git-svn-id: trunk@32400 -
2015-11-21 12:36:26 +00:00
Jonas Maebe
fa7ebba80d + new tcalo_no_dead_strip flag for the high level typed const builder to
indicate symbols that should never be removed by the linker
   o TODO for llvm, needs support for the @llvm.used array (only used for
     the compiler ident, so it's not that important

git-svn-id: trunk@31677 -
2015-09-14 16:10:51 +00:00
Jonas Maebe
2741b37f28 * only specify the "unnamed_addr" flag for initialised data if its symbol is
a tasmlabel, since otherwise the address needs to remain unique

git-svn-id: trunk@31654 -
2015-09-12 23:33:46 +00:00
Jonas Maebe
5a2217f645 + support for emitting simple placeholder elements in the high level
typed const builder, for use when e.g. emitting a table preceded by
    the number of elements in case that number is only known afterwards

git-svn-id: trunk@31648 -
2015-09-12 23:33:24 +00:00
Jonas Maebe
c80fb6a20e * explicitly specify whether an llvm specification is a definition (= locally
defined) or a declaration (external symbol), instead of deriving it from
    from the bind of the tasmsymbol. The reason is that with module-level
    inline assembly, some locally implemented functions (in pure assembler)
    won't have an LLVM IR body

git-svn-id: trunk@31629 -
2015-09-12 23:32:17 +00:00
Jonas Maebe
e93660c170 - removed ttai_lowleveltypedconstbuilder.queue_addrn(), as we are always
implicitly taking the address of a complex expression in a typed constant
    (you cannot put the contents of another memory location in a typed
    constant)

git-svn-id: trunk@31252 -
2015-07-30 16:58:07 +00:00
Jonas Maebe
ddeab221c0 * when starting a queued expression, immediately emit any necessary padding
bytes,becayse if we emit them at the end then we may interpret the first
    padding byte as the final component of the queued expression

git-svn-id: trunk@31246 -
2015-07-30 16:57:49 +00:00
Jonas Maebe
7a8b5fd6c5 * several fixes for emitting aggregate typed constants with C/ABI packing:
o don't emit explicit padding bytes (LLVM adds them)
   o don't mark them in LLVM as packed either

git-svn-id: trunk@31187 -
2015-07-03 20:04:15 +00:00
Jonas Maebe
4edb6e68fd * fixed emitting Pascal extended typed constants inside aggregates for llvm
(have to be emitted as arrays of bytes to ensure they don't take up
     more than 10 bytes)

git-svn-id: trunk@31186 -
2015-07-03 20:04:11 +00:00
Jonas Maebe
508828958c * changed getprocaddressprocvar() into a tprocvardef.getreusableprocaddr()
class method

git-svn-id: trunk@31148 -
2015-06-23 21:23:22 +00:00
Jonas Maebe
f402b0d7df * changed getpointerdef() into a tpointerdef.getreusable() class method
o allows removing the ugly x86 hacks

git-svn-id: trunk@31144 -
2015-06-22 08:17:49 +00:00
Jonas Maebe
89c4bd8522 * index the llvm shadow symtable with a fieldvarsym rather than with the
index of the corresponding llvm fieldvar, as this index is a member
    of the fieldvarsym that only gets initialised once the llvm shadow
    symtable gets built, which in turn is triggered by trying to access
    it for the first time -> if fieldvarsym.llvmfieldnr got loaded by
    the compiler before evaluating the llvmst expression and if the
    llvmst hadn't been built yet, this llvmfieldnr was not yet initialized

git-svn-id: trunk@31060 -
2015-06-13 22:48:37 +00:00
Jonas Maebe
494206fd6a * use queue_is_active() method to determine whether the complex typed
expression queue is active rather than the existing ad hoc check,
    which failed when no item had been added to the queue yet

git-svn-id: trunk@31059 -
2015-06-13 22:48:34 +00:00
Jonas Maebe
bd8079f896 * cache and reuse procvardefs internally created to get the address of a
procdef (halves the amount of memory needed to compile the googlapi
    package using a build unit, as done by fpmake)

git-svn-id: trunk@30856 -
2015-05-14 15:36:20 +00:00
Jonas Maebe
e2cf90ad8a * add type declarations for structure types in the llvm code so that we can
handle recursive record references (rec= record prec: ^rec)
   o llvm unfortunately does not support recursive references to array types
     or function pointers, so those will currently still result in endless
     recursion when the compiler tries to write them out. Solving those
     will require a lot of typecasting in the generated code

git-svn-id: trunk@30675 -
2015-04-19 21:37:46 +00:00
Jonas Maebe
f631430775 * made the allocation of labels for internal data in typed const builders
overridable, and implement those routines for llvm

git-svn-id: branches/hlcgllvm@30348 -
2015-03-28 11:34:04 +00:00
Jonas Maebe
e924dbed90 * moved the specification of the options for a ttai_typedconstbuilder from
get_final_asmlist() to the constructor, in preparation of supporting the
    creation of internal builders for local data that will ignore some of the
    irrelevant flags (at creation time)

git-svn-id: branches/hlcgllvm@30334 -
2015-03-27 21:25:27 +00:00
Jonas Maebe
c1e7c9de02 * support for flushing a ttai_typedconstbuilder queue with an ordinal
constant at the end (in case of e.g. ordinal -> pointer type
    conversions)

git-svn-id: branches/hlcgllvm@30128 -
2015-03-07 21:43:57 +00:00
Jonas Maebe
eba3f534de * correctly handle empty ansistring constants for llvm
git-svn-id: branches/hlcgllvm@30127 -
2015-03-07 21:43:52 +00:00
Jonas Maebe
9c42437326 * moved tasmlisttypedconstbuilder.tc_emit_string_offset() to
ttai_typedconstbuilder.emit_string_offset() so it can also be used outside
    the context of parsing a Pascal-level typed constant

git-svn-id: branches/hlcgllvm@30111 -
2015-03-06 19:45:04 +00:00
Jonas Maebe
ea00e559f8 * fixed compilation after previous merge
git-svn-id: branches/hlcgllvm@30106 -
2015-03-05 22:20:45 +00:00
Jonas Maebe
76e0ee7a41 * fixed adding padding bytes before anonymous records: the alignment of such
records is only known once we have completely parsed all of their data
    (the alignment of a record depends on the alignment requirements of its
     field with the largest alignment) -> only insert the padding bytes after
    completely parsing them

git-svn-id: branches/hlcgllvm@28765 -
2014-10-06 20:53:51 +00:00
Jonas Maebe
5a9b931e5c * renamed ttai_lowleveltypedconstbuilder to ttai_typedconstbuilder
git-svn-id: branches/hlcgllvm@28764 -
2014-10-06 20:53:49 +00:00
Jonas Maebe
d2b55b6f07 * moved the recording of aggregate type information during typed constant
parsing from nllvmtcon to aasmcnst
   o added automatic insertion of padding bytes when fields need to be aligned,
     so that once ncgvmt (and hopefully ncgrtti) are converted to the typed
     constant builder class, we can get rid of all the explicit alignment
     directives (only supported for non-bitpacked records for now)

git-svn-id: branches/hlcgllvm@28763 -
2014-10-06 20:53:46 +00:00
Jonas Maebe
bdb22772d9 * fixed whitespace
git-svn-id: branches/hlcgllvm@28756 -
2014-10-06 20:53:28 +00:00
Jonas Maebe
210b532832 * split up specifying the type of the section of a typed constant and whether
it should be put in a new section

git-svn-id: branches/hlcgllvm@28753 -
2014-10-06 20:53:20 +00:00
Jonas Maebe
6677e698cd * record the alignment in taillvmdecl, as it can be different from the
default

git-svn-id: branches/hlcgllvm@28752 -
2014-10-06 20:53:17 +00:00
Jonas Maebe
864b36fbe5 * create the recorddef at the start when building an anonymous recorddef,
so that we can already refer to its def while we are sill parsing
    individual elements

git-svn-id: branches/hlcgllvm@28750 -
2014-10-06 20:53:12 +00:00
Jonas Maebe
cc4482d6f8 - removed tck_simple_procvar2proc, instead use
procdef.getcopyas(procvardef,pc_address_only) as the def if we want to
    specify that we're interested in the address of a procedure/procvar of
    object

git-svn-id: branches/hlcgllvm@28476 -
2014-08-19 20:22:11 +00:00
Jonas Maebe
9e074d036b * migrated the handling of ansi/unicodestring constants to the high level
typed constant builder + llvm implementation

git-svn-id: branches/hlcgllvm@28327 -
2014-08-06 18:04:40 +00:00
Jonas Maebe
c84a8a4bc2 * separate methods to get the size of the ansistring/unicode header and to
get the offset relative from the returned label from
    emit_(ansi|unicode)_string() to the start of the string data
   o corrected return value for the offset on LLVM: it's always equal to the
     header size, since we can't emit labels in the middle of structured data
     there

git-svn-id: branches/hlcgllvm@28324 -
2014-08-06 18:04:31 +00:00
Jonas Maebe
7a10959aa0 + support for parsing structured data for which no tdef is available in
advance (e.g. ansistring constants, as they consist of a header
    followed by an array of char equal to the string length, or RTTI data)
   o use begin_anonymous_record() to start recording the field types (if
     necessary for the current target), and end_anonymous_record() at the
     end to generate the recorddef

git-svn-id: branches/hlcgllvm@28323 -
2014-08-06 18:04:28 +00:00
Jonas Maebe
2a45b57504 * removed todo comment, the "constant" information is already propagated in
the mean time via the section type (sec_rodata/sec_rodata_norel ->
    constant)

git-svn-id: branches/hlcgllvm@28212 -
2014-07-12 22:42:37 +00:00
Jonas Maebe
eef6f05697 * specify the asm section type when creating an LLVM declaration
o in case it's a read-only section, mark the data as "constant"

git-svn-id: branches/hlcgllvm@28155 -
2014-07-04 20:30:24 +00:00
Jonas Maebe
394dfdd220 * ensure that all initialised items have a type (and only one):
o remove the accompanying tdef operands from tai operands, because such
     tai operands should have a tdef already
   o check that every queued tai is a tai_simpletypedconst (which have a
     type)
   o wrap queued bitcast/getelementptr tai instances with a
     tai_simpletypedconst

git-svn-id: branches/hlcgllvm@28154 -
2014-07-04 19:24:20 +00:00
Jonas Maebe
fc7d5e2254 * insert a type conversion if the final result of an queued expression is
different from the type of typed constant/initialised data

git-svn-id: branches/hlcgllvm@28146 -
2014-07-03 22:28:40 +00:00