Commit graph

284 commits

Author SHA1 Message Date
H. Peter Anvin
9255b51369 test: simple pragma preprocessor test
Simple test to examine the preprocessor output from %pragma.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 15:01:34 -07:00
H. Peter Anvin
76c49379b7 test/Makefile: add rule to generate preprocessor output
Add a rule in the test directory to run the preprocessor.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 14:56:37 -07:00
H. Peter Anvin
04445364fc incbin: if we have to fread(), try to do it only once...
If we can't mmap a file and instead have to fread(), if the data is
small enough that we can reasonably accomodate it in a memory buffer,
then just read it once.

It seems rather unlikely that very large files would be used with
TIMES anyway.

Also note: the previous comment about nasm_file_size[_by_path]() being
invoked twice was spurious; it does not actually happen.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-09-21 15:56:19 -07:00
H. Peter Anvin
d81a235f33 file: improve the file access interface
A number of fairly common operations are invoked way too many times,
especially when using incbin.  Drastically reduce the number of system
calls that need to be executed, and use memory mapping to reduce
unnecessary double buffering.

We could improve this further by leaving files open once used;
however, that might run into file count problems on some systems.

Still unclear is why we seem to invoke nasm_file_size() twice per pass
for incbin.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-09-21 14:07:17 -07:00
H. Peter Anvin
3736895c07 Fix and clean up listing of macro expansion
Fix the printing of the macro stack: we need to follow the
mstk->next_active list, not mstk->next, and we need to reverse the
order so that the highest-level inclusion comes first.

Since this should be a rare or at least performance-insensitive
operation, do it using simple function recursion.

Finally, add an ellipsis before the "from macro" message; it greatly
enhances readability.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 14:10:32 -07:00
H. Peter Anvin
4def1a8db4 Show the expanded macro stack when displaying diagnostics
It can be hard to find errors inside potentially nested macros.
Show the mmacro expansion stack when printing diagnostics.
Note that a list file doesn't help for errors that are detected
before the code-generation pass.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 13:59:44 -07:00
H. Peter Anvin
69550eac55 Specifically if we encounter the PTR keyword
Issue a specific suppressible warning if we encounter the PTR keyword.
This usually indicates someone mistakenly using MASM syntax in NASM.

This introduces a generic infrastructure for issuing warnings for such
keywords.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 12:05:56 -07:00
H. Peter Anvin
fc0ff223b2 labels: emit the same label name to the output and debug backends!!
When a local label was seen, the debug backend would not receive the
full label name!  In order to both simplify the code and avoid this
kind of discrepancy again, make both the output and debug format calls
from a common static function.

However, none of the current debug format backends want to see NASM
special symbols (that start with .. but not ..@) so filter those from
the debug backend.

Finally, fix an incorrect comment in nasm.h: the debug format is
called *after* the output format.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Jim Kukunas <james.t.kukunas@linux.intel.com>
2016-03-07 22:00:01 -08:00
H. Peter Anvin
d414e5f4cd test/cv8struc.asm: fix missing comma in test case
Fix a missing comma in the test case which make the test case bogus.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-04 10:59:13 -08:00
H. Peter Anvin
a9a1b5c318 test: add test for cv8 structure bug (BR 3392342 and 3392343)
Add test case for bugs 3392342 and 3392343.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-03 17:05:20 -08:00
H. Peter Anvin
114ba75f7b test/Makefile: add a rule for nasm itself
If NASM needs to be rebuilt, build it in the proper directory.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-18 13:06:04 -08:00
H. Peter Anvin
89f78f5010 Merge branch 'nasm-2.11.xx'
Resolved Conflicts:
	assemble.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-05-21 08:30:40 -07:00
H. Peter Anvin
0a9250c2ab BR 3392279: Fix duplicated REX prefixes
The fix for BR 3392278:

aa29b1d93f assemble.c: Don't drop rex prefix from instruction itself

... would cause multiple REX prefixes to be emitted for some
instructions.  Create a new flag to indicate that REX has already been
emitted, which can be cleared for each instance of an instruction.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-05-21 08:24:21 -07:00
H. Peter Anvin
49de44e56d Merge remote-tracking branch 'origin/signrel' 2014-05-09 15:09:43 -07:00
H. Peter Anvin
1eef781594 BR 3392275: Don't require xmm0 to be specified when implicit
BR 3392275 complains about xmm0 having to be explicitly included in
the assembly syntax when it is implicit in the encoding.  In the
interest of "be liberal in what you accept", accept either form in the
input.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2014-02-16 10:25:25 -08:00
Jin Kyu Song
b0c729baeb mpx: Clean up instruction data
Cleaned up unneccessary size specifiers in the instruction data.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-12-18 22:37:36 -08:00
H. Peter Anvin
621a69ac5c Add {vex3} and {vex2} prefixes by analogy with {evex}
Allow specifying {vex3} or {vex2} (the latter is currently always
redundant, unless we end up with instructions at some point can be
specified with legacy prefixes or VEX) to select a specific encoding
of VEX-encoded instructions.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-11-28 12:21:11 -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
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
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
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
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
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
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
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
Jin Kyu Song
eb595942b2 AVX-512: Added AVX-512PF instructions
Added Prefetch (AVX-512PF) instructions.
These instructions are supported
if CPUID.(EAX=07H, ECX=0):EBX.AVX512PF[bit 26] = 1.
CPUID feature flag for PREFETCHWT1 is TBD
but PREFETCHWT1 is included in this commit.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-09-14 01:27:10 +04:00
Jin Kyu Song
dd1c0c13c8 AVX-512: Add AVX-512ER instructions
Added Exponential and Reciprocal (AVX-512ER) instructions.
These instructions are supported
if CPUID.(EAX=07H, ECX=0):EBX.AVX512ER[bit 27] = 1.
IF_AVX512 is now shared by all AVX-512* instructions as a bit mask.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-09-14 01:27:06 +04:00
Jin Kyu Song
d4b2b5f17c AVX-512: Add AVX-512CD instructions
Added Conflict Detection (AVX-512CD) instructions.
These instructions are supported
if CPUID.(EAX=07H, ECX=0):EBX.AVX512CD[bit 28] = 1.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-09-14 01:27:02 +04:00
Jin Kyu Song
c257bb6ae0 AVX-512: Add Pseudo-ops for CMP instructions
Added three-operand pseudo-ops for VCMPPD, VPCMPD and so on.
Test case is also updated to validate them.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-09-07 11:50:39 +04:00
Jin Kyu Song
088827bc6c AVX-512: Add test case for opmask instructions
Added K* instructions test cases in test/avx512f.asm.
The previous test case from GNU AS were repeating the same instruction twice,
so the repeated half part is removed.
Changed the python script (gas2nasm.py) to include opmask instructions.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-08-29 10:03:36 +04:00
Jin Kyu Song
6d16d2836d AVX-512: Fix comments
Fixed or purged some old comments and added a comment for a previous patch.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-08-29 10:03:09 +04:00
Jin Kyu Song
fe0ee08586 AVX-512: Add a feature to generate a raw bytecode file
From gas testsuite file, a text file containing raw bytecodes
is useful when verifying the output of NASM.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-08-28 14:27:25 +04:00
Jin Kyu Song
f9442f67d5 AVX-512: Add a test case for EVEX encoded instructions
This was converted from a gas testsuite.
(gas/testsuite/gas/i386/x86-64-avx512f-intel.d)
A python script that is used for converting is also included.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-08-28 14:27:17 +04:00
Cyrill Gorcunov
340ac1a915 test: Add br978756
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-07-21 14:45:48 +04:00
Cyrill Gorcunov
31d73aefb3 test: Add br3392259
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-07-21 14:45:48 +04:00
H. Peter Anvin
e20ca02cfb BR 3392260: Handle instructions only separated by vector SIB size
There are two instructions (VGATHERQPS, VPGATHERQD) where the only
separation between two forms is the vector length given to the vector
SIB.  This means the *matcher* has to be able to distinguish
instructions by vector SIB length and the matcher only operates on the
operands and the instruction flags, not on the bytecode.

Export the vector index-ness into the operand flags and add to the
matcher.

This resolves BR 3392260.

Reported-by: Agner <agner@anger.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-07-19 17:09:39 -07:00
Cyrill Gorcunov
29e2f74a58 test: Add br3392252 test
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-05-13 02:21:08 +04:00
H. Peter Anvin
56bff2df92 hle: opcode A2 forbidden with HLE prefixes
The moffset opcodes A2 and A3 do not support HLE.  Unfortunately
checkin

fb3f4e6d HLE: Change NOHLE to be an instruction flag

... inadvertently lost the NOHLE flag for opcode A2.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-07-22 21:04:20 -07:00
H. Peter Anvin
b55a1436e4 test: ilog2() test
Test for the ilog2 function/macros.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-31 10:28:00 -07:00
Cyrill Gorcunov
eaebcb4258 test: Add br3385573 testcase
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-03-06 11:18:02 +04:00
H. Peter Anvin
b106ba161f Try again to fix our handling of MOVD/MOVQ
Try to implement the handling of MOVD as attempted in checkin:

    70712c0df6

and reverted in:

    d279fbbd80

due to BR3392199.  This time make sure to use the SX flag to only
match when a size is explicitly given, and also don't duplicate the 0F
6F/7F opcodes, which are documented as MOVQ by AMD as well as Intel.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-03-05 22:37:21 -08:00
H. Peter Anvin
fb3f4e6ddb HLE: Change NOHLE to be an instruction flag
The way our matching system works we have to make NOHLE an instruction
flag rather than an byte code; by the time we run the byte code
interpreter we have already picked an instruction pattern once and for
all.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-25 22:22:07 -08:00
H. Peter Anvin
9fa2e72997 Add support for UTF-16BE and UTF-32BE
Add support for bigendian UTF-16 and UTF-32, and (for symmetry) add
explicitly littleendian operators.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-25 15:29:37 -08:00
H. Peter Anvin
c3bfc7f643 Clean up JMP/CALL patterns, especially for 64 bits
Clean up JMP/CALL patterns so they don't disassemble quite so uglily.
Fix a CALL pattern which would have incorrectly generated a (harmless)
REX.W prefix.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-25 12:13:50 -08:00
Cyrill Gorcunov
2c3f7573b8 Add AVX2 test file
nasm64developer kindly provided a testfile converted
to nasm format.

http://sourceware.org/ml/binutils/2011-06/msg00150.html

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-08-31 01:22:43 +04:00
Cyrill Gorcunov
767a4e8313 test: Add movd.asm
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-26 01:53:38 +04:00
H. Peter Anvin
95adeabff5 Implement the VGATHERP instruction
As an initial test of the VSIB handling, implement the VGATHERP
instruction.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2011-06-22 18:20:28 -07:00
Cyrill Gorcunov
a09fe1ebfb Merge branch 'nasm-2.09.xx'
Conflicts:
	doc/changes.src
	version

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-03-12 22:35:42 +03:00
Cyrill Gorcunov
ffa4c37eaf test: Add br3189064
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-03-07 12:42:46 +03:00