Commit Graph

416 Commits

Author SHA1 Message Date
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