Commit Graph

710 Commits

Author SHA1 Message Date
Jonas Maebe
101fc3d4ec * translate formaldef into "i8*", as intended, instead of "i8**" due to
the fact that this type is always passed by reference

git-svn-id: trunk@30486 -
2015-04-07 19:35:22 +00:00
Jonas Maebe
f94f9f44e4 * convert all arguments to integers in case of comparisons of pointers with
constants on llvm, as you can only compare with "null" in that case
  * convert all arguments to integers in case of pointer subtractions,
    as pointer subtractions are not supported by llvm

git-svn-id: trunk@30485 -
2015-04-07 19:35:08 +00:00
Jonas Maebe
94aadb23ab + implemented getintparaloc() for llvm
git-svn-id: trunk@30430 -
2015-04-04 14:29:19 +00:00
Jonas Maebe
2336d22985 * override instr_get_oper_spilling_info and substitute_spilled_registers for
llvm (add support for top_para)

git-svn-id: trunk@30428 -
2015-04-04 14:29:12 +00:00
Jonas Maebe
e12dff9a5e * support top_para in trgllvm.get_spill_temp()
git-svn-id: trunk@30426 -
2015-04-04 14:29:06 +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
Jeppe Johansen
e2272c8a7e Added aitconst_gs for AVR pointer references to Flash.
git-svn-id: trunk@30419 -
2015-04-04 10:29:11 +00:00
Jonas Maebe
f631430775 * made the allocation of labels for internal data in typed const builders
overridable, and implement those routines for llvm

git-svn-id: branches/hlcgllvm@30348 -
2015-03-28 11:34:04 +00:00
Jonas Maebe
e12bd99b59 * fixed compilation with -dllvm after r30343
git-svn-id: branches/hlcgllvm@30347 -
2015-03-28 11:34:02 +00:00
Jonas Maebe
5a2609933f * fixed crash in r30244 (we only have to get a new elementdef if we didn't
already initialise the location, and we won't get a new elementdef if
    the location is already assigned)

git-svn-id: branches/hlcgllvm@30346 -
2015-03-28 11:33:59 +00:00
Jonas Maebe
e924dbed90 * moved the specification of the options for a ttai_typedconstbuilder from
get_final_asmlist() to the constructor, in preparation of supporting the
    creation of internal builders for local data that will ignore some of the
    irrelevant flags (at creation time)

git-svn-id: branches/hlcgllvm@30334 -
2015-03-27 21:25:27 +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
bc7ba58798 * fixed compilation after removal of ait_set, ait_thumb_set and ait_symbol_pair
git-svn-id: branches/hlcgllvm@30243 -
2015-03-15 21:10:47 +00:00
Jonas Maebe
c1e7c9de02 * support for flushing a ttai_typedconstbuilder queue with an ordinal
constant at the end (in case of e.g. ordinal -> pointer type
    conversions)

git-svn-id: branches/hlcgllvm@30128 -
2015-03-07 21:43:57 +00:00
Jonas Maebe
eba3f534de * correctly handle empty ansistring constants for llvm
git-svn-id: branches/hlcgllvm@30127 -
2015-03-07 21:43:52 +00:00
Jonas Maebe
935c0c86aa * write all ait_const's of value 0 as 'zeroinitializer' so they also work
for pointer constants

git-svn-id: branches/hlcgllvm@30126 -
2015-03-07 21:43:47 +00:00
Jonas Maebe
9c42437326 * moved tasmlisttypedconstbuilder.tc_emit_string_offset() to
ttai_typedconstbuilder.emit_string_offset() so it can also be used outside
    the context of parsing a Pascal-level typed constant

git-svn-id: branches/hlcgllvm@30111 -
2015-03-06 19:45:04 +00:00
Jonas Maebe
511e878606 * fixed pointer plus/minus integer on llvm (since a_op_* only gets a single
def, we have to ensure that both arguments have in fact the same type)

git-svn-id: branches/hlcgllvm@30108 -
2015-03-05 22:45:32 +00:00
Jonas Maebe
f9ae2aadac * fixed llvm unsigned greater/lower than condition mnemoniics
git-svn-id: branches/hlcgllvm@30107 -
2015-03-05 22:20: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
76e0ee7a41 * fixed adding padding bytes before anonymous records: the alignment of such
records is only known once we have completely parsed all of their data
    (the alignment of a record depends on the alignment requirements of its
     field with the largest alignment) -> only insert the padding bytes after
    completely parsing them

git-svn-id: branches/hlcgllvm@28765 -
2014-10-06 20:53:51 +00:00
Jonas Maebe
5a9b931e5c * renamed ttai_lowleveltypedconstbuilder to ttai_typedconstbuilder
git-svn-id: branches/hlcgllvm@28764 -
2014-10-06 20:53:49 +00:00
Jonas Maebe
d2b55b6f07 * moved the recording of aggregate type information during typed constant
parsing from nllvmtcon to aasmcnst
   o added automatic insertion of padding bytes when fields need to be aligned,
     so that once ncgvmt (and hopefully ncgrtti) are converted to the typed
     constant builder class, we can get rid of all the explicit alignment
     directives (only supported for non-bitpacked records for now)

git-svn-id: branches/hlcgllvm@28763 -
2014-10-06 20:53:46 +00:00
Jonas Maebe
bdb22772d9 * fixed whitespace
git-svn-id: branches/hlcgllvm@28756 -
2014-10-06 20:53:28 +00:00
Jonas Maebe
210b532832 * split up specifying the type of the section of a typed constant and whether
it should be put in a new section

git-svn-id: branches/hlcgllvm@28753 -
2014-10-06 20:53:20 +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
37009c917b * pass alignment to tnodeutils.insertbsssym()
git-svn-id: branches/hlcgllvm@28751 -
2014-10-06 20:53:14 +00:00
Jonas Maebe
864b36fbe5 * create the recorddef at the start when building an anonymous recorddef,
so that we can already refer to its def while we are sill parsing
    individual elements

git-svn-id: branches/hlcgllvm@28750 -
2014-10-06 20:53:12 +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
0fbaa9e924 * record the alignment of temps, and set it when creating a reference based
on a temp instead of assuming it's always aligned to a multiple of
    the stackpointer size

git-svn-id: branches/hlcgllvm@28490 -
2014-08-19 20:22:48 +00:00
Jonas Maebe
9880b53242 * changed all alignment parameters in the temp manager to shortint
git-svn-id: branches/hlcgllvm@28489 -
2014-08-19 20:22:45 +00:00
Jonas Maebe
dd733bd5b5 * changed all size parameters in the temp manager from longint to asizeint
git-svn-id: branches/hlcgllvm@28488 -
2014-08-19 20:22:42 +00:00
Jonas Maebe
344acef9b5 * separate tracking the def of a temp and whether or not it needs to be
finalised (for llvm, we always keep track of the def)

git-svn-id: branches/hlcgllvm@28485 -
2014-08-19 20:22:34 +00:00
Jonas Maebe
3b7f43ad77 * renamed (hl)gettemptyped() to (hl)gettempmanaged() to better indicate the
meaning

git-svn-id: branches/hlcgllvm@28484 -
2014-08-19 20:22:32 +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
b6fc2f1542 * don't emit the */pointer suffix for procdefs in llvmaddencodedtype_intern(),
so that if a_loadaddr_ref_reg() is used to load the address of a procdef
    into a register, the getpointerdef(procdef) won't (wrongly) result in two
    *'s
   o the previous behaviour was necessary for the tck_simple_procvar2proc
     special case that was removed in the previous commit

git-svn-id: branches/hlcgllvm@28477 -
2014-08-19 20:22:13 +00:00
Jonas Maebe
cc4482d6f8 - removed tck_simple_procvar2proc, instead use
procdef.getcopyas(procvardef,pc_address_only) as the def if we want to
    specify that we're interested in the address of a procedure/procvar of
    object

git-svn-id: branches/hlcgllvm@28476 -
2014-08-19 20:22:11 +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
6aafe209d0 + llvm second_length() implementation (can't use generic one because of its
use of cg.makeregsize())

git-svn-id: branches/hlcgllvm@28389 -
2014-08-12 18:59:19 +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
0867b6e4f8 * added missing {$i fpcdefs.inc}
git-svn-id: branches/hlcgllvm@28378 -
2014-08-10 19:40:34 +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
0aab46b97f + tllvmtypeconvnode.second_int_to_bool() implementation
git-svn-id: branches/hlcgllvm@28370 -
2014-08-10 19:40:13 +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
6ab2c00ac6 * recognise LOC_CREFERENCE in tllvmsubscriptnode.handle_platform_subscript()
git-svn-id: branches/hlcgllvm@28364 -
2014-08-10 19:39:58 +00:00
Jonas Maebe
f70865fc1f * moved tjvmnotnode implementation to generic ncghlmat unit, and also use it
for llvm

git-svn-id: branches/hlcgllvm@28363 -
2014-08-10 19:39:55 +00:00
Jonas Maebe
39fa81eaa0 * fixed passing of C-style varargs parameters
git-svn-id: branches/hlcgllvm@28357 -
2014-08-10 13:19:29 +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
bae1f72896 * handle cdecl varargs parameters in llvm procdef string representations
git-svn-id: branches/hlcgllvm@28355 -
2014-08-10 13:19:24 +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
575911dcb0 + support for (section-based) threadvars for LLVM
git-svn-id: branches/hlcgllvm@28352 -
2014-08-10 13:18:46 +00:00
Jonas Maebe
9e074d036b * migrated the handling of ansi/unicodestring constants to the high level
typed constant builder + llvm implementation

git-svn-id: branches/hlcgllvm@28327 -
2014-08-06 18:04:40 +00:00
Jonas Maebe
099588aaf5 * don't write comments in the LLVM IR about ait_section/ait_align elements,
as these can appear in the middle of aggregate constants and hence
    otherwise break the definition

git-svn-id: branches/hlcgllvm@28326 -
2014-08-06 18:04:36 +00:00
Jonas Maebe
c84a8a4bc2 * separate methods to get the size of the ansistring/unicode header and to
get the offset relative from the returned label from
    emit_(ansi|unicode)_string() to the start of the string data
   o corrected return value for the offset on LLVM: it's always equal to the
     header size, since we can't emit labels in the middle of structured data
     there

git-svn-id: branches/hlcgllvm@28324 -
2014-08-06 18:04:31 +00:00
Jonas Maebe
7a10959aa0 + support for parsing structured data for which no tdef is available in
advance (e.g. ansistring constants, as they consist of a header
    followed by an array of char equal to the string length, or RTTI data)
   o use begin_anonymous_record() to start recording the field types (if
     necessary for the current target), and end_anonymous_record() at the
     end to generate the recorddef

git-svn-id: branches/hlcgllvm@28323 -
2014-08-06 18:04:28 +00:00
Jonas Maebe
5a49727cdf * moved functionality to create a global recorddef based on a tfplist of
tdefs to the new trecorddef.create_global_from_deflist() constructor

git-svn-id: branches/hlcgllvm@28322 -
2014-08-06 18:04:24 +00:00
Jonas Maebe
4f906fb9c9 * fixed datadef for untyped string constants (terminating #0 is one
character, not two)

git-svn-id: branches/hlcgllvm@28320 -
2014-08-06 18:04:19 +00:00
Jonas Maebe
2a45b57504 * removed todo comment, the "constant" information is already propagated in
the mean time via the section type (sec_rodata/sec_rodata_norel ->
    constant)

git-svn-id: branches/hlcgllvm@28212 -
2014-07-12 22:42:37 +00:00
Jonas Maebe
5c8e723cf8 * handle the fact that we emit constant strings that can be longer or shorter
than their type at the Pascal level

git-svn-id: branches/hlcgllvm@28211 -
2014-07-12 22:42:31 +00:00
Jonas Maebe
bfe431913d * fixed writing hex-encoded characters in string constants
git-svn-id: branches/hlcgllvm@28209 -
2014-07-12 22:42:20 +00:00
Jonas Maebe
9fada1a238 * don't internalerror when typecasting voidpointer^ or formaldef
git-svn-id: branches/hlcgllvm@28208 -
2014-07-12 22:42:15 +00:00
Jonas Maebe
27e350fa9a + llvm implementation of second_int_to_real()
git-svn-id: branches/hlcgllvm@28207 -
2014-07-12 22:42:11 +00:00
Jonas Maebe
4746e17be5 * implemented second_int_to_int() for llvm
o the generic implementation ignores the need for bitcasts from pointers to
     ordinals and vice versa, and also hacks around with offsets

git-svn-id: branches/hlcgllvm@28206 -
2014-07-12 22:14:37 +00:00
Jonas Maebe
1c9932d921 * llvm implementation of tmoddivnode
o doesn't reuse the generic code generator methods, as the div-to-mul/shift
     optimization can be performed by llvm if necessary

git-svn-id: branches/hlcgllvm@28205 -
2014-07-12 22:14:22 +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
b494f76b81 * made internalerror unique
git-svn-id: branches/hlcgllvm@28201 -
2014-07-12 22:13:39 +00:00
Jonas Maebe
39074edf10 - removed the globalsymbolmangleprefix/suffix constants that were added for
llvm
  * instead, add LLVM-specific name mangling based on the asmsymbol's bind
    and typ whenever we write out its name

git-svn-id: branches/hlcgllvm@28166 -
2014-07-05 15:44:16 +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
e18e98b540 * changed the type of the forcesize parameter of gethltemp() and friends
from aint to asizeint (fixes range check warning/error when compiling
    the AVR backend)

git-svn-id: branches/hlcgllvm@28147 -
2014-07-03 22:28:43 +00:00
Jonas Maebe
fc7d5e2254 * insert a type conversion if the final result of an queued expression is
different from the type of typed constant/initialised data

git-svn-id: branches/hlcgllvm@28146 -
2014-07-03 22:28:40 +00:00
Jonas Maebe
ab186e8d75 * override queue_emit_staticvar() and set the offset to 0 there for the same
reason as with queue_emit_asmsym()

git-svn-id: branches/hlcgllvm@28145 -
2014-07-03 22:28:38 +00:00
Jonas Maebe
b520fb12be * call def2regtyp via the chlcgobj class reference so it also works when
hlcg is nil

git-svn-id: branches/hlcgllvm@28144 -
2014-07-03 22:28:35 +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
5cf52bb957 * fixed writing nested conversion operations such as bitcast (missing
opening bracket)

git-svn-id: branches/hlcgllvm@28142 -
2014-07-03 22:28:28 +00:00
Jonas Maebe
8afffdb176 * moved get_string_symofs() to a virtual class method of
ttai_typedconstbuilder so that it can be overridden by other platforms
  * override get_string_symofs() for LLVM and always return 0, as you can't
    have labels in the middle of a declaration on that platform

git-svn-id: branches/hlcgllvm@28140 -
2014-07-03 22:28:21 +00:00
Jonas Maebe
a284902813 * emit the current offset when flushing tasmsymbols in the
ttai_lowleveltypedconstbuilder
   o set the offset to 0 in the llvm constbuilder before calling
     the lowlevel one, because it incorporates this offset already
     via getelementptr instructions

git-svn-id: branches/hlcgllvm@28136 -
2014-07-02 17:25:02 +00:00
Jonas Maebe
e0c1c4d3bf + support for merging multiple tai_strings/tai_consts emitted as part of the
same string constant to be merged together into a single tai_string
    (required to efficiently represent string constants in llvm assembler
     --i.e., without splitting them into bytes--, while keeping the
     flexibility in the typed constant parser to mix individual elements
     and strings)

git-svn-id: branches/hlcgllvm@28135 -
2014-07-02 17:24:59 +00:00
Jonas Maebe
9f39188253 * moved the tai_*typedconst classes to aasmcnst to make use of def-related
helpers in a cleaner way (defutils would not belong in the uses clause of
    aasmtai)

git-svn-id: branches/hlcgllvm@28132 -
2014-07-02 17:24:50 +00:00
Jonas Maebe
2af0b46792 - removed unused variables
git-svn-id: branches/hlcgllvm@28131 -
2014-07-02 17:24:47 +00:00
Jonas Maebe
7ca4ebee9d * fixed end of shortstring llvm def after r27015
git-svn-id: branches/hlcgllvm@28130 -
2014-07-02 17:24:44 +00:00
Jonas Maebe
3511aa4878 * don't write a tab character before an instruction that's a nested operand
git-svn-id: branches/hlcgllvm@28126 -
2014-07-01 16:31:03 +00:00
Jonas Maebe
1a77bc952e * immediate write out partial string respresentations of instructions
rather than first concatenating everything, because in case of
    instructions that have other tai as operands we have to ensure that
    all previous output is flushed before the tai-operand is evaluated
    (and written/flushed)

git-svn-id: branches/hlcgllvm@28125 -
2014-07-01 16:31:00 +00:00
Jonas Maebe
5b884c96f2 + initial llvm implementation of the ttai_typedconstbuilder class
o now simple typed constants (integer, floating pointer, pchar)
     and (non-variant) record typed constants containing such
     elements work for llvm

git-svn-id: branches/hlcgllvm@28124 -
2014-07-01 16:30:57 +00:00
Jonas Maebe
a0c39220b1 * fixed (harmless) typecast errors when creating a string representation of
a procvardef
  * handle procdefs like procvardefs when getting their string representation
    in arbitrary expressions

git-svn-id: branches/hlcgllvm@28123 -
2014-07-01 16:30:55 +00:00
Jonas Maebe
0c10cbe63b + support for tai_symbol (in nested typed constant expressions)
git-svn-id: branches/hlcgllvm@28122 -
2014-07-01 16:30:52 +00:00
Jonas Maebe
f89b2e2b26 + support for tai_string (in nested typed constant expressions)
git-svn-id: branches/hlcgllvm@28121 -
2014-07-01 16:30:49 +00:00
Jonas Maebe
204adf82c7 * handle tai_const instances as operands to other tai
git-svn-id: branches/hlcgllvm@28120 -
2014-07-01 16:30:46 +00:00
Jonas Maebe
f8f7c30f14 * support non-taillvm tai instances as operands to taillvm instances
git-svn-id: branches/hlcgllvm@28119 -
2014-07-01 16:30:43 +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
da3e931d68 + support for tai_realconst in llvm assembler writer
git-svn-id: branches/hlcgllvm@28114 -
2014-07-01 16:30:27 +00:00
Jonas Maebe
8043254461 * factored out generating string representations of floating point numbers
in the llvm assembler writer

git-svn-id: branches/hlcgllvm@28113 -
2014-07-01 16:30:24 +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
1fdb16b615 * fixed indentation
git-svn-id: branches/hlcgllvm@28110 -
2014-07-01 16:30:16 +00:00
Jonas Maebe
1047cdadcb * factored out writing of a single tai, so this routine can call itself
recursively when writing out typed constant data
   o basic support for tai_const

git-svn-id: branches/hlcgllvm@28109 -
2014-07-01 16:30:13 +00:00
Jonas Maebe
b0ff41406a * grouped all tai_real* types into a single tai_realconst type,
to free up space for more ait_* types in taitype (can't have
    more than 32 because they have to fit in a small set)
   o factored out writing of floating point numbers as an array of
     byte in the external assemblers

git-svn-id: branches/hlcgllvm@28105 -
2014-07-01 16:29:58 +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
0283670041 * set location.size if we handle a subscript access in
handle_platform_subscript()

git-svn-id: branches/hlcgllvm@27136 -
2014-03-14 18:22:12 +00:00
Jonas Maebe
482eb86047 - disabled can_call_ref() for llvm
git-svn-id: branches/hlcgllvm@27017 -
2014-03-06 21:42:27 +00:00
Jonas Maebe
2cb84bda6e * generate integer type definitions for smallsets
git-svn-id: branches/hlcgllvm@27016 -
2014-03-06 21:42:24 +00:00
Jonas Maebe
7d61ecf5ba * changed shortstring llvm representation to a plain array of bytes, so
it can be directly indexed rather than that we need to separately
    select the byte or data (just like at the Pascal level, and how it
    is/will be handled in the code generator)

git-svn-id: branches/hlcgllvm@27015 -
2014-03-06 21:42:21 +00:00
Jonas Maebe
0fd172ddf6 * ignore global labels with a comment for now, they're generated for
function symbol aliases

git-svn-id: branches/hlcgllvm@27014 -
2014-03-06 21:42:17 +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
bdc2aaec47 * fixed ansistring and unicodestring llvm defs (pointer indirection was
missing, and replaced by plain pointer because the array definition does
    not add any useful information)

git-svn-id: branches/hlcgllvm@27012 -
2014-03-06 21:42:10 +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
02ca215272 * reworked and fixed llvm procdef handling (except for variadic C functions):
o handle parameters and function results divided over multiple paralocs,
     including generating fake recorddefs that represent
   o fixed zero/sign extension handling
   o properly handle difference between procdefs as printed for the
    implementation, an alias declaration or a procvar definition

git-svn-id: branches/hlcgllvm@27009 -
2014-03-06 21:42:00 +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
c4869980e8 * fixed typo in comment
git-svn-id: branches/hlcgllvm@27006 -
2014-03-06 21:41:50 +00:00
Jonas Maebe
358b346bbc * fixed writing of constant operands outside the longint range
git-svn-id: branches/hlcgllvm@27005 -
2014-03-06 21:41:46 +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
fcbde1d6e9 + hlcg/llvm support for unary minus
o converted tcgunaryminusnode.emit_float_sign_change() to use a tdef instead
     of tcgsize

git-svn-id: branches/hlcgllvm@27002 -
2014-03-06 21:41:36 +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
cdfb23bf6c * converted some leftovers in tcgtypeconvnode.second_int_to_int/
second_real_to_real to thlcgobj
  + added type conversion to second_pointer_to_array for llvm

git-svn-id: branches/hlcgllvm@27000 -
2014-03-06 21:41:27 +00:00
Jonas Maebe
8cc9b64ad7 * don't discard typeconversion nodes that only change the result type when
compiling for llvm, because this type change also needs to be modelled in
    llvm IR

git-svn-id: branches/hlcgllvm@26999 -
2014-03-06 21:41:24 +00:00
Jonas Maebe
5e79789f9e + dummy mmregister allocator for platforms that use such registers
git-svn-id: branches/hlcgllvm@26998 -
2014-03-06 21:41:19 +00:00
Jonas Maebe
bc0d4bbc87 + support second_cmpfloat (just call through to second_addfloat, where the
comparisons are already implemented)

git-svn-id: branches/hlcgllvm@26997 -
2014-03-06 21:41:16 +00:00
Jonas Maebe
532d623be7 + support for encoding records/objectdefs in LLVM-speak
git-svn-id: branches/hlcgllvm@26991 -
2014-03-06 21:40:52 +00:00
Jonas Maebe
20a8175bf1 + support for subscript nodes in LLVM
git-svn-id: branches/hlcgllvm@26990 -
2014-03-06 21:40:49 +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
43e0eb3cfd + llvmaggregatetype() helper that returns whether a def is represented by an
aggregate type in llvm

git-svn-id: branches/hlcgllvm@26986 -
2014-03-06 21:40:36 +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
9902864cce * don't output alignments for reference operands to bitcast & co
git-svn-id: branches/hlcgllvm@26984 -
2014-03-06 21:40:29 +00:00
Jonas Maebe
9c674ff444 * made internalerror unique
git-svn-id: branches/hlcgllvm@26982 -
2014-03-06 21:40:21 +00:00
Jonas Maebe
c2c7f753a8 * don't hardcode the bitsize of the register states
git-svn-id: branches/hlcgllvm@26981 -
2014-03-06 21:40:18 +00:00
Jonas Maebe
839ad45b9e * ensure that the lineinfo of temps corresponds to the lineinfo of the
procedure entry code

git-svn-id: branches/hlcgllvm@26980 -
2014-03-06 21:40:15 +00:00
Jonas Maebe
c095a1b06a * also check regtype in get_spill_temp()
git-svn-id: branches/hlcgllvm@26979 -
2014-03-06 21:40:12 +00:00
Jonas Maebe
a6a72e210c * fixed typo in comment
git-svn-id: branches/hlcgllvm@26978 -
2014-03-06 21:40:08 +00:00
Jonas Maebe
0cc581825f * enabled darwin/ppc64 for the llvm target
git-svn-id: branches/hlcgllvm@26072 -
2013-11-12 19:22:50 +00:00
Jonas Maebe
c5c16da787 * corrected some llvm architecture names
git-svn-id: branches/hlcgllvm@26071 -
2013-11-12 19:21:53 +00:00
Jonas Maebe
1acd563d86 + unit that uses all required llvm code generation units
git-svn-id: branches/hlcgllvm@26057 -
2013-11-11 11:16:36 +00:00
Jonas Maebe
5409d4321e + basic llvm bitcode (textual format) writer:
o no support yet for many ait_* types, although eventually most of them
     shouldn't be generated at all for the llvm target
   o no support yet for calling "opt" (which optimises llvm bitcode) before
     calling llc (which translates llvm bitcode into native code) -- compile
     with -s and manually call "opt" with -std-compile-opts, -O1, -O2 or -O3
     if you want to experiment
   o override the assembler writer with the llvm one when compiling an llvm-
     targeting compiler
   o override the assembler file extension with .ll when compiling an llvm-
     targeting compiler

git-svn-id: branches/hlcgllvm@26054 -
2013-11-11 11:16:25 +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
aa5823a454 * factored out inserting a single bss symbol in ngenutil so it can be
overridden by the llvm target
  * override a bunch of other ngenutil methods with empty stubs for things
    that are not yet supported when targeting llvm

git-svn-id: branches/hlcgllvm@26051 -
2013-11-11 11:16:13 +00:00
Jonas Maebe
25fab5b0b6 + support for array vecnodes on the llvm target, both for regular and for
bitpacked arrays:
   o separate the element size from the index when constructing the memory
     references, so we can easily use the llvm getelementptr instruction
   o handle conversion of s80real values from their array declaration
     as array elements to floating point values when loading them

git-svn-id: branches/hlcgllvm@26050 -
2013-11-11 11:16:09 +00:00
Jonas Maebe
d33035dca2 + llvm implementation of load nodes (inherit from tcgnestloadnode, because
support for loading data from parent routines in nested routines has to
    be implemented explicitly via records, like for the jvm target)

git-svn-id: branches/hlcgllvm@26049 -
2013-11-11 11:16:05 +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
8fa91ab73f + llvm implementation of add nodes
git-svn-id: branches/hlcgllvm@26047 -
2013-11-11 11:15:58 +00:00
Jonas Maebe
d04e05ff82 + handling of floating point constants in llvm code (just load them in a
register, llvm will take care of putting them in memory if necessary)

git-svn-id: branches/hlcgllvm@26046 -
2013-11-11 11:15:54 +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
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
d13b510144 + helpers to convert tdefs to strings describing the types in llvm syntax.
Other than arrays and complex procvardefs, all aggregates are currently
    handled as opaque arrays of bytes
   o special case: s80real (x87 extended type) is encoded as "array[0..9] of
     byte" inside arrays, because when using the llvm type describing
     "extended" llvm will handle it in an ABI-compliant way (allocating e.g.
     16 bytes for it on Darwin and x86-64 platforms). Loading/storing them
     always happens using instructions that only read/write 10 bytes, so
     we only have to take care to convert them to the actual extended type
     when indexing arrays/subscripting records (when records are no longer
     handled in an opaque way)

git-svn-id: branches/hlcgllvm@26041 -
2013-11-11 11:15:35 +00:00
Jonas Maebe
8ede313ba1 + llvm parameter manager: it reuses the native parameter manager to create
the paraloc information, and then adds llvm-specific information to the
    paralocs
   o only partially implemented, in particular function result handling is
     not yet there

git-svn-id: branches/hlcgllvm@26040 -
2013-11-11 11:15:31 +00:00
Jonas Maebe
d245228ba6 + tcgllvm.a_label() and tcgllvm.a_jmp_always(). Special for llvm: every
basic block must end with a terminator instruciton (such as a branch) ->
    when emitting a label, check whether the previous instruction is a
    terminator instruction and if not, add an unconditional branch to the
    label we are adding.
   o Implemented at the tcg instead of at the thlcgobj level because
    a) these methods don't need any high level type information
    b) implementing them in thlcgobj would require making thlcg.a_label()
       virtual and ensuring that no-one ever calls cg.a_label() in any
       generic code

git-svn-id: branches/hlcgllvm@26038 -
2013-11-11 11:15:20 +00:00
Jonas Maebe
7db9d4c7e9 + basic tcg unit for llvm: initialise register allocators and getint
fpuregister overloads that ignore subregisters (everything is
    handled via tdef at the thlcgobj level)

git-svn-id: branches/hlcgllvm@26037 -
2013-11-11 11:15:16 +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
Jonas Maebe
44b1996158 + base units for llvm:
o opcodes + string representation
   o llvm string representations of targets supported by fpc
   o supported fpc optimisations
   o list of supported LLVM versions (currently only targeting 3.3)

git-svn-id: branches/hlcgllvm@26035 -
2013-11-11 11:15:09 +00:00
Jonas Maebe
1df3039424 + LLVM temp allocator based on new R_TEMPREGISTER register class. For every
temp we allocate, we set the base register to a newly allocated
    R_TEMPREGISTER. This allows for uniquely identifying a temp even if its
    offset is modified.

git-svn-id: branches/hlcgllvm@26033 -
2013-11-11 11:14:59 +00:00