Commit graph

40 commits

Author SHA1 Message Date
Peter Johnson
b32ee0152f * basic-optimizer.c (basic_optimize_bytecode_2): Fix check of
yasm_bc_resolve() return value (it's a flag, not a signed integer).

svn path=/trunk/yasm/; revision=1236
2005-09-25 03:27:05 +00:00
Peter Johnson
e2fa2c1c11 Since modules are now built into libyasm, it's no longer necessary to
version them.

 * parser.h, dbgfmt.h, objfmt.h, listfmt.h, optimizer.h, preproc.h, arch.h:
Remove YASM_xxx_VERSION and version module structure member.
 * (many) .c: Don't initialize version module structure member.


svn path=/trunk/yasm/; revision=1184
2004-12-01 08:09:43 +00:00
Peter Johnson
1a86c34026 * On most files: re-enable $IdPath$ as $Id$, and enable Id keyword expansion.
svn path=/trunk/yasm/; revision=1137
2004-09-04 01:24:57 +00:00
Peter Johnson
a4996c06c6 Massive libyasm / module interface update - Phase 2 (finally).
(Hopefully) finish cleanups begun in phase 1 (see phase 1 commit message),
making dbgfmt, objfmt, optimizer, and preproc module interfaces follow the
same thread-safe interface style as the phase 1 changes.

Also put in a large number of doxygen documentation cleanups.

svn path=/trunk/yasm/; revision=1097
2004-02-06 21:12:56 +00:00
Peter Johnson
55438b7229 Massive libyasm / module interface update - Phase 1
As yasm has evolved, various minor additions have been made to libyasm to
support the new features.  These minor additions have accumulated, and
some contain significant redundancies.  In addition, the core focus of
yasm has begun to move away from the front-end commandline program "yasm"
to focusing on libyasm, a collection of reusable routines for use in all
sorts of programs dealing with code at the assembly level, and the modules
that provide specific features for parsing such code.

This libyasm/module update focuses on cleaning up much of the cruft that
has accumulated in libyasm, standardizing function names, eliminating
redundancies, making many of the core objects more reusable for future
extensions, and starting to make libyasm and the modules thread-safe by
eliminating static variables.

Specific changes include:
 - Making a symbol table data structure (no longer global).  It follows a
   factory model for creating symrecs.
 - Label symbols now refer only to bytecodes; bytecodes have a pointer to
   their containing section.
 - Standardizing on *_create() and *_destroy() for allocation/deallocation.
 - Adding a standardized callback mechanism for all data structures that
   allow associated data.  Allowed the removal of objfmt and
   dbgfmt-specific data callbacks in their interfaces.
 - Unmodularizing linemgr, but allowing multiple linemap instances (linemgr
   is now renamed linemap).
 - Remove references to lindex; all virtual lines (from linemap) are now
   just "line"s.
 - Eliminating the bytecode "type" enum, instead adding a standardized
   callback mechanism for custom (and standard internal) bytecode types.
   This will make it much easier to add new bytecodes, and eliminate the
   possibility of type collisions.  This also allowed the removal of the
   of_data and df_data bytecodes, as objfmts and dbgfmts can now easily
   implement their own bytecodes, and the cleanup of arch's bytecode usage.
 - Remove the bytecodehead and sectionhead pseudo-containers, instead
   making true containers: section now implements all the functions of
   bytecodehead, and the new object data structure implements all the
   functions of sectionhead.
 - Add object data structure: it's a container that contains sections, a
   symbol table, and a line mapping for a single object.  Every former use
   of sectionhead now takes an object.
 - Make arch interface and all standard architectures thread-safe:
   yasm_arch_module is the module interface; it contains a create()
   function that returns a yasm_arch * to store local yasm_arch data; all
   yasm_arch_module functions take the yasm_arch *.
 - Make nasm parser thread-safe.

To be done in phase 2: making other module interfaces thread-safe.  Note
that while the module interface may be thread-safe, not all modules may be
written in such a fashion (hopefully all the "standard" ones will be, but
this is yet to be determined).

svn path=/trunk/yasm/; revision=1058
2003-10-02 05:03:50 +00:00
Peter Johnson
9800462fa7 Add versioning to all loadable module interfaces. The version is checked by
module users to ensure the module interface they're using matches the
interface the module was compiled with.  The #define YASM_module_VERSION
should be incremented on every functional change to the module interface.

svn path=/trunk/yasm/; revision=1021
2003-07-30 04:36:29 +00:00
Peter Johnson
16c09e4b41 Add lindex parameter to yasm_intnum_calc(), and add error messages for SEG,
WRT, and ':' (SEGOFF) usage.  This change also brings the yasm_intnum_calc()
interface in line with the yasm_floatnum_calc() interface.

Note: This may not be the final place we want these error messages to reside,
but the lindex addition should remain for the sake of consistency.

svn path=/trunk/yasm/; revision=953
2003-05-26 19:16:44 +00:00
Peter Johnson
cfc6bf0ded Clean up and simplify libyasm.h options and symbol visibility:
- Move config.h and util.h from libyasm (and installed libyasm) to top level.
- Move yasm_* functions from util.h to coretype.h.
- Remove a number of autoconf-related YASM_*_INTERNAL options from libyasm.h.
- Rename YASM_INTERNAL to YASM_LIB_INTERNAL; it now actually means what the
  comment describes: enables definitions that violate the yasm_* namespace.

While we're at it, no longer define YASM_LIB_INTERNAL from yasm frontend, so
it's closer to what a real typical libyasm-using application would look like.

svn path=/trunk/yasm/; revision=944
2003-05-05 03:42:12 +00:00
Peter Johnson
ddc08a6994 Use system includes instead of local includes. This allows replacement of
key headers in certain situations (config.h when compiling with Visual C++ for
one), and is also more correct in general.

svn path=/trunk/yasm/; revision=887
2003-03-26 05:07:57 +00:00
Peter Johnson
0786a76895 Make libyasm a "real" library, including installing header files.
Start separating modules and frontends from libyasm internals.

svn path=/trunk/yasm/; revision=849
2003-03-15 05:07:49 +00:00
Peter Johnson
d9f68d6d4b Unmodularize errwarn, while making key errwarn functions replaceable.
Also removes dependency of libyasm on libintl (gettext), so it can be linked
-no-undefined now!

svn path=/trunk/yasm/; revision=842
2003-03-10 08:55:41 +00:00
Peter Johnson
a2e07e1e10 The Great Renaming (prefixing with yasm_), Part 1.
svn path=/trunk/yasm/; revision=838
2003-03-08 19:15:40 +00:00
Peter Johnson
b1faf6329c Relicense under 2-clause BSD license.
svn path=/trunk/yasm/; revision=835
2003-02-21 03:50:29 +00:00
Peter Johnson
9f6cb6783f Modularize errwarn. gettext()-ize in errwarn, not in every module, eliminating
libintl dependency in modules.
Also standardize initialize() and cleanup() functions.
Move replace_extension() from file.c to main.c.
Clean up some extern variable declarations in various places (particularly
nasm-compatible parser).

svn path=/trunk/yasm/; revision=792
2002-11-01 10:05:03 +00:00
Peter Johnson
2f19ce4ecd Delete last of global variables by making a line manager and passing around
the line index.  Fixes some minor line number/error message nits due to
incorrect usage of line_index in old global variable method.

svn path=/trunk/yasm/; revision=787
2002-10-27 09:21:39 +00:00
Peter Johnson
d6f22c3fce Dynamically load all modules (preloading some of the default ones).
Start reducing global variables for cleaner module separation.
Add rudimentary debug format module interface and "null" debug format.

svn path=/trunk/yasm/; revision=784
2002-10-26 08:25:39 +00:00
Peter Johnson
a3a9fd2aa0 Completely revamp how label resolution is done (part of Bug#6). Now calculates
/distances/ between bytecodes in a section using bc_calc_dist() functions (a
"typical" one is provided for most occasions).  expr_expand_labelequ() is gone,
as its functionality is integrated into expr_simplify().  Currently these
changes break most bin objfmt output, as it doesn't know how to resolve
absolute labels yet.  Also, very preliminary expr support for :, SEG, and WRT
operators has been added (part of Bug#2).  Several other minor bug fixes.

svn path=/trunk/yasm/; revision=718
2002-10-01 18:56:28 +00:00
Peter Johnson
090a25b8d4 Rename intnum_new_int to intnum_new_uint, and add new signed version of
intnum_new_int.  Currently only just calls intnum_new_uint with a cast, but
eventually there may be a better way of handling signed numbers.

svn path=/trunk/yasm/; revision=708
2002-09-24 18:35:51 +00:00
Peter Johnson
7849f57e48 Fix build breakage caused by not using sect access function.
svn path=/trunk/yasm/; revision=702
2002-08-18 18:47:20 +00:00
Peter Johnson
c5ef1bf2dc Eliminate duplicate code for callbacks from expr_expand_labelequ() by moving
code and adding a resolve_precall function parameter (which caused cascading
changes in bytecode-related sources).

svn path=/trunk/yasm/; revision=701
2002-08-18 03:48:17 +00:00
Peter Johnson
ac2743de63 Prevent spurious "Circular reference detected" errors by refining the return
value for bc_resolve() to enum-defined flags.

svn path=/trunk/yasm/; revision=623
2002-05-20 01:08:42 +00:00
Peter Johnson
4407d49d66 During the first pass of basic optimization, continue reporting errors, don't
stop at the first error.
To help prevent spurios errors, make bytecodes with errors 0 length in
bc_resolve().

svn path=/trunk/yasm/; revision=621
2002-05-11 01:50:11 +00:00
Peter Johnson
0124032e2c Splint-noticed bugfixes: memory leaks, unreachable code.
svn path=/trunk/yasm/; revision=606
2002-04-23 05:04:41 +00:00
Peter Johnson
fe8c2a009f Restructure bc_calc_len() family into bc_resolve() family. Many many many
bugfixes to the bc_tobytes() family and other functions.  Binary object output
is now close to complete: just a few more bugs to kill!

svn path=/trunk/yasm/; revision=528
2002-03-18 07:16:52 +00:00
Peter Johnson
d85e7014a8 Binary object format output! Lots of structural changes needed, particularly
with regards to resolve_label().
MAJOR FIXME: The tobytes() pass acts like a final optimization pass.  This
causes internal errors because of length mismatches (optimized to shorter len).

svn path=/trunk/yasm/; revision=521
2002-03-17 21:58:36 +00:00
Peter Johnson
b667c33ea5 Don't call bc_resolve (it's going away soon).
FIXME: Do we really need to check completion of all sections?

svn path=/trunk/yasm/; revision=500
2002-03-15 22:19:58 +00:00
Peter Johnson
07c3299820 Add bin object format.
Changes to:
 objfmt interface: added parameter to directive() for sections access.
 section interface: moved start to be present for all section types.
 basic optimizer: add section start to offset determination.
(much of the section start changes are due to the need to make sure offsets
don't end up being optimized into byte-sized offsets that can't be relocated).

svn path=/trunk/yasm/; revision=490
2002-03-10 23:15:14 +00:00
Peter Johnson
a0d61f00c1 Enable second pass (resolve/calculate known values).
svn path=/trunk/yasm/; revision=475
2002-02-27 05:40:46 +00:00
Peter Johnson
f5bf04dd41 Include errwarn.h to declare ErrorAt().
svn path=/trunk/yasm/; revision=474
2002-02-21 05:30:48 +00:00
Peter Johnson
964c755067 Indicate actual line number of circular reference error.
svn path=/trunk/yasm/; revision=472
2002-02-20 08:05:10 +00:00
Peter Johnson
7217fd10db Bring up-to-date with traverse function changes. Start trying to check for
circular references.

svn path=/trunk/yasm/; revision=471
2002-02-20 07:43:26 +00:00
Peter Johnson
760e3c4d11 In optimize_bytecode(), calculate bc->offset *before* calling bc_calc_len().
This is because calc_len may want to know the current bytecode's offset (eg for
determining relative displacement length).

svn path=/trunk/yasm/; revision=458
2002-01-11 04:36:23 +00:00
Peter Johnson
3c0a749084 Rework resolve_label() and add a second pass.
svn path=/trunk/yasm/; revision=453
2002-01-10 05:02:40 +00:00
Peter Johnson
0276a2db37 - Use new symrec_get_label().
- Change optimize() function to return void.
- Pass LCLint.

svn path=/trunk/yasm/; revision=447
2002-01-09 09:04:41 +00:00
Peter Johnson
e23d88b957 Make resolve_label() take a symrec * instead of a section * and bytecode *.
Extend expr_expand_equ() into expr_expand_labelequ() and call resolve_label()
here.

svn path=/trunk/yasm/; revision=440
2002-01-09 07:23:00 +00:00
Peter Johnson
2727869bd8 Start work on optimizer module. Moved all "post-parser-finalization" code
into the optimizer stage, where it belongs.  Naming has changed, but most
implementations have not been brought up to date to do what they say they
do.

svn path=/trunk/yasm/; revision=388
2001-12-07 03:32:05 +00:00
Peter Johnson
a7ce9bf2d1 Delete dbg optimizer (won't be useful) and add "basic" (equiv. to NASM 2-pass)
optimizer.

svn path=/trunk/yasm/; revision=364
2001-12-01 03:07:23 +00:00
Peter Johnson
a7ac50c918 Add coretype.h, make util.h do a lot more, use util.h to simplify include
sections of C files.  Also remove IdPath from top comment in files where
RCSID() is used.  Move RCSID() to immediately after util.h include.

svn path=/trunk/yasm/; revision=313
2001-11-03 05:17:51 +00:00
Peter Johnson
b2890b8f9d $Id$ -> $IdPath$.
svn path=/trunk/yasm/; revision=174
2001-09-17 04:12:20 +00:00
Peter Johnson
d758a063b2 Add barebones optimizer module framework.
svn path=/trunk/yasm/; revision=169
2001-09-16 21:39:58 +00:00