Commit Graph

337 Commits

Author SHA1 Message Date
nickysn
6e7dd647fd * Tcgx86.g_concatcopy: optimization for the case where source.segment is
specified, but equal to DS in the current memory model

git-svn-id: trunk@27720 -
2014-05-02 13:07:54 +00:00
nickysn
1eb24f9d98 + remove the segment prefix in make_simple_ref on i8086, in case it is the same
as the default segment for the reference (SS for BP-relative, DS for all
  others)

git-svn-id: trunk@27687 -
2014-04-29 23:11:10 +00:00
sergei
07e90aaa24 + Implemented IEEE 754-compliant checking for unordered results of floating-point compares on x86 targets. Mantis #9362.
git-svn-id: trunk@27581 -
2014-04-14 12:36:11 +00:00
florian
18233f2c0c * fix compilation of i8086 compiler
git-svn-id: trunk@27566 -
2014-04-13 19:28:59 +00:00
florian
d88d644925 + support for FMA intrinsic: if there is no hardware support, the compiler throws an error.
Currently it is implemented only for x86-CPUs supporting the FMA extension. While it would
  be possible to implement it in software or simulate fma(<single>,<single>,<single>) using
  double operations, it makes no sense in my opinion to do so.

git-svn-id: trunk@27564 -
2014-04-13 19:21:54 +00:00
nickysn
afcb8c3f10 * initialize DS from CS in the interrupt procedure entry code in tiny model,
because dgroup emits relocations, which results in a linker warning and broken
  code when the target format is .com file.

git-svn-id: trunk@27517 -
2014-04-10 20:02:35 +00:00
nickysn
7a873f495d * use the stack segment for SP-relative addresses in Tcgx86.g_concatcopy in
the memory models with SS<>DS (necessary, because make_simple_ref isn't called
  in the copy_string case)

git-svn-id: trunk@27479 -
2014-04-05 12:02:04 +00:00
nickysn
ee20ecfcf2 * tcgx86.make_simple_ref: in i8086 memory models with DS<>SS, add an SS: segment
override when converting SP-relative references to use a general purpose
  register

git-svn-id: trunk@27473 -
2014-04-05 08:56:40 +00:00
nickysn
b36a98ce51 + Tcgx86.g_concatcopy: added support for memory models with DS<>SS
git-svn-id: trunk@27461 -
2014-04-04 01:13:02 +00:00
nickysn
e9e4cc8bcb * Tcgx86.g_concatcopy: use boolean variables saved_ds and saved_es to keep track
whether these segment registers were saved on the stack or not

git-svn-id: trunk@27460 -
2014-04-04 00:10:36 +00:00
nickysn
096bba90da * fixed Tcgx86.g_concatcopy not using the correct push instruction size when
pushing the source segment

git-svn-id: trunk@27389 -
2014-03-30 18:09:15 +00:00
pierre
044891fd94 Avoid range check error in a_op_const_reg_reg
git-svn-id: trunk@27060 -
2014-03-09 19:49:29 +00:00
nickysn
229ebf33a8 + support getting the address of far references on i8086 in
tcgx86.a_loadaddr_ref_reg

git-svn-id: trunk@26932 -
2014-03-02 22:21:16 +00:00
florian
37b34edbc6 * do not reuse registers when calculating addresses in pic mode
git-svn-id: trunk@26743 -
2014-02-09 21:12:07 +00:00
sergei
9c1f917e3a * a_call_ref functionality cannot be implemented efficiently at code generator level, because references need specific preparations at earlier points. Moved this support to tcgcallnode and its x86 descendants, and got rid of all ifdef's around.
+ x86 targets now directly call procedure variables located in references.
- a_call_ref method removed from tcg and thlcgobj.

git-svn-id: trunk@26666 -
2014-02-03 13:28:56 +00:00
sergei
0d3f36eebf - Remove references to global variable 'cg' from methods of tcg and some of its descendants.
git-svn-id: trunk@26665 -
2014-02-03 12:27:48 +00:00
florian
28a8dc42c6 * fix tcgx86.a_op_reg_reg on x86-64 and make use of it
git-svn-id: trunk@26636 -
2014-01-30 20:24:41 +00:00
florian
7d7bf1d877 + make use of SHLX/SHRX on CPUs supporting BMI2
git-svn-id: trunk@26635 -
2014-01-30 20:24:39 +00:00
florian
48ae2d215a + concatcopy variants using sse and avx, only activated if optimization for size is done because at least on an i7-4770 it has shown no benefit
git-svn-id: trunk@26588 -
2014-01-26 12:37:54 +00:00
nickysn
85dd9e5789 + added a size parameter to optimize_op_const and do a sign extension of the 'a' parameter up from the specified size, so that things like (i and $ffffffff) get optimized away the same way as (i and -1)
git-svn-id: trunk@26561 -
2014-01-22 15:00:34 +00:00
sergei
6b1f021fcf - Removed remaining optimizations that duplicate functionality of tcg.optimize_op_const.
- Don't call make_simple_ref if operation will be optimized away or replaced with another one, which calls make_simple_ref itself.

git-svn-id: trunk@26515 -
2014-01-19 01:19:01 +00:00
nickysn
1f7b14f38e * fixed the conversion of powerof2 mul/imuls to lea in tcgx86.a_op_const_reg_reg
git-svn-id: trunk@26509 -
2014-01-18 17:58:31 +00:00
nickysn
cc1faad3d2 + make use of the 3-operand form of IMUL on i386 and x86_64
git-svn-id: trunk@26508 -
2014-01-18 17:04:57 +00:00
nickysn
5d75bf4f92 * always use IMUL instead of MUL on i386, when doing a 32->32 multiplication
without overflow checking

git-svn-id: trunk@26498 -
2014-01-18 02:56:51 +00:00
nickysn
820b667e1b - rm the OP_IMUL to SHL optimization from tcgx86.a_op_const_reg and tcgx86.a_op_const_ref, because it's already done in optimize_op_const, which is called in the beginning of both methods.
git-svn-id: trunk@26491 -
2014-01-17 18:34:13 +00:00
florian
e210d5f30e + cpu_capabilites for x86_64 and i386
* take advantage of bmi2 instruction rorx

git-svn-id: trunk@26482 -
2014-01-16 21:47:28 +00:00
sergei
f2096de53a * tcg386.g_proc_exit: instead of recalculating stack size, use current_procinfo.final_localsize which was calculated in g_proc_entry.
* tcgx86.g_proc_entry: don't over-allocate stack in SEH finalizer procedures.

git-svn-id: trunk@26251 -
2013-12-19 10:32:32 +00:00
sergei
179586f589 + SEH support for Win32. Enable by cycling with OPT=-dTEST_WIN32_SEH.
Although basic things work (no regressions in test suite, also with TEST_OPT=-O2), there are some secondary issues/TODOs:
- Exception frame around PASCALMAIN is not properly removed in DLLs
- No stack traces yet
- Stack overallocated in finalizer procedures, their entry/exit code needs cleanup
- Signals unit is probably completely broken.

git-svn-id: trunk@26225 -
2013-12-12 12:43:46 +00:00
florian
4d5119bf1c * fixes several issues which cause warnings by the dfa code when using it to detect uninitialized variables
git-svn-id: trunk@26161 -
2013-12-01 17:02:08 +00:00
nickysn
7ae59a62c5 * emit a FWAIT after a floating point store, when targeting the 8087 and 80287
git-svn-id: trunk@26109 -
2013-11-19 23:11:26 +00:00
nickysn
dea947f87b * fixed tcgx86.a_op_const_ref for shl/shr/sar/rol/ror on i8086 and x86_64
git-svn-id: trunk@26018 -
2013-11-10 20:39:47 +00:00
nickysn
d0f988f7a8 * don't use LEA in the code generator on i8086, as this breaks it quite badly.
While it is possible to use 16-bit LEA on the i8086, it's probably not worth
  doing it in the code generator, because of the unpleasant register
  restrictions that 16-bit references have.

git-svn-id: trunk@25989 -
2013-11-07 17:00:58 +00:00
florian
7fc1d70e49 * do reg2=reg1*const by lea if possible
git-svn-id: trunk@25908 -
2013-11-01 19:01:36 +00:00
florian
3c58cad96b * make use of lea if possible
git-svn-id: trunk@25898 -
2013-11-01 19:01:11 +00:00
nickysn
67fdcb02f2 * in tcgx86.make_simple_ref, on the i8086, emit 'mov es, reg', instead of
'push reg/pop es', since that is a lot faster on 8088..80386

git-svn-id: trunk@25700 -
2013-10-06 19:52:38 +00:00
nickysn
6be9627e74 * use all kinds of copy and not just copy_string in Tcgx86.g_concatcopy, when
segments are specified on the i8086

git-svn-id: trunk@25698 -
2013-10-06 19:04:13 +00:00
nickysn
bd0585274e * tsettings.enablecld converted to a targetswitch ts_cld
git-svn-id: trunk@25592 -
2013-09-28 13:41:58 +00:00
nickysn
52fcc0a407 + added a new x86-specific compiler option 'enablecld', which controls whether
the compiler should emit a CLD before using the x86 string instructions.

git-svn-id: trunk@25590 -
2013-09-28 11:54:02 +00:00
Jonas Maebe
3b9b6a0cd7 * explicitly define the asmsymbols for Darwin call stubs as local
git-svn-id: trunk@25264 -
2013-08-16 10:07:46 +00:00
sergei
e1550e1aed * Restore registers in correct order (for push/pop it *does* matter), fixes crashes caused by r25224.
git-svn-id: trunk@25228 -
2013-08-08 05:35:51 +00:00
sergei
5c4abfa75a + Implemented saving/restoring registers using PUSH/POP instructions on i386 targets with non-fixed stack. Provides some advantage in code size (e.g. the compiler becomes about 20KBytes smaller).
* This should be applicable to i8086 targets as well (but needs testing), by copying changes from i386/cgcpu.pas to i8086/cgcpu.pas and removing "$ifdef i386" lines in cgx86.pas.

git-svn-id: trunk@25224 -
2013-08-07 09:59:07 +00:00
sergei
a21a20d559 + i8086-specific version of g_stackpointer_alloc.
git-svn-id: trunk@25219 -
2013-08-06 08:11:39 +00:00
sergei
1f72143eef * In preparation for fixing Mantis #24791: Copy related code from tcgx86.g_proc_entry to tcgx86_64.g_proc_entry, and remove win64-specific stuff from tcgx86 version.
git-svn-id: trunk@25218 -
2013-08-06 07:34:50 +00:00
florian
507edb16de * use add/sub instead of inc/dec on modern CPUs when optimizing for speed
git-svn-id: trunk@25057 -
2013-07-07 19:50:13 +00:00
nickysn
7e70a5f763 * i8086 fix after r25010: i8086 doesn't support lea sp,[sp-XXX]
git-svn-id: trunk@25012 -
2013-06-29 12:21:15 +00:00
florian
94cf650d9a * use lea to adjust stack pointer, this is equal or faster on all modern CPUs than add/sub
git-svn-id: trunk@25010 -
2013-06-28 17:06:57 +00:00
florian
466eb4c684 * use MOVAPS/MOVAPD for reg -> reg moves to reduce data dependencies
git-svn-id: trunk@24967 -
2013-06-24 20:55:04 +00:00
florian
e81d2d1f3b * basic avx support for floating point operations (use -Cfavx to activate)
git-svn-id: trunk@24896 -
2013-06-14 20:03:01 +00:00
nickysn
62316da236 * a_call_reg moved to a_call_reg_near
git-svn-id: trunk@24855 -
2013-06-09 22:09:39 +00:00
nickysn
604b7c9deb + added cg.a_call_ref_near and a_call_ref_far
git-svn-id: trunk@24853 -
2013-06-09 20:22:47 +00:00