Commit Graph

46 Commits

Author SHA1 Message Date
Jonas Maebe
4b9179636b + support for creating and writing LLVM landingpad instructions
git-svn-id: trunk@35161 -
2016-12-18 13:57:42 +00:00
Jonas Maebe
97d6f17cc8 + add support for marking an LLVM definition as using "appending" linkage
git-svn-id: trunk@35039 -
2016-12-02 12:32:58 +00:00
Jonas Maebe
3b7d9447ae * blockaddress creates a constant operand for another opcode, it's not an
independent operation
   o additionally, it does not take a "label" qualifier for its label argument

git-svn-id: trunk@34944 -
2016-11-21 07:39:05 +00:00
Jonas Maebe
f3409b4c9d + new la_asm LLVM pseudo-instruction to represent function-level inline
assembly blocks

git-svn-id: trunk@34890 -
2016-11-13 16:06:26 +00:00
Jonas Maebe
d2873e433e + top_asmlist operand type for LLVM inline assembly "call" instructions
git-svn-id: trunk@34889 -
2016-11-13 16:06:23 +00:00
Jonas Maebe
999cb7de6d + LLVM 3.7 support in the LLVM IR writer
git-svn-id: trunk@34550 -
2016-09-20 21:44:06 +00:00
Jonas Maebe
dfb20f3f6a * fixup the asmbind of aliases (an llvm alias can never refer to an
external symbol)

git-svn-id: trunk@34514 -
2016-09-11 17:12:00 +00:00
Jonas Maebe
7ebbb744e9 * also specify sret attribute at the caller side
git-svn-id: trunk@34302 -
2016-08-13 14:47:42 +00:00
Jonas Maebe
819f0c39fa * specify the "byval" attribute also at the caller side
git-svn-id: trunk@34301 -
2016-08-13 14:47:39 +00:00
Jonas Maebe
1cb8c0d00c * specify the def of assembler level symbols defined via
tasmdata.DefineAsmSymbol() and all routines that call it
   o will be used to automatically generate AB_INDIRECT sybols when
     necessary

git-svn-id: trunk@34164 -
2016-07-20 20:52:59 +00:00
Jonas Maebe
2148a20d6a * fixed returning results from functions that have a zero-sized result
(e.g. an empty record): return an "undefined" instance of the result
    type (since it's empty, its contents are irrelevant). Before, we
    returned "void", but that means returning nothing rather than returning
    something empty (part of fixing test/tnoext4 for llvm)

git-svn-id: trunk@34119 -
2016-07-14 15:19:09 +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
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
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
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
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
91e8f4c439 + custom section name support for llvm
git-svn-id: trunk@32400 -
2015-11-21 12:36:26 +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
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
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
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
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
07141e92d3 + support for llvm "undef" operand
git-svn-id: trunk@30669 -
2015-04-19 21:37:27 +00:00
Jonas Maebe
ee7198aa57 * fixed memory leak in case one tai operand is replaced by another
git-svn-id: trunk@30424 -
2015-04-04 14:29:00 +00:00
Jonas Maebe
3279cc052a * moved llvm-specific code from aasmtai to aasmllvm
* call add_reg_instruction_hook() for top_para parameters

git-svn-id: trunk@30423 -
2015-04-04 14:28:57 +00:00
Jonas Maebe
2ef753faae * support llvm spilling_get_reg_type() for the destination of call/invoke
git-svn-id: trunk@30422 -
2015-04-04 14:28:54 +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
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
575911dcb0 + support for (section-based) threadvars for LLVM
git-svn-id: branches/hlcgllvm@28352 -
2014-08-10 13:18:46 +00:00
Jonas Maebe
8ca4c80785 * mark tasmsymbols as declared in the taillvmdecl constructor so that we
don't have to do this everywhere such a declaration is generated

git-svn-id: branches/hlcgllvm@28202 -
2014-07-12 22:13:50 +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
394dfdd220 * ensure that all initialised items have a type (and only one):
o remove the accompanying tdef operands from tai operands, because such
     tai operands should have a tdef already
   o check that every queued tai is a tai_simpletypedconst (which have a
     type)
   o wrap queued bitcast/getelementptr tai instances with a
     tai_simpletypedconst

git-svn-id: branches/hlcgllvm@28154 -
2014-07-04 19:24:20 +00:00
Jonas Maebe
1e7d9c9f0e + support for instruction operands that are tai themselves in the llvm
backend (required for inserting bitcasts/ptrtoint/... operations inside
    typed constant declarations)
   o taillvm constructors for creating bitcast-style and getlementptr
     operations that accept a tai as their source/base operand

git-svn-id: branches/hlcgllvm@28112 -
2014-07-01 16:30:22 +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
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
227ff0ea48 * llvm requires that single precision constants are exactly representable
using single precision -> convert them to single precision in the code
    generator

git-svn-id: branches/hlcgllvm@27001 -
2014-03-06 21:41:32 +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
b7803ab974 + llvm support for the register allocator. While llvm works with virtual
registers itself, it requires them to be in SSA form. Therefore we
    spill all registers that are written more than once to memory.
  + support in the generic register allocator for generating code that is
    SSA-safe
  + spilling helpers for llvm

git-svn-id: branches/hlcgllvm@26044 -
2013-11-11 11:15:47 +00:00
Jonas Maebe
3296984bd9 + classes for llvm instructions (ait_llvmins), procedure definitions
(ait_llvmprocdef), global variable definitions (ait_llvmvarsym)
    and alias definitions (ait_llvmalias)

git-svn-id: branches/hlcgllvm@26036 -
2013-11-11 11:15:13 +00:00