Commit Graph

705 Commits

Author SHA1 Message Date
Jonas Maebe
28740dce2d - removed extra "fordefinition" parameter again from tprocdef.mangledname(),
since the definition-specific adorning of JVM mangled names is Jasmin-
    specific, and such code has no place in symdef
  * moved code to adorn JVM mangled names for Jasmin definitions to agjasmin

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

git-svn-id: branches/jvmbackend@18339 -
2011-08-20 07:48:33 +00:00
Jonas Maebe
e2e32fbbe9 * fixed temp leaking after release_unused_return_value_cpu() refactor:
renamed refactored routine to do_release_unused_return_value()
    which by default releases temps, and if something else needs to
    be done override (and call inherited if temps may have to be
    released)

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

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

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

git-svn-id: branches/jvmbackend@18288 -
2011-08-20 07:22:00 +00:00
florian
87696a4b70 * cr*, dr*, tr* registers are 64 bit on x86-64
git-svn-id: trunk@18243 -
2011-08-17 11:42:11 +00:00
florian
8308b46a94 + support for assembler instructions with four operands
+ support for insertq, resolves #19910

git-svn-id: trunk@18206 -
2011-08-14 16:46:35 +00:00
florian
58d1a66cd0 * set max_operands to 4 on x86 to be prepared for avx and to be able to fix #19910,
- memory usage of a compiler compilation increases by approx. 2 per cent due to this
  - actually docs say avx has operations with 5 parameter, however I were not able to find
    an instruction having 5 operands

git-svn-id: trunk@18202 -
2011-08-14 09:09:57 +00:00
pierre
bafbbe9f0f * Fix bug report 7210
git-svn-id: trunk@18154 -
2011-08-09 15:52:03 +00:00
sergei
0231863fce + Added missing PMULLD instruction, part of Mantis #19910
git-svn-id: trunk@18106 -
2011-08-06 06:59:33 +00:00
pierre
cff85bdb3b * Rename ag386nsm.pas unit source to agx86nsm.pas
git-svn-id: trunk@17933 -
2011-07-04 09:13:55 +00:00
pierre
f6ab12d677 * Move ag386nsm.pas to x86 directory
git-svn-id: trunk@17932 -
2011-07-04 09:08:54 +00:00
florian
01e9eacf5c * merge changes committed to the wrong branch
git-svn-id: trunk@17857 -
2011-06-28 18:23:02 +00:00
pierre
3fd3cc8099 * Avoid warning for i386 cpu
git-svn-id: trunk@17851 -
2011-06-28 08:02:35 +00:00
florian
26850e3425 * fix full cycle after adding new boolean types
git-svn-id: branches/pasboolxx@17847 -
2011-06-27 20:11:08 +00:00
florian
d35d1ed357 + initial support for pascal booleans with sizes 2, 4 and 8
git-svn-id: branches/pasboolxx@17836 -
2011-06-26 15:02:37 +00:00
sergei
7d99f95c45 * Always create a section before emitting data to current_asmdata.asmlists[al_typedconsts]. Without it, such data ends up in sections created elsewhere, creating very non-obvious dependencies on other parts of compiler.
git-svn-id: trunk@17816 -
2011-06-24 02:05:56 +00:00
pierre
8a0ed92957 * Remove useless code for i386
git-svn-id: trunk@17806 -
2011-06-23 14:50:31 +00:00
sergei
19c8000056 64-bit masm writer:
* fixed writing rip-relative references
* use correct name to close the last section

git-svn-id: trunk@17710 -
2011-06-10 03:47:13 +00:00
sergei
354d0520b7 + x86 assembler: fixed MOVABS instruction (it is a x86_64-only subset of MOV with 8-byte immediates/offsets) and same-form encodings of MOV instruction.
git-svn-id: trunk@17666 -
2011-06-05 17:32:18 +00:00
florian
2005f6869b * cycling with $R+ fixed
git-svn-id: trunk@17600 -
2011-05-28 21:18:35 +00:00
sergei
5bda700410 * External assemblers: moved some common code into the base class, 4 copies reduced to one.
git-svn-id: trunk@17561 -
2011-05-26 13:10:49 +00:00
sergei
d89aeeadaf x86 assembler:
* Adjust rip-relative offsets using values known from calcsize, instead of reinterpreting the tail of instruction. This is simpler and remains the same regardless of particular codes used in opcode table.
* Reduced maxinfolen to 8.
- 'jmp imm64' and 64-bit versions of 'in' do not exist, removed.

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

git-svn-id: trunk@17515 -
2011-05-20 20:39:35 +00:00
sergei
08ff5ff051 * x86 Intel assembler reader: disallow more than one register name per register operand, resolves #15672.
git-svn-id: trunk@17507 -
2011-05-19 20:00:15 +00:00
sergei
08e895cf7c * Fixed handling of 'movq' instruction by assembler reader, resolves #18205.
git-svn-id: trunk@17497 -
2011-05-19 06:44:24 +00:00
sergei
1aa5c4ac0e * Fixed wrong ModRM byte in movq encoding, causing regression of test/cg/tcalext6 in r17490.
git-svn-id: trunk@17493 -
2011-05-18 14:55:26 +00:00
sergei
9e8a31193b x86 assembler:
* Optimized the opcode representation of movq and remaining 3DNow instructions
* Disallow immediates not fitting in 32 bits (Mantis #14685) + test
* Disallow push/pop with 32-bit operands in x86_64 + test

git-svn-id: trunk@17490 -
2011-05-17 20:06:12 +00:00
sergei
d908fb42f7 x86 assembler fixes:
* Factored repeating REX operations into a separate function.
* Fixed instruction matching bug which was preventing compilation of 3-operand SIMD instructions with RIP-relative operand + test.
* Do not adjust offset of RIP-relative reference if it is a literal number, this was causing 0x123(%rip) to assemble as 0x122(%rip) in 3-operand instructions. Now tasm2.pp is the same with and without -Aas. Also fixed the expected result, improved verbosity of diagnostic and removed %norun, so it is actually executed.
+ Disallow high-byte registers in instructions requiring REX + test.

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

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

git-svn-id: trunk@17457 -
2011-05-14 16:36:42 +00:00
sergei
86d0c7f4c5 * x86 assembler: write REX prefix before the first literal byte of instruction (this becomes possible once the instruction table has all $66,$F2,$F3 prefixes changed to non-literal control codes). This way it is no longer necessary to manually specify position of REX in every instruction entry (code \323 becomes obsolete), and the situation when REX is not written (IE 200603191) is hopefully gone forever.
git-svn-id: trunk@17456 -
2011-05-14 16:02:31 +00:00
sergei
3b979fef6d * Re-commit r17437 after more testing and fixing aasmcpu.pp in r17449.
git-svn-id: trunk@17452 -
2011-05-14 11:04:52 +00:00
sergei
6d0d8734e0 * x86 assembler: operand type declarations rewritten using expressions instead of literal numbers where possible. Reassigned bit values to match the current NASM (the values themselves don't actually matter and can be chosen pretty arbitrary. What matters is the clean separation between different parts of the bitmask. In particular, the old value of XMM register class bit was equal to OT_BITS80, causing matching algorithm to effectively ignore it and accept e.g. MMX registers in place of XMM ones, part of Mantis #14387).
* Fixed matching of memory references with OT_XMMRM and OT_MMXRM.

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

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

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

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

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

git-svn-id: trunk@17430 -
2011-05-11 12:31:18 +00:00
pierre
0d7945d8ae Avoid range check error on internalerror function call
git-svn-id: trunk@17399 -
2011-05-03 14:15:52 +00:00
sergei
d288592c5a + Declared operand types OT_XMMRM (matches either xmm register or 128-bit memory reference) and OT_MMXRM (same for mmx).
* Modified taicpu.Pass2 to exclude non-definitely assigned variable and issue InternalError if impossible segment prefix is used.

git-svn-id: trunk@17374 -
2011-04-26 16:34:36 +00:00
sergei
1bcc41c8c6 * x86 assembler reader: fixed bug in Tx86Instruction.AddReferenceSizes which was causing "Unable to determine operand size" error on instructions like "cmpss $0x10,(%rax),%xmm7" (3-operand instructions with reference being the source operand).
git-svn-id: trunk@17370 -
2011-04-25 21:35:36 +00:00
sergei
92adf34e3f * Tighten rules for accepting ATT suffixes, no longer accept FPU suffixes for integer instructions and vice versa. Resolves #18900.
* tb0267.pp required patching due to 'fildw' instruction at line 72, which is rejected by GAS. Before this commit, FPC was silently converting it to 'filds', so it went unnoticed. Now FPC rejects 'fildw' like GAS does.

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

git-svn-id: trunk@17353 -
2011-04-20 11:18:13 +00:00
florian
c97869bd89 * merge user sections support branch
git-svn-id: trunk@17285 -
2011-04-10 18:08:59 +00:00
florian
9279c6955e * support for SSSE3, SSE4,1, SSE4.2, AES instructions set by Emelyanov Roman, resolves #18527
+ test for aes support

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