Commit Graph

112 Commits

Author SHA1 Message Date
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
Jonas Maebe
9225d43ccf * free temporary return parameter instance
git-svn-id: branches/hlcgllvm@28354 -
2014-08-10 13:19:10 +00:00
Jonas Maebe
ec77e64adc * fixed returns from functions that return their result in a parameter
git-svn-id: branches/hlcgllvm@28353 -
2014-08-10 13:18:59 +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
1516661249 + new chlcgobj class reference variable that can be used to call thlcg*
virtual methods even when hlcg doesn't contain a valid instance

git-svn-id: branches/hlcgllvm@28143 -
2014-07-03 22:28:31 +00:00
Jonas Maebe
a8b2b576ca + new llvmconvop() routine that determines the conversion operation to
convert one def to another, including information regarding whether
    it should be done via an intermediate integer typecast
  * use this routine in hlcgllvm

git-svn-id: branches/hlcgllvm@28116 -
2014-07-01 16:30:34 +00:00
Jonas Maebe
7ebb1b813f + basic support infrastructure in the llvm assembler writer to write out
typed constant data
   o llvm declarations now get an extra "initdata" list that contains the
     typed constant data associated with this declaration (if any)

git-svn-id: branches/hlcgllvm@28111 -
2014-07-01 16:30:19 +00:00
Jonas Maebe
bacd303208 * synchronized with trunk up to r27758
git-svn-id: branches/hlcgllvm@27779 -
2014-05-12 16:12:34 +00:00
Jonas Maebe
6dcfd73d21 + support for a_call_name() on the llvm target:
o make use of the fact that callparanodes always first load everything
     in temporary parameters (allocated via paramanager.createtempparaloc)
     -> we pass those temporary paralocs to the llvm call nodes and ignore
     the "real" locations with physical registers
   o all function results are forced to memory before handing them back
     to the generic code generator to avoid having to deal with special
     result locations and llvm<->pascal type differences (llvm removes
     the extra temp stores/loads while optimising)
   o ideally, the llvm code generator should share the common code with
      the generic code generator for a_load_ref_cgpara() at some point in
      the future

git-svn-id: branches/hlcgllvm@27013 -
2014-03-06 21:42:14 +00:00
Jonas Maebe
b82053ef40 * reworked handling of defined/declared symbols in llvm: we now automatically
generate declarations when external symbols are referred in a taillvm
    instruction
  * added "declared" field to tasmsymbol for llvm to make avoid declaring a
    symbol multiple times (harmless, but unnecessary)
  * all kinds of declarations/definitions are now handled using the new
    taillvmdecl, the old separate types have been removed

git-svn-id: branches/hlcgllvm@27010 -
2014-03-06 21:42:03 +00:00
Jonas Maebe
dad45d63b1 * improved symbol alias handling (pass in old sym instead of name, add
pointer add end of aliased procdef)

git-svn-id: branches/hlcgllvm@27008 -
2014-03-06 21:41:56 +00:00
Jonas Maebe
abee66b611 * optimized a_loadaddr_ref_reg() in cases where an offset is added to a
symbol or base register and the offset is a multiple of the def's size

git-svn-id: branches/hlcgllvm@27007 -
2014-03-06 21:41:53 +00:00
Jonas Maebe
161647f965 * simplified (incomplete) implementation of g_concatcopy() that simply calls
a_load_ref_ref (the llvm memcpy intrinsic can be lowered into a libc call,
    so we can't use it)

git-svn-id: branches/hlcgllvm@27004 -
2014-03-06 21:41:43 +00:00
Jonas Maebe
366baac98d * optimized version of a_load_ref_ref() in case the source has refaddr_full
(= "named register" in case of llvm)

git-svn-id: branches/hlcgllvm@27003 -
2014-03-06 21:41:40 +00:00
Jonas Maebe
e70175a10e * added extra boolean parameter to getelementptr taillvm constructors to
indicate whether or not an implicit indirection should be added (always
    was done until now)

git-svn-id: branches/hlcgllvm@26989 -
2014-03-06 21:40:46 +00:00
Jonas Maebe
98be5b0825 * correctly handle loads/stores of aggregate types if the source and
destination types are different: the pointer types of the load/store must
    be converted in that case, rather than the loaded/to be stored value
    (you can't bitcast aggregates in LLVM)

git-svn-id: branches/hlcgllvm@26987 -
2014-03-06 21:40:39 +00:00
Jonas Maebe
f344adaf22 * the first parameter of loadaddr_ref_reg has to be converted to a pointer
(it's the type of the data stored in memory at that address, but we use
     the address itself here)

git-svn-id: branches/hlcgllvm@26985 -
2014-03-06 21:40:32 +00:00
Jonas Maebe
d14ce7817f * factored out setlocalloc and the code to set the initial paravarsym
location from ncgutil into hlcgobj, and override/implement it for llvm
    (use the symbolic parameter names)

git-svn-id: branches/hlcgllvm@26052 -
2013-11-11 11:16:16 +00:00
Jonas Maebe
80c6225bf4 * fixed handling of comp and currency when they have to be handled by the
fpu: treat them as extended when they are loaded into registers, and as
    int64 when loading from/storing to memory

git-svn-id: branches/hlcgllvm@26048 -
2013-11-11 11:16:01 +00:00
Jonas Maebe
9d4ea0337a + basic implementation of the LLVM high level code generator
git-svn-id: branches/hlcgllvm@26045 -
2013-11-11 11:15:51 +00:00