aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* compile-i386: do not generate an infinite loopKamil Dudka2009-07-221-4/+4
| | | | | | | | | | | | I've probably encountered a bug within compile-i386.c. It generates an infinite loop for 'while' statement. My testing example and proposed patch are enclosed. Kamil Signed-off-by: Kamil Dudka <kdudka@redhat.com> Acked-by: Jeff Garzik <jgarzik@redhat.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Unhardcode byte size being 8 bits.David Given2008-12-171-1/+1
| | | | | | Signed-off-by: David Given <dg@cowlark.com> [negative value division fixed by alexey.zaytsev@gmal.com] Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
* fix handling of address_space in casts and assignmentsAl Viro2007-07-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Turn FORCE_MOD into storage class specifier (that's how it's actually used and that makes for much simpler logics). Introduce explicit EXPR_FORCE_CAST for forced casts; handle it properly. Kill the idiocy in get_as() (we end up picking the oddest things for address space - e.g. if we have int __attribute__((address_space(1))) *p, we'll get warnings about removal of address space when we do things like (unsigned short)*p. Fixed. BTW, that had caught a bunch of very odd bogosities in the kernel and eliminated several false positives in there. As the result, get_as() is gone now and evaluate_cast() got simpler. Kill the similar idiocy in handling pointer assignments; while we are at it, fix the qualifiers check for assignments to/from void * (you can't assign const int * to void * - qualifiers on the left side should be no less than on the right one; for normal codepath we get that checked, but the special case of void * skips these checks). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* Fix most -Wshadow warnings in Sparse.Josh Triplett2007-05-011-2/+0
| | | | Signed-off-by: Josh Triplett <josh@freedesktop.org>
* compile-i386.c: Declare regs_in_use staticJosh Triplett2007-04-201-1/+1
| | | | Signed-off-by: Josh Triplett <josh@freedesktop.org>
* Use GCC format and sentinel attributes on appropriate functionsJosh Triplett2007-03-091-1/+1
| | | | | | | | | | | | | Expose the FORMAT_ATTR portability macro in lib.h, and use it on the various printf-like functions in sparse. Add a new SENTINEL_ATTR portability macro for the GCC sentinel attribute, and use it on match_idents in parse.c. match_oplist in expression.c should use SENTINEL_ATTR, but GCC does not accept an integer 0 as a sentinel, only a pointer 0 like NULL. Signed-off-by: Josh Triplett <josh@freedesktop.org>
* Make local declarations be statements of their ownLinus Torvalds2005-12-311-1/+3
| | | | | | | | | | | This removes the list of symbols for block statements, and instead makes a declaration be a statement of its own. This is necessary to correctly handle the case of mixed statements and declarations correctly, since the order of declarations and statements is meaningful. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* Update the calling interface to "sparse()".Linus Torvalds2005-08-031-0/+4
| | | | | | | | | | | | | | Start off with sparse_initialize(argc, argv); which will return the number of filenames found. You can then use that, or just check if *argv is NULL in a loop like while (*argv) list = sparse(argv); where you get the declaration list for each file in turn.
* [PATCH] makes some needlessly global code staticLuc Van Oostenryck2005-06-271-7/+7
| | | | | | | | This makes some needlessly global code static so that sparse don't complain when self checking. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@looxix.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* Add "stream_name()" helper function, and use it.Linus Torvalds2005-04-071-1/+1
| | | | | | Much prettier than "input_streams[x].name", since most users really don't want to know about the internals of how the preprocessor lays out its stream tracking.
* Split out the blob allocator from lib.c into allocate.c.Linus Torvalds2005-04-071-0/+1
| | | | | | | | | It's disgusting how intimate lib.c is with all the types, and this is slowly trying to split things up a bit. Now the intimate part is in allocate.c, but maybe we can get to the point where each allocation user just declares its own allocation strategy, and just uses the generic routines in allocate.c
* Make compile-i386.c get with the program. We don't just useLinus Torvalds2005-04-071-3/+9
| | | | untyped "struct ptr_list **", we use properly typed ones.
* Remove EXPR_BITFIELD entirely.Linus Torvalds2005-04-071-10/+0
| | | | | | | | | I used to think I needed it. That's no longer the case: we just follow the "bit_offset" in the type information. There may be cases where we inadvertently cast the information away, and those places will break now, but that's a bug really, not an excuse for EXPR_BITFIELD.
* Separate explicit and implied casts.Linus Torvalds2005-04-071-0/+1
| | | | | | This also makes our evaluation simplification only happen for the implied ones. If you put an explicit cast somewhere, it does _not_ get combined with an implied one.
* Remove "fieldwidth" member of struct symbolLinus Torvalds2005-04-071-3/+1
| | | | | | | | | It's always the same as bit_size now, and having it just confuses things. We now check whether we have examined a type by looking at the "examined" bitfield, which allows us to set bit_size in the early parsing phase.
* Remove remnants of two-expression x ? : y handling..Linus Torvalds2005-04-071-10/+3
| | | | | | We turn it into a proper (tmp = x, tmp ? tmp : y) at evaluation time, so later phases never have to worry about the issue. But some of the old code lingered.
* Get rid of the old "iterate()" interfaces.Linus Torvalds2005-04-071-13/+12
| | | | | Use FOR_EACH_PTR() instead, or the much fancier iterators for basic blocks.
* Totally re-do how we build up the initializer tree: make theLinus Torvalds2005-04-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | positional markers be hierarchical rather than a flat list. This makes the data structure a bit more complex, but it simplifies some of the code, and makes it possible to evaluate complex initializers without going insane. In particular, we how support struct xxxx var = { .a.b[10] = 1; }; which we couldn't handle at all before (it had to be written as struct xxxx var = { .a = { .b = { [10] = 1; } } } or similar. The new code changes all array indexes and structure members to EXPR_POS expressions offset from the "outer" scope (either start of the symbol, or an outer EXPR_POS).
* Janitorial trivialities.welinder@darter.rentec.com2005-04-071-5/+5
|
* Many files:welinder@darter.rentec.com2005-04-071-10/+10
| | | | | | | | | | | warn->warning error->error_die new error lib.h: warn->warning error->error_die new error Add gcc format checking to warning/error/...
* Make END_FOR_EACH_PTR[_REVERSE] take the ptr name as an argument.Linus Torvalds2005-04-071-15/+15
| | | | | | ..and switch us entirely over to the new naming scheme. All the nasty work of going through the users thanks to Chris Li.
* Fix "compile-i386.c" incestuous list internal knowledge.Linus Torvalds2005-04-071-1/+1
| | | | Use the existing access macro instead.
* Fix up the worst regcache thinko's.Linus Torvalds2005-04-071-28/+31
| | | | | | | | | | | In particular: - we should only test (and not mark busy) the things a register aliases when we allocate it. This bug kept us from using %edx, because when we used %eax, we bogusly marked the 64-bit combination %eax:%edx as being busy, and refused to use %edx later. - "get_reg_value()" should take a regclass, so that we can allocate a new reg from a valid class.
* Add the proper accessor functions to turn a 32-bit regLinus Torvalds2005-04-071-0/+2
| | | | into a 16-bit one, and into the "high byte" version.
* Make "emit_conditional_test()" use register caches.Linus Torvalds2005-04-071-2/+5
|
* Improve "emit_move()" handling.Linus Torvalds2005-04-071-6/+34
| | | | | | If we are loading something into a register, and another register has that value already cached, used the cached register value.
* Make binops use the new register tracking in compile-i386.cLinus Torvalds2005-04-071-33/+13
|
* Do some rudimentary register content tracking.Linus Torvalds2005-04-071-34/+116
| | | | | | | | | | | | This still does just mainly EXPR_SELECT, since that is what I'm familiar with. It's also extremely lazy about invalidating register content info, since any code that hasn't been moved to the new format won't do things properly. Very much a work-in-progress, designed to eventually allow us to generate some kind of half-readable code from the SSA form.
* Start infrastructure for more dynamic register allocation.Linus Torvalds2005-04-071-14/+112
| | | | | | | Instead of using fixed register names, we keep track of busy registers, and allocate them as needed. Also changed EXPR_SELECT to actually use this.
* Let compile-i386 know about more registers.Linus Torvalds2005-04-071-56/+54
| | | | | | We don't actually _use_ any of them yet, but this lists them, and adds the information about which register conflicts with which register (eg %al conflicts with %eax, but not with %ah)
* Simplify the interface between compile.c and the actualLinus Torvalds2005-04-071-11/+4
| | | | | | | | | code emitter. Don't make the code emission have to know about symbol lists etc. Thus the code emitter can do whatever it wants to do to the symbols as they are encountered, as part of the main loop rather than as a separate phase afterwards. Straightforward.
* Make compile-i386.c create pseudo-code for the logical binops.Linus Torvalds2005-04-071-0/+8
| | | | | | | It gets them wrong right now: we can't just use "and" and "or", we need to convert to canonical logical form (0/1) too. But it's documentation.
* Teach compile-i386.c to emit select instructions.Linus Torvalds2005-04-071-1/+31
| | | | | They are valid now that we have a EXPR_SELECT type for safe conditionals.
* EXPR_SAFELOGICAL is unnecessary. It ends up being the same as EXPR_BINOP.Linus Torvalds2005-04-071-1/+0
| | | | | Make linearize.h show the right ops for the logical (as opposed to binary) and/or EXPR_BINOP.
* Make expression expansion calculate the "cost" of theLinus Torvalds2005-04-071-0/+1
| | | | | | | | | expression. This is just a very high-level cost, mainly distinguishing between "safe" and "unsafe" operations, so that we can determine if we can turn a C conditional into a select statement, or a logical op into one without short-ciruiting.
* Add "select" expression.Linus Torvalds2005-04-071-0/+1
| | | | | | It's the same as a regular C conditional, except you could evaluate both sides first. Right now we treat it exactly the same as an EXPR_CONDITIONAL.
* [be] fix amazingly stupid conditional expression handlingJeff Garzik2005-04-071-61/+69
| | | | | | | | | | | | | By virtue of attempting to be too smart, the conditional expression handling ("x ? foo : bar") would evaluate both 'foo' and 'bar', and then use the cmov instruction to determine the result, avoiding a branch in the process. Unfortunately this only makes sense for simple things (EXPR_VALUE, EXPR_SYMBOL) and is quite wrong for everything else. Changed so that 'if' statements and conditional expressions use largely the same code.
* [be] minor fixesJeff Garzik2005-04-071-1/+13
| | | | | | | | | | | | * Mostly revert function call stack frame construction ("correctly generate push* instruction") * Add comment regarding ABI-dictated function call argument size * Clamp function call arg size to 32-bit minimum. This will copy the correct value to the stack at the correct alignment, but (SECURITY/FIXME) will also copy extra bits (24 bits for an 8-bit value, 16 bits for a 16-bit value). * Add EXPR_FVALUE to the 'unhandled' portion of the master emit-expression 'switch' statement.
* [be] fix some of the brokenness related to non-32-bit variablesJeff Garzik2005-04-071-23/+37
| | | | | | Assumptions that values are 32-bit still remain in places, but some simple test cases involving 8-bit and 16-bit variables seem much more sane now.
* [PATCH] Generate correct push* instruction.Alexey Dobriyan2005-04-071-2/+1
| | | | | | | | | | Pay attention to size of function arguments when pushing them to stack. Generate "pushb" for char, "pushw" for short, ... [ Linus' note: this is likely "wrong". In a real x86 compiler, we'd expand the width of the argument to 32 bits regardless, but from a demonstration standpoint this is better ]
* [PATCH] Simplify mnemonic generation for mov* instructions.Alexey Dobriyan2005-04-071-23/+7
| | | | We already have a function that adds correct {b,w,l,q} suffix.
* [PATCH] Print instruction's suffix in a human-readable form.Alexey Dobriyan2005-04-071-1/+1
| | | | {'b', 'w', 'l', 'q'} instead of {ascii 8, ascii 16, ' ', '@'}
* Make "compile" assert more readable.Linus Torvalds2005-04-071-1/+1
| | | | | Quite frankly, anybody who uses assert() should be shot. It's a fundamentally broken thing.
* [PATCH] comparison operations fixAlexander Viro2005-04-071-17/+12
| | | | | | | | | | | simplify_int_binop() was completely broken for comparisons - there the signedness of (converted) arguments can not be obtained from type of result. IOW, we had all comparisons in constant expressions done as signed ones. Fixed by introducing new primitives for unsigned versions of comparions (SPECIAL_UNSIGNED_LT, etc.) and remapping in evaluate_compare() once we know the types. That also fixes similar mess in compile-i386 and linearize.
* [PATCH] teach sparse about __alignof__Stephen Hemminger2005-04-071-0/+1
| | | | | | | | | | | | | | | | This teaches sparse what __alignof__ really means, instead of just using the same code as "__sizeof__" It gets rid of the warnings in ebtables that does: struct ebt_entries { ... char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))); }; Which caused warning because sparse was evaluating __alignof__ as the same as sizeof, and sizeof was 57 (ie non-power of 2). This is just based on the existing code and a peek at the data structures in expression and symbol.
* Fix integer/pointer errors in sparse.Linus Torvalds2005-04-071-9/+9
| | | | Shown by running sparse on itself.
* Make sparse sources themselves be sparse-clean.Linus Torvalds2005-04-071-1/+3
| | | | | This actually showed a bug ("assignment in conditional") in evaluate.c.
* Now that BITS_IN_XXXX aren't defined contstants any more,Linus Torvalds2005-04-071-4/+4
| | | | rename them lower cased to match standard C naming rules.
* Support C types as first-class citizens, allowing typeLinus Torvalds2005-04-071-0/+3
| | | | | | | | | | comparisons etc: if (typeof(a) == int) { ... (although right now I don't actually do the proper comparison expansion and all comparisons return "true").
* Remove now-obsolete temporary statement types.Linus Torvalds2005-04-071-16/+0
| | | | | They were only used for the original pre-instruction linearization.