Commit Graph

2995 Commits

Author SHA1 Message Date
H. Peter Anvin
2e15eca688 NASM 2.11rc2 2013-11-28 11:36:26 -08:00
H. Peter Anvin
ed8df3eaef Remove "high 16" register class macros for xmm/ymm/zmm
The "high 16" register class macros were actually incorrect, as they
simply aliased the corresponding whole set class.  In oder to keep
someone from getting confused and making mistakes, remove them.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-28 11:35:34 -08:00
Jin Kyu Song
376701ef9a testcase: Remove escape characters - '\'
Since the multi-line macro preprocessor is modified to expand
grouped parameter with braces. The escape character is not needed
any more.
The testcase converter script is also modified not to generate '\'.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-27 21:01:01 -08:00
Jin Kyu Song
5eac14bb0e preproc: Handle curly braces in multi-line macro parameters
Multi-line macro uses curly braces for enclosing a parameter
containing comma(s). Passing curly braces as a part of a parameter
which is already enclosed with braces confuses the macro expander.

The number of braces in a group parameter is counted and any brace
in the outmost enclosing braces is treated as a part of parameter.
	e.g.) mmacro {1,2,3}, {4,{5,6}}
	      mmacro gets 2 parameters of '1,2,3' and '4,{5,6}'

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-27 20:54:07 -08:00
Jin Kyu Song
28f95668e0 Revert "AVX-512: Handle curly braces in multi-line macro parameters"
This reverts commit a800aed7b7.

As recommended by the community, braces inside a group parameter
of multi-line macro should be parsed without a need of a leading
escape character such as "\{ab,c\}".

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-27 20:23:53 -08:00
Jin Kyu Song
487f352b62 stdscan: Rework curly brace parsing routines
As recommended by the community, a comma-separated decorators ({k1,z})
and nested braces ({{k1},{z}}) are dropped out. So only standard syntax
is supported from now.

This rework made source code neat and easy to maintain. Most of the codes
for handling corner cases are removed.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-27 15:43:33 -08:00
Jin Kyu Song
6cfa968e8d iflags: Add IF_EVEX for checking {evex} availability
For checking the availability of {evex} prefix, AVX512 iflag
has been used. But this is a flag for an instruction set
not for an encoding scheme. And there are some AVX512 instructions
encoded with VEX prefix.

So a new instruction flag (IF_EVEX) is added for the instructions
which are actually encoded with EVEX prefix.

This flag is automatically added by insns.pl, so no need to add manually
in insns.dat.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-27 15:43:33 -08:00
Jin Kyu Song
08ae610ec9 opflags: Separate vector registers into low-16 and high-16
Since only EVEX supports all 32 vector registers encoding for now,
VEX/REX encoded instructions should not take high-16 registers as operands.

This filtering had been done using instruction flag so far, but
using the opflags makes more sense.

[XYZ]MMREG operands used for non-EVEX instructions are automatically
converted to [XYZ]MM_L16 in insns.pl

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-27 15:43:32 -08:00
Jin Kyu Song
1ab16e4673 doc: Update the change history and nasmdoc
Added the list of features added since 2.10 release.
Nasmdoc is also updated with those new features.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-27 15:43:32 -08:00
H. Peter Anvin
3143a462c2 disasm: Don't rely on iflag_cmp() returning +/-1
It is safer to just rely on the sign, for future options.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-11-27 13:43:45 -08:00
H. Peter Anvin
afcb66f412 iflag: Do the equality test in iflag_cmp() first
The equality test indicates how long we spin, so do that first.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-11-27 13:41:50 -08:00
H. Peter Anvin
72bf3fe98c assemble: Only treat a displacement as signed if it is < asize
Only generate a signed relocation if the displacement size is less
than the address size.  This matters when involving address size
overrides.

It is technically impossible to do this one perfectly, because it is
never really knowable if the displacement offset is used as a base or
an index.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-26 20:19:53 -08:00
H. Peter Anvin
186b533425 test: Add a test for various 32- and 64-bit relocations
Test signedness in a couple of different contexts.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-26 18:24:22 -08:00
H. Peter Anvin
89a2ac0d0a assemble: Emit signed relocations where appropriate
Emit signed relocations where we know they are necessary.  This is not
at all exhaustive; in particular we are missing this for a number of
8- and 16-bit cases, and probably others.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-26 18:23:20 -08:00
H. Peter Anvin
d35f230113 listing: handle negative (signed) address size values
The listing module also needs to know about this new convention.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-26 18:22:45 -08:00
H. Peter Anvin
fd52c277dd output: Allow OUT_ADDRESS with a negative size to mean signed relocation
This only matters for ELF64/ELFx32, at least for now.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-26 18:12:39 -08:00
H. Peter Anvin
80d18b5555 iflag: In iflag_cmp() scan from the most significant word down
In order for iflag_cmp() to return an ordering that makes sense, we
need to scan from the most significant word downward.  That way the
bits with the higher index consistently are the more significant.

This fixes the disassembler vendor selection algorithm.  While we are
doing that, make that dependency more explicit in the comments.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-26 15:21:15 -08:00
H. Peter Anvin
4b47c77d89 iflag: Drop the use of double underscores
Double underscores are reserved for the implementation, i.e. the C
compiler and its libraries.  NASM is an application and should not use
this namespace.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-24 17:14:34 -08:00
H. Peter Anvin
af90d3520f iflag: Make the insns_flags array const
Make the insns_flags array const, and change the helper functions to
match.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-24 17:13:20 -08:00
H. Peter Anvin
54c7711858 insns.dat: Fix a typo in a comment
isnsn-iflags.pl not insns-iflag.pl.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-24 17:07:33 -08:00
H. Peter Anvin
9a1db45895 iflag: Move instruction flag comment
Move the instruction flag comment to the Perl file where they are
defined.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-24 11:53:38 -08:00
H. Peter Anvin
8b0e5a34fc iflag: remove C99 constructs, don't hardcode the number of words
Avoid using C99 constructs when not necessary.  Don't hardcode the
number of words when we can autodiscover them.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-24 11:49:24 -08:00
H. Peter Anvin
cd4c89bbb9 "make alldeps"
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-24 11:18:50 -08:00
H. Peter Anvin
45a22d9a61 iflag: Fix dependencies, factor out static components of iflag.h
Multi-dependencies don't work as expected, especially not across Make
versions, this is why we don't use them and read the instructions list
multiple times.

iflag.h has a lot of static content, so factor out the static content.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-24 11:13:10 -08:00
H. Peter Anvin
015774dc3f "make alldeps"
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-24 10:56:49 -08:00
Cyrill Gorcunov
ea882d0b59 insns: Restore back MMX,FPU flags
In commit 9bb987d8e0
we had to drop some flags due to flags type used
in nasm code.

Since now flags internal structure is reworked, we
can restore them back.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-11-24 13:21:04 +04:00
Cyrill Gorcunov
970df6f47f Update .gitignore
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-11-24 13:21:04 +04:00
Cyrill Gorcunov
ddf803b498 make: Update deps
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-11-24 13:21:04 +04:00
Cyrill Gorcunov
0835915c1d iflag: Start using new instruction flags engine
Here we start using instruction flags generator.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-11-24 13:20:59 +04:00
Cyrill Gorcunov
d4e51d3e71 insns: Introduce insns-flags.pl
It been found that 64 bits for instruction flags is too small,
so instead we start using indirect addressing scheme to keep
instruction flags in bitvectors instead.

Using one bitvector per instruction template entry is wastefull
(especially if vector grow in future, at moment it's 128 bit length),
so we use indirect addressing, which is generated as follow

 - read instruction flags from insns.dat
 - flag sequence sorted and joined into one key string
 - this key string become a hash index
 - all hash entries are compacted into one array
 - every instruction template uses array offset instead
   of flags bitfield

Just for info, at moment we have 195 unique flags combination,
but since instruction template will use index as unsigned
integer, we can use a way more wider combination of flags
in future.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-11-24 13:20:52 +04:00
Cyrill Gorcunov
acfb97d3db make: Add 'golden' target
We've 'test' target in toplevel Makefile, lets be
complete and allow to generate "golden" tests from
toplevel as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-11-24 12:26:35 +04:00
Jin Kyu Song
305f3cee04 bnd: Drop bnd prefix for relaxed short jmp instructions
Reverted the redundant branch instruction patterns for bnd prefix.
And when a relaxed jmp instruction becomes a short (Jb) form,
bnd prefix is not needed because it does not initialize bnd registers.
So in that case, bnd prefix is silently dropped.

BND JMP foo       -> drops bnd prefix
BND JMP short foo -> shows an explicit error

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-22 11:59:14 -08:00
Jin Kyu Song
5f3bfee708 disp8: Consolidate a logic to get compressed displacement
Consolidated two separate but similar functions in nasm and ndisasm
into a commonly linked source code.
To encode and decode the compressed displacement (disp8*N) for EVEX,
N value should be derived using various conditions.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 15:40:55 -08:00
Jin Kyu Song
28d5bf811b disasm: Add suport for bnd registers
MPX uses a new bnd registers and a new mib syntax.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
5f80dace3a disasm: Add EVEX decorator syntax
Broadcasting, opmask, embedded rounding and SAE decorators
are not added at proper position.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
6076e8f335 disasm: Add ZMM vsib
ZMM registers can be used for vsib index and the number of registers
has been increased to 32.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
6b29602bf4 disasm: Support EVEX compressed displacement
When tuple type is indicated in the bytecode, disp8 is
treated as a compressed disp and gets calculated back to disp8*N.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
4a8dc019ef disasm: Add basic AVX512 support
Disassembler can translate EVEX prefix, count up to 32 vector registers
and recognize new ZMM / opmask registers.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
9e59ace66c disasm: style cleanup
Fix indentation.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
25c2212586 match: Check the number of elements in broadcasting operands
The broadcasting decorator {1to##} must describe exactly how many times
the memory element is repeated in order to clearly match the correct
instruction format.

For example,
    vaddpd zmm30,zmm29,QWORD [rdx+0x3f8]{1to8}   ; good
    vaddpd zmm30,zmm29,QWORD [rdx+0x3f8]{1to16}  ; fail qword * 16 = 1024b

    vaddps zmm30,zmm29,DWORD [rcx]{1to16}	 ; good
    vaddps zmm30,zmm29,DWORD [rcx]{1to8}	 ; fail dword * 8 = 256b

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
7903c07b77 match: Improve broadcast opsize matching
Broadcasting operand size is different from the original
operand size because 32b or 64b element is repeated to form a vector.
So when matching a broadcasting operand, opsize should be treated
differently.
The broadcasting element size is specified in the decorator information.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
c9486b965b Build: Suppress warning messages
Giving a correct printf format specifier supresses the warning message.
And a local pointer variable is initialized with NULL.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
945b1b8f36 AVX-512: Add {evex} instruction prefix
For instructions that can be encoded either in VEX or EVEX,
{evex} forces nasm to encode in EVEX.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
267d0af79c PREFETCHWT1: Add a new instruction flag
PREFETCHWT1 instruction's CPUID was TBD before.
Now it has its new CPUID bit : PREFETCHWT1

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
22b1f082bd AVX512: Update instruction group
CPUID bit for vptestnm[dq] changed.
vptestnm[dq]: AVX512CD -> AVX512F

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
b4e1ae18e2 MPX: Move BND prefix indication from bytecode to iflags
As BND prefix validity check conflicts with jcc8 prefix,
IF_BND is added for the instruction templates which can have
bnd prefix for preserving the content of bound register.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
3b65323d80 MPX: Adapt GAS's mib syntax with an index reg only
GAS uses *1 multiplier for explicitly marking an index register in mib operand.
e.g.) [rdx * 1 + 3] is equivalent to [3, rdx] in NASM's split EA format
So only for mib operands, this is encoded same as gas does.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
47e7389fdf iflags: Use UINT64_C() for 64bit values
UINT64_C() macro is used for iflags as it becomes 64bit.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
c7fcf6d516 SHA: SHA test cases
32bit and 64bit test asm files.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
da1a5cd514 SHA: Add SHA instructions
New instruction extensions of SHA family are added.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00