Commit Graph

15006 Commits

Author SHA1 Message Date
Jonas Maebe
a972de5a32 * renamed the first parameter of is_owned_by() from "childdef" into
"nesteddef", because it's about def's owned by other defs, not about
    parent/child relations like in OOP
  * stop checking whether a def is owned by another one when we reach a
    para/localsymtable, since a type declared locally in a record/object
    method is not nested inside the record/object type (fixes mantis
    #23819)

git-svn-id: trunk@23582 -
2013-02-06 21:39:39 +00:00
Jonas Maebe
2b78bb1674 - removed ppc-specific tcgpara.composite field, it's no longer used or
necessary

git-svn-id: trunk@23581 -
2013-02-06 15:37:50 +00:00
svenbarth
344571cb4e Added support for type helpers. In non Delphi modes they use "type helper" and in mode Delphi they use "record helper". They can also be used on constants.
symconst.pas:
  + extend "thelpertype" by "ht_type" which tells the code in "pdecobj.parse_extended_type" that a type helper declaration has been parsed
node.pas:
  + add a constant which identifies all constant node types
ptype.pas:
  + read_named_type: add a parameter "hadtypetoken" to tell the code whether a "type" token had been parsed before
  + read_named_type: if an identifier "helper" is parsed we need to check whether "hadtypetoken" is true and the modeswitch "m_class" is set, but the "m_delphi" one is not; in that case we have a "type helper" declaration
pgenutil.pas, generate_specialization:
  * adjust call to read_named_type
pdecl.pas, types_dec:
  * adjust call to read_named_type

pdecobj.pas:
  * parse_extended_type: extend for correct handling of primitive types (includes Delphi compatible handling as well) and reject types that are explicitly not allowed
  * method_dec: require "static" for class methods in type helpers
  * method_doc: allow constructors for type helpers as well
paramgr.pas, tparamanager:
  * set_common_funcretloc_info: handle type helper constructors like record constructors
  * handle_common_ret_in_param: the "self" value of a type helper constructor is also returned in a parameter
pexpr.pas:
  + add a function to postfixoperators which tries to find and apply a type helper for a given type
  * postfixoperators: try to apply type helpers for ordinal constants
  * postfixoperators: use the correct string type for string constants
  * postfixoperators: try to apply type helpers for enum constants
  * postfixoperators: try to apply type helpers for arrays
  * postfixoperators: try to apply type helpers for Variant
  * postfixoperators: try to apply type helpers for pointer types
  * postfixoperators: try to apply type helpers for other types
  * factor: check postfixoperators after _REALNUMBER, _CCHAR, _CWCHAR, _TRUE and _FALSE
  * factor: also check postfixoperators if a _POINT follows a _NIL

symdef.pas, tdefawaresymtablestack.addhelpers:
  * use "generate_objectpascal_helper_key" to generate the key
symtable.pas:
  + add function to generate the key value for the map of extended types using the extended def
  * adjust "search_last_objectpascal_helper" and "search_objectpascal_helper" to handle primitive types as well
  * use the new "generate_objectpascal_helper_key" function to generate the key

pparautl.pas:
  * insert_self_and_vmt_para: don't insert the $vmt symbol for record or type helpers (ToDo: check whether class helpers really need the symbol as well)
  * insert_self_and_vmt_para: pass "self" as var parameter for type helpers as well
psub.pas, generate_bodyentry_block: 
  * also allow type helpers for constructor methods
ncal.pas, tcallnode.gen_self_tree:
  * also use a temp variable for type helper constructors
ncgcal.pas, tcgcallnode.secondcallparan:
  * allow Pointers to be passed as address param if it is the Self value of a type helper extending a pointer type
  * correctly handle the location in case of type helper constructors

+ add tests

git-svn-id: trunk@23580 -
2013-02-06 09:49:35 +00:00
Jonas Maebe
f1ff92529b * group all -CT parameters together
git-svn-id: trunk@23578 -
2013-02-05 23:09:55 +00:00
Jonas Maebe
39e31337f1 * documented -CTthumbinterworking parameter
git-svn-id: trunk@23577 -
2013-02-05 23:09:48 +00:00
Jonas Maebe
227bb7d850 * made behaviour of -CT parameters consistent with other parameters: instead
of -CTnoTargetSwitch, now you can (and have to) use -CTTargetSwitch- to
    disable it

git-svn-id: trunk@23576 -
2013-02-05 23:09:41 +00:00
sergei
d82387ff72 * MIPS: fixed parameter management to properly align records smaller than 32 bits on big-endian targets.
* Also changed parameter management to allocate a single LOC_REFERENCE location for any parameter (or part of a parameter) passed on stack. Such locations can now be handled by generic code. As a consequence, TGMIPS.a_load_const_cgpara and a_load_ref_cgpara methods are no longer necessary (moreover they were ignoring parameter shifting).
* a_loadfpu_ref_cgpara patched to handle 64-bit location, which are now possible.

* This change eliminates code generation madness where each word of a record was copied individually, thus passing by value a 32K-word sized record was bloating into 64K instructions, multiply this number by 2 for larger records due to limited immediate offsets, and by another 2 for global record in PIC mode :/

git-svn-id: trunk@23575 -
2013-02-05 22:21:09 +00:00
pierre
a4e0a4c0f5 Adapt length of tprocinfoopt record string field to longest string
git-svn-id: trunk@23573 -
2013-02-04 23:01:36 +00:00
florian
3ca7a5ff8e - remove switch -Wx for arm thumb interworking, one should use -CTHUMBTINTERWORKING=ON instead
git-svn-id: trunk@23572 -
2013-02-04 21:46:27 +00:00
florian
cbf7eaaffc * copyright year updated
git-svn-id: trunk@23571 -
2013-02-04 21:33:23 +00:00
florian
4d3df8f518 * stupid typo in TVMTWriter.RedirectToEmpty fixed, resolves #23763
git-svn-id: trunk@23569 -
2013-02-03 22:02:02 +00:00
sergei
70c0d680a6 + MIPS linker: understand R_MIPS_JALR relocation and __gnu_local_gp symbol.
git-svn-id: trunk@23568 -
2013-02-03 21:54:37 +00:00
sergei
ef38193043 * MIPS: Once again fixed g_external_wrapper. My initial assumption about .cpload was wrong: it is optimized into position-dependent sequence only if "-KPIC -mno-shared" is passed to GAS command line, without -KPIC it is ignored altogether. Therefore r23566 breaks some non-PIC tests.
git-svn-id: trunk@23567 -
2013-02-03 21:53:30 +00:00
sergei
9bc758d62b * Forgot to set base register to NR_GP
git-svn-id: trunk@23566 -
2013-02-03 01:46:49 +00:00
sergei
a0c1e1b07f * MIPS: fixed a_call_name and a_call_reg methods to workaround a bug in GAS <2.21, see comments in source for details.
+ g_external_wrapper method.

git-svn-id: trunk@23565 -
2013-02-02 23:52:58 +00:00
Jonas Maebe
a51e64bd4d + {$targetswitch xxx} directive that enables changing target switches
(-CTxxx) in the source code

git-svn-id: trunk@23563 -
2013-02-02 15:22:18 +00:00
Jonas Maebe
4022c29500 * mark each target switch with whether it's global or not, so a compiler
directive can be added that enables changing the local ones

git-svn-id: trunk@23562 -
2013-02-02 15:22:13 +00:00
Jonas Maebe
185f71762f * fixed automatic setter generation if only a setter and no getter prefix
has been specified

git-svn-id: trunk@23561 -
2013-02-02 15:21:58 +00:00
pierre
899951577a Avoid wrong code generation for a_call_name if we create pic code
git-svn-id: trunk@23560 -
2013-02-01 21:16:58 +00:00
sergei
8bfbee747a * MIPS: Rewrote g_intf_wrapper method to support instance offsets greater than 32767 and PIC (the latter part untested yet).
git-svn-id: trunk@23557 -
2013-02-01 18:28:46 +00:00
sergei
a519741d89 - Revert {$J-} accidentally committed in r23555.
git-svn-id: trunk@23556 -
2013-02-01 16:49:46 +00:00
sergei
503b132096 * cgbase.pas: added more MIPS-specific address types, needed to support large GOT model.
* cpugas.pas: GetReferenceString: rewritten, it is easier than trying to fix it. Fixes incorrect writing of non-PIC references containing base, symbol and offset together, and some forms of PIC references. Also supports newly introduced address types.

git-svn-id: trunk@23555 -
2013-02-01 16:46:22 +00:00
sergei
6e4f6a64d6 + MIPS: Allow subset locations for boolean NOT, this appears sufficient to fix all bitpacking-related tests.
git-svn-id: trunk@23554 -
2013-01-31 21:52:29 +00:00
pierre
7e79042d58 Reorganize for better pic support (not yet working completly ...)
git-svn-id: trunk@23550 -
2013-01-31 13:35:52 +00:00
pierre
6e2db1a5e5 Use addr_pic_call16 in a_call_name method
git-svn-id: trunk@23549 -
2013-01-31 13:34:38 +00:00
pierre
9cb7be4c92 + Support addr_pic_call16
* Add more instructions to is_macro_instruction function

git-svn-id: trunk@23548 -
2013-01-31 13:32:18 +00:00
pierre
493c77bca0 + Add addr_pic_call16 relocation type for mips
git-svn-id: trunk@23547 -
2013-01-31 13:08:49 +00:00
Jonas Maebe
ddc03bdf03 * when automatically generating (s|g)etters, make sure that the visibility of
(g|s)etters whose naming convention is already correct is adjusted if
    necessary

git-svn-id: trunk@23546 -
2013-01-30 22:36:03 +00:00
Jonas Maebe
8f96ace589 * fixed -CTauto(g|s)etterprefix automatically generated helpers in case they
have to wrap an existing (g|s)etter that was marked as "abstract" (don't
    mark the helper also as abstract, sicnce it contains code)

git-svn-id: trunk@23545 -
2013-01-30 22:35:59 +00:00
svenbarth
d49b4043ab Implement DECLARED() for generic symbols. This fixes Mantis #21829 . The syntax is SomeGenericType<> for a generic with only one type parameter and SomeGeneric<,[,]*> for a generic with more than one type parameter. Spaces between the commas or brackets are allowed.
scanner.pas, parse_compiler_expr.read_factor:
  + allow "<>" after "declared" (handle "<>" operator specially)
  + count "," to get correct amount of type parameters
  + check together with the count string for symbols 
  + correctly handle dummy symbols

+ added tests

git-svn-id: trunk@23544 -
2013-01-30 16:10:15 +00:00
svenbarth
cca897cfd3 Fix a memory leak spotted by Blaise Thorn
pdecsub.pas, parse_proc_head.consume_generic_type_parameter:
  * avoid a memory leak if there are no generic type parameters following

git-svn-id: trunk@23543 -
2013-01-30 15:29:29 +00:00
florian
ef1c848198 * fix constant calculation for the AndAnd2And optimization if the first and is removed, noticed by Nico Erfurth
git-svn-id: trunk@23541 -
2013-01-29 20:39:22 +00:00
florian
bf57cdf409 + introduce new define CPUTHUMB2
git-svn-id: trunk@23539 -
2013-01-29 20:34:55 +00:00
sergei
08c0c265c9 * MIPS: use correct def to calculate parameter alignment (when parameter is passed by address, its def changes to pointer and the alignment of parameter itself is irrelevant). Fixes at least webtbs/tw7806.
git-svn-id: trunk@23538 -
2013-01-29 20:09:41 +00:00
florian
d0cbcd419e * update of the German compiler message file by Karl-Michael Schindler, resolves #23728
git-svn-id: trunk@23535 -
2013-01-29 18:34:12 +00:00
sergei
cb51c39dd7 * Forgot to assign result of SwapEndian() into place.
git-svn-id: trunk@23534 -
2013-01-29 16:42:47 +00:00
sergei
5e13334467 * Fixed tMIPSELtypeconvnode.second_int_to_bool handling of C booleans, webtbs/tw10233 and webtbs/tw17180 now work.
* Reused applicable code from the above mentioned method in tMIPSELnotnode.second_boolean, it is more efficient in handling 64-bit data.

git-svn-id: trunk@23531 -
2013-01-28 21:32:21 +00:00
Jonas Maebe
cb85846507 * fixed typo in jvm record clone implementation comment
git-svn-id: trunk@23527 -
2013-01-26 21:28:30 +00:00
Jonas Maebe
fffa2e163a - removed unused local type in internal jvm record clone implementation
git-svn-id: trunk@23526 -
2013-01-26 21:28:26 +00:00
Jonas Maebe
dc7760bda0 * let type conversion nodes handle type checking for if/while/repeat
conditions, so that used-defined implicit boolean type conversions are
    supported (patch by Peter-Jan Roes, mantis #23568)

git-svn-id: trunk@23525 -
2013-01-26 21:28:22 +00:00
Jonas Maebe
2ed4b295fe * only change the visibility of an existing getter/setter to that of
its property in case the visibility of the property is higher than
    that of the getter/setter (on the JVM target when automatically
    generating getters/setters)

git-svn-id: trunk@23523 -
2013-01-26 16:52:32 +00:00
Jonas Maebe
e7315d035c * inherit po_auto_raised_visibility flag when the visibility of a method is
raised because it was automatically raised in the parent class (can happen
    for the JVM target when letting the compiler generate getters/setters for
    properties)

git-svn-id: trunk@23522 -
2013-01-26 16:52:28 +00:00
sergei
d762ef9e78 + PECOFF targets: support more than 65535 relocations per object section, resolves #23752. DJCOFF targets: give a fatal error, since this object file format does not support extended relocations.
git-svn-id: trunk@23521 -
2013-01-26 16:15:59 +00:00
svenbarth
7bad1763b8 Decrease amount of code duplication regarding handling of safecall and record constructors.
paramgr.pas, tparamanager:
    + add new method "handle_common_ret_in_param"
    * extract common code (safecall + record constructor handling) from "ret_in_param" to "handle_common_ret_in_param" and call the latter in "ret_in_param"
[aarch64,arm,avr,i386,x86_64]/cpupara.pas, tCPUparamanager.ret_in_param:
    * call "handle_common_ret_in_param" instead of implementing the same check again and again
ncgcal.pas, tcgcallnode.handle_return_value:
    * move the check for (record) constructors to "tparamanager.handle_common_ret_in_param"

git-svn-id: trunk@23520 -
2013-01-25 20:39:28 +00:00
sergei
cb1098c26c * Do not create SEH finalization procedures in generic methods, their similarity with nested procedures causes compilation errors because actual nested procedures are not allowed for generics. Not creating them doesn't hurt because generic node tree is not used for code generation. Resolves #23724.
git-svn-id: trunk@23519 -
2013-01-25 18:50:04 +00:00
yury
d8902af3d6 * Do not replace ADD by SUB and vice-versa when overflow checking is enabled. Fixes tw15304 for ARM.
git-svn-id: trunk@23517 -
2013-01-24 21:49:21 +00:00
Jonas Maebe
9cbff6f5a6 + support for record constructors for the JVM target
git-svn-id: trunk@23510 -
2013-01-24 09:45:12 +00:00
Jonas Maebe
3abc7b0d9c * removed superfluous check (a procvardef can never be a constructor) and
typecasts

git-svn-id: trunk@23509 -
2013-01-24 09:45:06 +00:00
Jonas Maebe
10e3cab1b1 * fixed formatting
git-svn-id: trunk@23508 -
2013-01-24 09:44:59 +00:00
Jonas Maebe
9145f1d67d * integrated potype_constructor check in maybe_create_funcret_node
git-svn-id: trunk@23507 -
2013-01-24 09:44:52 +00:00
yury
8ae7c5784c * Sync with trunk r23500.
git-svn-id: branches/targetandroid@23501 -
2013-01-23 07:53:13 +00:00
yury
e13e2e1697 * Turn off special handling of interrupt calling convention for i386-android.
git-svn-id: branches/targetandroid@23492 -
2013-01-22 14:43:42 +00:00
yury
e82983e577 * Define CExtended and clongdouble as double for Android.
git-svn-id: branches/targetandroid@23487 -
2013-01-22 11:16:22 +00:00
sergei
40c510403f * Don't crash on a PLT-generating relocation to a local symbol (which should not normally appear, but nevertheless is possible).
git-svn-id: trunk@23481 -
2013-01-21 16:49:10 +00:00
yury
0960ee2034 * Add missing checks for android target.
git-svn-id: branches/targetandroid@23477 -
2013-01-21 12:08:25 +00:00
yury
f8af2cd49e * Set android-i368 stack alignment to 16.
git-svn-id: branches/targetandroid@23475 -
2013-01-21 11:51:09 +00:00
yury
3e151ac30f * Removed -z relro linker option, since it causes problems.
git-svn-id: branches/targetandroid@23474 -
2013-01-21 11:45:29 +00:00
paul
5d74e0578a compiler: remove unused variables and unneeded assignments
git-svn-id: trunk@23467 -
2013-01-21 01:24:36 +00:00
svenbarth
78f0d6f70e Revert the changes from r23383 for m68k/n68kadd.pas. Memo to self: Don't change code if you don't really understand why it does things the way it does.
With this change and the change from r23465 we are down from ~950 to ~650 failures :D

git-svn-id: trunk@23466 -
2013-01-20 18:00:51 +00:00
svenbarth
b455ae9534 m68k/cpupara.pas, tm68kparamanager.getintparaloc:
* initialize paraloc^.size to OS_INT instead of leaving it at 0

This fixes tests/test/cg/ttryexc1.pp. The problem was that the raise node generated code which resulted in a word(!) move of the raised object's address to the stack location for fpc_raiseexception. This then resulted in an error when freeing the exception object.

git-svn-id: trunk@23465 -
2013-01-20 16:33:10 +00:00
florian
9d76168b57 * refactored Bl2B condition code to make it more readable
git-svn-id: trunk@23464 -
2013-01-20 15:38:38 +00:00
florian
7184306a4c + option -Wx to generate thumb interworking safe code on arm
git-svn-id: trunk@23463 -
2013-01-20 15:26:59 +00:00
florian
3fff969ced * take care of instruction in between when doing ShiftShiftShift2ShiftShift optimizations
git-svn-id: trunk@23462 -
2013-01-20 14:58:03 +00:00
florian
f1b8fad6dc * make AndAnd2And working with other instructions in between
git-svn-id: trunk@23461 -
2013-01-20 14:57:59 +00:00
florian
fcef2dc3df * refactored some code and introduced usage of new method RegEndOfLife
git-svn-id: trunk@23460 -
2013-01-20 14:57:55 +00:00
florian
82f3ec7922 * if cs_opt_level3 is not set, limit lookahead of GetNextInstructionUsingReg to one instruction:
only -O3 means do the really slow optimizations

git-svn-id: trunk@23459 -
2013-01-20 14:57:51 +00:00
florian
a78af5b8fe + AndLslXsr2And and AndLsl2Lsl optimization
git-svn-id: trunk@23458 -
2013-01-20 14:57:46 +00:00
florian
ff522d7e18 * improve ShiftShiftShift2ShiftShift to look further ahead
* check register usage so the destination register can be different

git-svn-id: trunk@23457 -
2013-01-20 14:57:43 +00:00
florian
12d0c05ede * remove bic instructions after lsr if possible
git-svn-id: trunk@23456 -
2013-01-20 14:57:38 +00:00
svenbarth
632db2229f Fix for Mantis #23700 .
scanner.pas, parse_compiler_expr.read_factor:
  * initialize result value

git-svn-id: trunk@23454 -
2013-01-20 11:21:20 +00:00
florian
81e0e3114c * throw an error if threadvars are used but not supported
* fix building for arm-embedded

git-svn-id: trunk@23452 -
2013-01-19 15:17:47 +00:00
yury
9b600b9688 * Pass some security switches to LD. They are passed by GCC.
* Removed unused function.

git-svn-id: branches/targetandroid@23451 -
2013-01-18 23:32:26 +00:00
pierre
9e6a2b868c Fix -Cp option failure due to cputypestr array that must be uppercased
git-svn-id: trunk@23446 -
2013-01-18 17:09:28 +00:00
yury
c2fed960c9 * Add android to supported targets for assemblers. It fixes assembling for i386-android.
git-svn-id: branches/targetandroid@23441 -
2013-01-18 14:51:09 +00:00
paul
7c663af588 compiler: also don't allow record constructors with only default arguments
git-svn-id: trunk@23438 -
2013-01-18 11:59:25 +00:00
paul
fe338013a5 compiler: calculate offset of record fields in taddrnode also for bitpacked structures (Jonas comment in bug #0019357)
git-svn-id: trunk@23437 -
2013-01-18 01:56:55 +00:00
paul
1b8369dd99 compiler: don't allow parameterless constructors
git-svn-id: trunk@23436 -
2013-01-18 01:24:04 +00:00
yury
d05912cd8e * Enable safecall exception handling for arm-android.
git-svn-id: branches/targetandroid@23435 -
2013-01-17 22:46:23 +00:00
Jonas Maebe
583eb3f9a4 * re-enabled loadvmtaddrnode for records on JVM targets, fixes
tests/test/jvm/tpvar.pp after r23417

git-svn-id: trunk@23430 -
2013-01-17 19:45:09 +00:00
paul
65cbb4e9ba compiler: calculate offset of record fields in taddrnode (based on patch of Jeppe Johansen, fixes bug #0019357)
git-svn-id: trunk@23428 -
2013-01-17 14:30:55 +00:00
paul
3a3c10a474 compiler: don't allow constants, methods, class members and properties for local or anonymous records (fixes bug #0023000)
git-svn-id: trunk@23421 -
2013-01-17 09:05:59 +00:00
paul
4d79a44e4c compiler: don't create loadvmtaddrnode for record references, they have no VMT (fixes bug #23130)
git-svn-id: trunk@23417 -
2013-01-17 07:30:00 +00:00
florian
cad1309935 * don't write directly to the function result destination if we are inlining and if the destination is too complex to evaluate (threadvar etc.)
git-svn-id: trunk@23415 -
2013-01-16 20:25:49 +00:00
florian
247d6dd394 + implemented a tcasenode.printnodetree printing all cases
git-svn-id: trunk@23414 -
2013-01-16 20:24:56 +00:00
florian
abfa6c1b43 * redo LsrAnd2Lsr optimization
git-svn-id: trunk@23413 -
2013-01-16 20:24:07 +00:00
yury
2fc220cc6c * Regenerated makefiles.
git-svn-id: branches/targetandroid@23410 -
2013-01-16 14:52:36 +00:00
masta
fe520c215b New ARM Peephole optimizer FoldShiftLdrStr
This one folds
      mov r1, r2, lsl #2
      ldr/ldrb r0, [r0, r1]
into
      ldr/ldrb r0, [r0, r2, lsl #2]

There is still some room for improvement, maybe it would be better to do this before
the register allocator runs, as we'll currently waste a register (r1 in the above example)
in many cases. That would also allow to to fold more operations, because currently if r2
gets reused between the mov and ldr we'll not be able to do the optimization.

git-svn-id: trunk@23408 -
2013-01-16 14:37:28 +00:00
paul
e9615716c1 compiler: allow constructors in helpers for records
git-svn-id: trunk@23407 -
2013-01-16 13:47:22 +00:00
yury
281768b145 * Set stackalign field.
git-svn-id: branches/targetandroid@23406 -
2013-01-16 13:33:50 +00:00
yury
d26f0552a0 * Sync with trunk r23404.
* Regenerated makefiles.

git-svn-id: branches/targetandroid@23405 -
2013-01-16 13:21:51 +00:00
pierre
2b300ec2b4 Add breakpoint at Verbose.GenerateError procedure
git-svn-id: trunk@23399 -
2013-01-16 09:46:34 +00:00
pierre
6d8b1e03d7 Increase status.errorcount only inside GenerateError procedure, to simplify debugging
git-svn-id: trunk@23398 -
2013-01-16 09:45:57 +00:00
paul
b2a613c17f compiler: implement record constructors + tests
git-svn-id: trunk@23395 -
2013-01-16 02:07:42 +00:00
paul
51825b6f2e compiler: change ret_in_param to accept tabstractprocdef instead of tproccalloption to allow check more options (required for record constructor implementation)
git-svn-id: trunk@23394 -
2013-01-16 01:14:23 +00:00
sergei
b35d04ffa8 * MIPS: methodpointers must be compatible with records; since records are never passed by address in this ABI, so must be methodpointers. Fixes webtbs/tw9141.pp.
git-svn-id: trunk@23392 -
2013-01-15 19:09:19 +00:00
sergei
d2758265e3 * MIPS int->real conversion: When converting unsigned to single, load it into 64-bit FP register, otherwise further subtracting a 64-bit offset leads to invalid result. Fixes tw17714.pp.
* The addend is endian-dependent, fixes tcnvint4.pp on big-endian targets.

git-svn-id: trunk@23388 -
2013-01-15 10:49:37 +00:00
sergei
b5eecab582 * Procvars (methodpointers) must be treated as records, too. Fixes tw12318.pp and tw14155.pp after r23377.
* Factored related code into a separate method, as it will probably need further refinement.

git-svn-id: trunk@23387 -
2013-01-15 10:39:14 +00:00
svenbarth
c7a9e17bc5 Patch by Vasiliy Kevroletin. Fixes Mantis #23655.
compiler/node.pas, tnode.printnodeinfo:
  * write flags to file "t" instead of stdout

git-svn-id: trunk@23384 -
2013-01-15 06:04:10 +00:00
svenbarth
ccecf2c13c Fix comparisons (aka usage of flag/CCR register)
m68k/aasmcpu.pas, taicpu.spilling_get_operation_type:
  * add all Sxx instructions as "operand_write" instructions

m68k/n68kadd.pas, t68kaddnode.getresflags:
  * use the correct operation in case of swapped nodes

m68k/cgcpu.pas, tcg68k.g_flags2reg:
  - don't move a 0 to the register, because this will CLR it and thus the flags won't be valid anymore...
  - NEG would have been the wrong operation (NOT would have been correct), but it isn't needed anyway...
  * simplify the method by handling the address register case only when necessary

git-svn-id: trunk@23383 -
2013-01-14 20:31:15 +00:00
svenbarth
741992bae4 m68k/n68kmat.pas, tm68kshlshrnode.first_shlshr64bitint:
use RTL helper functions (through the inherited method) if we're not shifting by a constant

This fixes test/cg/tshlshr

git-svn-id: trunk@23378 -
2013-01-13 19:33:23 +00:00
sergei
162896e7d7 * MIPS code generator fixes and improvements:
- removed a_jmp_cond, it's not virtual and not applicable to this CPU.
* a_loadfpu_reg_cgpara: use direct register moves for simple destinations.
* g_concatcopy: don't take address of source/destination for small amounts of data if possible, for single 32-bit moves this reduces number of generated instructions from 4 to 2.
* g_intf_wrapper: 'Self' is in R4 (a0), not R2. Fixes test/tinterface1.pp.

* mips/cpupara.pas: for functions with result returned in parameter, pass its address in a0 only if result is a record. ABI does not specify behavior for types except records/unions. At the same time, Pascal code relies on the fact that results like strings/interfaces does not change their locations, i.e. "function foo(<self>): IInterface" can be invoked as "procedure foo(<self>, out obj)". This fixes test/tdel1.pp and some Variant-related tests.

git-svn-id: trunk@23377 -
2013-01-13 18:24:06 +00:00
sergei
32ffddaad8 + ELF linker back-ends for ARM and MIPS.
ARM status: roughly corresponds to i386 one, passes the test suite. Handles libraries, can link static libc code including basic PIC and TLS IE/LE stuff. Completely misses Thumb support. Also does not handle ABI-specific stuff, for this reason internally linked .so cannot be used for linking executables with ld. Little-endian only. Tested only on "versatilepb" QEMU virtual machine.

MIPS status: can link the compiler and at least some dynamic executables including fpmake. Some PIC support is present but almost untested. Specific header flags and sections are also not handled yet. Written to handle both endian, but tested for big-endian only ("malta" QEMU VM), including cross-linking from x86_64.

git-svn-id: trunk@23376 -
2013-01-13 18:05:19 +00:00
sergei
af4935e346 + Support dynamic copy relocations.
* For unresolved weak symbols, provide dynamic binding only if they are referenced via GOT or PLT (ld-compatible behavior).
* Made more TElfExeOutput properties/methods usable by descendant classes.
* x86_64/cpuelf.pas: some refactoring, handle DTPOFF relocations, prohibit TPOFF relocations in shared objects.
* i386/cpuelf.pas: set symref_from_text flags for copy relocations to work correctly.

git-svn-id: trunk@23375 -
2013-01-13 17:44:14 +00:00
sergei
a1503b51f2 + chmod 755 on executable files produced by internal linker. I missed this "small" detail for half a year because all development was going on a NTFS drive where everything is executable.
git-svn-id: trunk@23374 -
2013-01-13 17:18:11 +00:00
svenbarth
252744ad24 m68k/cgcpu.pas, tcg68k.g_concatcopy:
use the correct flag for the copy loop: we jump back to the copy code as long as the value is positive aka BPL instead of BMI

This fixes around 30 tests (it fixes a quite bit more, but now some other tests seem to be broken...)

git-svn-id: trunk@23373 -
2013-01-13 16:21:59 +00:00
sergei
4b925763c3 + Enable CPU-specific descendants to write specific dynamic tags.
+ Read version definitions from shared objects.

git-svn-id: trunk@23370 -
2013-01-13 06:36:39 +00:00
sergei
f98e09d86e - TObjData.sectiontype2options: removed oso_keep flags. They don't have any effect here because this function is used only during assembling, and oso_keep cannot be represented in object files and therefore gets lost before linking.
git-svn-id: trunk@23364 -
2013-01-11 17:14:44 +00:00
sergei
ad1621df3f * Revert part of r22548, correct fix for the issue is provided by r23188.
Only referencing data labels from code should change "GOT is needed" property. Writing data labels or referencing them from data should have no effect on it.

git-svn-id: trunk@23363 -
2013-01-11 15:31:12 +00:00
sergei
bc4c1149c3 + Native threadvar implementation for Win32 and Win64 (most of it, but not yet complete).
git-svn-id: trunk@23359 -
2013-01-10 19:13:02 +00:00
svenbarth
b5827ce363 Move the handling of "misstyled" floating point constants like "2." or "2.e10" from the scanner to the parser. This way type helpers calls for integer constants can be parsed correctly in the future.
Note: the error messages for incorrect "misstyled" floating point numbers (e.g. "2e10foo") have changed because of this.

scanner.pas, tscannerfile.readtoken:
  instead of tokenizing "2.", "2.e10", "2.e+10" and "2.e-10" as "_REALNUMBER" tokenize them as "_INTCONST _POINT", "_INTCONST _POINT _ID", "_INTCONST _POINT _ID _PLUS _INTCONST" "_INTCONST _POINT _ID _PLUS _INTCONST"; tokenizing of normal floating constants is not changed

pexpr.pas:
  factor: 
    * extract the code for creating a new constant floating point from "factor" into a new function "real_const_node_from_pattern"
    + allow the parsing of postfixoperators for integer constants if a "." is encountered
  + postfixoperators: check for a "misstyled" floating point number if an ordinal const (not an enum and not a boolean) is encountered (the code is already partially prepared for type helper support)
  
+ Added tests

git-svn-id: trunk@23356 -
2013-01-10 16:23:00 +00:00
svenbarth
359a228085 Fix one problem type of Mantis #23546. A record must not contain a static array that uses itself as an element type (in can contain a dynamic array however) otherwise an infinite loop is encountered when checking whether the record needs special init/final code.
pdecvar.pas, read_record_fields:
  * if the def of the field is a static array then use the array's element def (the final element def if it is a multi dimensional array) to check for whether this is the current record type

+ added tests

git-svn-id: trunk@23352 -
2013-01-09 14:07:01 +00:00
svenbarth
29bd000a4a Fix for Mantis #23571.
ptype.pas, single_type:
  * if using a message that expects a parameter, provide that parameter...

+ added tests

git-svn-id: trunk@23349 -
2013-01-09 11:28:17 +00:00
svenbarth
6fb958a491 symdef.pas, tstoreddef:
* adjust "is_generic" so that it will really work for true generics only
  + added an analogous method "is_specialization" for specializations

Both methods are not used yet, but this will change in the future...

git-svn-id: trunk@23348 -
2013-01-09 09:34:20 +00:00
svenbarth
fdb1950227 Fix for revision 23344.
pgenutil.pas, generate_specialization:
  in case of "assigned(parsedtype)" an ">" could immediately follow (only one type parameter), so don't necessarily expect a type identifier

git-svn-id: trunk@23347 -
2013-01-09 09:12:39 +00:00
paul
97d7a4ff50 compiler: fix indentation
git-svn-id: trunk@23346 -
2013-01-09 01:26:46 +00:00
sergei
d43c38633c * Fixed tMIPSELnotnode.second_boolean do handle QWordBool type correctly and deal with difference between Pascal and C booleans. Also improved it to produce code without macros. Fixes webtbs/tw20874 (and maybe something else).
git-svn-id: trunk@23345 -
2013-01-08 17:43:33 +00:00
svenbarth
27f5e4f582 Fix for Mantis #23547. Basically we now fail with nicer error messages.
pgenutil.pas:
  generate_specialization:
    + instead of giving an internal error if "symname" is empty and "tt" is "nil" we now do an error recovery by parsing the specialization parameters and returning an errordef (this happens if the "generic" type before the "<" is not found)
    * handle "<>" specially by giving an approbiate error message (both when doing a recovery/parsing a generic and during normal specialization)
  parse_generic_parameters:
    * set the "block_type" to "bt_type" to be on the safe side
    * don't continue with inspecting the def (especially hard typecasting) if the found def is not an "objectdef"

Added tests.

git-svn-id: trunk@23344 -
2013-01-08 09:05:11 +00:00
sergei
7530fb3352 * tcgx86.make_simple_ref: handle references to absolute addresses (these are quite rare on x86_64, but still worth to handle correctly).
* If possible, use reference base instead of index, this yields shorter instructions.
* Added comment about offset limits for rip-relative addressing.
- Removed code related to taking threadvar address on win32, it is incorrect because Windows TLS is not directly accessible via segment registers (fs:0x2c points to array of pointers to TLS storages of each module, so at least double indirection is needed).

git-svn-id: trunk@23342 -
2013-01-07 16:00:12 +00:00
sergei
49d7448f44 * Made TElfExeOutput.CreatePLT method protected virtual, so CPU-specific handling can be provided by descendants.
* Handle SHT_GNU_ATTRIBUTES sections (ignore them for now).

git-svn-id: trunk@23339 -
2013-01-07 15:22:04 +00:00
sergei
b197919953 * Handle relocation section prefixes (.rel/.rela) in internal linker script based on ElfTarget.relocs_use_addend, getting rid of $ifdef's.
+ Linker script adjustments for ARM target.

git-svn-id: trunk@23338 -
2013-01-07 15:13:05 +00:00
florian
889b7285b1 * disable record register variables with a size of 2*sizeof(asizeint) on big endian architectures
git-svn-id: trunk@23331 -
2013-01-06 19:46:53 +00:00
Jonas Maebe
39f46d8350 * restored accidentally removed call to fpc_handleerror in r23325
git-svn-id: trunk@23330 -
2013-01-06 19:46:21 +00:00
paul
1508fd427d compiler: handle calling convention of record (class)constructors/destructors later as it is done with other record methods
git-svn-id: trunk@23329 -
2013-01-06 17:04:28 +00:00
Jonas Maebe
69c29a415f * pass the procdef to getintparaloc instead of only the proccalloption, so
that the type of the parameters can be determined automatically
   o added compilerproc declarations for all helpers called in the compiler
     via their assembler name, so we can look up the corresponding procdef

git-svn-id: trunk@23325 -
2013-01-06 15:05:40 +00:00
Jonas Maebe
4ea78538e4 * enabled threading feature for jvm target so that rtl/inc/genmath.inc
compiles again there (it's possible to take the address of arbitrary
    threadvars on the jvm platform, but not of arbitrary other variables)
  - disabled inclusion of generic thread manager and threadvar support
    on the jvm target if the threading feature is enabled

git-svn-id: trunk@23322 -
2013-01-06 15:05:24 +00:00
florian
4f30ac0247 * put records with 16 bytes size into two register on 64 bit targets if possible
* don't put records containing floats into integer registers
* copy&paste error in tcg128.a_load128_const_reg fixed

git-svn-id: trunk@23317 -
2013-01-05 22:58:32 +00:00
sergei
2bba4e2d44 + Stabs debug info needs swapping when linking for different endianness.
* A few minor tweaks for Stabs generation.

git-svn-id: trunk@23316 -
2013-01-05 12:26:23 +00:00
florian
c781f21a46 * records with two times the size of a register can be kept in registers
git-svn-id: trunk@23313 -
2013-01-04 21:48:41 +00:00
florian
b43b4bb455 + pseudo procedure aligned: tells the compiler to assume that the given parameter is naturally aligned, counterpart of unaligned
git-svn-id: trunk@23310 -
2013-01-04 19:13:24 +00:00
florian
fce9e953b4 + nested exit support
git-svn-id: trunk@23309 -
2013-01-04 19:09:04 +00:00
masta
6fabe49828 Readded cutils to compiler/arm/rgcpu.pas for DEBUG_SPILLING
Commit r23306 broke compiling with DEBUG_SPILLING set. Unit cutils will
now be included when DEBUG_SPILLING is set.

git-svn-id: trunk@23308 -
2013-01-04 12:21:54 +00:00
florian
47d43750e4 * remove unused units from uses statements
git-svn-id: trunk@23306 -
2013-01-03 23:07:09 +00:00
florian
318f0e5cab * enable section smartlinking for powerpc-linux to reduce compilation
times, some testing with qemu-ppc showed no problems

git-svn-id: trunk@23305 -
2013-01-03 23:04:29 +00:00
florian
198907797b * don't replace vmt entries of empty methods by FPC_EMPTYMETHOD
if the code is compiled for x86 and returns the result in an fpu register

git-svn-id: trunk@23304 -
2013-01-03 23:01:07 +00:00
florian
7ac9f11cc7 * check if current_procinfo is assigned in paramanager code to avoid crashes
git-svn-id: trunk@23303 -
2013-01-03 23:00:03 +00:00
florian
329257d76e * check for empty procedures after helper test so even empty helper methods cannot be called directly
* don't remove calls to subroutines taking arrays of const

git-svn-id: trunk@23302 -
2013-01-03 22:58:56 +00:00
sergei
d7c5daeccd * Don't calculate data position of each object section. Instead, write out a copy of exesection's memory image, i.e. every objsection is placed at the same offset from its owning exesection both on disk and in memory. This approach is simpler and works regardless of alignment requirements, while existing one could work only if SectionDataAlign<=SectionMemAlign.
* Netware target may be broken by this change; at least it deserves a good cleanup because it contains a lot of code trying to solve similar task: to write exesections without alignment and deal with objsections that are nevertheless being aligned by TExeOutput.

git-svn-id: trunk@23291 -
2013-01-02 10:10:23 +00:00
sergei
35439c0e1d * Moved creation of GOT section into separate virtual method.
* TElfSymtab.WriteSymbol: write type of external symbols as STT_NOTYPE only in object files; external symbols in exe/so files must have type of their resolving symbol.
* TElfObjData.writeReloc_internal: RELOC_RELATIVE needs adjustment by size presumably on x86 only; ARM data relocations don't need it, other CPUs aren't checked yet.
* Use VER_xx and VERSYM_xx constants instead of literal values.

git-svn-id: trunk@23290 -
2013-01-02 08:11:49 +00:00
yury
2dcb174f25 * Always specify dynamic linker name for executables.
git-svn-id: branches/targetandroid@23289 -
2013-01-02 00:53:36 +00:00
yury
9b5511adac * libctype is not needed, since only bionic is supported anyway.
git-svn-id: branches/targetandroid@23285 -
2013-01-01 23:59:48 +00:00
yury
6ccb152647 * Rework of Android startup code. It is needed to always link to libc on android to implement finalization and environment variables in shared libraries.
* Cleanup of Android linker.
* Use only INSERT command in the linker script to inject custom .fpc sections. Whole linker script duplication is nor needed anymore.
* Use BFD linker, since GOLD linker does not support INSERT command. Other incompatibilities may also exist.
* Enable tf_smartlink_sections for i386-android.
* i386-android is broken after this commit. Will be fixed later.

git-svn-id: branches/targetandroid@23284 -
2013-01-01 23:49:12 +00:00
yury
f37a18f600 * Enable weak externals for android.
git-svn-id: branches/targetandroid@23283 -
2013-01-01 23:48:07 +00:00
pierre
1dd964960c * Enable use of amd64 ld GNU linker for i386 by adding target and emul command line args for freebsd
git-svn-id: trunk@23282 -
2013-01-01 23:00:02 +00:00
florian
903f18ea38 * get rid of calls which redirect the program flow only, Bl2B optimization
git-svn-id: trunk@23279 -
2013-01-01 19:31:52 +00:00
florian
24f518f232 + redirect calls to empty virtual methods to FPC_EMPTYMETHOD
* do empty subroutine/method optimization only for O2 and higer

git-svn-id: trunk@23276 -
2013-01-01 16:43:27 +00:00
florian
4d6471fef6 * get rid of calls to empty procedures having parameters without side effect
git-svn-id: trunk@23274 -
2013-01-01 15:58:05 +00:00
florian
ff98d2567c * don't crash on thumb instructions with only two operands when optimizing ADD, SUB, AND statements
git-svn-id: trunk@23272 -
2013-01-01 12:29:48 +00:00
Károly Balogh
8fe2828e5a it seems Coldfire needs tf_requires_proper_alignment, fixes taddr1/2 tests, maybe others too (but someone with clue about RTTI should confirm)
git-svn-id: trunk@23270 -
2013-01-01 04:51:47 +00:00
florian
288820715d * don't crash in case a symbol is not found in type/var/const section
git-svn-id: trunk@23264 -
2012-12-31 20:24:55 +00:00
florian
00af813eee * write supported cpu and fpu types more compact
git-svn-id: trunk@23260 -
2012-12-31 16:45:30 +00:00
florian
a5cc48da0e * write controller types more compact
git-svn-id: trunk@23259 -
2012-12-31 16:31:23 +00:00
florian
c9d8047113 * open config files read only so they can be open by multiple compilers at once
git-svn-id: trunk@23254 -
2012-12-31 14:13:05 +00:00
pierre
eaeb63f86d FreeBSD and OpenBSD also seem to use eax:edx for small strcut returns
git-svn-id: trunk@23253 -
2012-12-29 22:03:17 +00:00
florian
d140c5b4ee * handle inc/dec/pred/succ correctly with type parameters, resolves #23299
git-svn-id: trunk@23248 -
2012-12-29 10:01:54 +00:00
florian
728c074bd6 * accept with statements with generic variables having a generic parameter type, resolves #21329
git-svn-id: trunk@23243 -
2012-12-28 19:48:33 +00:00
florian
f6b78719bc * fix trealconstnode.dogetcopy and trealconstnode.docompare, taking care of all fields, resolves #23486
git-svn-id: trunk@23241 -
2012-12-28 14:16:09 +00:00
florian
feefcb6d3d * don't generate dec for case nodes of unsigned types because dec does not set the carry flag, resolves #23503
git-svn-id: trunk@23229 -
2012-12-27 19:35:58 +00:00
pierre
8b4603ed51 Set OSABI in elf header for openbsd OS, contributed by Pascal Stumpf
git-svn-id: trunk@23224 -
2012-12-26 15:01:38 +00:00
sergei
d967566a37 * Changed TExternalAssembler.CreateSmartLinkPath to use ansistrings (TPathStr), like the rest of file handling routines do.
git-svn-id: trunk@23214 -
2012-12-23 14:11:27 +00:00
sergei
1116bc3542 * Fixed incorrect condition (a linked list always has at least one dummy element) which was causing every unit to have a threadvar table, regardless of actual presence of threadvars. For units without code, this was causing creation of .o files which aren't necessary otherwise.
git-svn-id: trunk@23201 -
2012-12-21 14:13:30 +00:00
sergei
c766c50907 * Proper fix for SPARC cycling with -dCHECK_PIC, pi_needs_got additionally must be set in following cases:
1) tguidconstnode.pass_1 (location is LOC_CREFERENCE)
  2) tonnode.pass_1 (generic secondpass references VMT of exception class)
  3) Conversion from unsigned to floating-point involves 'magic constant' as GOT-relative data object.
  4) Case jumptable address is loaded relative to GOT.

(1) and (2) also provide more accurate setting of pi_needs_got for all targets.

git-svn-id: trunk@23188 -
2012-12-18 17:56:56 +00:00
pierre
658968ef44 Add debugging generation ability for m68k compiler
git-svn-id: trunk@23187 -
2012-12-18 15:57:40 +00:00
pierre
11e743e5b8 Use FPC_INCLUDE_LONGWORD_TO_DOUBLE for m68k
git-svn-id: trunk@23181 -
2012-12-18 15:11:48 +00:00
pierre
ab52c48520 Add DynLinkStr support
git-svn-id: trunk@23180 -
2012-12-18 15:08:59 +00:00
pierre
39219cc30f Also handle fpu_soft
git-svn-id: trunk@23179 -
2012-12-18 15:07:13 +00:00
pierre
2a610e74b7 Also handle fpu_soft
git-svn-id: trunk@23178 -
2012-12-18 15:06:24 +00:00
pierre
080034982f Use GasCpuTypeStr array: GAS uses different names for cpu variants
git-svn-id: trunk@23177 -
2012-12-18 15:04:57 +00:00
pierre
0af0da69b1 New GasCpuTypeStr array: GAS uses different names for cpu variants
git-svn-id: trunk@23176 -
2012-12-18 15:00:38 +00:00
pierre
548a687a17 LOC_FPUREGISTER is not used for func_getretloc ig using fpu_soft
git-svn-id: trunk@23175 -
2012-12-18 14:58:53 +00:00
sergei
0196c62ee8 + Initial work to support versions of ELF dynamic symbols.
git-svn-id: trunk@23170 -
2012-12-18 08:25:57 +00:00
Károly Balogh
7fa067265b small & ugly patch to work around old GNU AS on Amiga, which doesn't know about -march=
git-svn-id: trunk@23160 -
2012-12-17 00:12:30 +00:00
svenbarth
4adb36e8da Add support for generic type constraints. They are currently only useful to stop specialization of a generic. The parsing of a generic is still too lax and needs to be changed in the future...
symconst.pas:
  + extend "tdefoptions" by a "df_genconstraint" which will be used to mark dummy defs that should mainly satisfy the compiler's type checking without to much changes
symsym.pas:
  + add a class "tgenericconstraintdata" which will hold information about the constraints associated with a specific generic type parameter (designed for future extensions)
  + extend "ttypesym" by a reference to a "tgenericconstraintdata" which is written to the ppu only if needed
symtype.pas:
  + add a pointer to "tderef" as this is needed for the ppu reading/writing code for the "tgenericconstraintdata"
pdecl.pas, types_dec:
  + call "parse_generic_parameters" so that constraints are allowed
pgenutil.pas:
  + extend "generate_specialization" by a "parsedpos" to give in the file position of the first parsed parameter (needed for correct error locations when checking the constraints)
  + add an overloaded call of "generate_specialization" to differentiate between the use cases "first parameter parsed by generate_specialization" and "first parameter parsed by other code"; this also allows to write the "fillchar" for the "parampos" parameter only once ( => otherwise a warning is triggered => error in compilation)
  + extend the "parse_generic_specialization_types" by a "poslist" parameter which will contain the positions of all parsed type parameters (can only be used in the case that all parameters are parsed)
  * move the original code of "parse_generic_specialization_types" to a new procedure "parse_generic_specialization_types_internal" which take an additional "parsedpos" parameter which will be added to the "poslist" before all others; "parse_generic_specialization_types" calls this new procedure with a dummy argument (which won't be used)
  + extend "parse_generic_parameters" by the parsing of generic constraints which constructs correct defs for the parameters and fills in the new "tgenericconstraintdata" object for each parameter (note: the "constructor" constraint is only parsed for Delphi compatibility and basically means the same as a "class" constraint... (it's a relict of Delphi.NET))
  * adjust "insert_generic_parameter_types" as specializations and generics can no longer be differed by whether the type parameters are of type "undefineddef"
pdecsub.pas, parse_proc_head, consume_generic_interface:
  * adjust call to "generate_specialization"
  + add a new function "check_generic_constraints" which is used from within "generate_specialization" to ensure that the given specialization parameters are compatible with the constraints of the generic parameters
ptype.pas:
  * single_type: adjust call to "generate_specialization"
  * read_named_type, expr_type: adjust call to "generate_specialization"
  + write_persistent_type_info: don't write typeinfo for constraints
pexpr.pas, sub_expr:
  * adjust call to "generate_specialization"
* adjusted ppudump, because of added "tdefoptions.df_genconstraint" value

+ added tests for generic constraints
* modified test for class helper inside a generic which extends a class type parameter
+ added test for record helper inside a generic which extends a record type parameter

git-svn-id: trunk@23158 -
2012-12-16 13:44:58 +00:00
florian
e4b0c1b284 + lazarus compiler project for aarch64
git-svn-id: trunk@23157 -
2012-12-16 12:35:02 +00:00
sergei
c73ec250a6 + Endian-swapping procedures for version (TElfverneed, etc.) records.
git-svn-id: trunk@23155 -
2012-12-16 09:43:48 +00:00
sergei
0aa7204707 + Added codes of dynamic relocations to TElfTarget; since most targets use similar dynamic relocation model differing only in code values, this will allow to do majority of handling in the base class.
git-svn-id: trunk@23154 -
2012-12-16 09:36:34 +00:00
Jonas Maebe
c37c039905 * report resolveref errors on the correct line number
git-svn-id: trunk@23153 -
2012-12-15 22:54:22 +00:00
Jonas Maebe
6ac8b4fbdf * give a proper error when an mmx/fpu/sse register is used inside a memory
reference (mantis #23441)

git-svn-id: trunk@23152 -
2012-12-15 22:47:16 +00:00
Jonas Maebe
68dd05e259 * fixed std_regname() for xmm registers with custom sizes
* fixed findreg_by_number() for xmm registers with R_SUBNONE
    (from the assembler reader)

git-svn-id: trunk@23151 -
2012-12-15 22:47:12 +00:00
Jonas Maebe
6e9a8c9187 * write node flags to log file instead of to stdout
git-svn-id: trunk@23150 -
2012-12-15 22:47:07 +00:00
svenbarth
9ef4a35a7b Fix the fix for Mantis #21538. The check never really worked up to now...
defcmp.pas, compare_defs_ext:
  use "equal_defs" instead of a reference comparison to check whether the type defs are equal
pgenutil.pas, insert_generic_parameter_types:
  * add to each (specialized) generic parameter the "sp_generic_para" flag so that it will be added to the "genericparas" list upon ppu loading
  * add the generic parameter to the genericparas list as well, so that the comparison in "compare_defs_ext" is triggered at all... (up to now the list was always empty -.-)
ppu.pas:
  * increase PPU version

git-svn-id: trunk@23149 -
2012-12-15 21:43:52 +00:00
sergei
db72b8d7fd * TCGMips.a_loadfpu_reg_cgpara: temps of type Double need 8-byte alignment, according to description of sdcX/ldcX instructions. Using TCGSize2Size to specify alignment is somewhat weird, but it is being used in other CPU back-ends and looks working.
git-svn-id: trunk@23146 -
2012-12-15 08:47:11 +00:00
florian
db68214e88 + support setpeoptflags directive, resolves #23447
git-svn-id: trunk@23132 -
2012-12-10 19:17:25 +00:00
Jonas Maebe
d180d6f241 * fixed size of movzx/movsx with 64bit operand in x86-64 Intel asm reader
git-svn-id: trunk@23131 -
2012-12-09 22:42:52 +00:00
florian
2ea6979277 * handle Movzl/Op/Mov optimization correctly, resolves #23431
git-svn-id: trunk@23128 -
2012-12-09 21:27:05 +00:00
sergei
00ca4a74a3 * Reworked/fixed TExeSymbol.State behavior:
* Added symstate_undefweak for undefined symbols having only weak references to them, this state is removed when a normal reference to symbol is seen.
  * Use a separate boolean property to determine if ExeSymbol is referenced.
  * Use a separate property TExeOutput.AllowUndefinedSymbols to suppress error messages when linking dynamic shared objects.
  * Don't issue InternalError when an undefined symbol is encountered during unused section removal.

git-svn-id: trunk@23127 -
2012-12-09 08:02:58 +00:00
sergei
a771d68685 * Fixed a bug introduced in r23077: relative_reloc_count must be increased only once per GOT entry, not every time a relocation to that entry is seen.
git-svn-id: trunk@23126 -
2012-12-09 06:39:43 +00:00
sergei
a7eab8ff67 * TElfObjInput: Factored section creation code into separate method which can be called by CPU-specific routines.
+ Load SHT_INIT_ARRAY,SHT_FINI_ARRAY,SHT_PREINIT_ARRAY section types.

git-svn-id: trunk@23124 -
2012-12-08 11:26:38 +00:00
sergei
59593f86a7 + Some more ELF definitions (related to symbol versioning).
git-svn-id: trunk@23119 -
2012-12-06 18:24:44 +00:00
sergei
36859068f5 * Propagate AS_NEEDED flag further into Load_DynamicObject and handle it properly: shared objects marked with AS_NEEDED are added to dependencies only if they actually resolve some symbol.
* Dropped TObjInput.newObjData method. Instead, TObjData instances are created directly in ReadObjData, this gives possibility to create a different type of TObjData based on file header.
- Dropped TObjInput destructor, it does nothing except calling inherited.

git-svn-id: trunk@23118 -
2012-12-06 18:19:19 +00:00
Jonas Maebe
29095e9dd3 * fixed if-simplication for C-style booleans by considering all values
different from 0 to be "true", instead of only 1 (patch by Jeppe Johansen,
    mantis #23436)

git-svn-id: trunk@23117 -
2012-12-06 15:18:58 +00:00
sergei
7d19a6d551 * Propagate AS_NEEDED flag down the expression tree an assign it to TStaticLibrary objects.
git-svn-id: trunk@23116 -
2012-12-05 16:05:16 +00:00
sergei
67a41e1e94 * Fixed 2 bugs introduced in r22951:
* Require symbol table presence only in dynamic objects; relocatable objects may not contain one (example is crtn.o).
  * Attempt to write relocations from dynreloclist regardless of relative_reloc_count, the latter is typically 0 in executables.

git-svn-id: trunk@23115 -
2012-12-05 15:49:45 +00:00
florian
8e5bd14e3a * overleft newline fix
git-svn-id: trunk@23110 -
2012-12-03 21:56:01 +00:00
florian
e6863aeb80 * typo fixed, patch by Mark Morgan Lloyd
git-svn-id: trunk@23108 -
2012-12-03 21:55:09 +00:00
florian
69d96d9bf9 * modified patch by Mark Morgan Lloyd to pass cpu type to the assembler, resolves #23390
git-svn-id: trunk@23107 -
2012-12-03 21:54:37 +00:00
sergei
c4d8396158 * Function RelocName made a member of TElfTarget, so it can be used outside of TElfExeOutput class.
* Methods ReportNonDSOReloc and ReportRelocOverflow moved to TElfExeOutput, they are applicable to all target-specific descendants.

git-svn-id: trunk@23094 -
2012-12-02 13:05:53 +00:00
svenbarth
5adb28a935 m68k/aasmcpu.pas, taicpu.spilling_get_operation_type:
+ NEGX is a readwrite instruction

git-svn-id: trunk@23093 -
2012-12-02 11:48:57 +00:00
sergei
d79761c607 * Changed TElfTarget from class to record, so it can contain data members while remaining statically allocated.
* Moved target-dependent constants into ElfTarget records, eliminates a lot of $ifdef's in ogelf.pas.
+ Added TElfTarget.loadsection hook and pass unknown sections to it.

git-svn-id: trunk@23090 -
2012-12-02 11:15:35 +00:00
sergei
006d795797 * Moved TElfsechdr into interface and cleaned up some ugliness in TElfObjInput code caused by TElfsechdr being not publicly available. Providing target-specific section loading becomes easier now as well.
git-svn-id: trunk@23087 -
2012-12-02 10:02:21 +00:00
sergei
8688f5e7b9 * Moved ELF definitions into a separate unit, which can be reused by CPU back-end units.
git-svn-id: trunk@23086 -
2012-12-02 09:50:15 +00:00
sergei
eb13da9355 * ognlm.pas cleanup:
- removed redundant assigned() checks before .Free
  - removed DataPos_ExeSection method which only calls inherited
  - removed all references to RelocSections variable, it's safe because TExeOutput doesn't handle it since r21971.

git-svn-id: trunk@23085 -
2012-12-01 15:25:34 +00:00
sergei
73030ddb57 + Support smart-linked .rdata section with external linker for Windows targets after r23025.
git-svn-id: trunk@23084 -
2012-12-01 15:04:23 +00:00
sergei
129d737523 + Allow TObjRelocation to be created without a symbol, such relocations are being used to tag specific positions on non-x86 targets.
* Write relocation format dependent dynamic tags based on actual sh_type of dynamic relocation sections, instead of global relocs_use_addend flag.
* Don't write DT_REL[A]COUNT tag if .rel[a].dyn section is not present.

git-svn-id: trunk@23083 -
2012-12-01 13:38:28 +00:00
pierre
93b2c1a717 Use dwarf2 as default debug format for Win64 target OS
git-svn-id: trunk@23081 -
2012-11-29 14:20:13 +00:00
sergei
a730830c19 * Factored code for allocating GOT slots into TElfExeOutput.AllocGOTSlot.
* Changed signature of GOTRelocPass1 to pass relocation index instead of relocation itself, because sometimes (e.g. when doing TLS relaxation) we need to process several subsequent relocations at once.

git-svn-id: trunk@23077 -
2012-11-29 06:37:28 +00:00
Jonas Maebe
a1923f02f8 * always mark symbols referenced by properties as "used"; in case the
property is private, the "used" tracking of the property itself will
    indicate whether the symbol is actually used (mantis #22155)

git-svn-id: trunk@23070 -
2012-11-27 16:40:51 +00:00
Jonas Maebe
2dac1c445a - disabled Stabs support on 64 bit targets (mantis #23365)
* show a warning if an unsupported debug format is selected

git-svn-id: trunk@23056 -
2012-11-24 13:15:58 +00:00
Jonas Maebe
d749ac5354 * make ansistring unique before starting to change it using a pchar
git-svn-id: trunk@23055 -
2012-11-24 13:15:54 +00:00
Jonas Maebe
c7255f153e * sets with the same base/range can still have a different size (and hence
not be equal) due to different packset settings -> still need conversion
    (mantis #23204)

git-svn-id: trunk@23054 -
2012-11-24 12:32:57 +00:00
masta
e982f4789d Removed unused register allocation in tarminlinenode.second_abs_long
git-svn-id: trunk@23047 -
2012-11-22 19:20:39 +00:00
pierre
d956808080 Fix bug introduced by myself for win32 dwarf info generation Bug #23365 and 23330
git-svn-id: trunk@23046 -
2012-11-22 13:49:21 +00:00
Jonas Maebe
dfe3ca5328 * prevent invalid typecast on targets using nestedfpstruct functionality
in case of type errors in the source (the compiler will already have
    printed an error at this point)

git-svn-id: trunk@23044 -
2012-11-22 12:22:00 +00:00
Jonas Maebe
3eb527b532 * make use_fixed_stack for i386 more generic (any target with more than
4 byte stack alignment needs a fixed stack)

git-svn-id: trunk@23043 -
2012-11-22 12:17:52 +00:00
florian
4aca018f62 * setelement nodes itself should not be considered, since setelement
nodes generate no code except loading data into registers, this does
  not hurt, resolves #23342

git-svn-id: trunk@23039 -
2012-11-20 21:15:38 +00:00
sergei
a7e7d97da6 * ELF linker: fixed written values of STT_TLS symbols, they must be relative to PT_TLS segment address.
* Made name of dynamic interpreter variable, it is now set correctly for each target.
- Removed setting header flags for ARM. This functionality belongs to CPU-specific unit anyway, and probably must be implemented using object attributes in modern ABIs.

git-svn-id: trunk@23032 -
2012-11-19 09:07:45 +00:00
florian
ab1815273c + added comment on movsd hack
git-svn-id: trunk@23031 -
2012-11-18 21:34:38 +00:00
florian
d49a88c3c8 * merge fixes by Torsten Grundke
git-svn-id: trunk@23030 -
2012-11-18 21:18:49 +00:00
florian
2aaa7514f4 + started cpupara for aarch64
git-svn-id: trunk@23029 -
2012-11-18 20:42:11 +00:00
sergei
0369a30f49 * Internal linker: made sec_rodata_norel read-only.
* For Win32 and Win64 targets made sec_rodata read-only, too (for these targets it doesn't matter if read-only section contains relocations).

git-svn-id: trunk@23025 -
2012-11-18 17:40:17 +00:00
florian
a42b934c69 * introduce FPC_SUPPORT_X87_TYPES_ON_WIN64 define which allows to build
a win64 compiler support the x87 types extended and comp/currency handled by the FPU, this
  requires to use a i386 compiler as starting compiler and cross compilation because the starting
  compiler must support the 80 bit extended type

git-svn-id: trunk@23023 -
2012-11-18 17:30:51 +00:00
florian
45f60bc4b5 * small changes (copyright, typo, readability)
git-svn-id: trunk@23022 -
2012-11-18 17:28:30 +00:00
florian
f6109d7c65 * improved error reporting by printing the type being found in with expressions
git-svn-id: trunk@23019 -
2012-11-18 17:09:36 +00:00
florian
0e92f68032 - 2.0 overlefts removed
git-svn-id: trunk@23018 -
2012-11-18 17:07:57 +00:00
sergei
afd34cf9d5 * Changed section for ansi/wide/unicodestring constants, resourcestrings (content only) and dataconstnodes from sec_rodata to sec_rodata_norel, because they never contain relocations.
git-svn-id: trunk@23017 -
2012-11-18 17:00:18 +00:00
sergei
2c011312db * Changed TElf32Header and TElf64Header definitions, making them look closer to canonical ones (first 16 bytes are a single array field, addressable via EI_xx indices).
git-svn-id: trunk@22999 -
2012-11-16 17:05:06 +00:00
sergei
1aea22a6ca + Internal linker: generic and ELF-specific support for grouped sections, allow same symbol to be defined in several COMDAT groups.
* ELF linker: don't make unresolved weak symbols dynamic if linking statically (-Xt in command line).
* Now internal linker produces working executable for tw14265 also on i386-linux when compiling manually (still unable to locate required libraries when run from test suite).

git-svn-id: trunk@22987 -
2012-11-15 13:41:25 +00:00
Jonas Maebe
cb41d6355c * clarified -Cb explanation (mantis #23308)
git-svn-id: trunk@22982 -
2012-11-12 10:34:00 +00:00
Jonas Maebe
d9e67fc835 * don't add a separate high parameter for array-of-const parameters on the
JVM target (just like for open array parameters), since the array length
    is already encoded in the array itself there

git-svn-id: trunk@22968 -
2012-11-10 20:26:42 +00:00
florian
d67f31a0e1 * allow type parameters variables being passed to new/dispose, resolves #23270
git-svn-id: trunk@22963 -
2012-11-09 20:46:30 +00:00
sergei
49501413e1 + Support library grouping in internal linker script, use it to load C libraries.
git-svn-id: trunk@22962 -
2012-11-09 14:38:11 +00:00
sergei
8ff1d76239 + x86_64/cpuelf.pas: Support writing RELATIVE relocations separately from other ones.
+ i386/cpuelf.pas: Support R_386_TLS_IE and R_386_TLS_LE relocations.

git-svn-id: trunk@22961 -
2012-11-09 14:22:37 +00:00
Jonas Maebe
4aa05f5133 + support for automatically generating setters/getters for properties on the
JVM target, since Java bytecode itself has no support for properties and
    hence exposing properties to external Java code can only be done through
    getters/setters. Use the new parameters to do so:
      -CTautogetterprefix=XXX
      -CTautosetterprefix=YYY
    The getter/setter will get the same visibility as the property. If a
    getter/setter with the same naming convention was already specified for a
    property and this getter/setter is declared in the same class as the
    property, then the visibility of this existing getter/setter is
    modified and no new routine is generated.

    Newly generated getters/setters are virtual methods, because that is
    the only way in Java bytecode to allow redefining these getters/setters
    in child classes. However, that also means that using these switches can
    change the behvaviour of code, since normally the used property definition
    is only determined by the declared type of its associated class instance,
    and not by the actual instance type. The compiler will therefore warn when
    such an automatically generated getter/setter is overridden by another
    automatically generated getter/setter in a child class.

git-svn-id: trunk@22959 -
2012-11-08 20:18:08 +00:00
Jonas Maebe
1c32590294 + added search_struct_member_no_helper() to search a struct for a symbol
without looking inside helpers

git-svn-id: trunk@22958 -
2012-11-08 20:18:03 +00:00
Jonas Maebe
bc6f078247 * don't create the synthetic routines if any errors occurred, since that
will likely only cause more errors (or, in the worst case, internal
    errors)

git-svn-id: trunk@22957 -
2012-11-08 20:17:58 +00:00
Jonas Maebe
c4a55f5481 * store the "synthetic kind" information about procdefs in ppu files,
required by future patch

git-svn-id: trunk@22956 -
2012-11-08 20:17:53 +00:00
Jonas Maebe
5929ec5592 * turned getpropaccesslist, add_parameters and add_index_parameter into
methods of tpropertysym (refactoring)
  * turned code to copy the contents of a property into another one
    into a method of tpropertysym (refactoring)

git-svn-id: trunk@22955 -
2012-11-08 20:17:48 +00:00
Jonas Maebe
cf717c4b75 * use -iphone_os_min rather than -ios_version_min, because the former
(older) version of the parameter is still supported by current linker
    versions, but the older version isn't supported by older linker
    versions

git-svn-id: trunk@22954 -
2012-11-08 20:17:42 +00:00
sergei
277200e7ae + ELF linker: Support writing RELATIVE dynamic relocations ahead of the rest, and their number in DT_REL[A]COUNT dynamic tag (still needs changes in CPU-specific code to function properly).
* TElfObjInput.LoadSymbols: ignore STT_SECTION symbols for sections that were ignored in LoadSections().
* TElfObjInput: changed symtabndx (index of .symtab/.dynsym section) into field and its type to unsigned.

git-svn-id: trunk@22951 -
2012-11-08 11:10:01 +00:00
pierre
5ad752ab70 Avoid range check error in IDE by changing value of sfHasMemInfo constant to fit with longint value
git-svn-id: trunk@22947 -
2012-11-07 16:22:57 +00:00
florian
761fcca4ec + is_dynamicstring
+ implement low/high for dynamic strings, resolves #15244 and #22936
+ basic support for $zerobasedstrings directive

git-svn-id: trunk@22933 -
2012-11-04 21:48:53 +00:00
svenbarth
1bc47815be m68k/cgcpu.pas, tcg64k.fixref:
* in the case of ref.base + ref.symbol always add the base to the index; with this the compiler now cycles for Coldfire

git-svn-id: trunk@22931 -
2012-11-04 20:29:22 +00:00
svenbarth
a4f390e4d9 m68k/cgcpu.pas, tcg64f68k:
+ a_op64_reg_reg: add support for "NEG" and "NOT" of 64-bit values
  + a_op64_const_reg: make sure that we know whether a NEG or NOT with a constant is performed

git-svn-id: trunk@22930 -
2012-11-04 20:27:01 +00:00
florian
bc4a8ac63e + constant postfixoperator_tokens
+ check for postfix operators after string contants, resolves #23136

git-svn-id: trunk@22929 -
2012-11-04 19:21:19 +00:00
svenbarth
2038a607ac cg64f32.pas, tcg64f32.a_load64_*_cgpara:
* since m68k is 1) a big endian system and 2) a system without a fixed stack (thus we use a push-equivalent) we need to swap the order of the hi and lo longwords of a 64-bit value when passing it to a function

git-svn-id: trunk@22928 -
2012-11-04 19:12:57 +00:00
svenbarth
22552e468b m68k/cgcpu.pas, tcg68k.g_concatcopy:
* in case of copying from the parameter location to the local location we need to use the alignment size for the source as byte/word values are passed as LongInts (this is how the ABI is specified)

git-svn-id: trunk@22924 -
2012-11-04 16:11:16 +00:00
svenbarth
30f006d751 m68k/cgcpu.pas, tcg64f68k.a_op64_const_reg:
* use the correct register for the high value

git-svn-id: trunk@22923 -
2012-11-04 16:08:37 +00:00
florian
0b30b0fd5a * re-enable jump tables for x86-64, they are fixed, see also
http://www.hu.freepascal.org/lists/fpc-devel/2012-June/029141.html

git-svn-id: trunk@22921 -
2012-11-03 22:14:45 +00:00
joost
55d03b775e * Within the LaTeX help-text, underscores have to be escaped.
git-svn-id: trunk@22920 -
2012-11-03 17:07:59 +00:00
sergei
d019670495 - Removed generic implementation of TObjData.sectionname, its existence is useless because it is completely overridden by all TObjData descendants.
- Removed separate ELF section names for PIC. The only difference was .data named .data.rel; however .rel suffix has nothing to do with PIC. It only signifies that the section has relocations so such sections can be grouped together in output file and reduce number of pages for dynamic linker to visit  while resolving the relocations at load time. At the same time, no existing link scripts distinguish between .rel and any other suffix (except .rel.ro, but it's a different story), meaning that long section names will break .rel grouping.
While support for .data.rel can be added similar to existing rodata handling (separate sec_data and sec_data_norel sections), this doesn't seem worth the trouble.

git-svn-id: trunk@22915 -
2012-11-02 08:03:54 +00:00
sergei
4410fe86d2 * ELF linker: moved some code (which must be executed only once when linking with separate debug file) from MemPos_Start into AfterUnusedSectionRemoval, this removes some checks and simplifies things.
* Simplified .shstrtab handling between passes by using oso_debug_copy attribute on it.
- Don't recreate segment mapping: only debug sections are removed between passes, and they are never part of any segment.

git-svn-id: trunk@22914 -
2012-11-02 06:41:03 +00:00