Commit Graph

75 Commits

Author SHA1 Message Date
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
4939c9a7b9 * implemented overflow checking for llvm
git-svn-id: trunk@32736 -
2015-12-26 20:00:44 +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
3ff265da88 * fixed rol/ror
git-svn-id: trunk@32556 -
2015-11-29 21:46:10 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Jonas Maebe
98c5f7d20f * simplify references before generating getelementptr instructions with them
git-svn-id: trunk@30722 -
2015-04-25 15:51:36 +00:00
Jonas Maebe
78e68b89df * gen_load_cgpara_loc() should only honour reusepara if it's a memory
parameter

git-svn-id: trunk@30721 -
2015-04-25 15:51:33 +00:00
Jonas Maebe
491d9cfff1 * fixed reuse of the same register for different types in
a_loadaddr_ref_reg()

git-svn-id: trunk@30718 -
2015-04-25 15:51:25 +00:00
Jonas Maebe
70ffaba901 * ensure that the loading of the uninitialised function result for llvm
doesn't result in a temp allocation, since this can happen while
    generating the exit code

git-svn-id: trunk@30711 -
2015-04-25 15:51:04 +00:00
Jonas Maebe
62239ba890 * handle named registers correctly for fpu and mm loads
git-svn-id: trunk@30677 -
2015-04-19 21:37:52 +00:00
Jonas Maebe
3496129f79 * only handle a_load_const_ref() directly when storing ordinals, as in case
of pointers llvm only supports 0 (as null, which we don't generate either)

git-svn-id: trunk@30676 -
2015-04-19 21:37:49 +00:00
Jonas Maebe
4a25afb839 * load an undef value in the function result in the exit code of a pure
assembler function, as the inline assembly code itself will be
    responsible for returning the function result (we will have to add
    the "return" instruction to it) while llvm requires a terminator
    at the end of the function and it must return something

git-svn-id: trunk@30671 -
2015-04-19 21:37:34 +00:00
Jonas Maebe
ff3061a7cf + thlcgllvm.gen_load_uninitialized_function_result
git-svn-id: trunk@30670 -
2015-04-19 21:37:31 +00:00
Jonas Maebe
765044aede * fixed a number of (mostly false) warnings regarding uninitialised
variables with -Oodfa

git-svn-id: branches/hlcgllvm@30244 -
2015-03-15 21:10:50 +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
cc596225fa + thlcg.g_ptrtypecast_reg/ref() to typecast a pointer in a register, or the
pointer type describing a reference, to another pointer type

git-svn-id: branches/hlcgllvm@28781 -
2014-10-06 20:54:33 +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
b710220a5e * fixed calldef specified in case of calling a varargs C function
git-svn-id: branches/hlcgllvm@28494 -
2014-08-19 20:22:59 +00:00
Jonas Maebe
d09243c8c1 * correctly handle make_simple_ref() for voidpointers
git-svn-id: branches/hlcgllvm@28493 -
2014-08-19 20:22:56 +00:00
Jonas Maebe
33c277b3a7 + temp_to_ref() implementation for llvm
git-svn-id: branches/hlcgllvm@28491 -
2014-08-19 20:22:50 +00:00
Jonas Maebe
9d118567cd + support for a_call_reg() on the llvm target (can call simple procvars now)
git-svn-id: branches/hlcgllvm@28480 -
2014-08-19 20:22:21 +00:00
Jonas Maebe
bd3f0b3ada * factored out the common calling code from a_call_name (to reuse in
a_call_reg()

git-svn-id: branches/hlcgllvm@28478 -
2014-08-19 20:22:16 +00:00
Jonas Maebe
4e3f504caa * don't try to check whether the last parameter of a cdecl function is a
varargs parameter if it doesn't have any parameters

git-svn-id: branches/hlcgllvm@28399 -
2014-08-12 23:17:43 +00:00