summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGBuiltin.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Support IRgen of sqrt -> llvm.sqrt, pow -> llvm.pow.Daniel Dunbar2009-02-161-1/+30
| | | | | | | | | | | | | | | | - Define pow[lf]?, sqrt[lf]? as builtins. - Add -fmath-errno option which binds to LangOptions.MathErrno - Add new builtin flag Builtin::Context::isConstWithoutErrno for functions which can be marked as const if errno isn't respected for math functions. Sema automatically marks these functions as const when they are defined, if MathErrno=0. - IRgen uses const attribute on sqrt and pow library functions to decide if it can use the llvm intrinsic. llvm-svn: 64689
* Fix IRgen of __builtin_memset.Daniel Dunbar2009-02-161-1/+2
| | | | | | - Fix test case to not only have negative tests. llvm-svn: 64674
* Implicitly declare certain C library functions (malloc, strcpy, memmove,Douglas Gregor2009-02-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | etc.) when we perform name lookup on them. This ensures that we produce the correct signature for these functions, which has two practical impacts: 1) When we're supporting the "implicit function declaration" feature of C99, these functions will be implicitly declared with the right signature rather than as a function returning "int" with no prototype. See PR3541 for the reason why this is important (hint: GCC always predeclares these functions). 2) If users attempt to redeclare one of these library functions with an incompatible signature, we produce a hard error. This patch does a little bit of work to give reasonable error messages. For example, when we hit case #1 we complain that we're implicitly declaring this function with a specific signature, and then we give a note that asks the user to include the appropriate header (e.g., "please include <stdlib.h> or explicitly declare 'malloc'"). In case #2, we show the type of the implicit builtin that was incorrectly declared, so the user can see the problem. We could do better here: for example, when displaying this latter error message we say something like: 'strcpy' was implicitly declared here with type 'char *(char *, char const *)' but we should really print out a fake code line showing the declaration, like this: 'strcpy' was implicitly declared here as: char *strcpy(char *, char const *) This would also be good for printing built-in candidates with C++ operator overloading. The set of C library functions supported by this patch includes all functions from the C99 specification's <stdlib.h> and <string.h> that (a) are predefined by GCC and (b) have signatures that could cause codegen issues if they are treated as functions with no prototype returning and int. Future work could extend this set of functions to other C library functions that we know about. llvm-svn: 64504
* Use EmitVAListRef instead of EmitLValue directly to handle array decayDaniel Dunbar2009-02-111-1/+1
| | | | | | case on x86_64. llvm-svn: 64333
* Reapply Daniel's patch to match up with llvm 63765.Dale Johannesen2009-02-051-6/+3
| | | | | | Untested, Daniel or Nate please review. llvm-svn: 63814
* Chase LLVM TOT in circles (i.e., revert r63773 to match revert ofDaniel Dunbar2009-02-041-3/+6
| | | | | | r63765). llvm-svn: 63795
* (llvm up) Update for intrinsic lookup changes.Daniel Dunbar2009-02-041-6/+3
| | | | llvm-svn: 63773
* Make the constant folder aware of Eli Friedman2009-01-251-2/+2
| | | | | | | __builtin___CFStringMakeConstantString. (We get into trouble in GenerateStaticBlockVarDecl if the constant folder isn't accurate.) llvm-svn: 62949
* Slight cleanup, and fix for va_arg on architectures where va_list is a Eli Friedman2009-01-201-14/+3
| | | | | | struct. llvm-svn: 62585
* Do codegen correctly for va_start/end/copy on architectures where Eli Friedman2009-01-201-4/+14
| | | | | | | | | va_list is a struct, like x86-64. If anyone has a better idea for how to do the check in the if statements, suggestions are welcome. llvm-svn: 62582
* Fix for PR3350: add special-casing for "references" to va_lists in Eli Friedman2009-01-201-5/+1
| | | | | | | | builtins. Also, a minor tweak to va_copy for consistency. llvm-svn: 62574
* Vector codegen improvementsNate Begeman2009-01-181-0/+2
| | | | llvm-svn: 62458
* Generate code for __builtin_ia32_pshufwAnders Carlsson2008-12-221-0/+7
| | | | llvm-svn: 61324
* Use the new Expr::EvaluateAnders Carlsson2008-12-011-5/+5
| | | | llvm-svn: 60321
* rename Expr::tryEvaluate to Expr::Evaluate.Chris Lattner2008-11-161-1/+1
| | | | llvm-svn: 59426
* Fix bug in va_copyAnders Carlsson2008-11-041-1/+1
| | | | llvm-svn: 58680
* Fix for PR2966: va_start/va_end use the *address* of the Eli Friedman2008-10-291-1/+1
| | | | | | | | | | | va_list, not the value. Patch fixes an assert on x86-64 and a wrong-code bug on x86. I'm not completely sure, but I think it's a regression from r58306. Does anyone run regression tests regularly on x86-64? The crash should have been picked up there. llvm-svn: 58366
* Added pinsrd, pinsrq, and some other vector intrinsicsMon P Wang2008-10-151-0/+4
| | | | llvm-svn: 57563
* Lift EmitTargetBuiltinExpr out of EmitBuiltinExpr.Daniel Dunbar2008-10-101-8/+11
| | | | llvm-svn: 57335
* Make sema and codegen allow __builtin___CFStringMakeConstantString as a validChris Lattner2008-10-061-17/+2
| | | | | | | constant lvalue. Implement this in codegen by moving the code out of CGBuiltin into EmitConstantExpr. llvm-svn: 57163
* always try to fold a builtin before emitting it. In the futureChris Lattner2008-10-061-18/+5
| | | | | | | it is possible that a builtin could sometimes be folded (e.g. __builtin_clz) if it's operand is a constant. llvm-svn: 57161
* Move handling of __builtin_nan("") out of CGBuiltin.cpp into ExprConstant.cppChris Lattner2008-10-061-18/+5
| | | | llvm-svn: 57157
* remove some code where CGBuiltin folds constants, and use tryEvaluate toChris Lattner2008-10-061-22/+19
| | | | | | | do it instead. We should still handle __builtin_nan etc, but don't yet. This fixes incorrect evaluation of __builtin_constant_p, a FIXME. llvm-svn: 57156
* Added support for sse intrinsics loadlpd, loadhpd, muldq128, and mulld128Mon P Wang2008-09-301-0/+7
| | | | llvm-svn: 56830
* Add __builtin_object_size support.Daniel Dunbar2008-09-031-0/+10
| | | | | | | - Currently CodeGen always returns a conservative value for this (-1 or 0 depending on the context). llvm-svn: 55735
* Simplify some calls to Builder.CreateCallAnders Carlsson2008-08-301-5/+4
| | | | llvm-svn: 55567
* Change WarnUnsupported to ErrorUnsupported (in name and in practice).Daniel Dunbar2008-08-161-1/+1
| | | | | | | - We are beyond the point where this shows up often and when it does generating miscompiled files is bad. llvm-svn: 54836
* More #include cleaningDaniel Dunbar2008-08-111-4/+0
| | | | | | | | | | | - 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
* More #include cleaningDaniel Dunbar2008-08-111-0/+1
| | | | | | | | - Drop {Decl.h,DeclObjC.h,IdentifierTable.h} from Expr.h - Moved Sema::getCurMethodDecl() out of line (dependent on ObjCMethodDecl via dyn_cast). llvm-svn: 54629
* Updated to match new atomic names (to enable overloading for pointers toMon P Wang2008-07-311-4/+8
| | | | | | different address spaces) for llvm r54195. llvm-svn: 54241
* X86 builtin fixesNate Begeman2008-07-251-32/+10
| | | | llvm-svn: 54049
* don't depend on the result of CreateNeg to be a binopChris Lattner2008-07-231-3/+3
| | | | llvm-svn: 53948
* Implement bzero, memset, memmove builtins.Daniel Dunbar2008-07-221-10/+31
| | | | | | | This subsumes Nico Weber's patch and implements bzero in terms of llvm.memset to match llvm-gcc. llvm-svn: 53888
* Implement nans, prefetch, and trap builtins. Daniel Dunbar2008-07-211-1/+15
| | | | | | | This closes <rdar://problem/6080720>, support for __builtin_constant_p has been filed separately. llvm-svn: 53885
* Kill an unused variable warningDaniel Dunbar2008-07-211-3/+0
| | | | llvm-svn: 53878
* Add __builtin_powi[fl] supportDaniel Dunbar2008-07-211-0/+14
| | | | llvm-svn: 53866
* Implement ffs, parity, and popcount builtins.Daniel Dunbar2008-07-211-2/+55
| | | | | | + test case llvm-svn: 53851
* Add support shufpdMon P Wang2008-07-181-0/+4
| | | | llvm-svn: 53747
* Codegen support for __builtin_stdarg_startChris Lattner2008-07-091-2/+3
| | | | llvm-svn: 53329
* Make a few related changes:Chris Lattner2008-06-301-76/+91
| | | | | | | | | | | | | | 1) add a new ASTContext::getFloatTypeSemantics method. 2) Use it from SemaExpr.cpp, CodeGenTypes.cpp and other places. 3) Change the TargetInfo.h get*Format methods to return their fltSemantics byref instead of by pointer. 4) Change CodeGenFunction::EmitBuiltinExpr to allow builtins which sometimes expand specially and othertimes fall back to libm. 5) Add support for __builtin_nan("") to codegen, cases that don't pass in an empty string are currently lowered to libm calls. 6) Fix codegen of __builtin_infl. llvm-svn: 52914
* Updated atomic intrinsic name from llvm r52706. Fixed dropped bit in shufps.Mon P Wang2008-06-251-4/+4
| | | | llvm-svn: 52707
* This patch is motivated by numerous strict-aliasing warnings when compilingTed Kremenek2008-06-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clang as a Release build. The big change is that all AST nodes (subclasses of Stmt) whose children are Expr* store their children as Stmt* or arrays of Stmt*. This is to remove strict-aliasing warnings when using StmtIterator. None of the interfaces of any of the classes have changed (except those with arg_iterators, see below), as the accessor methods introduce the needed casts (via cast<>). While this extra casting may seem cumbersome, it actually adds some important sanity checks throughout the codebase, as clients using StmtIterator can potentially overwrite children that are expected to be Expr* with Stmt* (that aren't Expr*). The casts provide extra sanity checks that are operational in debug builds to catch invariant violations such as these. For classes that have arg_iterators (e.g., CallExpr), the definition of arg_iterator has been replaced. Instead of it being Expr**, it is an actual class (called ExprIterator) that wraps a Stmt**, and provides the necessary operators for iteration. The nice thing about this class is that it also uses cast<> to type-checking, which introduces extra sanity checks throughout the codebase that are useful for debugging. A few of the CodeGen functions that use arg_iterator (especially from OverloadExpr) have been modified to take begin and end iterators instead of a base Expr** and the number of arguments. This matches more with the abstraction of iteration. This still needs to be cleaned up a little bit, as clients expect that ExprIterator is a RandomAccessIterator (which we may or may not wish to allow for efficiency of representation). This is a fairly large patch. It passes the tests (except CodeGen/bitfield.c, which was already broken) on both a Debug and Release build, but it should obviously be reviewed. llvm-svn: 52378
* force size of alloca to i32, which is currently required by LLVM IR.Chris Lattner2008-06-161-3/+6
| | | | | | This fixes use of alloca on 64-bit systems. llvm-svn: 52334
* Basic support for volatile loads and stores. Stores the volatile Eli Friedman2008-06-131-1/+0
| | | | | | | | | | qualifier in the lvalue, and changes lvalue loads/stores to honor the volatile flag. Places which need some further attention are marked with FIXMEs. Patch by Cédric Venet. llvm-svn: 52264
* Implementation of __builtin_ctlz.Eli Friedman2008-05-271-0/+14
| | | | llvm-svn: 51595
* Add codegen support for stack address intrinsics.Eli Friedman2008-05-201-0/+8
| | | | llvm-svn: 51309
* Implement CodeGen for __builtin_memcpy.Eli Friedman2008-05-191-0/+10
| | | | llvm-svn: 51282
* Fix some prototypes, and implement some builtins until we have our header ↵Nate Begeman2008-05-161-0/+3
| | | | | | files completed. llvm-svn: 51199
* Handle a couple missing builtins that will go away eventually when the variousNate Begeman2008-05-151-1/+16
| | | | | | intrin.h files are finished llvm-svn: 51137
* Added support to generate some atomic operators (add, sub, and, or etc..)Mon P Wang2008-05-091-0/+39
| | | | llvm-svn: 50919
OpenPOWER on IntegriCloud