Peter Johnson [Sat, 31 Oct 2009 21:52:42 +0000 (21:52 -0000)]
Fix #187: Add new variable CFLAGS_FOR_BUILD for CC_FOR_BUILD compiles.
Due to the need to support cross-building, CC_FOR_BUILD is used instead of
CC for tools that will be run as part of the build process. However, it
is sometimes necessary to add custom CFLAGS for these builds; CFLAGS_FOR_BUILD
supports this cleanly.
Peter Johnson [Thu, 6 Aug 2009 07:13:11 +0000 (07:13 -0000)]
Fix #186: Avoid memory runaway in optimizer TIMES circular reference checking.
Check for duplicates in backtrace used when checking for circular references.
This uses a simple N^2 algorithm (as the number of items in the backtrace is
usually small) but avoids memory runaway due to duplicate item storage.
Peter Johnson [Wed, 3 Jun 2009 05:49:18 +0000 (05:49 -0000)]
Fix #173: Debug full paths were being generated incorrectly.
This was because the path returned by yasm__getcwd() did not have a trailing
slash and thus yasm__combpath() stripped off the last path component.
Peter Johnson [Sun, 10 May 2009 05:24:46 +0000 (05:24 -0000)]
Add support for AMD XOP, FMA4, and CVT16 instructions (replacing SSE5).
AMD has obsoleted the SSE5 spec in favor of these instructions. These
instructions use an AVX-like new opcode structure called XOP instead of
the SSE5 DREX byte.
The AMD FMA4 instructions are a copy of the *old* Intel FMA instructions.
Intel has since updated their spec, and AMD may follow, but for now we've
implemented what AMD's spec contains.
Peter Johnson [Sun, 10 May 2009 05:21:26 +0000 (05:21 -0000)]
Add gencheck.py Python script to make it easier to generate expected results
from long .asm files that generate simple binary output (e.g. for opcode
testing).
Peter Johnson [Fri, 17 Apr 2009 03:25:08 +0000 (03:25 -0000)]
tasm (tweaked nasm) preproc fixes:
- comments stripped before tokenization caused strings containing ';'
to generate warnings (unterminated string) and incorrect output.
- assume directive parsing did not properly handle ';' as end of line
Peter Johnson [Tue, 24 Mar 2009 06:33:32 +0000 (06:33 -0000)]
Fix #155: Don't crash on missing %endmacro.
We were crashing because we didn't generate this error until the preproc
module was getting cleaned up, which doesn't happen until after linemap
is cleaned up. Instead detect and output this error when we reach the end
of preprocessed tokens during the parsing stage.
Peter Johnson [Tue, 24 Mar 2009 05:04:15 +0000 (05:04 -0000)]
Remove vc7 and vc8 build files, as they're no longer being maintained.
There's a Python script (vc98_swap.py) in the Mkfiles/vc9 directory for
those who want to build with vc8.
Peter Johnson [Fri, 20 Mar 2009 07:36:49 +0000 (07:36 -0000)]
Update code generated for alignment padding for more recent processors.
Also match GAS behavior by using different NOP sequences for AMD and Intel.
Different "Long" NOP opcode sequences are used based on the below criteria.
Defaults in 32-bit mode:
- CPU directive not used: backwards compatible (no long NOP opcodes)
- CPU directive with Intel CPU >= 686: Intel guidelines, using long NOPs
- CPU directive with AMD CPU >= K6: AMD guidelines, using long NOPs
Defaults in 64-bit mode:
- CPU directive not used: Intel guidelines, using long NOPs
- CPU directive with Intel CPU >= 686: Intel guidelines, using long NOPs
- CPU directive with AMD CPU >= K6: AMD guidelines, using long NOPs
The above defaults may be overridden with these options to the CPU directive:
- CPU basicnop: backwards compatible (no long NOP opcodes)
- CPU intelnop: Intel guidelines, using long NOPs
- CPU amdnop: AMD guidelines, using long NOPs
Suggested by: Brian Gladman <brg@gladman.plus.com>
Peter Johnson [Mon, 2 Feb 2009 08:20:12 +0000 (08:20 -0000)]
Add support for VEX-encoded pclmul*qdq instructions per the latest AVX spec.
To stay consist with handling of other VEX instructions, also add yasm
extensions to support combining the first two operands for direct translation
from non-VEX to VEX-encoded by simply adding a "v" prefix to the opcode.
Contributed by: Mark Charney, Intel Corporation <Mark.Charney@intel.com>
Yasm extensions by: Peter Johnson
Peter Johnson [Wed, 14 Jan 2009 08:28:13 +0000 (08:28 -0000)]
Update AVX and FMA to latest Intel specification (Dec 2008).
- Removed VPERMIL2 opcodes (VPERMIL2PS, VPERMIL2PD).
- Replaced 4-operand FMA instructions with completely new set of opcodes.
Contributed by: Mark Charney, Intel Corporation <mark.charney@intel.com>
Peter Johnson [Fri, 2 Jan 2009 07:27:39 +0000 (07:27 -0000)]
Gas parser: Move instruction/prefix lookup from tokenizer to parser.
Use the single token of lookahead to detect the label case.
This is significantly cleaner as it removes the special-casing of labels
in the tokenizer (so there is just a single identifier rule) and removes
the INSTDIR parser state (as this was only used to prevent instruction
lookup within other locations).
Also, ID and LABEL now provide the string length to the parser. We needed
to do this for ID due to parse_check_insnprefix() needing the length, so
both were folded in for consistency.
Peter Johnson [Sun, 21 Dec 2008 10:57:36 +0000 (10:57 -0000)]
Legalize effective addresses such as [eax*2+ebx*2-ebx].
These were incorrectly identified as invalid. The code would see the
ebx*2 term and identify ebx as the index register. After the ebx was
subtracted, the ebx remained in the index register slot, so eax*2 had
nowhere to go. The code now recognizes this case and frees the slot
when the -ebx is processed, leaving the index register selection up
to the main part of the code.
Peter Johnson [Fri, 5 Dec 2008 07:13:33 +0000 (07:13 -0000)]
gen_x86_insn.py: Handle invalid rcstag.
This can happen if somehow this file is retrieved without expanded keywords
(e.g. directly from the webpage, or via something like git-svn).
Reported by: Patrick Walton <pcwalton@cs.ucla.edu>
Peter Johnson [Tue, 7 Oct 2008 05:38:11 +0000 (05:38 -0000)]
Add core TASM syntax support.
Contributed by: Samuel Thibault <samuel.thibault@ens-lyon.org>
It is built on top of the NASM parser and preproc, with the following
notable extensions for TASM syntax:
- case insensitive symbols and filenames,
- support for segment and size of labels, which permits to avoid giving
them on each memory dereference,
- support for data reservation (i.e. e.g. "var dd ?"),
- support for multiples (i.e. e.g. "var dd 1 dup 10"),
- little endian string integer constants,
- additional expression operators: shl, shr, and, or, low, high,
- additional offset keyword,
- additional fword and df,
- support for doubled quotes within quotes,
- support for array-like and structure-like notations: t[eax] and
[var].field,
- support for tasm directives: macro, rept, irp, locals, proc, struc,
segment, assume.
Notes:
- Almost all extensions are only effective when tasm_compatible_mode is
set, so we should have very reduced possible breakage.
- Because the "and" keyword can be an expression operator and an
instruction name, the data pseudo-instructions explicitly switch the
lexer state to INSTRUCTION state to fix the ambiguity.
- In gen_x86_insn.py, several instructions (namely lds and lea) now take
relaxed memory sizes. The reason is that in the case of tasm, the size
of the actual pointed data is passed up to there, and thus any type of
data should be accepted.
With all of this, loadlin can be compiled by yasm with quite reduced
modifications.
Peter Johnson [Sun, 5 Oct 2008 08:31:04 +0000 (08:31 -0000)]
Optimize non-strict push with 66 override to byte size if possible in NASM
syntax.
Previously, the forms of push that did this optimization were disabled in
NASM syntax due to conflicting with the size=BITS case. Fix this via
reordering to allow these forms to be active in NASM syntax.
Peter Johnson [Tue, 30 Sep 2008 03:56:37 +0000 (03:56 -0000)]
Fix expr simplification bug.
If an expression of the form INT+(a+b)+INT was simplified, constant folding
would combine the ints, but then the level stage (to make INT+a+b) would
start reading from the second (deleted due to folding) INT rather than the
new end of the expression.
Peter Johnson [Tue, 30 Sep 2008 02:52:56 +0000 (02:52 -0000)]
Nasm lexer: Don't read past end of passed string.
This was because the re2c-generated code always reads the next character
prior to user code being executed. Instead, check for the \0 marker prior
to entering the re2c code. Retain the re2c check just for sanity.
Peter Johnson [Tue, 15 Jul 2008 05:49:29 +0000 (05:49 -0000)]
Actually implement yasm__abspath() according to its documentation.
Formerly, it would not correctly handle absolute paths. Now it uses
yasm__combpath() to do absolute-path aware path combination.
As a benefit, it no longer needs to be OS-specific.
Peter Johnson [Sun, 6 Jul 2008 22:26:49 +0000 (22:26 -0000)]
Generated files listed in SOURCES (rather than included by other files)
should not be listed in BUILT_SOURCES but rather have nodist_ prepended.
They still need to be separately listed as CLEANFILES as they're built
at make time.
Reported by: David Harvey <dmharvey@math.harvard.edu>
Peter Johnson [Thu, 3 Jul 2008 04:19:12 +0000 (04:19 -0000)]
Bin map file: Fix incorrect address printing for symbols.
We were printing the previous bytecode's start rather than the label's
bytecode. Use yasm_bc_next_offset() to get the correct offset.
Peter Johnson [Sun, 8 Jun 2008 09:06:05 +0000 (09:06 -0000)]
Fix #132: Add --prefix and --suffix (aka --postfix) options.
These allow arbitrary prefixes and/or suffixes to be added to
externally-visible (GLOBAL, EXTERN, or COMMON) symbol names.
Peter Johnson [Thu, 5 Jun 2008 08:48:21 +0000 (08:48 -0000)]
Fix #141: Add macho64 PIC support.
The way PIC relocations are generated for macho64 requires a bit of a hack
to detect MOV opcodes and generate GOT_LOAD relocs.
GAS contains a similar hack.