Commit Graph

647 Commits

Author SHA1 Message Date
Jonas Maebe
882d676bc9 * synchronised with trunk till r40635
git-svn-id: branches/debug_eh@40636 -
2018-12-24 22:12:19 +00:00
Jonas Maebe
acf02ab64b * when creating wrappers, add a prefix to parameter names to prevent them
hiding the method name of the wrapped routine
   o also add a few more '&' prefixes to the generated wrapper code to
     prevent issues when keywords are used as identifiers

git-svn-id: trunk@40634 -
2018-12-24 22:10:06 +00:00
Jonas Maebe
4cd6f59bc3 * changed create_hlcodegen into a procvar, so that we don't have to insert
hlcgllvm in the uses clause of every unit that calls create_hlcodegen
   o prevents dependency cycles that can cause llvm codegen units to init
     before the cpu variants, which is bad since the llvm versions have to
     override the cpu variants in their init code (+ added checks in the
     init code that they are in fact initialised later)

git-svn-id: branches/debug_eh@40410 -
2018-11-29 21:31:15 +00:00
florian
9b0ff05ee8 - get rid of MaxOps, it is redundant with max_operands
* MatchOpType with three operands is only available of max_operands>2

git-svn-id: trunk@40190 -
2018-11-02 21:32:29 +00:00
pierre
9c90f593ab Add global range check disable for i8086 cgcpu and x86 nx86add units
git-svn-id: trunk@40124 -
2018-10-31 23:20:29 +00:00
Jonas Maebe
0b246f3dbd * converted Boolean8 to an internal type, and mapped Boolean to the
new internal pasbool1(type) (part of mantis )
   o apply the _Bool x86-64 parameter passing rules only to pasbool1

git-svn-id: trunk@39949 -
2018-10-16 21:14:18 +00:00
tg74
1ef9cc01e6 avx512 disp8*N
git-svn-id: branches/tg74/avx512@39909 -
2018-10-09 21:19:52 +00:00
florian
8943c0584e + patch by J. Gareth Moreton to support BMI2 instructions
+ extended avx test generator with the newly added BMI2 instructions

git-svn-id: trunk@39875 -
2018-10-07 10:10:19 +00:00
tg74
7deacdd036 bugfix avx512 opcodes VFNMSUB231PS,VFPCLASSPS
git-svn-id: branches/tg74/avx512@39783 -
2018-09-21 05:34:04 +00:00
tg74
14d392fd0e avx512 broadcast for special opcodes vcvt...
git-svn-id: branches/tg74/avx512@39779 -
2018-09-19 21:29:49 +00:00
tg74
fba72b280b avx512 broadcast vcvt...,vfpclass...
git-svn-id: branches/tg74/avx512@39778 -
2018-09-19 15:28:15 +00:00
tg74
4265f4d6a5 avx512 broadcast for special opcodes vfpclass.., vcvt...
git-svn-id: branches/tg74/avx512@39768 -
2018-09-19 06:25:42 +00:00
tg74
f3e18cedf6 bugfix opcode definition vrsqrt..., vscale...
git-svn-id: branches/tg74/avx512@39755 -
2018-09-14 09:09:35 +00:00
tg74
865563fc82 bugfixes x86ins.dat avx512-opcodes vpexpand..., vptest..., vrcp...
git-svn-id: branches/tg74/avx512@39754 -
2018-09-14 05:19:28 +00:00
tg74
2c40a09d04 bugfixes x86ins.dat avx512-opcodes vf...
git-svn-id: branches/tg74/avx512@39753 -
2018-09-13 22:01:23 +00:00
tg74
1bc0ecec11 bugfix opcode definition vfmadd132pd/ps
git-svn-id: branches/tg74/avx512@39751 -
2018-09-13 11:04:09 +00:00
tg74
ac26adf7c9 bugfix avx512-opcodes
git-svn-id: branches/tg74/avx512@39745 -
2018-09-12 13:59:29 +00:00
tg74
dd967ecfee remove any gather/scatter opcodes for nights mill
git-svn-id: branches/tg74/avx512@39742 -
2018-09-12 09:59:04 +00:00
tg74
608992ecf5 minor bugfixes avx512 tests
git-svn-id: branches/tg74/avx512@39740 -
2018-09-12 05:03:05 +00:00
tg74
c611e4814a new avx512 opcodes
git-svn-id: branches/tg74/avx512@39720 -
2018-09-10 06:19:45 +00:00
tg74
1d9cbb4dcb new AVX512 opcodes
git-svn-id: branches/tg74/avx512@39705 -
2018-09-03 05:40:44 +00:00
tg74
914e31dbd1 new AVX512 instructions vextracti..,vextractf..
git-svn-id: branches/tg74/avx512@39674 -
2018-08-27 06:06:27 +00:00
tg74
6985da744b change x86ins.dat vmovq for test tasm9
git-svn-id: branches/tg74/avx512@39654 -
2018-08-20 13:31:42 +00:00
tg74
2b1da37d66 new avx512 instructions and bugfixes avx512
git-svn-id: branches/tg74/avx512@39636 -
2018-08-19 10:18:32 +00:00
tg74
867d145e50 support vector operand bcst,{sae},{er} + k-register
git-svn-id: branches/tg74/avx512@39457 -
2018-07-16 17:06:57 +00:00
florian
d4c65cdac4 * better register de-allocation after CWD/CWB
git-svn-id: trunk@39413 -
2018-07-07 21:38:42 +00:00
nickysn
fdc896ad0a + inline support for the x86 'in' and 'out' instructions. Currently only enabled
in the i8086-msdos 'ports' unit, but will be enabled on other targets (e.g.
  go32v2) in the future as well. 32-bit 'in' and 'out' not inlined on i8086, but
  will be on i386 and x86_64.

git-svn-id: trunk@39362 -
2018-07-03 17:01:42 +00:00
tg74
4dc5442fa5 support vector operand writemask,zeroflag
git-svn-id: branches/tg74/avx512@39359 -
2018-07-02 20:20:03 +00:00
tg74
31e4d4ef5e AVX512 support for MMRegister xmm16..31 and ymm16..31, zmm0..31, vpaddsb support AVX512
git-svn-id: branches/tg74/avx512@39196 -
2018-06-08 06:53:35 +00:00
pierre
019da9517f Set return value when calling inherited in ti8086inlinenode.pass_typecheck_cpu
git-svn-id: trunk@39100 -
2018-05-23 20:43:40 +00:00
nickysn
a275d15da2 + added an i8086-specific column in x86reg.dat for the dwarf register numbers
and filled it with the dwarf register mapping, used by Open Watcom (Watcom
  also uses this mapping on i386, but we don't need to support their debugger on
  i386 for now)

git-svn-id: trunk@39097 -
2018-05-23 15:12:58 +00:00
nickysn
20abb13bca - do not compile in the stabs debug info support for the i8086 target
git-svn-id: trunk@39015 -
2018-05-17 14:47:39 +00:00
nickysn
b80642c384 + started implementing support for generating Microsoft CodeView debug
information. Only enabled on i8086 (for now). Does not do much yet, but
  hopefully, soon it'll start emitting line number information for i8086-msdos
  that is usable by DOS debuggers.

git-svn-id: trunk@39006 -
2018-05-16 15:25:33 +00:00
nickysn
d9925f7074 - removed pocall_far16 from the supported calling conventions of the i8086
code generator

git-svn-id: trunk@38938 -
2018-05-06 15:14:40 +00:00
nickysn
eb95dcb85f - removed pocall_mwpascal from the supported calling conventions of the i8086
code generator

git-svn-id: trunk@38937 -
2018-05-06 14:40:08 +00:00
nickysn
4fbc658184 - removed check for system_i386_wince in i8086's cpupara
git-svn-id: trunk@38936 -
2018-05-06 14:30:05 +00:00
nickysn
0a12bc4697 - removed pocall_oldfpccall from the supported calling conventions of the i8086
code generator

git-svn-id: trunk@38935 -
2018-05-06 14:07:31 +00:00
Jonas Maebe
d69ad8fa41 * removed temppos field again from parameter locations: they're not allocated
by the temp manager of the current procedure

git-svn-id: trunk@38858 -
2018-04-27 19:18:55 +00:00
nickysn
9a6e490699 * changed the 'register' and 'cdecl' calling conventions on i8086, so they don't
modify the SI and DI registers. For 'register', this makes it compatible with
  Borland C++'s __fastcall calling convention, while 'cdecl' becomes compatible
  with Borland C, Microsoft C and Watcom C.

git-svn-id: trunk@38824 -
2018-04-23 16:12:16 +00:00
Jonas Maebe
4686f61002 * keep track of the temp position separately from the offset in references,
so that they can still be freed after the reference has been changed
    (e.g. in case of array indexing or record field accesses) (mantis )

git-svn-id: trunk@38814 -
2018-04-22 17:03:16 +00:00
nickysn
518cdf9674 * replaced the saved_XXX_registers arrays with virtual methods inside
tcpuparamanager, very similar to the existing get_volatile_registers_XXX. The
  new methods are called get_saved_registers_XXX, where XXX is the register
  type ("int", "address", "fpu" or "mm")

git-svn-id: trunk@38794 -
2018-04-19 21:22:16 +00:00
nickysn
bd3d35f2da + add support for passing 32-bit values in a pair of registers in
tcg8086.a_load_const_cgpara. This fixes passing const longint parameters in
  dx:ax when using the register calling convention on i8086.

git-svn-id: trunk@38785 -
2018-04-18 15:40:09 +00:00
nickysn
a73aabcc39 * support loading longint in dx:ax when using the 'register' calling convention
on i8086. This is compatible with Borland C++ 3.1's _fastcall. Note that
  passing parameters in multiple registers is not yet implemented, so using this
  will cause internal errors, but these will be fixed later (and the 'register'
  calling convention was never officially supported on i8086).

git-svn-id: trunk@38784 -
2018-04-18 15:36:55 +00:00
nickysn
91707deba7 * changed the registers, used by the 'register' calling convention on i8086 to
ax,dx,bx instead of ax,dx,cx, because that makes it more compatible with
  Borland C++ 3.1's _fastcall calling convention

git-svn-id: trunk@38783 -
2018-04-18 13:46:56 +00:00
nickysn
42ebdbe277 + introduce po_hasnearfarcallmodel (specifies that the near/far call model was
specified explicitly). This will be useful, when we implement an automatic
  call model selection optimization.

git-svn-id: trunk@38732 -
2018-04-11 12:31:09 +00:00
nickysn
17823821ca * make procedures and functions, declared in the interface part of a unit in an
i8086 far code memory model to be 'far' even in {$F-} mode. This is TP7
  compatible.

git-svn-id: trunk@38728 -
2018-04-10 15:37:28 +00:00
nickysn
dcdd498524 + allow far procedures and functions in the tiny, small and compact i8086 memory
models. Even though, they generate less efficient code, they are useful when
  interacting with external APIs (e.g. declaring callbacks for the Win16 API).

git-svn-id: trunk@38726 -
2018-04-10 13:26:14 +00:00
nickysn
e1d0e7572e * i8086 TP7 compatibility fixes, related to obtaining procedure addresses:
o The @ and Addr() operators in TP or Delphi mode can now be applied to both
    near and far procedures and they always produce a CodePointer, regardless of
    the call model of the procedure.
  o Ofs() and Seg() can now also be applied to both near and far procedures.
  o The @ and Addr() operators in non-TP/Delphi modes, as well as the procedure
    name itself in TP/Delphi modes now can be applied to both near and far
    procedures and produce a near or a far procvar.

git-svn-id: trunk@38691 -
2018-04-05 15:09:12 +00:00
nickysn
58ead31f49 * optimized ofs(proc) on i8086, so it only loads the offset in all memory models
git-svn-id: trunk@38682 -
2018-04-04 15:26:47 +00:00
nickysn
c7503ca291 + introduced tabstractprocdef.ofs_address_type - the address type, generated for
ofs()

git-svn-id: trunk@38681 -
2018-04-04 15:16:42 +00:00
nickysn
dadd5568db + override set_labelsym_resultdef for i8086 and set a near pointer resultdef if
the anf_ofs flag is set

git-svn-id: trunk@38677 -
2018-04-04 12:34:21 +00:00
nickysn
3318703ece * moved nf_typedaddr to addrnodeflags (anf_typedaddr)
git-svn-id: trunk@38671 -
2018-04-03 16:41:01 +00:00
nickysn
c665866517 + introduce the tcnf_proc_2_procvar_2_voidpointer flag (for now it is only set,
but not used)

git-svn-id: trunk@38638 -
2018-03-27 16:15:06 +00:00
nickysn
3b70fc628c + override tabstractprocdef.getcopyas for i8086, so it preserves the po_far
option (so that for far procedures, a far procdef is created)

git-svn-id: trunk@38601 -
2018-03-22 23:22:26 +00:00
nickysn
23250a2ead + allow declaring near and far procvars in all i8086 memory models. Only simple
procvars can be declared near or far. Methodpointers/nested proc vars, etc
  must still follow the default calling model of the current memory model. Note
  that this feature isn't TP7 compatible (TP7 doesn't allow near procvars at
  all), but is common to 16-bit C compilers and is quite useful for calling
  external code (e.g. for far calling BIOS or some other real mode API entry
  points from any memory model, etc.)

git-svn-id: trunk@38595 -
2018-03-22 17:13:30 +00:00
nickysn
48b57c2f9a * use is_proc_far(procdefinition) instead of the current memory model to
determine whether to issue a near or a far call in ti8086callnode.do_call_ref.
  This will allow adding support for near and far procvars in any memory model.

git-svn-id: trunk@38594 -
2018-03-22 17:07:15 +00:00
florian
8b0bbdcaab * fix flag subregs after r38206
git-svn-id: trunk@38502 -
2018-03-11 20:30:11 +00:00
marco
f0042a4719 * vcmppd hardcoded primitives like vcmpeqpd.
* required increasing maxinfolen to 9 

git-svn-id: trunk@38404 -
2018-03-03 23:32:54 +00:00
marco
f21a141144 * mantis , add 32 vcmpps variants.
git-svn-id: trunk@38403 -
2018-03-03 23:10:03 +00:00
florian
8c5606b41d + support mmx shifting
git-svn-id: trunk@38367 -
2018-02-27 21:40:12 +00:00
nickysn
f1b6be2d74 + only allocate a result variable for asm routines on i8086, if they are
returned in a parameter. This improves TP7 compatibility.

git-svn-id: trunk@38246 -
2018-02-15 17:51:03 +00:00
nickysn
b2665b43aa - removed darwin-i386 stuff from i8086's cpupara
git-svn-id: trunk@38240 -
2018-02-14 15:47:03 +00:00
pierre
019a8b66dc Transform internal error into error message for seg(procvar) with is not usable for some i8086 memory models
git-svn-id: trunk@38219 -
2018-02-12 10:07:35 +00:00
florian
6400d612e8 + seg(<procvardef>) returns the segment stored in the procedure variable
git-svn-id: trunk@38216 -
2018-02-11 22:26:01 +00:00
florian
31f78ea2b6 + implementation of the vectorcall calling convention by J. Gareth Moreton
+ tests

git-svn-id: trunk@38206 -
2018-02-11 17:50:37 +00:00
florian
980c689d37 + Peephole optimizer MovPush2Push
git-svn-id: trunk@38195 -
2018-02-10 22:20:04 +00:00
florian
09af451c2e * try to get rid at least of one mov when looking for les/lds optimization
+ debug messages

git-svn-id: trunk@38191 -
2018-02-10 22:19:57 +00:00
nickysn
2019e622e1 * fixed typed constants, initialized with Ofs(proc) in modes TP and DELPHI as well
git-svn-id: trunk@38134 -
2018-02-06 13:24:15 +00:00
nickysn
e23a13a482 * fixed seg(proc) in tp and delphi modes in all i8086 memory models
git-svn-id: trunk@38133 -
2018-02-06 13:00:08 +00:00
nickysn
899707979a - removed debug writeln, committed by accident in r37727
git-svn-id: trunk@38123 -
2018-02-05 16:39:31 +00:00
nickysn
fe7fb70e2c * fixed the handling of Ofs(x) typed constants on i8086; previously, they would
sometimes produce a far pointer constant (depending on the memory model and
  the type of 'x'), which would accidentally work for single constants, but will
  fail for consts, which are a part of a record or an array. This fixes e.g.
  const c:array[0..1] of word=(Ofs(a),Ofs(b)); in all memory models

git-svn-id: trunk@38121 -
2018-02-05 16:12:20 +00:00
nickysn
614755d799 * fixed the handling of Seg(proc) typed constants on i8086
git-svn-id: trunk@38120 -
2018-02-05 16:07:57 +00:00
nickysn
0119e7afb3 * changed the codepointer type in the i8086 small and compact memory models from
nearpointer to nearcspointer

git-svn-id: trunk@37730 -
2017-12-14 17:36:15 +00:00
nickysn
ae52295232 * fixes for Seg(proc) for i8086
git-svn-id: trunk@37727 -
2017-12-13 16:56:01 +00:00
nickysn
8d18dafe34 * in the i8086 load node, when generating static/global var access to variables
in the default data segment, set their treference.segment to NR_DS, in order
  to avoid creating redundant segment relocations to the default data segment
  (which is a problem with win16 multiple instance applications). Redundant
  segment overrides are stripped later anyway, so it doesn't hurt the generated
  code.

git-svn-id: trunk@37715 -
2017-12-11 20:06:42 +00:00
nickysn
04f0029b77 - don't generate addr_seg relocations for the Seg() directive on i8086, if the
load node didn't fill the segment value in the treference record; instead,
  just use the default segment for the reference

git-svn-id: trunk@37713 -
2017-12-11 17:18:07 +00:00
nickysn
b571f48735 * fixed the return type of FarAddr(), so that it is assignment compatible to
typed far pointers as well

git-svn-id: trunk@37629 -
2017-11-27 19:42:36 +00:00
nickysn
78e0f6c68b + added an i8086-specific FarAddr() function, similar to Addr(), but always
returns a far pointer, regardless of the current memory model

git-svn-id: trunk@37628 -
2017-11-27 16:41:48 +00:00
nickysn
4fc2fa7899 * alloc/dealloc NR_DEFAULTFLAGS in the a_cmp_* methods in the i8086 code
generator

git-svn-id: trunk@37601 -
2017-11-17 19:28:37 +00:00
florian
73fda1ccb6 * factored out OptPass1Sub
+ make use of OptPass1Sub on x86_64 and i8086 as well

git-svn-id: trunk@37572 -
2017-11-10 20:55:22 +00:00
nickysn
ae92973196 + added support for the retw, retnw, retfw, retd, retnd, retfd, retq, retnq and
retfq x86 instructions. These are variants of the ret instruction with the
  return offset size set explicitly, e.g. retfw is a 16-bit far ret (i.e. pops
  a 16-bit offset and a 16-bit segment), retfd is a 32-bit far ret (pops a
  32-bit offset, followed by a 16-bit segment), etc.

git-svn-id: trunk@37571 -
2017-11-10 16:53:29 +00:00
pierre
ba3afefa4c Regenerate register include files after commit 37564: Fix value of NR_DR6 and NR_DR7
git-svn-id: trunk@37565 -
2017-11-07 07:30:42 +00:00
nickysn
034b753e10 * commented out PostPeepholeOptMov, because it breaks the pascal port of cwsdpmi
git-svn-id: trunk@37563 -
2017-11-06 23:30:11 +00:00
florian
c36c4d838d + PostPeepHoleOptsCpu for i8086
git-svn-id: trunk@37552 -
2017-11-04 19:10:15 +00:00
nickysn
303309b28f + added support for 'external far' variables for i8086
git-svn-id: trunk@37532 -
2017-10-30 18:03:44 +00:00
nickysn
d220d6f2c6 * use get_default_segment_of_ref() in the seg() handling on i8086
git-svn-id: trunk@37510 -
2017-10-23 14:55:52 +00:00
nickysn
80226e3af4 + added an optimization pass, that optimizes x86 references
git-svn-id: trunk@37494 -
2017-10-20 15:55:55 +00:00
nickysn
e8bbc4eef9 + support the xlat x86 instruction syntax with a memory operand. This allows
specifying the address size (e.g. xlat byte ptr [bx] or xlat byte ptr [ebx])

git-svn-id: trunk@37478 -
2017-10-17 16:40:06 +00:00
nickysn
0fb79946a5 + added support for the parameterized versions of the x86 string instructions
(movs, cmps, scas, lods, stos, ins, outs) in the inline asm of the i8086, i386
  and x86_64 targets. Both intel and at&t syntax is supported.
* NEC V20/V30 instruction 'ins' (available only on the i8086 target, because it
  is incompatible with 386+ instructions) renamed 'nec_ins', to avoid conflict
  with the 186+ 'ins' instruction.

git-svn-id: trunk@37446 -
2017-10-12 00:07:02 +00:00
nickysn
92a52a9f4d + implemented support for instructions with non-native address size on i8086
(16-bit and 32-bit), i386 (16-bit and 32-bit) and x86_64 (32-bit and 64-bit).
  Known bug: 32-bit addresses with an offset have their offset truncated to its
  low 16-bits on i8086

git-svn-id: trunk@37409 -
2017-10-06 15:27:14 +00:00
nickysn
aec03309ef + added CPUX86_HAS_SSE2 to x86 tcpuflags
git-svn-id: trunk@37326 -
2017-09-26 16:02:56 +00:00
nickysn
e701fa8de1 * converted the x86 instruction flags to a set, so they can be extended more
easily and so that all the values are now available to the compiler
  (previously, there were several, which were mapped to the same value and thus
  were only used to make x86ins.dat easier to read)

git-svn-id: trunk@37299 -
2017-09-21 15:48:27 +00:00
nickysn
ab62e2237b * mark the sldt,syscall,sysenter,sysexit,sysret,andn,bextr,rorx,sarx,shlx and
shrx instructions as protected mode only

git-svn-id: trunk@37275 -
2017-09-20 15:43:23 +00:00
nickysn
db09759763 * also integrated the getnextreg() implementation for 8-bit and 16-bit alus from
the avr and i8086 code generators into the base tcg class

git-svn-id: trunk@37182 -
2017-09-11 15:47:39 +00:00
nickysn
cf28b202eb * integrated the getintregister() implementation for 8-bit and 16-bit alus from
the avr and i8086 code generators into the base tcg class (so it can be reused
  by other 8-bit and 16-bit targets)

git-svn-id: trunk@37181 -
2017-09-11 15:23:59 +00:00
nickysn
ddba821561 * GetNextReg(), used by 16-bit and 8-bit code generators (i8086 and avr) moved
from cpubase unit to a method in the tcg class. The reason for doing that is
  that this is now a standard part of the 16-bit and 8-bit code generators and
  moving to the tcg class allows doing extra checks (not done yet, but for
  example, in the future, we can keep track of whether there was an extra
  register allocated with getintregister and halt with an internalerror in case
  GetNextReg() is called for registers, which weren't allocated as a part of a
  sequence, therefore catching a certain class of 8-bit and 16-bit code
  generator bugs at compile time, instead of generating wrong code).
- removed GetLastReg() from avr's cpubase unit, because it isn't used for
  anything. It might be added to the tcg class, in case it's ever needed, but
  for now I've left it out.
* GetOffsetReg() and GetOffsetReg64() were also moved to the tcg unit.

git-svn-id: trunk@37180 -
2017-09-11 14:53:06 +00:00
nickysn
4e489f2b33 + generate faster, branchless code for abs(int64) on i8086
git-svn-id: trunk@37172 -
2017-09-10 18:58:45 +00:00
nickysn
ebf4f715e8 + added a i8086 specific implementation of 32-bit abs(), which generates even
better code

git-svn-id: trunk@37162 -
2017-09-10 12:28:00 +00:00
nickysn
74dad2099e + added tcpuflags and cpu_capabilities to i8086's cpuinfo.pas
git-svn-id: trunk@37155 -
2017-09-08 14:38:40 +00:00
nickysn
aa415bfc6b + optimized division by negative power of 2 constants in the i8086 code
generator as well

git-svn-id: trunk@37004 -
2017-08-21 11:56:11 +00:00
nickysn
b92b0eac83 * also improve the code, generated for signed division by 2 on i8086, when
optimize cpu target is 486+, by replacing the sequence
    sar reg, 15
    and reg, 1
  with:
    shr reg, 15

git-svn-id: trunk@36807 -
2017-07-28 15:38:40 +00:00
nickysn
bb7cd4866d * corrected comment in x86 division code - it said "signed", when it actually meant "negative"
git-svn-id: trunk@36799 -
2017-07-27 15:04:56 +00:00
pierre
8b6563bef2 Generate error if stack size of a procedure/function is bigger than globally allocated stack size
git-svn-id: trunk@36506 -
2017-06-16 07:47:17 +00:00
florian
912e6d129a * fix modification flags for *ROUND*
git-svn-id: trunk@36280 -
2017-05-21 11:12:57 +00:00
nickysn
efc5e339d0 * use an enum instead of integer constants to represent inline numbers
* compinnr.inc include file converted to a unit
* inline number field size stored in ppu increased from byte to longint
* inlines in the parse tree (when written with the -vp option) now printed with
  their enum name, instead of number

git-svn-id: trunk@36174 -
2017-05-10 14:41:43 +00:00
florian
4a43d992f5 * unified usage of MatchOpType
* fixed generic MatchOpType

git-svn-id: trunk@36145 -
2017-05-07 16:18:33 +00:00
nickysn
af48d176ec + precise flag information for the ucomiss,ucomisd,vucomiss and vucomisd x86 instructions
git-svn-id: trunk@36115 -
2017-05-05 13:41:43 +00:00
nickysn
4e4e5d6d07 + allocate and free the flags register (when necessary), when generating code
for OP_SHR,OP_SHL and OP_SAR in tcg64f8086.a_op64_const_reg

git-svn-id: trunk@36021 -
2017-04-30 01:25:54 +00:00
nickysn
b8c4dd9e18 + implemented 64-bit OP_SHR,OP_SHL and OP_SAR in a_op64_reg_reg for i8086 and
use it in the shl/shr node for code generation.

git-svn-id: trunk@36018 -
2017-04-29 21:57:48 +00:00
nickysn
a82c89d894 + implemented OP_SHR,OP_SHL and OP_SAR in a_op64_const_reg for i8086. The shlshr
node now uses them for 64-bit shift by constant.

git-svn-id: trunk@36017 -
2017-04-29 20:58:55 +00:00
nickysn
aee000a773 * i8086's TCpuAsmOptimizer made a descendant of TX86AsmOptimizer
git-svn-id: trunk@35985 -
2017-04-27 18:22:14 +00:00
nickysn
ff1ee6836d + fix RegReadByInstruction for the x86 MOVSD instruction
git-svn-id: trunk@35968 -
2017-04-27 14:42:08 +00:00
nickysn
c8487c4150 + added individual bits of the x86 flags register as subregisters
git-svn-id: trunk@35955 -
2017-04-26 13:52:52 +00:00
nickysn
5f66f5cebb + distinguish between x86 flags subregisters: flags, eflags and rflags
git-svn-id: trunk@35953 -
2017-04-25 16:10:43 +00:00
nickysn
65977f9f27 + implemented OP_ROL and OP_ROR in tcg8086.a_op_reg_reg and .a_op_reg_ref
git-svn-id: trunk@35952 -
2017-04-25 13:46:20 +00:00
nickysn
8c200fcfba + implemented OP_SHR,OP_SHL,OP_SAR,OP_ROL and OP_ROR in tcg8086.a_op_const_ref
git-svn-id: trunk@35945 -
2017-04-25 11:06:12 +00:00
nickysn
50b1c9c088 + implemented 32-bit OP_SHR,OP_SHL and OP_SAR in tcg8086.a_op_reg_ref
git-svn-id: trunk@35935 -
2017-04-24 13:43:18 +00:00
nickysn
0c244046a9 * proper register change info for the movs,cmps and scas x86 string instructions
(movsd still todo, because of the overlap with the sse2 instruction)

git-svn-id: trunk@35929 -
2017-04-23 21:30:25 +00:00
nickysn
1d34e96064 + added x86 instruction flag Ch_RFLAGScc, indicating instructions that read
specific bits from the flags register, according to their condition (used by
  Jcc/SETcc/CMOVcc)

git-svn-id: trunk@35907 -
2017-04-22 22:07:05 +00:00
nickysn
1146b7c12c + added detailed information for individual flag bits use for most x86
instructions. Not used by the compiler yet, but may allow more
  optimizations in the future.

git-svn-id: trunk@35882 -
2017-04-21 23:03:33 +00:00
nickysn
869f395a31 + added knowledge to the compiler for the x86 instructions, that don't read
their input registers, in case both parameters are the same register (e.g.
  xor eax, eax; sub eax, eax; etc.)

git-svn-id: trunk@35861 -
2017-04-20 15:11:56 +00:00
nickysn
328d546155 + extend the i8086 peephole optimization that converts certain sequences to lds
and les instructions to also support the lss, lfs and lgs instructions on i386
  (won't be generated by the current code generator, but might become useful in
  the future, if we start using the fs and gs segment registers as well)

git-svn-id: trunk@35858 -
2017-04-20 13:00:26 +00:00
nickysn
12a1ad66b2 + added the Ch_RDirFlag change attribute to the STOSx instructions (previously
was missing, due to the 3 attributes per instruction limit)

git-svn-id: trunk@35855 -
2017-04-19 20:23:24 +00:00
nickysn
9303a8f61a * changed the x86 TInsProp.Ch structure from a 3-element array to a pascal set;
this removes the limit of 3 Ch_XXX flags per instruction (thus allowing adding
  more precise flags, e.g. for tracking only certain bits of the flags register,
  etc.) and avoids the ugliness of having the Ch_None filler, which makes
  x86ins.dat less readable.

git-svn-id: trunk@35850 -
2017-04-19 16:48:35 +00:00
nickysn
189e49998c * fixes to the x86 instruction flags tracking attributes:
* AAA and AAS also read flags (AF)
  * CMC reads and writes flags (it inverts CF)
  * CMPSx and SCASx write flags
  * CMPSx, SCASx, LODSx, STOSx, MOVSx read the direction flag
  * NOT doesn't affect flags
  * REP isn't affected by and doesn't affect flags
  * REPE/REPNE/REPZ/REPNZ/REPC/REPNC don't write flags, only read them
  * ROL and ROR don't read flags
  * SAL doesn't read flags
  * SHLD and SHRD don't read flags

git-svn-id: trunk@35849 -
2017-04-19 15:42:50 +00:00
nickysn
7ee0c07b8d + added flags register tracking for many i8086 operations
git-svn-id: trunk@35848 -
2017-04-19 13:46:20 +00:00
nickysn
256dc546ac + implemented the in_neg_assign_x and in_not_assign_x inline nodes, which will
be used (TBD in a future commit) for optimizing x:=-x and x:=not x on CPUs
  that support performing these operations directly in memory (such as x86)

git-svn-id: trunk@35749 -
2017-04-07 16:02:40 +00:00
nickysn
9093047a7a * fixed a bug in the i8086 32-bit rol/ror code generation method rm_fast_386
git-svn-id: trunk@35745 -
2017-04-06 15:55:43 +00:00
nickysn
1560f20e7f + implemented other 32-bit rol/ror by const methods for i8086 and added a
(hopefully) reasonable selection for them for all consts between 1 and 31

git-svn-id: trunk@35744 -
2017-04-06 15:41:39 +00:00
nickysn
0fd860d9e7 * refactored the code generation for 32-bit rol/ror by const for i8086, so it
uses less code repetition and allow choosing various methods (some of which
  will be implemented later and selected, according to the cpu and optimization
  settings (size vs speed))

git-svn-id: trunk@35743 -
2017-04-06 13:59:53 +00:00
nickysn
d5e33cce7f * generate better i8086 code for ror32 by 1 and 17
git-svn-id: trunk@35741 -
2017-04-05 14:16:00 +00:00
nickysn
321876252b + enabled the rol/ror intrinsic on i8086
git-svn-id: trunk@35734 -
2017-04-04 22:37:58 +00:00
nickysn
b957b65ec8 * generate better i8086 code for 64-bit shl/shr, by masking the shift count by 63
git-svn-id: trunk@35730 -
2017-04-04 17:58:00 +00:00
nickysn
76cb419241 * use 16-bit 386+ instructions (shld,shrd) for performing fast 32-bit
shl/shr/sar on i8086, in a_op_const_reg, when the target CPU is set to 80386
  or later

git-svn-id: trunk@35726 -
2017-04-04 14:40:29 +00:00
nickysn
0ab4f01668 * implemented fast (loopless) 32-bit shift by constant for 8086 as well
git-svn-id: trunk@35725 -
2017-04-03 21:04:59 +00:00
nickysn
0f2ad7b712 * generate faster (i.e. loopless) code for 32-bit shl/shr/sar by const on 186+
git-svn-id: trunk@35723 -
2017-04-03 20:37:21 +00:00
nickysn
f0a63fa895 + added an optimized implementation of a_op64_reg_ref for i8086; this improves
the generated code on i8086 for things like inc(int64_var,int64_var) and
  dec(int64_var,int64_var)

git-svn-id: trunk@35657 -
2017-03-25 18:45:31 +00:00
Jonas Maebe
880d438704 * renamed t<cpuname>procinfo to tcpuprocinfo for all targets, so we can
inherit from it for LLVM without a thousand ifdefs

git-svn-id: trunk@35141 -
2016-12-16 22:41:21 +00:00
Jonas Maebe
a25ebbba3e + added volatility information to all memory references
o separate information for reading and writing, because e.g. in a
     try-block, only the writes to local variables and parameters are
     volatile (they have to be committed immediately in case the next
     instruction causes an exception)
   o for now, only references to absolute memory addresses are marked
     as volatile
   o the volatily information is (should be) properly maintained throughout
     all code generators for all archictures with this patch
   o no optimizers or other compiler infrastructure uses the volatility
     information yet
   o this functionality is not (yet) exposed at the language level, it
     is only for internal code generator use right now

git-svn-id: trunk@34996 -
2016-11-27 18:17:37 +00:00
sergei
133fcb5ab2 * Fixed VMOVQ instruction encoding, now assembles correctly also in 32-bit code.
+ Test

git-svn-id: trunk@34949 -
2016-11-21 13:59:44 +00:00
sergei
ebe134febc * Fixed memory reference size for MOVSS instruction, Mantis .
git-svn-id: trunk@34943 -
2016-11-21 03:31:25 +00:00
sergei
870fda34d5 * x86 AT&T reader and writer: cleaned up usage of attsufMM suffix:
* It is now only used to select size of vector instructions (i.e. 128 or 256 bits)
  * Scalar instructions reverted to use attsufINT suffix (selecting between 32 or 64 bits).
  * Additionally, vcvtsi2sd and vcvtsi2ss with rm64 operand are x86_64 only.

git-svn-id: trunk@34942 -
2016-11-21 02:07:13 +00:00
sergei
edf943a4f6 * Changed memory operand size for VMOVSS instruction to 32 bits, Mantis .
git-svn-id: trunk@34918 -
2016-11-18 23:37:01 +00:00
florian
56252d59f0 + support for the PREFETCHTW1 instruction based on a patch by Emelyanov Roman, resolves
git-svn-id: trunk@34917 -
2016-11-18 20:19:39 +00:00
pierre
abaea9959f Fix parameter loading of FPC_CHECKPOINTER to handle correctly references with offsets
git-svn-id: trunk@34743 -
2016-10-18 21:48:59 +00:00
nickysn
35b0201002 + added an unsigned counterpart to tpointerdef.pointer_arithmetic_it_type (needed by inc/dec)
git-svn-id: trunk@34653 -
2016-10-08 11:45:24 +00:00
nickysn
f76722b6c3 * fixed i8086's tcpupointerdef.pointer_arithmetic_int_type and
.pointer_subtraction_result_type methods after r34607

git-svn-id: trunk@34613 -
2016-10-04 00:06:50 +00:00
nickysn
481a8ec58d * for pointers, converted to arrays, use a newly added virtual method
tpointerdef.converted_pointer_to_array_range_type to obtain their integer
  range type, instead of using ptrsinttype

git-svn-id: trunk@34612 -
2016-10-04 00:01:06 +00:00
svenbarth
c8202061dc * get rid of addr_load_indirect again by having tcgx86 provide an internal implementation of both make_simple_ref() and a_load_ref_reg() so that make_direct_ref() can call the latter (and the latter the former) without fear of inifinite recursive calls due to the symbol; a_load_ref_reg() is additionally declared as "final" as a_load_ref_reg_internal() needs to be overloaded instead (which is the case for tcg8086)
git-svn-id: trunk@34579 -
2016-09-30 14:01:02 +00:00
pierre
4d09dfca95 Remember usage of checkpointer (-gc) option:
Use new cs_checkpointer_called moduleswitches set element.
     Use new uf_checkpointer_called PPU flag (reusing obsolete uf_local_browser flag value)
     Emit warning if compiled library/program has any code using checkpointer.
  
 * ppu.pas: New constant: uf_checkpointer_called
 * globtype.pas: New constant: cs_checkpointer_called
 * fppu.pas: Set uf_checkpointer_called flag if cs_checkpointer_called is set in current_settings.module_switches
 * i8086/n8086mem.pas: Include cs_checkpointer_called in current_settings.moduleswitches
 *  ncgmem.pas: Likewise.
 * msg/errore.msg: Add new message saying that -gc and -Ur options are incompatible
   Add description to -gc option, saying it is experimental.
   Add warning at link time for program/library if checkpointer is used in any unit or main code.
 * options.pas: if -gc and -Ur options are used, never enable checkpointer code,
   instead output a warning that release is incompatible with -gc option.
 * pmodules.pas: proc_program: Check all modules for uf_checkpointer_called flag,
   emit a warning if checkpointer is used.
 * utils/ppuutils/ppudump.pp: Add code for uf_codepointer_called option.

git-svn-id: trunk@34567 -
2016-09-27 14:46:09 +00:00
Jonas Maebe
0afbe85aab * various memory reference alignment fixes
git-svn-id: trunk@34544 -
2016-09-20 21:43:19 +00:00
Jonas Maebe
aa1be3276f - removed default value of _typ parameter of TAsmData.(Weak)RefAsmSymbol():
it was AT_NONE, which is invalid and should never be used
  * explicitly pass the correct value for all calls to those methods elsewhere
    in the compiler

git-svn-id: trunk@34250 -
2016-08-05 07:09:16 +00:00
Jonas Maebe
a0efde8167 * automatically generate necessary indirect symbols when a new assembler
symbol is defined
   o removed all places where AB_INDIRECT symbols were explicitly generated
   o only generate AB_INDIRECT symbols for AT_DATA on systems_indirect_var_imports
   o for some symbols an indirect symbol is always required (because they are
     dereferenced by code in RTL units) -> use new AT_DATA_FORCEINDIRECT type

git-svn-id: trunk@34165 -
2016-07-20 20:53:03 +00:00
Jonas Maebe
1cb8c0d00c * specify the def of assembler level symbols defined via
tasmdata.DefineAsmSymbol() and all routines that call it
   o will be used to automatically generate AB_INDIRECT sybols when
     necessary

git-svn-id: trunk@34164 -
2016-07-20 20:52:59 +00:00
nickysn
ac5658470e + use the 16-bit movsx and movzx instructions on 386+ in tcg8086.a_load_ref_reg
as well

git-svn-id: trunk@34050 -
2016-07-02 17:05:48 +00:00
nickysn
a5f1ae97d4 + make use of the 16-bit movsx and movzx instructions in tcg8086.a_load_reg_reg
when the cpu target is 80386 or later

git-svn-id: trunk@34046 -
2016-07-02 14:06:25 +00:00
nickysn
c2305809dc + added an i8086-embedded target support to the compiler (RTL and makefile
support are not done yet)

git-svn-id: trunk@33999 -
2016-06-17 19:15:24 +00:00
florian
a7516dfb50 * fix modification information of VCOMISS and VCOMISD
git-svn-id: trunk@33874 -
2016-06-01 19:58:43 +00:00
nickysn
c78f406d99 + implemented proper stack checking for the i8086
git-svn-id: trunk@33787 -
2016-05-24 23:57:47 +00:00
nickysn
ce66597df8 * handle classrefdefs properly, according to the memory model in i8086's
thlcgobj.getaddressregister. This should fix several regressions in the
  compact, large and huge memory models after r33591

git-svn-id: trunk@33637 -
2016-05-03 15:11:32 +00:00
florian
0c13f3ce3e * fix modification information for vand*
git-svn-id: trunk@33593 -
2016-05-01 12:00:25 +00:00
florian
406e3c4ac1 + support xgetbv instruction, resolves issue
git-svn-id: trunk@33418 -
2016-04-03 20:53:10 +00:00
florian
8d5cc3dfa4 * (extended and modified) patch by Emelyanov Roman to add suport of RDRAND, RDSEED and TSX instructions set, resolves issue .
In comparison with the original patch, support for a i386 has been added as well as a test program. 
  Further, a small issue with xbegin has been fixed

git-svn-id: trunk@33375 -
2016-03-28 19:08:13 +00:00
nickysn
cf3230b100 - removed IF_CENTAUR and replaced it with IF_CYRIX. Rationale: only 3 Centaur -
specific instructions were marked as CENTAUR, all the others were marked
  CYRIX, so it wasn't an accurate flag at all

git-svn-id: trunk@33326 -
2016-03-25 17:01:11 +00:00
nickysn
9a2f5e01d7 + added range checking for the immediate operand of NEC V20/V30's instructions CLR1, SET1, NOT1 and TEST1
git-svn-id: trunk@33322 -
2016-03-24 16:05:11 +00:00
nickysn
0be6d062ac + added range checking for the imm4 operand of NEC V20/V30's instructions
'EXT reg8,imm4' and 'INS reg8,imm4'

git-svn-id: trunk@33321 -
2016-03-24 15:45:23 +00:00
nickysn
5f87ac5d47 + added 486 to the list of supported CPUs on the i8086 and i386 targets
git-svn-id: trunk@33317 -
2016-03-23 15:07:56 +00:00
sergei
0f301b4c57 * Fixed spilling info for vcvt* instructions, part of Mantis .
git-svn-id: trunk@33208 -
2016-03-09 16:36:30 +00:00
nickysn
80b3e3020a * the SEGFS and SEGGS prefixes are 386+
git-svn-id: trunk@32925 -
2016-01-11 15:51:40 +00:00
pierre
40193ea1db Add pi_has_open_array_parameter to proc_info.flags as this requires special handling for i8086 huge memory model to restore DS register correctly
git-svn-id: trunk@32922 -
2016-01-11 15:02:10 +00:00
nickysn
741a3eedf9 * fixed the cpu level of several 186+ instructions, that were mistakenly marked as either 286+ or 8086+
git-svn-id: trunk@32921 -
2016-01-11 13:22:08 +00:00
nickysn
6037976202 * several imul variants, featuring 32-bit or 64-bit registers marked 386+, instead of 286+
git-svn-id: trunk@32889 -
2016-01-08 17:07:36 +00:00
nickysn
e877bae4fc + add 'jmp rm16' and 'call rm16' before the rm32 versions on i8086, so the
16-bit version is picked up by default for opsize=S_NO. Previously the 386
  version was picked on i8086, but the generated code was correct, because we
  don't yet generate a 0x66 prefix for "\325", which leads to many 32-bit
  instructions not being assembled correctly with the internal asm obj writer on
  the i8086

git-svn-id: trunk@32887 -
2016-01-08 16:41:21 +00:00
nickysn
66bad5a1cf * pushf and popf are 8086 level instructions, not 186+
git-svn-id: trunk@32677 -
2015-12-17 15:23:21 +00:00
florian
a3964d9ee0 + support for RDTSCP, resolves issue
git-svn-id: trunk@32652 -
2015-12-13 13:28:51 +00:00
nickysn
1e33924f73 + support procvardefs (address only) in i8086's hlcgcpu.getaddressregister; this
fixes e.g. obtaining the address of a method in i8086 far code memory models
  after r32414

git-svn-id: trunk@32562 -
2015-12-01 15:58:11 +00:00
sergei
a78250a78b * x87 FBSTP and FBLD instructions cannot have size suffix in ATT syntax. Mantis .
git-svn-id: trunk@32541 -
2015-11-27 03:59:06 +00:00
nickysn
ad92f4e80a + implemented thlcgcpu.a_op_const_reg with far pointer support for i8086, so
that second_class_to_intf can be converted to the high level code generator

git-svn-id: trunk@32301 -
2015-11-12 22:01:44 +00:00
nickysn
ef2c6065b6 + added support for word/smallint typed constants, initialized with ofs() on i8086
git-svn-id: trunk@32285 -
2015-11-11 15:01:08 +00:00
nickysn
ac97d20249 + added support for typed word/smallint constants, initialized with Seg(symbol) on the i8086
git-svn-id: trunk@32251 -
2015-11-05 16:18:47 +00:00
Jonas Maebe
fa3b0ca312 * support marking defs created via the getreusable*() class methods as
"don't free even if not registered"; use for defs that may not be written
    to a ppu file, but that must nevertheless survive the compilation of the
    current module
  * mark all defs created for para locations as "don't free even if not
    registered", because we don't discard and recalculate all para locations
    after a module has been compiled (since that's not needed)
   o solves issues if the paralocations for a routine in the interface of
     unit A are calculated while the implementation of unit B gets
     compiled, and a new reusable type is allocated at that point which
     is not used anywhere else (after r32160)

git-svn-id: trunk@32235 -
2015-11-04 20:46:18 +00:00
nickysn
a55b728d34 * optimizations for ofs() on i8086 to load only the offset (in a temporary
register), without the segment

git-svn-id: trunk@32211 -
2015-10-30 21:27:35 +00:00
Jonas Maebe
d440daf47f * fixed compilation with -Oodfa/-O3
git-svn-id: trunk@32152 -
2015-10-25 19:21:57 +00:00
nickysn
1491d9655c + fixed the emitting of non-nil far and huge pointer constptrs in typed
constants on i8086

git-svn-id: trunk@32141 -
2015-10-24 20:25:49 +00:00
nickysn
863daace35 + implemented correct simplification of far pointer comparison of two pointer const nodes
git-svn-id: trunk@32122 -
2015-10-22 14:07:45 +00:00
nickysn
b0130c008d + show the full segment:offset value of far and huge pointer const nodes in the node tree generated by -vp
git-svn-id: trunk@32117 -
2015-10-21 16:53:41 +00:00
nickysn
09218c88aa + optimizations in tcg8086.g_flags2reg for the case where the carry flag or the
inverted carry flag is converted to int, using shorter branchless code and
  the adc/rcl/sbb instructions

git-svn-id: trunk@32106 -
2015-10-20 23:22:32 +00:00
nickysn
7e6ba9db2a * do an even better optimization (swap registers in the result, saving 2 mov
instructions) on i8086 for 64-bit shl/shr with a constant in the range 32..47

git-svn-id: trunk@32062 -
2015-10-15 21:13:28 +00:00
nickysn
ff5eed1c00 * user xor reg,reg to zero out registers in the i8086 optimized 64-bit shl code
git-svn-id: trunk@32061 -
2015-10-15 21:02:53 +00:00
nickysn
6ece867305 * in the i8086 64-bit shl code, use jcxz instead of test cx,cx+jz when
optimization target is 386 or earlier (or when optimizing for size)

git-svn-id: trunk@32060 -
2015-10-15 20:51:20 +00:00
nickysn
dc92c3eb09 + i8086 optimization for the code generated for 64-bit shl/shr with a constant in the range 32..47
git-svn-id: trunk@32059 -
2015-10-15 15:59:27 +00:00
nickysn
44f6f607c5 * optimized the generated code on i8086 for 64-bit shl/shr with constant >=48
git-svn-id: trunk@32058 -
2015-10-15 15:15:11 +00:00
nickysn
66725cf170 * fixed huge memory model threadvars after r32013
git-svn-id: trunk@32016 -
2015-10-11 12:55:44 +00:00
florian
79619df936 + use the or instruction to compare 32 bit values with 0
git-svn-id: trunk@31862 -
2015-09-27 20:50:59 +00:00
florian
298cde6489 + initial code in aoptcpu for i8086: make use of lds/les
git-svn-id: trunk@31861 -
2015-09-27 20:50:57 +00:00
nickysn
b26e10d53c + generate proper win16 prologue/epilogue for exported routines (we don't yet
actually export them from the .exe or .dll, but they can now be used as
  callbacks)
+ support win16 smart callbacks via the $K switch

git-svn-id: trunk@31835 -
2015-09-26 18:04:59 +00:00
nickysn
aa57e7e835 * moved the i8086-specific threadvar generation code from
ti8086loadnode.pass_generate_code to ti8086loadnode.generate_threadvar_access

git-svn-id: trunk@31699 -
2015-09-15 13:02:25 +00:00
Jonas Maebe
3c6aa91a96 * factored out the loading of threadvars in its own method, and put the
x86-specific part in nx86ld

git-svn-id: trunk@31639 -
2015-09-12 23:32:53 +00:00
nickysn
182dffcbd8 * fixed i8086 compilation after r31593
git-svn-id: trunk@31605 -
2015-09-11 16:20:50 +00:00
Jeppe Johansen
3cb9be73bc Moved tcontrollerdatatype out into cpuinfo.
Added cputype and fputype info to tcontrollerdatatype arrays.

git-svn-id: trunk@31574 -
2015-09-07 20:36:54 +00:00