Commit graph

2767 commits

Author SHA1 Message Date
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
Jin Kyu Song
40762afbe8 MPX: Add test cases for MPX
MPX test asm files are added. These include all three different styles of
mib syntax (NASM, ICC and gas).

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
0304109b3d MPX: Add BND prefix for branch instructions
BND prefix is used for adding bounds checking protection
across flow control changes such as call, ret, jmp and jcc calls.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
164d60740f MPX: Add MPX instructions
Added MPX instructions and corresponding parser and encoder.

ICC style mib - base + disp and index are separate - is supported.
E.g. bndstx [ebx+3], bnd2, edx -> ebx+3 : base+disp, edx : index

As a supplement to NASM style mib - split EA - parser,
omitted base+disp is now treated as 0 displacement.
E.g. bndstx [,edx], bnd2 -> bndstx [0,edx], bnd2

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:41 -08:00
H. Peter Anvin
0bc288f8b9 disasm: add support for emitting split EA format
Add support for emitting split EA format in the disassembler,
indicated by the MIB instruction flag.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:41 -08:00
H. Peter Anvin
9148fb5951 parser: support split base,index effective address
Mostly intended for the "mib" expressions in BNDLDX/BNDSTX.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:41 -08:00
H. Peter Anvin
9f4706ff45 parse: factor out mref parsing
Factor out the parsing of an mref from parse_line().  In order to
support the [base,index] syntax we need to be able to parse an mref in
two steps.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:41 -08:00
H. Peter Anvin
df0d1ba107 parser: simplify code by keeping a pointer to the current operand
There is an awful lot of syntax-heavy "result->oprs[operand]" going
on; simplify by making a pointer to the current operand.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:41 -08:00
Jin Kyu Song
9f6188f05e AVX-512: Add perfomtest-compliant headers to test cases
test/avx512*.asm files are now tested by using perfomtest.pl
Refer to pefomtest help message for the usage.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:41 -08:00
Cyrill Gorcunov
e75331cc09 BR3392270: preproc: Handle all token chains in mmacro params range
A typical example is

|
| %macro m0 0-*
|     %rep %0
|         m0 arg is %1
|         %rotate 1
|     %endrep
| %endmacro
|
| %macro m1 0-*
|     m0 %{1:-1}
| %endmacro
|
| m1 a=b, c=d

If passed with nasm -E the output must be like

 m0 arg is a=b
 m0 arg is c=d

http://bugzilla.nasm.us/show_bug.cgi?id=3392270

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-11-09 12:08:41 +04:00
H. Peter Anvin
c6c750cb3d Add (redundant) parentheses around bit tests mixed with &&
It is easy to get confused when mixing & and &&, so add redundant
parenteses for clarity.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-11-08 15:28:19 -08:00
Jin Kyu Song
1be09ee0d7 REX: Set REX bits in accordance with 32-register environment
REX.RXB bits were set for high-8 registers previously.
Since high-16 zmm registers are newly added, those bits should
be set as one bit of binary number of register value.
Similarly EVEX.R'/V'/X should be set in the same manner.

Authored-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-08 01:48:31 -08:00
Cyrill Gorcunov
32019da3a4 Revert "make: Remove generated files on clean target"
This reverts commit b6c7291b3d.

We already have this cleanup stage in "cleaner" target, I managed
to miss it.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-10-28 11:35:55 +04:00
Cyrill Gorcunov
b6c7291b3d make: Remove generated files on clean target
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-10-27 21:15:47 +04:00
H. Peter Anvin
8bbf299307 Merge remote-tracking branch 'origin/master' 2013-10-24 14:17:23 +01:00
H. Peter Anvin
33eecb68c2 Makefile.in: always run "make alldeps" when "make dist"
"make dist" (tarball generation) really should include "make alldeps"
so the Makefile dependencies are correct.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-10-24 13:57:57 +01:00
H. Peter Anvin
faf04eec3c Run "make alldeps" to update dependencies 2013-10-24 13:45:06 +01:00
H. Peter Anvin
165eead3b8 Makefile.in: generate manpages for "make dist"
Make sure the "dist" target generates the man pages.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-10-24 13:25:51 +01:00
H. Peter Anvin
d089c2251b Revert "build: Include pregenerated nasm manpages"
This reverts commit 99427bdb6c.

We don't include generated files in the repository, instead we should
pregenerate them for the tarball generation, just as we do for the
Perl-generated files.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-10-24 13:22:19 +01:00
H. Peter Anvin
f9f8017ea1 macros.pl: Remove superfluous whitespace
Squeeze multiple whitespace characters together, since they have no
semantic function.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-10-19 12:20:28 -07:00
Jin Kyu Song
36ccfa5fb4 iflags: Eliminate perl smart match operator
As smart match operator reuiqres perl version 5.10.1 or later,
it is replaced with grep function.
This part of code is going to be completely removed once iflags
renovataion is done. This commit is a quick fix for a build error.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-10-07 14:51:09 -07:00
Cyrill Gorcunov
a1d481041a Merge branch 'nasm-2.10.xx'
* nasm-2.10.xx:
  coff: Better handling of section redefinition
2013-10-03 17:21:39 +04:00
Marat Dukhan
29227125f0 coff: Better handling of section redefinition
Currently, if we try to define an already defined section and specify
section flags, NASM will output "warning: section attributes ignored
on redeclaration of section %SECTIONNAME%".

The patch modifies this behaviour:

1. If the previous section definition differs only in alignment flags,
   no warning is generated

2. If the new definition implies larger alignment, it overrides the
   previous section alignment

3. If the new definition specifies any section alignment, the content of
   the section will be aligned on the new boundary (i.e. the effect is the
   same as if there was ALIGN macro)

Signed-off-by: Marat Dukhan <maratek@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-10-03 16:55:50 +04:00
H. Peter Anvin
9d5461069d Add support for DZ and RESZ, document the ZWORD keyword
Add the DZ and RESZ pseudoinstructions and add ZWORD to the
documentation.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-10-02 18:28:49 -07:00
H. Peter Anvin
a9ecfa5ae8 NASM 2.11rc1 2013-10-02 14:58:19 -07:00
H. Peter Anvin
92a4b71f1b NASM 2.10rc1 2013-10-02 14:58:02 -07:00
H. Peter Anvin
20b262ed45 Merge branch 'avx512'
AVX512 is ready enough that it will realistically be in version 2.11.
Add AVX512 to the master branch; for legacy branch maintenance use the
nasm-2.10.xx branch.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-10-02 14:28:09 -07:00
Cyrill Gorcunov
e81b2ee85c strfunc: Tabs to spaces conversion
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-09-21 13:14:15 +04:00
Marat Dukhan
91c43d789a coff: Support for section names longer than 8 bytes
http://bugzilla.nasm.us/show_bug.cgi?id=3392233

Signed-off-by: Marat Dukhan <maratek@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-09-21 13:09:03 +04:00