Commit Graph

333 Commits

Author SHA1 Message Date
Jonas Maebe
4e8bda76cb * update alignment when advancing offset to next element of array constructor node
git-svn-id: trunk@34279 -
2016-08-12 13:35:28 +00:00
Jonas Maebe
aa1be3276f - removed default value of _typ parameter of TAsmData.(Weak)RefAsmSymbol():
it was AT_NONE, which is invalid and should never be used
  * explicitly pass the correct value for all calls to those methods elsewhere
    in the compiler

git-svn-id: trunk@34250 -
2016-08-05 07:09:16 +00:00
svenbarth
a173c34d96 * have tcgrttinode use the indirect RTTI labels if necessary
git-svn-id: trunk@34224 -
2016-07-29 14:03:31 +00:00
svenbarth
02ebae7658 * use the indirect symbol for resource strings if necessary
* have the unit import the resource string symbol if necessary

git-svn-id: trunk@34188 -
2016-07-22 16:04:51 +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
svenbarth
345d83c3e3 Merge RTTI changes from packages branch (including adjustments that were required due to changes in trunk since then). These changes favor source backwards compatibility in contrast to Delphi compatibility. Binary compatiblity is however drastically broken due to the indirect references that are platform independant!
Merged revision(s) 28239-28289 from branches/svenbarth/packages:
Provide the possiblity to switch between the direct and indirect RTTI symbols.

ncgrtti.pas, TRTTIWriter:
  + get_rtti_label, get_rtti_label_ord2str & get_rtti_label_str2ord: add new "indirect" parameter and pass that along to rtti_mangledname
hlcgobj.pas, thlcgobj:
  * g_incrrefcount, g_initialize, g_finalize, g_array_rtti_helper: for now pass along False to get_rtti_label()
ncgvmt.pas, TVMTWriter:
  * writevmt: for now pass along False to get_rtti_label()
ncgld.pas, tcgrttinode:
  * pass_generate_code: for now pass along False to the get_rtti_label*() methods
........
Provide possibility to select between using a direct and an indirect RTTI reference. This way the references can be changed for selected cases.

ncgrtti, TRTTIWriter:
  * ref_rtti: new "indirect" parameter that's relayed to rtti_mangledname()
  * write_rtti_reference: new "indirect" paramater that's relayed to ref_rtti()
........
Switch properties to use the indirect type information without breaking backwards compatiblity. :)

compiler/ncgrtti.pas, TRTTIWriter:
  * published_properties_write_rtti_data: use the indirect reference, not the direct one
rtl/objpas/typinfo.pp:
  * to allow compilation with both 2.6.x and 2.7.1 and too avoid too many ifdefs at least in the declarations we define a macro TypeInfoPtr which is either PTypeInfo (2.6.x) or PPTypeInfo (2.7.1 and newer)
  * TPropInfo: rename PropType to PropTypeRef and change type to TypeInfoPtr
  + TPropInfo: add a new property PropType which returns a PTypeInfo out of the PropTypeRef depending on the compiler version
........
Switch further simple types (sets, enums, class references, pointers) to indirect type information (again without breaking backwards compatibility).

compiler/ncgrtti.pas, TRTTIWriter.write_rtti_data:
  * enumdef_rtti, setdef_rtti, classrefdef_rtti & pointerdef_rtti: write an indirect RTTI reference

rtl/objpas/typinfo.pp, TTypeData:
  * rename BaseType to BaseTypeRef, CompType to CompTypeRef, InstanceType to InstanceTypeRef and RefType to RefTypeRef and change their type to TypeInfoPtr
  + add properties BaseType, CompType, InstanceType & RefType which return a PTypeInfo out of the corresponding *Ref field depending on the compiler version
........
Switch class and interface parent as well as extended type to indirect type information

compiler/ncgrtti.pas, TRTTIWriter:
  * write_rtti_data.objectdef_rtti.objectdef_rtti_class_full: use indirect reference for class parent and extended type
  * write_rtti_data.objectdef_rtti.objectdef_rtti_interface_full: use indirect reference for interface parent

rtl/objpas/typinfo.pp, TTypeData:
  + add new method DerefTypeInfoPtr which returns Nil if the indirect reference is Nil and otherwise returns the dereferences indirect reference (for 2.6.x the direct reference is returned as is)
  * rename ParentInfo to ParentInfoRef, HelperParent to HelperParentRef, ExtendedInfo to ExtendedInfoRef, IntfParent ot IntfParentRef and RawIntfParent to RawIntfParentRef and change their type to TypeInfoPtr
  + introduce ParentInfo, HelperParent, ExtendedInfo, IntfParent and RawIntfParent properties that return a PTypeInfo and use the new DerefTypeInfoPtr to return the correct type info value
  * change the other newly introduced properties of TTypeData to use DerefTypeInfoPtr as well to be on the safe side
........
Switch record/object fields to indirect type information references.

compiler/ncgrtti.pas, TRTTIWriter.fields_write_rtti_data:
  * use the indirect reference for the object parent type
  * use the indirect reference for the field type

rtl/inc/rtti.inc:
  * TRecordElement: change TypeInfo to PPointer for 2.7.1 and newer
  * RecordRTTI: correctly dereference the element type for 2.7.1 and newer
  * fpc_copy: correctly reference the element type for 2.7.1 and newer
........
Switch static arrays to indirect RTTI reference.

compiler/ncgrtti.pas, TRTTIWriter.write_rtti_data:
  * arraydef_rtti: write the dimension types and the final field type as indirect references

rtl/inc/rtti.inc:
  * TArrayInfo: switch ElInfo to PPointer for 2.7.1+
  * ArrayRTTI & fpc_copy: correctly dereference ElInfo for 2.7.1+
rtl/objpas/typinfo.pp, TArrayTypeData:
  * switch ElType and Dims to PPTypeInfo; no backwards compatibility needed here as TArrayTypeData was added in 2.7.1 only

tests/test/trtti8.pp: fix test
........
Switch dynamic arrays to indirect RTTI references.

compiler/ncgrtti.pas, TRTTIWriter.write_rtti_data.arraydef_rtti:
  * write indirect references for the two element entries

rtl/inc/dynarr.inc:
  * tdynarraytypedata: change elType2 to PPointer for 2.7.1+
  * fpc_dynarray_clear, fpc_dynarray_setlength & fpc_dynarray_copy: correctly dereference elType2 for 2.7.1+
rtl/objpas/typinfo.pp, TTypeData:
  * rename elType and elType2 to elTypeRef and elType2Ref respectively and change type to TypeInfoPtr
  * add properties elType and elType2 which return PTypeInfo by dereferencing elTypeRef and elType2Ref respecively correctly
  * remove a few stray "inline" directives in the implementation
........
Switch procedure parameters and result type to indirect RTTI references.

compiler/ncgrtti.pas, TRTTIWriter.write_rtti_data.procvardef_rtti:
  * write_procedure_param: use indirect RTTI reference
  * write result info for both methods and procvars as indirect RTTI reference
  * write parameters for procvars as indirect RTTI reference

rtl/objpas/typinfo.pp:
  * TProcedureParam: change type of ParamType to PPTypeInfo (no backwards compatiblity needed here; was added for 2.7.1)
  * TProcedureSignature: change type of RseultType to PPTypeInfo (no backwards compatibility needed here; was added for 2.7.1)
  * TTypeData: remark in the comments of tkMethod that ResultTypeRef and ParamTypeRefs are of type PPTypeInfo and not PTypeInfo

tests/test/trtti9.pp: 
  * fix test
........
Remove no longer needed "indirect" parameter for TRTTIWriter methods.

ncgrtti.pas, TRTTIWriter:
  - ref_rtti & write_rtti_reference: remove "indirect" parameter
  * ref_rtti: call rtti_mangledname with "indirect" always set to "true"
  - remove "true" parameter on callsites of write_rtti_reference & ref_rtti
........

git-svn-id: trunk@33944 -
2016-06-10 17:01:51 +00:00
svenbarth
9d4e322cd0 Add AT_FUNCTION or AT_DATA to calls to (Weak)RefAsmSymbol. powerpc-macos needs them.
git-svn-id: trunk@33287 -
2016-03-19 12:29:21 +00:00
svenbarth
e4feacf29d Load global variables and typed constants from different units using indirect references if necessary.
ncgld.pas, tcgloadnode:
  + new method use_indirect_symbol to determine whether using an indirect reference is necessary at all
  * generate_threadvar_access & pass_generate_code: pass result of use_indirect_code() to RefAsmSymbol() for using an indirect access if needed

git-svn-id: trunk@33282 -
2016-03-18 22:27:28 +00:00
Jonas Maebe
4643913d58 - disable x86-specific workarounds when using LLVM (even when targeting x86)
git-svn-id: trunk@32782 -
2015-12-28 15:06:50 +00:00
Jeppe Johansen
f21f9ab930 Fix issue with absolute offsets being sign extended from aint to asizeint.
git-svn-id: trunk@32576 -
2015-12-03 21:43:39 +00:00
Jonas Maebe
0c4edd2aa9 * fixed getting address of interface methods after r32414: interfaces are not
a pointer to a vmt, but a pointer to a pointer to vmt (mantis #29086)
   o also adjusted the llvm type for interfaces accordingly

git-svn-id: trunk@32530 -
2015-11-25 19:28:17 +00:00
Jonas Maebe
554be0c301 * fixed hlcg type correctness when getting the address of a virtual method
o handle interfaces like classrefdef, since they also point to the vmt

git-svn-id: trunk@32414 -
2015-11-21 12:37:11 +00:00
Jonas Maebe
a3cdf466e3 * fixed type of proc address when loading a complex procvar
git-svn-id: trunk@32413 -
2015-11-21 12:37:08 +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
7ce34ac7d2 * fixed code generator type correctness when loading a resourcestring
git-svn-id: trunk@32403 -
2015-11-21 12:36:35 +00:00
Jonas Maebe
98c08dee1a * fixed indentation
git-svn-id: trunk@32246 -
2015-11-04 22:23:44 +00:00
Jonas Maebe
22d8b273bd * the type of tvarrec fields that are passed by address is already a pointer
-> don't make a double pointer

git-svn-id: trunk@32245 -
2015-11-04 22:23:41 +00:00
Jonas Maebe
9914f02faa * always set the resultdef for variant array constructors correctly, so we
don't need to pull all kinds of special tricks pass_generate_code

git-svn-id: trunk@32233 -
2015-11-04 20:46:10 +00:00
Jonas Maebe
2c5187cb97 * fixed size when storing arrayconstructor vtype field
git-svn-id: trunk@32215 -
2015-10-31 14:25:56 +00:00
Jonas Maebe
af4d69f446 * always write the entire integer field when storing a value < integer in an
arrayconstructor, so the upper bits get zeroed (tbs/tb0581)

git-svn-id: trunk@32214 -
2015-10-31 14:25:54 +00:00
nickysn
94a5364c2c * fixed 'array of const' in the i8086 tiny/small/medium memory models
git-svn-id: trunk@32212 -
2015-10-31 11:43:04 +00:00
Jonas Maebe
4670e0abc9 * converted "array of const" handling to the high level code generator
git-svn-id: trunk@32207 -
2015-10-30 20:45:15 +00:00
Jonas Maebe
3b2bd718d8 * corrected the def of the temp for array constructor nodes in case of
an array of const

git-svn-id: trunk@31777 -
2015-09-22 19:59:37 +00:00
yury
374148b966 * fixed compilation of 8086 compiler.
git-svn-id: trunk@31746 -
2015-09-17 16:30:02 +00:00
yury
47b316d0e2 * Removed unused vars for x86-64 compiler.
git-svn-id: trunk@31744 -
2015-09-17 15:26:31 +00:00
nickysn
c7ecf84fc0 * fixed compilation of threadvars in i8086 far data memory models
git-svn-id: trunk@31662 -
2015-09-13 12:52:23 +00:00
Jonas Maebe
19882aea7e * converted threadvar loading to high level code generator and updated/added
comments

git-svn-id: trunk@31644 -
2015-09-12 23:33:10 +00:00
Jonas Maebe
3c6aa91a96 * factored out the loading of threadvars in its own method, and put the
x86-specific part in nx86ld

git-svn-id: trunk@31639 -
2015-09-12 23:32:53 +00:00
Jonas Maebe
0fc1fd6ac1 * replaced current_procinfo.currtrue/falselabel with storing the true/false
labels of LOC_JUMP in the node's location. This generates some extra jumps
    for short circuit boolean and/or-expressions if optimizations are off, but
    with optimisations enabled the generated code is the same (except for JVM
    because the jump threading optimisation isn't enabled there yet).

git-svn-id: trunk@31431 -
2015-08-27 18:28:57 +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
388cef8a34 * fixed types for shortstring handling in tcgassignmentnode.pass_generate_code
git-svn-id: trunk@30716 -
2015-04-25 15:51:19 +00:00
Jonas Maebe
61e4a1b811 + added tasmlist parameter to getintparaloc() (needed for llvm)
git-svn-id: trunk@30429 -
2015-04-04 14:29:16 +00:00
Jonas Maebe
67b8aceaee * synchronized with privatetrunk till r30095
git-svn-id: branches/hlcgllvm@30101 -
2015-03-05 20:32:15 +00:00
Jonas Maebe
290e3f5ff8 * fixed assigning one float loc_reference to another of a different size if a
platform does not support (hl)cg.a_loadfpu_*, but only (hl)cg.a_loadmm_*

git-svn-id: trunk@29820 -
2015-02-23 22:47:47 +00:00
Jonas Maebe
ac02c92a0d * disable cg64/cg128 special cases for high level targets
git-svn-id: branches/hlcgllvm@28365 -
2014-08-10 19:40:00 +00:00
Jonas Maebe
7949bebb8d * synchronised with r28168 of trunk
git-svn-id: branches/hlcgllvm@28169 -
2014-07-05 21:30:28 +00:00
svenbarth
441e6c6083 Fix for Mantis #26177. Use the correct value for the method data when using a method pointer of a type or record helper.
Please note that Delphi has the exact same bug as we have and thus code working in FPC will not work in Delphi.
Additionally taking the method address of a local variable or a local/global constant for a method pointer is dangerous as the variable (in case of constants is a temporary local variable) will go out of scope once the containing procedure/function/method exits!

ncgld.pas, tcgloadnode.pass_generate_code:
  * only use the value of Self if it is an implicit pointer object (class instance) or a class reference, but not for everything else (objects, records, primitive types)

+added test

git-svn-id: trunk@28160 -
2014-07-05 08:54:10 +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
nickysn
24bf272c69 * fixed the passing of array of const parameters in i8086 far data memory models
git-svn-id: trunk@27700 -
2014-05-01 12:46:29 +00:00
nickysn
40a6a9c820 + added i8086 specific implementation of thlcgcpu.a_load_loc_ref, which handles
6-byte method pointers and other i8086 types that use loc.registerhi
* changed the i8086 specific code in tcgassignmentnode.pass_generate_code to
  use hlcg.a_load_loc_ref

git-svn-id: trunk@27555 -
2014-04-13 01:38:43 +00:00
nickysn
02988023b7 * tcgloadnode.pass_generate_code: fixes for i8086 far data model fixes in the
handling of method procsyms + even more ifdef i8086s removed

git-svn-id: trunk@27551 -
2014-04-12 19:59:04 +00:00
nickysn
68ff3fb1e2 * tcgloadnode.pass_generate_code: rm the ifdef'd i8086 code from the handling of
non-method procsyms by using def_cgsize(pd.address_type) to determine the
  address size

git-svn-id: trunk@27550 -
2014-04-12 16:26:51 +00:00
nickysn
9ae26316e8 * fixed the handling of const resourcestrings in the i8086 far data memory models
git-svn-id: trunk@27380 -
2014-03-30 16:30:51 +00:00
Jonas Maebe
4a79481c51 * isolated segment-related functionality of tabsolutevarsym into i386/i8086-
specific descendent classes and moved the code that deals with this in the
    code generator also to target-specific classes -> only ifdefs left in
    pdecvar

git-svn-id: trunk@27379 -
2014-03-30 15:42:53 +00:00
nickysn
0082db46ea * i8086 far data memory model fix in tcgloadnode.generate_nested_access.
The system unit now compiles in the compact and large memory models again.

git-svn-id: trunk@27341 -
2014-03-29 18:32:01 +00:00
nickysn
d43d7e59b5 * partially converted the threadvar handling in tcgloadnode.pass_generate_code
to use the hlcg in order to support the i8086 far data memory models. Only the
  instructions that handle the case when there's no thread manager installed
  (FPC_THREADVAR_RELOCATE=nil) are converted, since that's what's used on the
  msdos target. The rest still uses the low level code generator.

git-svn-id: trunk@27336 -
2014-03-29 16:22:48 +00:00
nickysn
7f014c5040 * replaced ifdef i8086 with hlcg.reference_reset_base in tcgloadnode.pass_generate_code
git-svn-id: trunk@27327 -
2014-03-28 23:38:57 +00:00
nickysn
897802c7c4 + fill the treference segment correctly in the load node for localvarsyms and
paravarsyms that are passed by reference in a i8086 far data memory model

git-svn-id: trunk@27277 -
2014-03-25 00:50:18 +00:00
Jonas Maebe
73a3f5ced4 * moved ncgutil.maybechangeloadnodereg() to hlcg.maybe_change_load_node_reg()
and moved ifdef'd jvm code to overridden method

git-svn-id: trunk@27153 -
2014-03-16 11:24:40 +00:00
Jonas Maebe
d8e228e82d - removed unnecessary JVM-specific code
git-svn-id: trunk@27151 -
2014-03-16 11:24:32 +00:00