Commit graph

14 commits

Author SHA1 Message Date
Jeff Epler
110a02f9b5 Delete dead code
.. the previous arrangement lead to compiler diagnostics when
building with 'scan-build make':

libtvm/tvm_htab.c:113:3: warning: Value stored to 'node' is never read
                node = node->next;
                ^      ~~~~~~~~~~
2018-03-17 13:48:25 -05:00
Joseph Kogut
ca87b3c5e9 Refactor with a consistent coding style
This commit refactors the project using a single, consistent coding
style, derived from the Linux Kernel Coding Style, available here:

https://www.kernel.org/doc/Documentation/CodingStyle

This includes, but is not limited to:
* Removal of typedefs, especially for structs
* Limiting lines to a reasonable length, 80 characters, mostly
* K&R style braces
* Removal of CamelCase
2016-08-28 20:31:12 -07:00
Payton Turnage
daa02f5082 Fix bug where an outdate node is returned.
If htab_add_core added a node that happened to push the htab past its load
factor, it would return a pointer to where the added node was *before* the
rehash. Now it does not do this.
2014-01-14 20:54:31 -05:00
Payton Turnage
584217a142 Modify htab_add to have a generic core. 2014-01-14 20:03:41 -05:00
Payton Turnage
ae63e45c65 Rename htab functions; rewrite find to be generic.
The htab functions find_str and add_str have been renamed to include _ref in
the places they previously noted _str. These are intended to manage an htab
containing references to any data; string or not.

The htab_find function has been divided up. htab_find_core now handles actually
finding the correct node. htab_find and htab_find_ref are just outward facing
functions for retrieving a specific kind of data from the node, depending on
what the htab is used for.
2014-01-14 19:09:35 -05:00
Payton Turnage
27a090e704 Remove assumption that node is in the bottom of the bucket.
This is the last remaining instance of this assumption.
2014-01-14 00:51:42 -05:00
Payton Turnage
e6d9d92d8c Do not write a value for strings in htab.
The assignment is unnecessary, and was overwriting the first element in the bucket (not the added string's value) in the case of a collision.
2014-01-13 13:50:56 -05:00
Payton Turnage
d945c9a3f6 Add a new function to return strings from htab.
The htab_find_str function eliminates the assumption that the string
is in the first place in the bucket.
2014-01-13 11:31:58 -05:00
Payton Turnage
aa57b007c7 Make sure strings are moved into the rehash. 2014-01-13 11:16:00 -05:00
Payton Turnage
e99a0428f3 Implement defines using the htab structure.
The htab_structure has been modified in two ways, which should not break
compatability with any of its uses.

It includes a void pointer, which is in this commit used to point to a
string for defines, and will in the future be used to point to the address
space for words, bytes, and double words.

It now includes a function htab_add_str specifically for storing strings.
It calls htab_add so as not to be redundant, but makes the node's value
their index for the lexer to fetch using htab_find, and assigns their
void pointer.

The lexer will now use htab_find on all tokens to see if they are a define
string, and if so, substitute them with the appropriate token.

The defines htab is destroyed after lexing, because that memory is done.
2014-01-13 10:20:21 -05:00
bl0ckeduser
07c32b9869 Simplify a structure copy 2013-08-12 18:43:17 -04:00
bl0ckeduser
716936a8eb Fix incorrect truncation of floating-point data
If the entire parenthesized division expression is cast to float, as it
was prior to this commit, C performs truncating integer division before
converting to float, which always leads to a result of zero.  `git-blame'
traces the bug to commit d5ed7e75d9, which
added the faulty parentheses as a matter of style. No parentheses are
necessary, since increments have higher precedence than type-casts,
type-casts have higher precedence than division, and division has
higher precedence than comparison. The operations will execute in the
desired order.
2013-08-12 18:33:08 -04:00
Joseph Kogut
d5ed7e75d9 * Replaced all instances of malloc with calloc
* Replaced magic number in tvm_htab.c with define
2013-03-07 12:19:03 -07:00
Joseph Kogut
3d895e0948 Made hash table naming conventions more consistent 2013-01-24 10:42:40 -07:00
Renamed from libtvm/tvm_hashtab.c (Browse further)