Commit graph

21 commits

Author SHA1 Message Date
H. Peter Anvin
f7606613d0 Handle multiple standard macro sets sanely
The ordering of the macro sets ended up changing due to the recent
file reorganization.  Instead of forcing the order again, handle
multiple macro sets (rather than just two) in a coherent manner.

macros/macros.pl could use a cleanup of duplicated code, however.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-07-13 14:23:48 -07:00
H. Peter Anvin
e1f985c167 Reorganize the source code into subdirectories
Make the source code easier to understand and keep track of by
organizing it into subdirectories depending on the function.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-05-25 12:06:29 -07:00
H. Peter Anvin
aa958b1ab6 ifunc.mac: the ilog2 warning may want to be both ceil and floor
There is no reason why the warning-generating ilog2 has to be only the
floor variant.  However, I am pretty sure we can simply implement the
ilog2cw() as a macro only; we can always fix that if that turns out to
be incorrect.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-24 23:03:17 -07:00
H. Peter Anvin
f29123b936 smartalign.mac: Ignore smartalign in preprocess-only mode
When running in preprocess-only mode generate the equivalent of
standard alignment using nops.  This at the very least allows some
kind of reasonable output and allows for dependency generation to
proceed; the only way to *really* address this problem is to move
alignment generation into the assembler proper; this would also allow
the align/alignb distinction to be removed and handle padding with
instructions which are more than one byte.

This should resolve bug 3392319.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-15 11:03:40 -08:00
H. Peter Anvin
290b4cb3a4 eval: add general support for "integer functions" and add ilog2*()
Add general support in the function parser for "integer functions"
(actually implemented as special unary operators, then wrapped in
macros) and implement a family of integer logarithms.  The only
difference is the behavior on a non-power-of-two argument:

	ilog2[e]	-- throw an error
	ilog2w		-- throw a warning
	ilog2f		-- round down to power of 2
	ilog2c		-- round up to power of 2

This is useful for back-converting from masks to bit values.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-31 10:25:37 -07:00
H. Peter Anvin
f237c71c0d New %use package "fp"
New standard macro package with utility macros for floating-point
constants.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-05-07 13:42:09 -07:00
Cyrill Gorcunov
2ef5c27be7 Rename SEGALIGN to SECTALIGN
"sectalign" is preferred over "segalign"
since it operates over section attributes.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 18:09:54 +04:00
Cyrill Gorcunov
1f3db76ee9 smartalign.mac: align macro should align a segment as well
This change may have backward compatibility issue but
most probably the sane program never used sections with
base address less then instruction alignment.

Note that alignment may only increase which means if a
section is aligned on 2^5 the align 2^4 will not affect
the section.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:22:31 +04:00
Cyrill Gorcunov
92aa187f3a smartalign: Introduce nojmp mode
This allows to force nasm to generate multibyte
NOPs without jmp injected.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:06:53 +04:00
H. Peter Anvin
143689d35d Add copyright headers to standard macro packages
These are all recent and written by me.  BSD license them.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-28 17:18:13 -07:00
H. Peter Anvin
a168ab1e01 smartalign: clean up unnecessary duplication; tweak dependencies
Remove unnecessary duplicated patterns; with indirection we can handle
lists of any length.

For 16-bit generic padding, alternate between SI and DI dependencies.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-25 17:48:33 -07:00
H. Peter Anvin
f991f5ae56 smartalign: use a "times" construct rather than %rep
Use a "times" construct rather than "%rep" for higher performance.
No need to preprocess the same line over and over for no good reason.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-19 16:45:27 -07:00
H. Peter Anvin
777cdbee01 smartalign: rewrite to use the indirect construct, %[...]
This code can be made so much smaller with clever use of the
indirection construct.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-19 16:38:28 -07:00
Victor van den Elzen
fd49408ed9 Already aligned aligns should be 0 bytes, not %1. 2008-10-01 13:21:02 +02:00
H. Peter Anvin
152656f8d3 Actually make non-power-of-2 alignments work
We can't use ($$-$) % (%1) since the wraparound will be wrong except
for powers of 2.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-09-25 02:31:50 -07:00
H. Peter Anvin
7f0ac96fed smartalign: use context-local label
Use a context-local label in the smart align macro.
2008-07-17 14:28:29 -07:00
H. Peter Anvin
ca66ec5eec smartalign: adjust the alignment threshold
Apparently the current recommendation is for a smaller threshold when
using the "generic"-style alignment macros (short jumps are cheaper on
newer CPUs.)

Also change the alignment threshold definition to reflect the maximum
number of padding instead of when to start using jumps.
2008-07-17 14:22:10 -07:00
H. Peter Anvin
1ac41d34ba smartalign: 16-bit generic alignment macros
Smart alignment content for 16-bit "generic" mode
2008-07-17 14:20:06 -07:00
H. Peter Anvin
47b0c2d428 smartalign: 16-bit P6 NOPs
Add 16-bit P6 NOPs
2008-07-17 14:13:53 -07:00
H. Peter Anvin
f5975eead1 smartalign.mac: smart alignments macro package
"%use smartalign" followed by an optional "alignmode" can be used to
enable smart macros.
2008-07-16 14:41:39 -07:00
H. Peter Anvin
d2456590fc preproc: add support for builtin include modules (%use)
Add a builtin equivalent to the %include directive called %use.
%use includes a standard macro file compiled into the binary; these
come from the macros/ directory in the source code.

The idea here is to be able to provide optional macro packages with
the distribution, without adding complex host filesystem dependencies.
2008-06-19 15:04:18 -07:00