Commit Graph

1015 Commits

Author SHA1 Message Date
Jonas Maebe
aee5380ae0 * merged trunk up to r20882
o support for the new codepage-aware ansistrings in the jvm branch
   o empty ansistrings are now always represented by a nil pointer rather than
     by an empty string, because an empty string also has a code page which
     can confuse code (although this will make ansistrings harder to use
     in Java code)
   o more string helpers code shared between the general and jvm rtl
   o support for indexbyte/word in the jvm rtl (warning: first parameter
     is an open array rather than an untyped parameter there, so
     indexchar(pcharvar^,10,0) will be equivalent to
     indexchar[pcharvar^],10,0) there, which is different from what is
     intended; changing it to an untyped parameter wouldn't help though)
   o default() support is not yet complete
   o calling fpcres is currently broken due to limitations in
     sysutils.executeprocess() regarding handling unix quoting and
     the compiler using the same command lines for scripts and directly
     calling external programs
   o compiling the Java compiler currently requires adding ALLOW_WARNINGS=1
     to the make command line

git-svn-id: branches/jvmbackend@20887 -
2012-04-15 15:54:10 +00:00
Jonas Maebe
188677ea91 * fixed the offset of memory parameters allocated via getintparaloc():
the register parameters are not put on the stack, so don't count them
    (only makes a practical difference for fixed stack targets, fixes
     random crashes with webtbs/tw3870 on Darwin/i386)

git-svn-id: trunk@20499 -
2012-03-10 18:01:22 +00:00
florian
fc569e224d * handle all operand combinations of xadd, resolves #21146
git-svn-id: trunk@20177 -
2012-01-25 21:26:59 +00:00
sergei
e11c880b1e x86 assembler improvements:
* Don't generate rex.w for "CALL|JMP|LCALL|LJMP regmem", they are 64-bit by default.
* LCALL,LJMP flagged as calljump instructions.
* LCALL,LJMP encode only far jumps and don't accept register operands.
* GAS writer: fixed writing rip-relative operands of calljump instructions.
+ test.

git-svn-id: trunk@19413 -
2011-10-08 11:34:04 +00:00
florian
111d05c68f o patch by Alexander Shishkin, resolves #20409
* eliminate warnings in compiler (i386 & i368->x86_64) and minor refactorings
    - comment out unused vars and types
    - comment out unneeded comparisons (Longword <=> 0)
    - suppress some "comparison always true|false" warnings
    - tweak visiblity sections

git-svn-id: trunk@19385 -
2011-10-05 20:11:09 +00:00
sergei
c6d382fe18 * Moved procedure genlinearlist from ti386casenode to tx86casenode. This optimization works well on x86_64, resulting in approximately twice less instructions than when using generic code.
git-svn-id: trunk@19363 -
2011-10-04 11:48:33 +00:00
florian
d7f7a9bb76 * patch by Alexander Shishkin to clean up $ifopt usage by $push/$pop, resolves #20346
git-svn-id: trunk@19256 -
2011-09-27 20:22:40 +00:00
sergei
d94460e3b3 * Made the x86-specific scalefactor optimization of tvecnode available on x86_64 as well, by moving update_reference_reg_mul method from ti386vecnode to newly introduced tx86vecnode.
git-svn-id: trunk@19245 -
2011-09-26 12:58:59 +00:00
florian
4868b09844 * patch by alexvin to replace $ifopt by $push/$pop, resolves #20332
git-svn-id: trunk@19239 -
2011-09-25 21:19:50 +00:00
florian
e8dafe4dde * fixed change information for a lot of sse instructions
git-svn-id: trunk@18787 -
2011-08-20 12:28:49 +00:00
Jonas Maebe
28740dce2d - removed extra "fordefinition" parameter again from tprocdef.mangledname(),
since the definition-specific adorning of JVM mangled names is Jasmin-
    specific, and such code has no place in symdef
  * moved code to adorn JVM mangled names for Jasmin definitions to agjasmin

git-svn-id: branches/jvmbackend@18346 -
2011-08-20 07:49:31 +00:00
Jonas Maebe
b023627f6a * converted tcgcasenode.pass_generate_code() to hlcgobj
o changed type of opsize field of tcgcasenode from tcgsize into tdef,
     and fixed compilation of other code generator units after this change

git-svn-id: branches/jvmbackend@18339 -
2011-08-20 07:48:33 +00:00
Jonas Maebe
b837694207 * factored out releasing an unused return value into
release_unused_return_value_cpu(), so it can be cleanly
    overridden by cpu-specific code

git-svn-id: branches/jvmbackend@18322 -
2011-08-20 07:45:44 +00:00
Jonas Maebe
71deda6f50 + added interface to ncgutil.gen_load_loc_cgpara() to hlcgobj + generic
implementation (without loc_©mmregister support)
  * moved ncgutil.gen_load_return_value() to hlcgobj, and factored out
    architecture-specific behaviour to load an uninitialised function result
    into a virtual method (+ JVM-specific implementation of that method),
    gen_load_uninitialized_function_result()
  + added hlcgx86 unit and thlcgx86 type to override the
    thlcgobj.gen_load_uninitialized_function_result() method for x87
    function results; the i386 and x86_64 units now instantiate thlcgx86
    instead of thlcg2ll
  * moved calling of ncgutil.gen_load_loc_cgpara() from ncgcal also to hlcgobj
  -> returning function results works for JVM

git-svn-id: branches/jvmbackend@18317 -
2011-08-20 07:38:16 +00:00
Jonas Maebe
0ee702b3a2 * tprocdef.mangledname now gets an extra boolean parameter indicating
whether the mangled name is for defining a symbol, or for referencing
    it later (e.g. for a call or load of its address). The reason is that
    on the JVM both cases are different.
  + jvmdef unit to encode types according to the JVM rules
  + tprocdef.jvmmangledname() to encode a procdef's JVM mangled name
    (the common part of defining/referencing it; tprocdef.mangledname
     afterwards adorns it as required)

git-svn-id: branches/jvmbackend@18288 -
2011-08-20 07:22:00 +00:00
Jonas Maebe
72e9cfee24 * create/destroy also the high level code generator for all architectures,
so it can be used in generic code

git-svn-id: branches/jvmbackend@18280 -
2011-08-20 07:21:16 +00:00
florian
c011949765 + iretq for x86_64
git-svn-id: trunk@18273 -
2011-08-19 12:56:26 +00:00
florian
8308b46a94 + support for assembler instructions with four operands
+ support for insertq, resolves #19910

git-svn-id: trunk@18206 -
2011-08-14 16:46:35 +00:00
florian
ff5f311b34 - removed no more used constants
git-svn-id: trunk@18199 -
2011-08-13 20:54:01 +00:00
sergei
0231863fce + Added missing PMULLD instruction, part of Mantis #19910
git-svn-id: trunk@18106 -
2011-08-06 06:59:33 +00:00
pierre
cff85bdb3b * Rename ag386nsm.pas unit source to agx86nsm.pas
git-svn-id: trunk@17933 -
2011-07-04 09:13:55 +00:00
pierre
f6ab12d677 * Move ag386nsm.pas to x86 directory
git-svn-id: trunk@17932 -
2011-07-04 09:08:54 +00:00
florian
a6b2fcfe22 * fixes breakage of r17766, should resolve #19598
git-svn-id: trunk@17814 -
2011-06-23 21:30:40 +00:00
florian
b00a610aec * optimize andb/w const,reg andw/l const,reg sequences as well
git-svn-id: trunk@17766 -
2011-06-18 15:22:09 +00:00
florian
ce76ce8769 * fixed wrong tmpref usage as mentioned by Pierre on the mailing list
git-svn-id: trunk@17754 -
2011-06-14 18:48:22 +00:00
sergei
354d0520b7 + x86 assembler: fixed MOVABS instruction (it is a x86_64-only subset of MOV with 8-byte immediates/offsets) and same-form encodings of MOV instruction.
git-svn-id: trunk@17666 -
2011-06-05 17:32:18 +00:00
florian
69e7d8b02f * generate correct PIC in tcg386.a_loadaddr_ref_cgpara, resolves #19464
git-svn-id: trunk@17657 -
2011-06-04 16:57:45 +00:00
sergei
5bda700410 * External assemblers: moved some common code into the base class, 4 copies reduced to one.
git-svn-id: trunk@17561 -
2011-05-26 13:10:49 +00:00
sergei
d89aeeadaf x86 assembler:
* Adjust rip-relative offsets using values known from calcsize, instead of reinterpreting the tail of instruction. This is simpler and remains the same regardless of particular codes used in opcode table.
* Reduced maxinfolen to 8.
- 'jmp imm64' and 64-bit versions of 'in' do not exist, removed.

git-svn-id: trunk@17546 -
2011-05-23 20:43:50 +00:00
sergei
504e0c6816 x86 assembler fixes:
* mkx86ins.pp: 'regmem' operand type in x86ins.dat must be converted to OT_RM_GPR, not OT_REGMEM. The latter does not restrict register type, allowing to use e.g. xmm registers in place of regular ones. 
* Finished 'movd' and 'movq', added some tests for them to tasm2.pp.

git-svn-id: trunk@17515 -
2011-05-20 20:39:35 +00:00
sergei
1aa5c4ac0e * Fixed wrong ModRM byte in movq encoding, causing regression of test/cg/tcalext6 in r17490.
git-svn-id: trunk@17493 -
2011-05-18 14:55:26 +00:00
sergei
9e8a31193b x86 assembler:
* Optimized the opcode representation of movq and remaining 3DNow instructions
* Disallow immediates not fitting in 32 bits (Mantis #14685) + test
* Disallow push/pop with 32-bit operands in x86_64 + test

git-svn-id: trunk@17490 -
2011-05-17 20:06:12 +00:00
sergei
c28197bac3 * PSADBW second operand is xmmrm, not xmmreg
+ A couple of tests related to the recent assembler changes

git-svn-id: trunk@17460 -
2011-05-14 18:59:06 +00:00
florian
77f2d6cc0d * introduce usage of TCGInt in the code generator units
git-svn-id: trunk@17459 -
2011-05-14 17:58:23 +00:00
sergei
958954890e A big update of x86 instruction table, part 2:
- Removed remaining address-size control codes \300 and \301
- Also removed codes \323, they are no longer necessary once REX is being written on the first literal.

git-svn-id: trunk@17457 -
2011-05-14 16:36:42 +00:00
sergei
3b979fef6d * Re-commit r17437 after more testing and fixing aasmcpu.pp in r17449.
git-svn-id: trunk@17452 -
2011-05-14 11:04:52 +00:00
sergei
b257231203 * Revert r17437, it breaks builds with -O2 and builds on i386 (although -O- on x86_64 is ok).
git-svn-id: trunk@17439 -
2011-05-12 23:53:18 +00:00
sergei
1d81a1244b A big update of x86 instruction table, part 1 (mostly SIMD instructions):
* Using ot_mmxrm and ot_xmmrm operand types to match arguments, reduces number of required entries by half.
* Replaced all literal $66, $F2 and $F3 prefixes with control codes (\361, \334 and \333, respectively).
* Prefix control codes imply writing REX, so code \323 after them is no longer necessary, removed.
* Fixed technology flags (SSSE3, SSE4.1, SSE4.2)
- Removed codes \300 and \301 (intended to generate address size prefix). FPC does not support this feature (the prefix itself is generated, but process_ea rejects operands needing non-default address size). Probably we don't even need to support it. But if we do, a much simpler solution is check all operands, like today's NASM does.
* Fixed/added some instructions along the way, namely CRC32, UNPCKHPD, CMPNEQSD.

git-svn-id: trunk@17437 -
2011-05-12 19:49:19 +00:00
sergei
de8ae0f873 x86 assembler improvements:
* Simplified REX handling: instead of useless adjusting instruction length on every REX change, adjust it just once, based on the final REX value.
* Similar for omitting REX.W in certain instructions: set a flag and consider it once the entire instruction has been processed. This removes the requirement for \335 to be the last opcode.
* maybewriterex also after $F2 prefix
* Fixed behavior of codes \310 and \311 (16- and 32-bit address respectively), this is needed for a few fancy instructions like LOOP and JCXZ, which honor address-size prefix instead of REX.
+ control code \361 for $66 prefix
+ IF_SSSE3, IF_SSE41, IF_SSE42 instruction flags (with dummy values)

x86/x86ins.dat:
* replaced literal $67 prefixes with \310 or \311
* marked encodings containing code \310 as NOX86_64
* replaced literal $48 prefixes with \326

git-svn-id: trunk@17433 -
2011-05-12 13:09:51 +00:00
sergei
6739cec2b9 * Flagged with NOX86_64 instructions/encodings that are invalid in 64-bit mode.
* AESKEYGENASSIST is not ATT-specific name, it is used by Intel-style assemblers as well. Also updated tests/test/taes1.pp to reflect the change.
+ Added SCASQ, resolves #16730 (other opcodes mentioned in that report were added/fixed earlier)

git-svn-id: trunk@17431 -
2011-05-11 15:50:59 +00:00
sergei
9bb0dc6cfe * mkx86ins.pp: ot_signed flag must not be set by literal opcodes. Ignore 2- and 3-byte literal sequences, not just 1-byte ones.
* x86ins.dat: replaced codes \17 with literal zeros. They aren't necessary for FPC, and they were removed from NASM quite a while ago.

git-svn-id: trunk@17430 -
2011-05-11 12:31:18 +00:00
Jonas Maebe
a08989a76b * zero/sign extend parameter values and return values < 32 bit to 32 bit on
x86_64 (mantis #19269)
  * this is also required for darwin/i386 and was already done there for
    parameters, but not yet for return values

git-svn-id: trunk@17388 -
2011-05-01 11:33:29 +00:00
pierre
af32b57170 * increase op2strtable size to string[15] and rectify askeygen to askeygenassist for ATT
git-svn-id: trunk@17358 -
2011-04-21 13:38:20 +00:00
sergei
f97f223de6 x86_64 assembler reader improvements:
+ Added new value TAttSuffix.attsufINTdual, assigned it to movsX and movzX instructions
* Moved suffix-to-size translation tables from rax86att.pas to itcpugas.pas
+ Added x86_64 specific suffix-to-size translation, enabling BQ and WQ suffixes (LQ seems unnecessary at the moment)
* Fixed logic of tx86attreader.is_asmopcode so it only assigns dual suffix to instructions that explicitly allow it. This disambiguates cases like movsbq=movs+bq vs. cmovbq=cmovb+q
* As a net result: movz[bw]q and movs[bw]q now compile for x86_64; cmovbw and cmovbl which were incorrectly handled for i386 are now fixed.
+ Test for correct assembling of cmov.

git-svn-id: trunk@17353 -
2011-04-20 11:18:13 +00:00
florian
ee54a8b879 * Merged helper branch made by Sven Barth
-- Zusammenführen der Unterschiede zwischen Projektarchiv-URLs in ».«:
 U   rtl/inc/objc1.inc
U    rtl/inc/system.inc
U    rtl/objpas/typinfo.pp
A    tests/test/tchlp30.pp
A    tests/test/thlp35.pp
A    tests/test/tchlp3.pp
A    tests/test/thlp7.pp
A    tests/test/trhlp24.pp
A    tests/test/tchlp13.pp
A    tests/test/thlp44.pp
A    tests/test/thlp18.pp
A    tests/test/trhlp33.pp
A    tests/test/tchlp22.pp
A    tests/test/thlp27.pp
A    tests/test/trhlp16.pp
A    tests/test/tchlp31.pp
A    tests/test/thlp36.pp
A    tests/test/tchlp4.pp
A    tests/test/thlp8.pp
A    tests/test/trhlp25.pp
A    tests/test/trhlp1.pp
A    tests/test/uhlp41a.pp
A    tests/test/tchlp40.pp
A    tests/test/tchlp14.pp
A    tests/test/thlp19.pp
A    tests/test/trhlp34.pp
 U   tests/test/ttpara1.pp
A    tests/test/tchlp23.pp
A    tests/test/thlp28.pp
A    tests/test/urhlp14.pp
A    tests/test/trhlp17.pp
A    tests/test/tchlp32.pp
A    tests/test/uhlp43.pp
A    tests/test/thlp37.pp
A    tests/test/tchlp5.pp
A    tests/test/thlp9.pp
A    tests/test/trhlp26.pp
A    tests/test/trhlp2.pp
A    tests/test/uchlp12.pp
A    tests/test/tchlp41.pp
A    tests/test/uhlp41b.pp
A    tests/test/tchlp15.pp
A    tests/test/trhlp35.pp
 U   tests/test/ttpara2.pp
A    tests/test/tchlp50.pp
A    tests/test/tchlp24.pp
A    tests/test/thlp29.pp
A    tests/test/trhlp18.pp
A    tests/test/thlp10.pp
 U   tests/test/cg/ttincdec.pp
A    tests/test/tchlp33.pp
A    tests/test/thlp38.pp
A    tests/test/tchlp6.pp
A    tests/test/trhlp27.pp
A    tests/test/trhlp3.pp
A    tests/test/tchlp42.pp
A    tests/test/tchlp16.pp
A    tests/test/trhlp36.pp
A    tests/test/tchlp51.pp
A    tests/test/tchlp25.pp
A    tests/test/trhlp19.pp
A    tests/test/thlp11.pp
A    tests/test/tchlp34.pp
A    tests/test/thlp39.pp
A    tests/test/tchlp7.pp
A    tests/test/trhlp28.pp
A    tests/test/thlp20.pp
A    tests/test/trhlp4.pp
A    tests/test/tchlp43.pp
A    tests/test/tchlp17.pp
A    tests/test/trhlp37.pp
A    tests/test/tchlp52.pp
A    tests/test/tchlp26.pp
A    tests/test/thlp1.pp
A    tests/test/urhlp17.pp
A    tests/test/thlp12.pp
A    tests/test/tchlp35.pp
A    tests/test/tchlp8.pp
A    tests/test/trhlp29.pp
A    tests/test/thlp21.pp
A    tests/test/trhlp5.pp
A    tests/test/tchlp44.pp
A    tests/test/tchlp18.pp
A    tests/test/trhlp10.pp
A    tests/test/trhlp38.pp
A    tests/test/thlp30.pp
A    tests/test/tchlp53.pp
A    tests/test/tchlp27.pp
A    tests/test/thlp2.pp
A    tests/test/thlp13.pp
A    tests/test/tchlp36.pp
A    tests/test/tchlp9.pp
A    tests/test/thlp22.pp
A    tests/test/trhlp6.pp
A    tests/test/tchlp45.pp
A    tests/test/tchlp19.pp
A    tests/test/trhlp11.pp
A    tests/test/trhlp39.pp
A    tests/test/thlp31.pp
A    tests/test/tchlp54.pp
A    tests/test/tchlp28.pp
A    tests/test/uhlp39.pp
A    tests/test/thlp3.pp
A    tests/test/trhlp20.pp
A    tests/test/thlp40.pp
A    tests/test/thlp14.pp
A    tests/test/tchlp37.pp
A    tests/test/thlp23.pp
A    tests/test/trhlp7.pp
A    tests/test/tchlp46.pp
A    tests/test/trhlp12.pp
A    tests/test/thlp32.pp
A    tests/test/tchlp29.pp
A    tests/test/thlp4.pp
A    tests/test/trhlp21.pp
A    tests/test/tchlp10.pp
A    tests/test/thlp41.pp
A    tests/test/thlp15.pp
A    tests/test/tchlp38.pp
U    tests/test/trtti1.pp
A    tests/test/trhlp30.pp
A    tests/test/thlp24.pp
A    tests/test/trhlp8.pp
A    tests/test/uchlp18.pp
A    tests/test/tchlp47.pp
A    tests/test/trhlp13.pp
A    tests/test/thlp33.pp
A    tests/test/tchlp1.pp
A    tests/test/thlp5.pp
A    tests/test/trhlp22.pp
A    tests/test/tchlp11.pp
A    tests/test/thlp42.pp
A    tests/test/thlp16.pp
A    tests/test/tchlp39.pp
A    tests/test/uhlp3.pp
A    tests/test/trhlp31.pp
A    tests/test/tchlp20.pp
A    tests/test/uhlp31.pp
A    tests/test/thlp25.pp
A    tests/test/trhlp9.pp
A    tests/test/tchlp48.pp
A    tests/test/trhlp40.pp
A    tests/test/trhlp14.pp
A    tests/test/thlp34.pp
A    tests/test/tchlp2.pp
A    tests/test/thlp6.pp
A    tests/test/trhlp23.pp
A    tests/test/tchlp12.pp
A    tests/test/thlp43.pp
A    tests/test/thlp17.pp
A    tests/test/trhlp32.pp
A    tests/test/tchlp21.pp
A    tests/test/thlp26.pp
A    tests/test/tchlp49.pp
A    tests/test/trhlp41.pp
A    tests/test/trhlp15.pp
 U   tests/webtbf/tw13815.pp
 U   tests/tbf/tb0216.pp
U    compiler/msgtxt.inc
U    compiler/nld.pas
U    compiler/dbgdwarf.pas
U    compiler/sparc/cgcpu.pas
U    compiler/fmodule.pas
U    compiler/i386/cgcpu.pas
U    compiler/msgidx.inc
U    compiler/pdecsub.pas
U    compiler/ncgld.pas
U    compiler/symdef.pas
U    compiler/nobj.pas
U    compiler/nflw.pas
U    compiler/pdecobj.pas
U    compiler/objcdef.pas
U    compiler/pinline.pas
U    compiler/pexpr.pas
U    compiler/ncgrtti.pas
U    compiler/x86_64/cgcpu.pas
U    compiler/htypechk.pas
U    compiler/parser.pas
U    compiler/tokens.pas
U    compiler/symbase.pas
U    compiler/ncal.pas
U    compiler/symtable.pas
U    compiler/pp.lpi
U    compiler/m68k/cgcpu.pas
U    compiler/ppu.pas
U    compiler/rautils.pas
U    compiler/arm/cgcpu.pas
U    compiler/ptype.pas
U    compiler/symconst.pas
U    compiler/mips/cgcpu.pas
U    compiler/msg/errore.msg
U    compiler/psub.pas
U    compiler/utils/ppudump.pp
 U   compiler/utils
U    compiler/pdecvar.pas
U    compiler/ncgcal.pas
U    compiler/pdecl.pas
U    compiler/dbgstabs.pas
U    compiler/ppcgen/cgppc.pas
 U   packages/fcl-xml/tests/README_DOM.txt
 U   packages/unzip/src/unzip51g.pp
 U   packages/winunits-base/src/dwmapi.pp
 U   .

git-svn-id: trunk@17328 -
2011-04-16 14:01:44 +00:00
sergei
06311e5aad * i386-win32: Pass const variants by reference to safecall procedures, confirmed this behavior with Delphi (in general, safecall on win32 must behave as close as possible to stdcall).
git-svn-id: trunk@17323 -
2011-04-15 12:12:36 +00:00
svenbarth
35b47e491c Rebase to revision 17306
git-svn-id: branches/svenbarth/classhelpers@17314 -
2011-04-13 10:04:14 +00:00
florian
c97869bd89 * merge user sections support branch
git-svn-id: trunk@17285 -
2011-04-10 18:08:59 +00:00
sergei
c6accaba5c * tcg386.g_copyvaluepara_openarray, improved generated code:
- second calculation of EDI is obsolete, its value is never used.
  - calculation of ECX can be partially shared with first calculation of EDI.
  - multiplying ECX by 1 is also redundant (was happening due to a wrong condition).

git-svn-id: trunk@17260 -
2011-04-06 08:54:20 +00:00
florian
9279c6955e * support for SSSE3, SSE4,1, SSE4.2, AES instructions set by Emelyanov Roman, resolves #18527
+ test for aes support

git-svn-id: trunk@17256 -
2011-04-05 20:22:57 +00:00