Commit Graph

432 Commits

Author SHA1 Message Date
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
Jonas Maebe
ba37a48bcb * support OS_32..OS_128 as source size for LOC_(C)MMREGISTER records
in a_load_ref_cgpara() (if a record is located in memory and needs
    to be passed in mmregisters)

git-svn-id: trunk@32402 -
2015-11-21 12:36:32 +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
d02eb7059b + pointerdef support in llvmgettemprecorddef()
git-svn-id: trunk@32314 -
2015-11-13 17:48:19 +00:00
Jonas Maebe
5de3785c0e * fixed allocation of temps for empty arrays on llvm
git-svn-id: trunk@32299 -
2015-11-12 22:00:28 +00:00
Jonas Maebe
1675c27e59 * fixed writing of procvardef records (they're also written as tck_record)
git-svn-id: trunk@32298 -
2015-11-12 22:00:25 +00:00
Jonas Maebe
3e917f5889 * fixed llvm a_load_reg_ref() when storing a register to a record reference
of 3/5/6/7 bytes

git-svn-id: trunk@32292 -
2015-11-11 20:46:46 +00:00
Jonas Maebe
4f54f8b3bd * fixed expectloc for llvm bool_2_int typeconversions where the location
doesn't change

git-svn-id: trunk@32248 -
2015-11-04 22:23:50 +00:00
Jonas Maebe
69b832c1d0 * added in_sqr_x support for llvm
git-svn-id: trunk@32247 -
2015-11-04 22:23:47 +00:00
Jonas Maebe
fa3b0ca312 * support marking defs created via the getreusable*() class methods as
"don't free even if not registered"; use for defs that may not be written
    to a ppu file, but that must nevertheless survive the compilation of the
    current module
  * mark all defs created for para locations as "don't free even if not
    registered", because we don't discard and recalculate all para locations
    after a module has been compiled (since that's not needed)
   o solves issues if the paralocations for a routine in the interface of
     unit A are calculated while the implementation of unit B gets
     compiled, and a new reusable type is allocated at that point which
     is not used anywhere else (after r32160)

git-svn-id: trunk@32235 -
2015-11-04 20:46:18 +00:00
Jonas Maebe
5e32590741 * handle variant record fields in
thlcgllvm.g_set_addr_nonbitpacked_record_field_ref()

git-svn-id: trunk@32213 -
2015-10-31 14:25:50 +00:00
Jonas Maebe
cf0164b460 + support for classrefdef
git-svn-id: trunk@32163 -
2015-10-26 21:24:33 +00:00
Jonas Maebe
d7bda793f2 * record rather than immediately append encountered defs, so that we don't
emit the same def multiple times

git-svn-id: trunk@32162 -
2015-10-26 21:24:29 +00:00
Jonas Maebe
954cfd8d40 * replaced use of current_asmdata.currasmlist with the "list" parameter
in g_set_addr_nonbitpacked_record_field_ref()

git-svn-id: trunk@31776 -
2015-09-22 19:59:34 +00:00
Jonas Maebe
f8d9e70ec2 * converted tnodeutils.InsertMemorySizes() to the high level typed constant
builder and activated it for llvm

git-svn-id: trunk@31678 -
2015-09-14 16:10:54 +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
bf10ae45de * only add the llvm "sret" attribute to "struct return" parameters if they
are the first parameter (as required by llvm)
   o ensure that for AArch64, "struct return" the parameter always is the first
     parameter, as it needs to be returned in a special register there

git-svn-id: trunk@31676 -
2015-09-14 16:10:48 +00:00
Jonas Maebe
75012405fa * add some llvm function flags
o in particular, mark fpc_setjmp as "returns_twice" so calls to it are
     never converted into tail calls

git-svn-id: trunk@31659 -
2015-09-12 23:34:04 +00:00
Jonas Maebe
616dbead35 + handle abs(real) internally for LLVM, as the generic code calls a helper
that is not implemented for some architectures

git-svn-id: trunk@31656 -
2015-09-12 23:33:53 +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
7a08319d2e * converted taillvmdecl properties to a set
git-svn-id: trunk@31653 -
2015-09-12 23:33:42 +00:00
Jonas Maebe
4b92083006 * converted tnodeutils.InsertRuntimeInitsTablesTable to the high level typed
const builder
   o enabled the routines that use this one for LLVM

git-svn-id: trunk@31652 -
2015-09-12 23:33:38 +00:00
Jonas Maebe
a4ee982269 * converted tnodeutils.InsertInitFinalTable to the high level typed const
builder and enabled it for LLVM

git-svn-id: trunk@31651 -
2015-09-12 23:33:35 +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
c813e024ee * support non-section-based threadvars on the LLVM target
git-svn-id: trunk@31645 -
2015-09-12 23:33:14 +00:00
Jonas Maebe
4da34a6046 + llvm implementation of g_set_addr_nonbitpacked_record_field_ref
git-svn-id: trunk@31642 -
2015-09-12 23:33:03 +00:00
Jonas Maebe
54172d7de4 * fixed alignment of subscripts if the variant part of a record starts at a
non-zero offset from the reference field in the llvm version of the record

git-svn-id: trunk@31637 -
2015-09-12 23:32:46 +00:00
Jonas Maebe
cabb16efdb - removed the no longer used generation of uninitialised results for
pure assembler routines

git-svn-id: trunk@31634 -
2015-09-12 23:32:35 +00:00
Jonas Maebe
839482751d * when generating code for a pure assembler routine with LLVM, instantiate
a code and temp generator for the architectural target instead of for LLVM
  * write the code for pure assembler routines using a GNU-style external
    assembler writer for the target, with a decorator to wrap it in
    LLVM module-level assembly statements

git-svn-id: trunk@31633 -
2015-09-12 23:32:31 +00:00
Jonas Maebe
5c69d57674 + TLLVMModuleInlineAssemblyDecorator to decorate inline module-level
assembly

git-svn-id: trunk@31632 -
2015-09-12 23:32:28 +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
991e1f49bd * store a pointer to the used tasminfo record in every assembler writer, so
that we can use assembler writers with different conventions from the
    currently set target_asm (e.g. an x86 assembler writer for inline assembly
    in LLVM IR)

git-svn-id: trunk@31628 -
2015-09-12 23:32:13 +00:00
Jonas Maebe
b3d0197f98 * factored out the output file handling (mostly writing data) from the
external assembler writer, so we can reuse the archtecture-specific
    writers to write inline assembly in LLVM IR files

git-svn-id: trunk@31625 -
2015-09-12 23:32:01 +00:00
Jonas Maebe
0fc1fd6ac1 * replaced current_procinfo.currtrue/falselabel with storing the true/false
labels of LOC_JUMP in the node's location. This generates some extra jumps
    for short circuit boolean and/or-expressions if optimizations are off, but
    with optimisations enabled the generated code is the same (except for JVM
    because the jump threading optimisation isn't enabled there yet).

git-svn-id: trunk@31431 -
2015-08-27 18:28:57 +00:00
Jonas Maebe
677595880a + support for get_frame() for the LLVM target (using the llvm.frameaddress()
intrinsic)

git-svn-id: trunk@31409 -
2015-08-24 22:07:03 +00:00
Jonas Maebe
be9d2b1c26 * implement concatcopy for complex types by calling the llvm.memcpy()
intrinsic. This may insert actual calls to a function called memcpy with
    the signature of the libc function, but llvm optimizers are free to
    insert such calls by themselves already. This means that for non-libc
    targets, we will have to add weak symbols for memcpy/memmove/memset
    that call through to move/fillchar when using LLVM, so that these
    implementation are used when not linking to libc

git-svn-id: trunk@31408 -
2015-08-24 22:07:00 +00:00
Jonas Maebe
ba9d54beb5 * don't mangle symbol names for llvm intrinsics
git-svn-id: trunk@31406 -
2015-08-24 22:06:53 +00:00
Jonas Maebe
4c5191f5d7 * generate LLVM typedefs for file-typed data
git-svn-id: trunk@31344 -
2015-08-18 16:10:29 +00:00
Jonas Maebe
a722b5dbc5 * add alignment padding to internally constructed llvm records
git-svn-id: trunk@31290 -
2015-08-05 21:06:09 +00:00
Jonas Maebe
bfa94ae908 * further (final?) reworking of llvm external symbol handling:
o all external symbol definitions are now inserted in the llvmtype post pass
     based on all declarations and types used in llvm instructions
   o this means we don't have to use the workaround with the Pascal mangled
     names anymore for all external names, as we now insert the external
     references only once we know all type information

git-svn-id: trunk@31287 -
2015-08-05 21:06:01 +00:00
Jonas Maebe
6dcf61f057 * an alias is an explicit definition of a symbol -> override types gleaned
from implicit ones

git-svn-id: trunk@31286 -
2015-08-05 21:05:58 +00:00
Jonas Maebe
a58504990a * fixed llvm handling of routines that are normally declared in the
interface of a unit, or forward declared, and then the implementation turns
    out to be external. We now properly generate a wrapper routine at the
    Pascal level for the original declaration that calls through to the
    external routine

git-svn-id: trunk@31285 -
2015-08-05 21:05:55 +00:00
Jonas Maebe
1cdaf8e332 * don't write external linkage for aliases: llvm 3.6 has a bug that rejects
linkage types for aliases (or its documentation hasn't been updated), and
    external linkage is the default so it doesn't matter for earlier versions

git-svn-id: trunk@31284 -
2015-08-05 21:05:52 +00:00
Jonas Maebe
9a8a323578 * (again) fixed loading the address of the string data of an ansi/
unicodestring constants: specify the type of the pointer to the
    string record (which is indirect) rather than that of the string
    array (which will implicitly be the result of the getelementptr)

git-svn-id: trunk@31256 -
2015-07-30 16:58:19 +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
b55c7df996 * factored out internal type prefixes
git-svn-id: trunk@31248 -
2015-07-30 16:57:55 +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
e9d2eb6cff * fixed a_load_reg_reg() when storing an array/record to another
array/record type (can happen for parameters/function results
    that got a different type for ABI reasons)

git-svn-id: trunk@31189 -
2015-07-03 20:04:22 +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
f40ea04540 * changed getarraydef() into a tarraydef.getreusable() class method
git-svn-id: trunk@31147 -
2015-06-23 21:23:18 +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
4c11d34169 * fixed loading the address of the string data of an ansi/unicodestring
constant in the llvm code generator (the constant is a record rather than
    a pointer to a record -> not indirect)

git-svn-id: trunk@31062 -
2015-06-13 22:48:43 +00:00
Jonas Maebe
b176ed9f80 * ensure that the llvmst is initialised before using a field's llvmfieldnr
(and at the same time take advantage of this to perform a sanity check)

git-svn-id: trunk@31061 -
2015-06-13 22:48:40 +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
bcd04953c2 * fixed open array constructors for llvm
git-svn-id: trunk@31057 -
2015-06-13 22:48:28 +00:00
Jonas Maebe
9175809d5d * use correct llvm type conversion operator when loading a "named register"
with a pointer value into an integer register or vice versa

git-svn-id: trunk@31055 -
2015-06-13 22:48:23 +00:00
Jonas Maebe
cf2e46c2c1 * reworked external symbol handling on llvm to deal with the fact that
a single external symbol may be used with multiple declarations that
    have different types:
   o always declare an alias with the Pascal-mangled name that aliases the
     external symbol, with the type of that Pascal declaration
   o if the external symbol is not actually external but in the same unit,
     we will determine the type of that symbol via its declaration and
     insert type conversions in the alias declarations in case they use a
     different type
   o if it is external (so there is no declaration from which we can determine
     its real type) and there are nevertheless multiple aliases for it with
     different types, we just take the type of the first alias and insert
     type conversions for the other aliases. LLVM will take care of the
     conflicting types in multiple modules when performing WPO if necessary

git-svn-id: trunk@31054 -
2015-06-13 22:48:20 +00:00
Jonas Maebe
54dd25b448 * support llvm aliases for defs other than procdef
git-svn-id: trunk@31052 -
2015-06-13 22:48:14 +00:00
Jonas Maebe
4eea652576 * fixed writing non-default linkage and visibility of llvm alias declarations
git-svn-id: trunk@31051 -
2015-06-13 22:48:11 +00:00
Jonas Maebe
1019a6b090 * use the def of the paraloc rather than the parasym's vardef in
gen_load_para_value(), as this may be different depending on
    the calling conventions
  * adapt llvm's gen_load_cgpara_loc() to use this passed def rather
    than hardcoding the para's def (although these will normally match)

git-svn-id: trunk@31050 -
2015-06-13 22:48:08 +00:00
Jonas Maebe
337716d413 * fixed subscripting classes in llvm
* fixed subscripting an objectdef in llvm if the field belongs to a
    parent type

git-svn-id: trunk@30957 -
2015-05-31 16:51:07 +00:00
Jonas Maebe
6c5f1327f4 * generate the correct llvm type description for classrefdef
git-svn-id: trunk@30956 -
2015-05-31 16:51:04 +00:00
Jonas Maebe
0d00c1a19d * fixed type used when subscripting implicit pointer types (don't add
another indirection)

git-svn-id: trunk@30953 -
2015-05-31 16:50:56 +00:00
Jonas Maebe
033c28e5ac * removed unnecessary and potentially wrong typecast
git-svn-id: trunk@30946 -
2015-05-31 16:50:36 +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
8034ef1f31 * support for dynamic strings and arrays in update_reference_reg_mul()
git-svn-id: trunk@30784 -
2015-05-03 16:51:13 +00:00
Jonas Maebe
eae68e86a1 * don't insert a typeconversion from pasbool to int in case the left
location was LOC_JUMP or LOC_FLAGS, as in that case the generic
    code has already done this using location_force_reg()

git-svn-id: trunk@30783 -
2015-05-03 16:51:10 +00:00
Jonas Maebe
8f1fb60f61 * also collect the llvm type info from the initialisation data of typed
constants

git-svn-id: trunk@30782 -
2015-05-03 16:51:06 +00:00
Jonas Maebe
74da8720c5 * insert type conversions in case a symbol is declared via 'external' as an
alias for another symbol with a different type (such as
    FPC_ANSISTR_UNIQUE, which is defined as a function and referenced as a
    procedure)

git-svn-id: trunk@30781 -
2015-05-03 16:51:02 +00:00
Jonas Maebe
d546e74d1c * don't write newlines after nested taillvm instructions (since they're
embedded in the middle of another instruction)

git-svn-id: trunk@30779 -
2015-05-03 16:50:55 +00:00
Jonas Maebe
4a5b7b7d50 * once we've defined a symbol as an alias, it's declared to the same extent
as a regular symbol definition

git-svn-id: trunk@30778 -
2015-05-03 16:50:51 +00:00
Jonas Maebe
8234fcd229 * implemented thlcgllvm.g_external_wrapper by just declaring the new symbol
as an alias for the old one (rather than creating an interprocedural
    jump, which is not possible in llvm IR and which is less efficient
    anyway) (declaration for this method was already accidentally committed
    in r30722)

git-svn-id: trunk@30777 -
2015-05-03 16:50:47 +00:00
Jonas Maebe
72277f5098 * store the used tabstractprocdef when generating an llvm call instruction,
because due to aliasing symbols a single symbol may be called using
    different procdefs (e.g. FPC_ANSISTR_UNIQUE in the system unit is defined
    as an alias for a function and called as a procedure). This means we have
    to insert extra type conversions for llvm, which requires both the source
    and destination type

git-svn-id: trunk@30776 -
2015-05-03 16:50:43 +00:00