Commit Graph

1550 Commits

Author SHA1 Message Date
florian
1a69c49e81 * fix range check errors by explicit casts
git-svn-id: trunk@37945 -
2018-01-11 21:00:18 +00:00
florian
724b822b54 * patch based on a proposal by J. Gareth Moreton to reduce register usage
git-svn-id: trunk@37941 -
2018-01-09 21:32:18 +00:00
florian
11a3d8762a * patch by J. Gareth Moreton:
- Moved the part that emits the CMOV command outside of the if-else block, because it's the same in both branches and was just duplicated code.
  - Moved a comment about powers of 2 to be right before the correct if-else block.
  - Added a couple of comments to explain what the algorithm is doing to obtain the remainder.
  - Added missing "writeln('ok');" (since 'tmoddiv3.pp' has it) and program header to 'tmoddiv4.pp'.
  - Changed program name from "testfile2" to "tmoddiv3" in 'tmoddiv3.pp'.

git-svn-id: trunk@37939 -
2018-01-09 20:04:49 +00:00
florian
81b2cf5d65 * slightly modified patch by J. Gareth Moreton: Optimization for 'mod' on i386/x86-64, resolves #32945
git-svn-id: trunk@37922 -
2018-01-06 14:58:28 +00:00
Jonas Maebe
f1ace2b74d - reverted r36870, Darwin's assembler uses a different way to specify
32/64 bit (like it was before; fixes mantis #32954)

git-svn-id: trunk@37914 -
2018-01-05 19:48:19 +00:00
Jonas Maebe
1b66995754 * factored out check to determine whether a variable can be subscripted in
inline assembly, and fixed check after r35959 (mantis #32318)
   o can also subscript parameters passed by value on the stack
   o can also subscript local variables, the parameters passed by reference
     that are subsequently copied into a local

git-svn-id: trunk@37886 -
2018-01-01 14:29:21 +00:00
nickysn
c464f7fa56 * fixed the SEG inline asm directive when used with 32-bit registers on the i8086 target
git-svn-id: trunk@37613 -
2017-11-22 15:04:30 +00:00
Károly Balogh
e6aed467b5 renamed script unit to cscript to avoid namespace conflict with univint package on Darwin. this makes it possible to build the textmode IDE on Darwin
git-svn-id: trunk@37598 -
2017-11-17 11:27:19 +00:00
florian
674398c5a5 * i8086 compilation fixed after r37572
git-svn-id: trunk@37573 -
2017-11-11 13:25:02 +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
176cec14c9 Fix value of NR_DR6 and NR_DR7
git-svn-id: trunk@37564 -
2017-11-07 07:29:54 +00:00
florian
1556599ad5 * symbols with bind type AB_EXTERNAL_INDIRECT need to be declared as EXTERN for masm/nasm etc.
git-svn-id: trunk@37553 -
2017-11-04 19:10:17 +00:00
florian
4da4b768ec * factored out PostPeepholeOptTest
+ use PostPeepholeOptTest on x86-64

git-svn-id: trunk@37551 -
2017-11-04 19:10:14 +00:00
florian
3097eaf8ee * made PostPeepholeOptMov a function
git-svn-id: trunk@37550 -
2017-11-04 19:10:12 +00:00
florian
a7ea7fb569 * factored out PostPeepholeOptCmp
+ use PostPeepholeOptCmp for x86_64

git-svn-id: trunk@37549 -
2017-11-04 19:10:09 +00:00
nickysn
e5dad9c98c + set oper.haslabelref in several other places, where a reference, containing a
label is created in the intel syntax x86 assembler. This fixes tfarcal3.pp and
  tfarcal4.pp after r37538

git-svn-id: trunk@37541 -
2017-11-01 14:31:16 +00:00
nickysn
9649154368 * fixed the token2str const array for intel syntax x86 asm
git-svn-id: trunk@37540 -
2017-11-01 13:36:16 +00:00
nickysn
9450beb99c * fixed bug in intel syntax i8086 inline asm, when certain 'jmp/call [v]'
instructions got erroneously converted to 'jmp/call v', if 'v' is an external
  far variable that points to certain things (like a local label, exported via
  public)

git-svn-id: trunk@37538 -
2017-10-31 16:49:38 +00:00
nickysn
29558a74cd + support exporting labels from asm blocks in intel syntax asm blocks via the
'public' directive

git-svn-id: trunk@37530 -
2017-10-30 16:44:13 +00:00
nickysn
8a0d8f025b * fixed another i8086 inline asm 32-bit constant bug (e.g. in 'or eax, 80000001h')
git-svn-id: trunk@37521 -
2017-10-25 19:38:37 +00:00
nickysn
325e66287c * fix for inline asm of instructions with 32-bit constant operands on i8086
git-svn-id: trunk@37519 -
2017-10-25 18:03:22 +00:00
nickysn
2af5c9d508 * changed type used for section alignment from byte/shortint to longint, so the
internal object writer and the internal linker support object files with
  sections with alignment >=256

git-svn-id: trunk@37518 -
2017-10-25 15:47:29 +00:00
nickysn
8cc230ef1a - don't switch index into base in the gas assembly writer. This optimization
(and others) are performed in optimize_ref().

git-svn-id: trunk@37517 -
2017-10-25 13:42:18 +00:00
nickysn
d7e4b50068 + also optimize x86_64 references by switching [rbp+reg64] to [reg64+rbp],
[r13+reg64] to [reg64+r13] and [r13d+reg32] to [reg32+r13d]

git-svn-id: trunk@37516 -
2017-10-24 16:18:43 +00:00
nickysn
5ae32a0ec5 + always do the x86_64 reference optimizations as if SS=DS, because the CPU
basically ignores these segments in long mode

git-svn-id: trunk@37515 -
2017-10-24 15:38:59 +00:00
nickysn
e58bad8eef + check for the 'pop cs' instruction in the x86 inline assembler and print a
warning (on the i8086 target) or an error (on i386 and x86_64) when this
  instruction is used (because it only works on 8086 and 8088 CPUs)

git-svn-id: trunk@37514 -
2017-10-24 15:07:20 +00:00
nickysn
0d1f7910d7 + also apply optimize_ref() on references of inline asm instructions
git-svn-id: trunk@37512 -
2017-10-23 22:28:08 +00:00
nickysn
875339993f * strip segment overrides, for segments, which should be equal in the current
model to the default segment of the reference in optimize_ref, when
  inlineasm=false

git-svn-id: trunk@37511 -
2017-10-23 15:51:33 +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
67a0e9bdae + added x86 helper function get_default_segment_of_ref, which returns the
default segment base for the ref, in case there's no segment override
* in the internal assembler, use get_default_segment_of_ref to strip redundant
  prefixes, instead of always assuming all refs are DS-based

git-svn-id: trunk@37486 -
2017-10-18 14:24:58 +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
9cebeeffa9 + check for address size mismatch in intel syntax assembler as well
git-svn-id: trunk@37475 -
2017-10-16 16:19:15 +00:00
nickysn
353efcb163 * fixed rdi register name in error message
git-svn-id: trunk@37474 -
2017-10-16 16:14:18 +00:00
nickysn
cece021bd1 + check whether the address sizes match for x86 string instructions with two
memory operands, when using the at&t syntax inline assembler

git-svn-id: trunk@37473 -
2017-10-16 16:01:38 +00:00
nickysn
4cb1a96ec1 * use get_ref_address_size in the nasm writer, when handling the parameterized
string instructions

git-svn-id: trunk@37471 -
2017-10-16 14:21:03 +00:00
nickysn
6f2e64ff90 + added function get_ref_address_size
git-svn-id: trunk@37470 -
2017-10-16 14:13:03 +00:00
nickysn
b0653a6313 + added functions is_32_bit_ref and is_64_bit_ref, similar to is_16_bit_ref
* taicpu.needaddrprefix now uses is_32_bit_ref on x86_64
* is_16/32/64_bit_ref made part of the aasmcpu unit interface, so they can be
  used elsewhere (e.g. in the inline assembler readers)

git-svn-id: trunk@37469 -
2017-10-16 14:05:06 +00:00
nickysn
2b6e5d817e * changed the parameter of is_16_bit_ref to be a treference, instead of toper
git-svn-id: trunk@37463 -
2017-10-16 00:30:26 +00:00
nickysn
acfa199b09 * in the nasm writer, only output a segment prefix for the [si] operand, in
case there's a segment operand, different that DS (the default source
  segment) for parameterized x86 string instructions

git-svn-id: trunk@37459 -
2017-10-14 16:58:15 +00:00
nickysn
a8232ac477 + added warning if source or destination for x86 string instructions isn't
specified to be (%esi) or (%edi), when using at&t syntax assembler (this is
  not considered an error by intel syntax assemblers, so we're not adding a
  warning there, for now)

git-svn-id: trunk@37458 -
2017-10-14 15:27:00 +00:00
nickysn
dd9b5eb2aa + added the 'Cannot override ES' message in the at&t assembler reader as well
git-svn-id: trunk@37456 -
2017-10-14 00:48:46 +00:00
nickysn
1ee36b5b9b + added error message in the intel assembler reader, when an attempt is made to
override the ES segment in an x86 string instruction (because it cannot be
  overriden)

git-svn-id: trunk@37454 -
2017-10-13 14:56:38 +00:00
nickysn
baf492c7a5 + another helper function: x86_parameterized_string_op_param_count
* when generating x86 code for parameterized string instructions with the
  internal object writer, don't rely on the destination operand being [(r/e)di]
  when determining the segment prefix, because when using intel syntax, source
  and destination can be anything (only the operand size, the address size and
  the source segment is taken into account)

git-svn-id: trunk@37452 -
2017-10-12 16:07:15 +00:00
nickysn
4c75b15afe * shortened the names of the is_x86_string_instruction_op,
is_x86_parameterless_string_instruction_op and
  is_x86_parameterized_string_instruction_op by removing 'instruction' from
  their names

git-svn-id: trunk@37451 -
2017-10-12 15:20:22 +00:00
nickysn
e3ca2a3043 + added helper functions get_x86_string_op_si_param and get_x86_string_op_di_param
* use get_x86_string_op_si_param in the nasm writer

git-svn-id: trunk@37450 -
2017-10-12 15:12:40 +00:00
nickysn
5a5cd65559 + added helper functions x86_param2paramless_string_op and
get_x86_string_op_size
* refactored the AT&T inline asm handling of x86 parameterized string ops, so it
  uses the new helper functions

git-svn-id: trunk@37449 -
2017-10-12 14:25:32 +00:00
nickysn
2f28768d2d * simplify some code, by using is_x86_parameterized_string_instruction_op
git-svn-id: trunk@37448 -
2017-10-12 13:26:07 +00:00
nickysn
98c4986b6d + added x86 helper functions is_x86_string_instruction_op,
is_x86_parameterless_string_instruction_op and
  is_x86_parameterized_string_instruction_op

git-svn-id: trunk@37447 -
2017-10-12 13:18:38 +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
d96558cd64 * fixed bug in assembling some 32-bit instructions on the i8086 target (e.g.
mov dword ptr [something], ebx)

git-svn-id: trunk@37430 -
2017-10-08 11:10:42 +00:00
florian
4cf2a2672a changes to fix #32043
* changed most of the variables in the assembler readers used to store constants from aint to tcgint 
  as aint has only the size of the accumular while some CPUs (AVR) allow larger constants in instructions
+ allow access to absolute symbols with address type in inline assembler
* allow absolute addresses in avr inline assembler
+ tests

git-svn-id: trunk@37411 -
2017-10-06 21:07:19 +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
8589b946fc * different versions (behind cpu specific ifdefs) of process_ea_ref renamed
process_ea_ref_64_32, process_ea_ref_32 and process_ea_ref_16, indicating
  the address size they support; this is done, so that in the future, we can
  mix them all on the same x86 architecture and support multiple address sizes

git-svn-id: trunk@37407 -
2017-10-05 22:15:26 +00:00
nickysn
31c9214884 * replaced R_SUBADDR with the appropriate size (R_SUBW, R_SUBD or R_SUBQ) in
the cpu specific process_ea_ref function

git-svn-id: trunk@37400 -
2017-10-05 20:39:32 +00:00
florian
ce7487b7de o patch by J. Gareth "Kit" Moreton, resolves partially issue #32037
o improves readibility of TX86AsmOptimizer.OptPass1MOV and fixes some spelling mistakes
  + Optimization MovAnd2Mov 2
  + extended Optimization MovTestJxx2TestMov and MovTestJxx2ovTestJxx to take care of and as well
  + Peephole Optimization: movq x,%reg -> movd x,%reg

git-svn-id: trunk@37377 -
2017-10-01 18:40:11 +00:00
florian
198c53a908 o patch by J. Gareth "Kit" Moreton, resolves partially issue #32037
* generate instructions with shorter imm on x86-64 if possible

git-svn-id: trunk@37376 -
2017-10-01 18:40:09 +00:00
florian
15b617546e + call TX86AsmOptimizer.OptPass1VOP for logical operations as well
git-svn-id: trunk@37367 -
2017-10-01 14:40:21 +00:00
nickysn
b3f7bce3a6 * check for CPUX86_HAS_SSE2 instead of CPUX86_HAS_SSEUNIT in Tcgx86.g_concatcopy
git-svn-id: trunk@37327 -
2017-09-26 16:05:23 +00:00
pierre
3c8d38674f Change single/double/extended-str functions to methods
* Disable asd_cpu for wasm (generates errors as it disabled the .xmm added at start)
 - Remaining problem: 'DT inf' Error: not implemented ...

git-svn-id: trunk@37325 -
2017-09-25 22:04:41 +00:00
pierre
ccd8e6a78b Partial fix for watcom wasm
git-svn-id: trunk@37323 -
2017-09-25 20:47:31 +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
florian
05ecd784f2 * factored out OptPass1LEA and use it for x86-64 as well
+ LEAMov2LEA optimization

git-svn-id: trunk@37199 -
2017-09-13 20:40:32 +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
30c38a81a9 + also check register type (must be R_INTREGISTER) and subregister (must be
R_SUBW) in i8086's GetNextReg()

git-svn-id: trunk@37177 -
2017-09-11 13:25:32 +00:00
nickysn
16d7eefbca + adapted and enabled the x86 specific abs() code generation for i8086, because
it generates slightly better code, than the generic implementation

git-svn-id: trunk@37161 -
2017-09-10 12:12:34 +00:00
nickysn
6634141bf4 + generate better code for division by negative power of 2 constants in the x86
(i386 and x86_64) code generator (same as the division by a positive power of
  2, followed by a NEG instruction, to invert the sign of the result; previously
  the code generator generated an IMUL instruction with a magic constant,
  followed by shift; the new code sequence should be both shorter and faster)

git-svn-id: trunk@37003 -
2017-08-21 11:35:20 +00:00
florian
dba1761a76 + tcgx86.a_load_reg_ref cuts data if the ref. size is smaller than the reg. size
git-svn-id: trunk@36953 -
2017-08-20 16:45:02 +00:00
pierre
6a416a6aa1 use --32/--64 for Darwin GNU assembler calls
git-svn-id: trunk@36870 -
2017-08-11 16:04:40 +00:00
pierre
90e846a470 Obsolete system_i386_qnx and remove last references to system_i386_qnx
git-svn-id: trunk@36860 -
2017-08-08 18:00:02 +00:00
pierre
c98e9b230f Some watcom assembler wasm improvements
git-svn-id: trunk@36850 -
2017-08-04 21:15:10 +00:00
nickysn
19087d04da * replace several emit_const_reg calls that generate SHR or SAR instructions
with calls to cg.a_op_const_reg in the x86 div code generator, so that the
  same code can be used in the future for i8086 as well (SHR and SAR by
  constants other than 1 are 186+, so on 8086 they have to go through the CL
  register, which is handled correctly in cg.a_op_const_reg)

git-svn-id: trunk@36815 -
2017-07-31 16:02:52 +00:00
nickysn
9e8cc127b0 * improved the code, generated for signed division by 2 on i386 and x86_64 by
replacing the sequence
    sar reg, 31 (or 63)
    and reg, 1
  with:
    shr reg, 31 (or 63)

git-svn-id: trunk@36800 -
2017-07-27 16:02:30 +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
nickysn
b6c3329f20 + also check for negative powers of 2 in the mod by power-of-2 constant x86 optimization, since the sign of the divisor is ignored by the 'mod' operation
git-svn-id: trunk@36797 -
2017-07-26 16:10:41 +00:00
nickysn
7c306f18e3 + perform unsigned modulus by power of 2 constant by using an AND instruction (instead of DIV) on x86
git-svn-id: trunk@36756 -
2017-07-21 15:58:26 +00:00
florian
22956c4393 + TX86AsmOptimizer.OptPass1OP
git-svn-id: trunk@36365 -
2017-05-28 13:49:43 +00:00
florian
c83e6991d5 * properly check number of operands
git-svn-id: trunk@36322 -
2017-05-25 12:44:30 +00:00
yury
884cb758e7 * Ensure the number of operands is 2 for MOVXX instructions in OptPass1MOVXX. Otherwise the classic MOVSD/W/B no-operand instructions (REP MOVSX) cause AV during checks of operands. The AV is thrown when trying to compile ucomplex.pp with -Cfsse3.
* Also fixed generation of debug comments in OptPass1MOVXX.

git-svn-id: trunk@36295 -
2017-05-22 15:20:18 +00:00
Jonas Maebe
744facb7fc * properly support accepting register parameters of assembler routines in
the intel assembler reader: no longer parse them as register tokens,
    but as local operands that are later converted into registers. This
    ensures in particular that the type of the operand is set, which is
    necessary in case this operand later subscripted (as in tasm10a)

git-svn-id: trunk@36288 -
2017-05-21 20:17:15 +00:00
Jonas Maebe
61af0fb72d * only take into account the location of the parameter at the callee side to
determine whether it's in a register if it's a pure assembler routine
  * you can't "index" implicit pointers either using their fields

git-svn-id: trunk@36287 -
2017-05-21 20:17:11 +00:00
florian
358bfb4858 * SSE4.1+ implementation of int(...)
git-svn-id: trunk@36285 -
2017-05-21 15:28:34 +00:00
florian
3c5ec4e76c * allocate register correctly for "MovMov2Mov 2"
+ more debug messages
* debug message naming fixed

git-svn-id: trunk@36284 -
2017-05-21 15:06:22 +00:00
florian
12dec14859 * try to break dependency chains when generating vsqrt instructions
git-svn-id: trunk@36282 -
2017-05-21 11:35:33 +00:00
florian
8eec29b139 + enable support for a processor specific frac function
* implemented inlined frac support for CPUs with SSE4.1+

git-svn-id: trunk@36281 -
2017-05-21 11:12:59 +00:00
florian
912e6d129a * fix modification flags for *ROUND*
git-svn-id: trunk@36280 -
2017-05-21 11:12:57 +00:00
florian
1ffdf02b94 + Ch_*Op4
+ op_const_reg_reg_reg

git-svn-id: trunk@36279 -
2017-05-21 11:12:55 +00:00
nickysn
7b70848d83 + allow the src register size to be different from the op size or the dst
register size for OP_SHR/OP_SHL/OP_SAR/OP_ROL/OP_ROR in tcgx86.a_op_reg_reg().
  This is required for the in_[shr/shl/sar/rol/ror]_assign_x_y inline nodes.

git-svn-id: trunk@36251 -
2017-05-19 14:03:13 +00:00
florian
0f16f6d94d + OptPass1MOVXX
git-svn-id: trunk@36209 -
2017-05-14 20:59:10 +00:00
florian
535c990233 + OptPass1MOVAP
git-svn-id: trunk@36203 -
2017-05-13 21:48:44 +00:00
florian
3ade6ae9b8 + Mov2Nop optimization
git-svn-id: trunk@36201 -
2017-05-13 09:58:27 +00:00
florian
f4a29bb75d * moved InstructionLoadsFromReg and RegReadByInstruction from TCpuAsmOptimizer (i386) to TX86AsmOptimizer
git-svn-id: trunk@36200 -
2017-05-13 09:58:25 +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
7b658f56dc * compilation fixed after last cleanup
git-svn-id: trunk@36166 -
2017-05-09 20:06:36 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
florian
f93b784895 * make fullcycle for i8086 fixed
git-svn-id: trunk@36164 -
2017-05-09 19:53:06 +00:00
florian
52d3756c26 * factored out OptPass1Movx and merged i386 and x86-64 version
git-svn-id: trunk@36159 -
2017-05-08 20:44:27 +00:00
florian
06c4c651fd * factored out PrePeepholeOptSxx
+ x86-64 uses PrePeepholeOptSxx now as well

git-svn-id: trunk@36158 -
2017-05-08 20:44:24 +00:00
florian
74b338266d * ifdef cmov optimization, as i8086 has no cpu_capabilities
git-svn-id: trunk@36150 -
2017-05-07 16:18:44 +00:00
florian
5c2c5d72a2 * use avx for copying data only on i386 for 8 byte chunks
git-svn-id: trunk@36149 -
2017-05-07 16:18:42 +00:00
florian
f8d517be70 * make TX86AsmOptimizer.IsExitCode usable for x86-64 as well
git-svn-id: trunk@36148 -
2017-05-07 16:18:40 +00:00
florian
4a43d992f5 * unified usage of MatchOpType
* fixed generic MatchOpType

git-svn-id: trunk@36145 -
2017-05-07 16:18:33 +00:00
florian
7afe762d22 * factored out OptPass2Jcc assembler optimization
* OptPass2Jcc now used by x86-64 as well
* remove orphaned alignments if the label is not used anymore after cmov is used

git-svn-id: trunk@36143 -
2017-05-07 12:45:48 +00:00
florian
e3f0b338d4 * SkipLabels moved to aoptutils
* factored out OptPass2Jmp assembler optimization
* OptPass2Jmp now used by x86-64 as well

git-svn-id: trunk@36141 -
2017-05-06 21:07:02 +00:00
florian
f985971a62 * apply mov reg1, mem1; cmp x, mem1 to mov reg1, mem1; cmp x, reg1 also for test
git-svn-id: trunk@36138 -
2017-05-06 18:47:47 +00:00
nickysn
c28d533bb0 + support the cmpsd sse instruction in the at&t inline assembly reader
git-svn-id: trunk@36124 -
2017-05-05 15:46:47 +00:00
nickysn
98d2684368 + correctly support the sse2 version of the cmpsd x86 instruction, when writing
at&t style asm output

git-svn-id: trunk@36122 -
2017-05-05 15:01:38 +00:00
nickysn
b882ba5fd2 + also recognize sbb reg,reg as writing a new value in the register in TX86AsmOptimizer.RegLoadedWithNewValue
git-svn-id: trunk@36119 -
2017-05-05 14:24:13 +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
0e0e5c0caf + support the flags register and its subregisters in TX86AsmOptimizer.RegLoadedWithNewValue
git-svn-id: trunk@36114 -
2017-05-05 12:17:50 +00:00
nickysn
85fbbec319 + recognize xor reg,reg (same register twice) and sub reg,reg as writing a new
value to reg in TX86AsmOptimizer.RegLoadedWithNewValue

git-svn-id: trunk@36112 -
2017-05-05 11:01:34 +00:00
nickysn
aa93259463 + support the lahf,fstsw and fnstsw instructions in
TX86AsmOptimizer.RegLoadedWithNewValue

git-svn-id: trunk@36087 -
2017-05-04 16:02:01 +00:00
nickysn
92cc447326 + support the aam instruction in TX86AsmOptimizer.RegLoadedWithNewValue
git-svn-id: trunk@36083 -
2017-05-04 15:34:48 +00:00
nickysn
2431b1fa19 + support the lodsb,lodsw,lodsd and lodsq instructions in
TX86AsmOptimizer.RegLoadedWithNewValue

git-svn-id: trunk@36082 -
2017-05-04 15:12:37 +00:00
nickysn
6b7593d7d0 + support the SETcc instructions in TX86AsmOptimizer.RegLoadedWithNewValue
git-svn-id: trunk@36081 -
2017-05-04 14:43:18 +00:00
nickysn
e10f184b74 + support lds,les,lfs,lgs and lss in TX86AsmOptimizer.RegLoadedWithNewValue
git-svn-id: trunk@36079 -
2017-05-04 14:08:36 +00:00
nickysn
eac74f5a81 + support the cwd,cdq,cqo and cbw instructions in
TX86AsmOptimizer.RegLoadedWithNewValue (cwde and cdqe don't need special
  support)

git-svn-id: trunk@36077 -
2017-05-04 12:15:40 +00:00
nickysn
1a139b951d + properly support the one operand version of imul and mul in
TX86AsmOptimizer.RegLoadedWithNewValue

git-svn-id: trunk@36068 -
2017-05-03 15:07:21 +00:00
nickysn
65960048c8 * fixed TX86AsmOptimizer.RegLoadedWithNewValue for 3-operand imul, where the
second operand is a memory reference

git-svn-id: trunk@36067 -
2017-05-03 13:43:16 +00:00
nickysn
1f5aec6d3d + make use of the Reg1WriteOverwritesReg2Entirely and Reg1ReadDependsOnReg2
instead of SuperRegistersEqual in TX86AsmOptimizer.RegLoadedWithNewValue, so
  it returns correct information for the 16-bit and 8-bit subregisters
  (including AH,BH,CH and DH)

git-svn-id: trunk@36066 -
2017-05-03 12:14:30 +00:00
nickysn
8926adbab5 * fixed names, returned by std_regname for ymm registers
git-svn-id: trunk@35997 -
2017-04-28 13:46:57 +00:00
nickysn
66c350d8d2 * fixed access violation bug in TX86AsmOptimizer.RegLoadedWithNewValue for the
A_MOVSD string instruction

git-svn-id: trunk@35995 -
2017-04-28 13:09:27 +00:00
nickysn
e6e55b3004 + added function TX86AsmOptimizer.Reg1ReadDependsOnReg2, which checks whether
two registers are independent (taking into account AH vs AL)

git-svn-id: trunk@35991 -
2017-04-28 09:24:48 +00:00
nickysn
33f9b36a54 + added and implemented function TX86AsmOptimizer.Reg1WriteOverwritesReg2Entirely,
which takes into account how 16-bit and 8-bit subregisters work on the x86
  (the new function is not used for now, but is probably going to replace
  SuperRegistersEqual in a few specific places (in RegLoadedWithNewValue),
  so that our register tracking becomes more accurate for 8-bit and 16-bit
  subregisters)

git-svn-id: trunk@35990 -
2017-04-27 22:30:47 +00:00
nickysn
ff1ee6836d + fix RegReadByInstruction for the x86 MOVSD instruction
git-svn-id: trunk@35968 -
2017-04-27 14:42:08 +00:00
Jonas Maebe
aa82e00615 * fixed check to determine whether a record parameter can be subscripted
directly in inline assembly: that's only possible if it's a register
    parameter where the address of the record was passed (rather than the
    record itself), or if a parameter has been explicitly typecasted in
    Intel-style assembly using ".size"

git-svn-id: trunk@35959 -
2017-04-26 19:43:35 +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
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
florian
50dba9ad66 * if both labels of a case label are equal, we still cannot skip the comparison in a jump tree, resolves #31589
git-svn-id: trunk@35880 -
2017-04-21 19:32:27 +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
ec11864272 * use a native sized int register for the shift count in in_sar_assign_x_y,
in_shl_assign_x_y,in_shr_assign_x_y,in_rol_assign_x_y,in_ror_assign_x_y

git-svn-id: trunk@35857 -
2017-04-20 12:38:54 +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
16af6f03fb + support OP_SHR/OP_SHL/OP_SAR/OP_ROL/OP_ROR in tcgx86.a_op_reg_ref
git-svn-id: trunk@35837 -
2017-04-18 15:14:28 +00:00
nickysn
3d28878210 + added taicpu.op_reg_reg_ref() constructor for x86, in order to support the
shld/shrd [ref],reg,CL instructions

git-svn-id: trunk@35832 -
2017-04-18 12:47:57 +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
sergei
8ae0864c9a * x86 Intel asm reader: handle special variables "self" and "result" similar to regular ones in terms of subscripting. This makes fix from r34911 apply to these special variables. Resolves #31542.
git-svn-id: trunk@35669 -
2017-03-27 19:58:55 +00:00
florian
d5754cf47c * create jmp trees for really big case statements
git-svn-id: trunk@35645 -
2017-03-23 17:50:53 +00:00
sergei
2357ca1fe6 * Fixed size suffix generated for CVTSI2SS, CVTSI2SD, VCVTSI2SS, VCVTSI2SD instructions. Mantis #31550.
* tasm2.pp already detected this bug if run with -al option. Added a copy of tasm2.pp and configured it with -al, so it is run daily on all suitable machines.

git-svn-id: trunk@35626 -
2017-03-19 10:29:28 +00:00
florian
ad557a1da6 * allow call dword ptr eax in delphi, resolves #18225
git-svn-id: trunk@35572 -
2017-03-12 16:37:48 +00:00
yury
94a65e99f1 * Removed unused var.
git-svn-id: trunk@35546 -
2017-03-09 13:49:46 +00:00
florian
a8ba81a585 * unused data structure removed
git-svn-id: trunk@35523 -
2017-03-05 08:13:34 +00:00
florian
b9dba41ad0 * intel assembler reader: scale factor in references can also be a constant symbol, resolves #31165
git-svn-id: trunk@35473 -
2017-02-22 20:59:52 +00:00
florian
c4fe4ab1f5 * correctly handle push <imm> on 80186+
git-svn-id: trunk@35455 -
2017-02-19 19:15:16 +00:00
Jonas Maebe
015f034904 * reverted r35424, wasn't ready for commit yet
git-svn-id: trunk@35426 -
2017-02-11 21:21:44 +00:00