Commit Graph

590 Commits

Author SHA1 Message Date
Daniel Dunbar a461e6d124 Disable some debug prints.
llvm-svn: 59174
2008-11-12 21:52:46 +00:00
Eli Friedman 9a156e5c1e Some additions to tryEvaluate I've had sitting around for a while.
This pushes it a lot closer to being able to deal with most of the stuff 
CodeGen's constant expression evaluator knows how to deal with.  This 
also fixes PR3003.

The test could possibly use some improvement, but this'll work for now.  
Test 6 is inspired by PR3003; the other tests are mostly just designed
to exercise the new code.  The reason for the funny structure of the 
tests is that type fixing for arrays inside of structs is the only place 
in Sema that calls tryEvaluate, at least for the moment.

llvm-svn: 59125
2008-11-12 09:44:48 +00:00
Chris Lattner fac05aeae5 fix a crash analyzing constants in 176.gcc/expr.c with my next patch. It was
crashing because we errors are ignored in subexpressions that are not evaluated,
but we still evaluate the result of parents.  This would cause an assertion 
because the erroneous subexpr didn't have its result value set to the right type.

llvm-svn: 59110
2008-11-12 07:43:42 +00:00
Chris Lattner aa3f951efc Teach the aggressive constant folder to fold X && 0 -> 0 and X || 1 -> 1
llvm-svn: 59105
2008-11-12 07:04:29 +00:00
Sebastian Redl 6f28289aca Introduce a single AST node SizeOfAlignOfExpr for all sizeof and alignof expressions, both of values and types.
llvm-svn: 59057
2008-11-11 17:56:53 +00:00
Daniel Dunbar d7be95d60a PR2919: __builtin_types_compatible_p strips CRV qualifiers.
llvm-svn: 58079
2008-10-24 08:07:57 +00:00
Daniel Dunbar c3d79cf6b3 Teach tryEvaluate that fabs, copysign, and unary +/- are constants for
floats.
 - With testcase, which also has some other things GCC folds but we
   don't commented out in it.

llvm-svn: 57624
2008-10-16 03:51:50 +00:00
Daniel Dunbar 1be9f88a2f Fix test suite regression, getFloatTypeSemantics shouldn't be called
on non-float types.

llvm-svn: 57477
2008-10-14 05:41:12 +00:00
Dale Johannesen c48814bc98 Adjust calls to APFloat conversion for new interface.
llvm-svn: 57332
2008-10-09 23:02:32 +00:00
Chris Lattner 2c091b1ead ExprConstant should not abort when it sees a pointer constant that isn't.
llvm-svn: 57162
2008-10-06 07:20:11 +00:00
Chris Lattner cb13691a62 Add a Expr::isEvaluatable method, eliminate isBuiltinConstantExpr
which is checking for something that can be inconsistent with
what we can constant fold.

llvm-svn: 57159
2008-10-06 06:49:02 +00:00
Chris Lattner 86ee286b09 Move folding of __builtin_classify_type out of the CallExpr
interface into the constant folding interface.

llvm-svn: 57158
2008-10-06 06:40:35 +00:00
Chris Lattner 0b7282eafc Move handling of __builtin_nan("") out of CGBuiltin.cpp into ExprConstant.cpp
llvm-svn: 57157
2008-10-06 06:31:58 +00:00
Chris Lattner 37346e081c Teach FloatExprEvaluator to evaluate __builtin_huge_val and inf.
llvm-svn: 57154
2008-10-06 05:53:16 +00:00
Chris Lattner 4deaa4ea24 Add a comment that describes tryEvaluate. Make tryEvaluate fold
__builtin_constant_p properly, and add some scaffolding for
FloatExprEvaluator to eventually handle huge_val and inf.

llvm-svn: 57152
2008-10-06 05:28:25 +00:00
Eli Friedman 24c0154b77 Initial implementation of floats in Expr::tryEvaluate; this doesn't
implement some things, like unary operators and casts, but it's enough
to fix PR2703 as filed.

llvm-svn: 55155
2008-08-22 00:06:13 +00:00
Argyrios Kyrtzidis 3bab3d21f9 Add ExplicitCastExpr to replace the current CastExpr, and have ImplicitCastExpr and ExplicitCastExpr derive from a common base class (CastExpr):
Expr
  -> CastExpr
     -> ExplicitCastExpr
     -> ImplicitCastExpr 

llvm-svn: 54955
2008-08-18 23:01:59 +00:00
Daniel Dunbar 56fdb6ae69 More #include cleaning
- Kill unnecessary #includes in .cpp files. This is an automatic
   sweep so some things removed are actually used, but happen to be
   included by a previous header. I tried to get rid of the obvious
   examples and this was the easiest way to trim the #includes in one
   fell swoop.
 - We now return to regularly scheduled development.

llvm-svn: 54632
2008-08-11 06:23:49 +00:00
Anders Carlsson d361a7df78 Remove the old evaluator code.
llvm-svn: 54615
2008-08-10 17:03:01 +00:00
Eli Friedman 5cf85cc977 Turn on the new constant expression evaluator; it isn't
anywhere near complete, but I don't know of any issues, and it can 
handle enough to allow removing the I-C-E pointer cast hack.

llvm-svn: 54597
2008-08-09 22:21:56 +00:00
Eli Friedman bd84059cdb Minor tweak plus a couple of FIXMEs.
llvm-svn: 54119
2008-07-27 05:46:18 +00:00
Chris Lattner 477c4be1e9 expand casts to handle what isIntegerConstantExpr handles.
Casts from pointers remain a problem. :)

llvm-svn: 53501
2008-07-12 01:15:53 +00:00
Chris Lattner 7174bf3722 Add support for __builtin_type_compatible_p, enums, etc.
llvm-svn: 53500
2008-07-12 00:38:25 +00:00
Chris Lattner 9941570ce9 start remembering diagnostics for various cases, add some missing
code.  Switch to Eli's getIntWidth method.

llvm-svn: 53499
2008-07-12 00:14:42 +00:00
Chris Lattner cdf34e7668 Provide a structure for passing down 'is evaluated' and passing up
diagnosic+loc info for i-c-e evaluation.

llvm-svn: 53490
2008-07-11 22:52:41 +00:00
Chris Lattner f09ad16cfc simplify some code a bit.
llvm-svn: 53477
2008-07-11 22:15:16 +00:00
Chris Lattner f8d7f72956 share code between sizeof(expr) and sizeof(type)
llvm-svn: 53475
2008-07-11 21:24:13 +00:00
Chris Lattner b062dcc17b implement support for __extension__, make sure the result of a
comparison has the right width.

llvm-svn: 53469
2008-07-11 19:29:32 +00:00
Chris Lattner ae8cc15977 add a new getIntTypeSizeInBits method.
llvm-svn: 53468
2008-07-11 19:24:49 +00:00
Chris Lattner 2bd2e028ca rename "SInt" methods to "Int" in APValue.
llvm-svn: 53467
2008-07-11 19:19:21 +00:00
Chris Lattner e13042c04f make the new evaluator avoid conversions APValue<->APSInt in some cases.
Add some accessors to APValue.

llvm-svn: 53465
2008-07-11 19:10:17 +00:00
Chris Lattner 05706e8859 rearrange some code, no functionality changes.
llvm-svn: 53463
2008-07-11 18:11:29 +00:00
Anders Carlsson 0166481455 Fix small bug. The evaluator now works well enough to pass all tests
llvm-svn: 53238
2008-07-08 16:49:00 +00:00
Anders Carlsson 4a3585b7c0 More constant expression work.
llvm-svn: 53235
2008-07-08 15:34:11 +00:00
Anders Carlsson 9c18165448 Move out some methods.
llvm-svn: 53234
2008-07-08 14:35:21 +00:00
Anders Carlsson b5ad021cd7 More work.
llvm-svn: 53233
2008-07-08 14:30:00 +00:00
Seo Sanghyeon 1904f44757 Compilation fix
llvm-svn: 53222
2008-07-08 07:23:12 +00:00
Anders Carlsson 374b93df76 Port more of Eli's evaluator over. This makes the int evaluator handle binary and unary operators.
llvm-svn: 53221
2008-07-08 05:49:43 +00:00
Anders Carlsson 0a1707c6ba Commit beginnings of int evaluator. Currently not used.
llvm-svn: 53219
2008-07-08 05:13:58 +00:00
Anders Carlsson 7a241baf2f Shuffle things around in preparation for integrating Eli's constant evaluator.
llvm-svn: 53074
2008-07-03 04:20:39 +00:00