Commit Graph

69 Commits

Author SHA1 Message Date
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
Jonas Maebe
a2e0f729c6 * use the correct opcode when loading integer pointer constants (such as nil)
git-svn-id: branches/hlcgllvm@28386 -
2014-08-12 18:59:10 +00:00
Jonas Maebe
4acd43c643 * don't force simple function results in memory
o results in simpler code, and more importantly is required for some code
     that expects a LOC_REGISTER after calling certain system unit helpers
     (e.g. in ncgutil.new_exception)

git-svn-id: branches/hlcgllvm@28375 -
2014-08-10 19:40:26 +00:00
Jonas Maebe
ac4c455991 * handle non-integer/non-record memory destinations in gen_load_cgpara_loc()
git-svn-id: branches/hlcgllvm@28374 -
2014-08-10 19:40:24 +00:00
Jonas Maebe
50274f58b6 * ignore get/unget/alloc/dealloc of cpu registers when generating llvm code
o there are no cpu registers on the llvm target, but generic code may still
     occasionally allocate them via the generic routines in case of e.g. a
     hardcoded use of a function return register

git-svn-id: branches/hlcgllvm@28373 -
2014-08-10 19:40:21 +00:00
Jonas Maebe
53e1d5c26f * fixed optimised form of a_cmp_const_reg_label(): when inverting the branch, we still
have to emit the label we originally allocated for the fallthrough path (otherwise
    the branch is not inverted at all, and moreover the caller will also emit the
    original target label somewhere so it will be doubly defined)

git-svn-id: branches/hlcgllvm@28367 -
2014-08-10 19:40:06 +00:00
Jonas Maebe
db54588afa * when calling a procdef that either returns a procvardef or that accepts
(C-style) varargs, you have to specify the full function definition
    rather than only its result

git-svn-id: branches/hlcgllvm@28356 -
2014-08-10 13:19:26 +00:00