Commit Graph

88 Commits

Author SHA1 Message Date
Jonas Maebe
c421171461 * fixed handling of fpu/mm loads from "named registers" in case they involve
a typecast from a struct to a scalar type (webtbs/tw26993)

git-svn-id: trunk@34027 -
2016-06-30 15:33:24 +00:00
Jonas Maebe
542b6b604e * missing closing comment
git-svn-id: trunk@34025 -
2016-06-30 15:32:50 +00:00
Jonas Maebe
5313db710b * override gen_stack_check_size_para() and gen_stack_check_call()
for llvm and do nothing (see comments in the code)

git-svn-id: trunk@33991 -
2016-06-15 18:31:58 +00:00
Jonas Maebe
b76539a049 * fixed handling of uninitialised complex function results
git-svn-id: trunk@33940 -
2016-06-09 22:00:05 +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
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
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
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
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
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
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