Commit Graph

269 Commits

Author SHA1 Message Date
Nate Begeman ad5dd42817 vdup_lane was missing
<rdar://problem/8278732>

llvm-svn: 110420
2010-08-06 01:24:57 +00:00
Nate Begeman f568b074db Add support for VFP status & control operations for ARM.
llvm-svn: 110153
2010-08-03 21:32:34 +00:00
Nate Begeman 1194bd2bd8 Wire up sema checking for __builtin_arm_usat and __builtin_arm_ssat immediates.
llvm-svn: 109814
2010-07-29 22:48:34 +00:00
Fariborz Jahanian 0ebca28f1d 2nd argument of __builtin_expect must be evaluated
if it hs side-effect to matchgcc's behaviour.
Addresses radar 8172109.

llvm-svn: 109467
2010-07-26 23:11:03 +00:00
Chandler Carruth bc8cab16c5 Improve the representation of the atomic builtins in a few ways. First, we make
their call expressions synthetically have the "deduced" types based on their
first argument. We only insert conversions in the AST for arguments whose
values require conversion to match the value type expected. This keeps PR7600
closed by maintaining the return type, but avoids assertions due to unexpected
implicit casts making the type unsigned (test case added from Daniel).

The magic is moved into the codegen for the atomic builtin which inserts the
casts as needed at the IR level to raise the type to an integer suitable for
the LLVM intrinsic. This shouldn't cause any real change in functionality, but
now we can make the builtin be more truly polymorphic.

llvm-svn: 108638
2010-07-18 07:23:17 +00:00
Chris Lattner 5e016ae983 finally get around to doing a significant cleanup to irgen:
have CGF create and make accessible standard int32,int64 and 
intptr types.  This fixes a ton of 80 column violations 
introduced by LLVMContextification and cleans up stuff a lot.

llvm-svn: 106977
2010-06-27 07:15:29 +00:00
Nate Begeman ed48c857dc Implement remaining codegen for NEON, all operations should now work.
llvm-svn: 106407
2010-06-20 23:05:28 +00:00
Anton Korobeynikov cc50b7d7d5 More AltiVec support.
Patch by Anton Yartsev!

llvm-svn: 106387
2010-06-19 09:47:18 +00:00
Nate Begeman dbafec1f3e Remove last of the bool shifts for MS VC++, patch by dimitry andric
llvm-svn: 106206
2010-06-17 02:26:59 +00:00
Fariborz Jahanian 4a30307840 Fixed conflict between objc_memmove_collectable builtin
decl. and one ddefined in darwin header file.

llvm-svn: 106107
2010-06-16 16:22:04 +00:00
Fariborz Jahanian 021510e96f Patch adds support for copying of those
objective-c++ class objects which have GC'able objc object
pointers and need to use ObjC's objc_memmove_collectable
API (radar 8070772). 

llvm-svn: 106061
2010-06-15 22:44:06 +00:00
Benjamin Kramer 7039fcbc5d An implementation of __builtin__fpclassify the way Chris Lattner described by Jörg Blank.
llvm-svn: 105936
2010-06-14 10:30:41 +00:00
Nate Begeman 91e1feab7a Add some missing shifts
Fix multiplies by scalar
Add SemaChecking code for all immediates
Add SemaChecking-gen support to arm_neon.td

llvm-svn: 105930
2010-06-14 05:21:25 +00:00
Nate Begeman d773fe67dd Most of NEON sema checking & fix to polynomial type detection
llvm-svn: 105908
2010-06-13 04:47:52 +00:00
Nate Begeman c6ac0ce89f Shifts complete. Only vld & sema checking of constants remain.
llvm-svn: 105879
2010-06-12 06:06:07 +00:00
Nate Begeman dd715805ab vbsl, vrev* is implemented via arm_neon.h
llvm-svn: 105875
2010-06-12 03:11:41 +00:00
Nate Begeman 8ed060b95a Most of remaining builtins, 2 generics, vld, and rounding shfits remain.
llvm-svn: 105848
2010-06-11 22:57:12 +00:00
Nate Begeman e0935ffa50 Multiplies, some shifts, set_lane
llvm-svn: 105793
2010-06-10 18:11:55 +00:00
Nate Begeman 4a04b467d9 support _lane ops, and multiplies by scalar.
llvm-svn: 105770
2010-06-10 00:17:56 +00:00
Nate Begeman d90aa43bdf Implement codegen for hadd, hsub, max, min, mlal, movl, movn, padal, mov_n
Make note about how to handle the dozen or so multiply by scalar ops.

llvm-svn: 105734
2010-06-09 18:04:15 +00:00
Nate Begeman 4307a25545 More accurate BuiltinsARM.def
vget_lane support

llvm-svn: 105684
2010-06-09 05:30:26 +00:00
Rafael Espindola 6bb986d530 Simplify the code a bit and avoid a gcc waring about uninitialized variables.
llvm-svn: 105676
2010-06-09 03:48:40 +00:00
Nate Begeman 5548309fa7 Implement transpose/zip/unzip & table lookup.
Test out some basic constant-checking.

llvm-svn: 105667
2010-06-09 01:10:23 +00:00
Nate Begeman ae6b1d8010 Fix NEON intrinsic argument passing, support vext. Most now successfully make it through codegen to the .s file
llvm-svn: 105599
2010-06-08 06:03:01 +00:00
Rafael Espindola 895e51de4a Fix what looks like a merge problem that broke __clear_cache.
llvm-svn: 105595
2010-06-08 03:52:53 +00:00
Nate Begeman 16372afeab Implement ARM NEON up through vcvt, alphabetically.
llvm-svn: 105590
2010-06-08 00:17:19 +00:00
Rafael Espindola a54062ef0c Implement __clear_cache on ARM.
llvm-svn: 105537
2010-06-07 17:26:50 +00:00
Nate Begeman 5968eb270a weekend checkpoint of arm neon builtins codegen.
TODO: add remainder of builtins to CGBuiltin, add code to SemaChecking to validate constants.

llvm-svn: 105532
2010-06-07 16:01:56 +00:00
Dan Gohman ed0347333e This cast is no longer needed; the FIXME is fixed.
llvm-svn: 104919
2010-05-28 01:45:35 +00:00
Jim Grosbach 4cf59b9e91 Update __builtin_setjmp codegen to match llvmCore changes in r104900.
llvm-svn: 104902
2010-05-27 23:54:20 +00:00
John McCall 02269a66b3 Enable the implementation of __builtin_setjmp and __builtin_longjmp. Not all
LLVM backends support these yet.

llvm-svn: 104867
2010-05-27 18:47:06 +00:00
Benjamin Kramer fdb61d78e9 Implement codegen for __builtin_isnormal.
llvm-svn: 104118
2010-05-19 11:24:26 +00:00
Chris Lattner 3628326b44 add todos for isinf_sign and isnormal, which I don't intend to implement
in the near future.

llvm-svn: 103169
2010-05-06 06:13:53 +00:00
Chris Lattner dbff4bf5f4 implement codegen support for __builtin_isfinite, part of PR6083
llvm-svn: 103168
2010-05-06 06:04:13 +00:00
Chris Lattner 43660c5bc0 implement part of PR6083: codegen support for isinf. Like isnan,
this is generating correct but suboptimal (extra extend to double)
code for the float case.  Will investigate next.

llvm-svn: 103166
2010-05-06 05:35:16 +00:00
Eric Christopher 1bbc7086ff Rewrite handling of 64-bit palignr intrinsics to be vector shuffles.
Stop multiplying constant by 8 accordingly in the header and change
intrinsic definition for what types we expect.

Add to existing palignr test to check that we're emitting the correct things.

llvm-svn: 101332
2010-04-15 01:43:08 +00:00
Chris Lattner dad4062b4d implement altivec.h and a bunch of support code, patch by Anton Yartsev!
llvm-svn: 101215
2010-04-14 03:54:58 +00:00
John McCall 8586bfd85d @llvm.sqrt isn't really close enough to C's sqrt to justify emitting calls
to the intrinsic, even when math-errno is off.

Fixes rdar://problem/7828230 by falling back on the library function.

llvm-svn: 100613
2010-04-07 08:20:20 +00:00
Mon P Wang cc2ab0cdc9 Reapply patch for adding support for address spaces and added a isVolatile field to memcpy, memmove, and memset.
llvm-svn: 100305
2010-04-04 03:10:52 +00:00
Mon P Wang f7f3bff646 Revert r100193 since it causes failures in objc in clang
llvm-svn: 100200
2010-04-02 18:43:42 +00:00
Mon P Wang 4b82a88764 Reapply patch for adding support for address spaces and added a isVolatile field to memcpy, memmove, and memset.
llvm-svn: 100193
2010-04-02 18:04:30 +00:00
Bob Wilson adb58e32cc Revert Mon Ping's 99930 due to broken llvm-gcc buildbots.
llvm-svn: 99949
2010-03-30 22:28:46 +00:00
Mon P Wang 231e99743a Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset
llvm-svn: 99930
2010-03-30 21:02:45 +00:00
Daniel Dunbar 3f540c0d7d Remove support for nand atomic builtins. They are inconsistently implemented in
gcc, and the common expectation seems to be that they are unused. If and when
someone cares we can add them back with well documented demantics.

llvm-svn: 99522
2010-03-25 17:13:09 +00:00
Daniel Dunbar 4ff562d557 IRgen: Wrap atomic intrinsics with memory barriers, to ensure we honor the semantics.
- This should be conservatively correct, we eventually should have target hooks for platforms that are less strict.

llvm-svn: 99050
2010-03-20 07:04:11 +00:00
Eli Friedman 99d20f83ba PR6515: Implement __builtin_signbit and friends.
I'm reasonably sure my implementation is correct, but it would be nice if
someone could double-check.

llvm-svn: 97864
2010-03-06 02:17:52 +00:00
John McCall beec5a080f Implement __builtin_dwarf_sp_column for i386 (Darwin and not), x86-64 (all),
and ARM.  Implement __builtin_init_dwarf_reg_size_table for i386 (both) and
x86-64 (all).

llvm-svn: 97859
2010-03-06 00:35:14 +00:00
John McCall 731be6620c Revert changes r97693, r97700, and r97718.
Our testing framework can't deal with disabled targets yet.

llvm-svn: 97719
2010-03-04 04:29:44 +00:00
John McCall 81d4d12504 Implement __builtin_dwarf_sp_column().
llvm-svn: 97700
2010-03-04 00:44:01 +00:00
Chris Lattner 5cc15e058b add framework for ARM builtins, Patch by Edmund Grimley Evans!
llvm-svn: 97656
2010-03-03 19:03:45 +00:00
John McCall 515c3c548c Sketch out an implementation for __builtin_dwarf_cfa. I have no idea
why the front-end is calculating the argument to llvm.eh.dwarf.cfa().

llvm-svn: 97653
2010-03-03 10:30:05 +00:00
John McCall 66769f8544 Implement __builtin_eh_return.
llvm-svn: 97643
2010-03-03 05:38:58 +00:00
John McCall d4f4b7f5ee Add proper target hooks for __builtin_extract_return_address and
__builtin_frob_return_address.  The implementations for both are
still trivial in the default case.

llvm-svn: 97638
2010-03-03 04:15:11 +00:00
John McCall b6cc2c0439 Inspired by seeing "MIPS" go by in the commits, I've gone ahead and
implemented a (codegen) target hook for __builtin_extend_pointer.
I'm also making it return a uint64_t instead of an unsigned word;  this
comports with typical usage (i.e. the one use I know of).

I don't know if any of the existing targets requires this hook to be
set (other than x86 and x86_64, which I know do not).

llvm-svn: 97547
2010-03-02 03:50:12 +00:00
John McCall 4b613fae35 After much consultation aimed at figuring out what this builtin actually
does, document the results and then implement __builtin_extend_pointer for
platforms where it's a no-op.

llvm-svn: 97540
2010-03-02 02:31:24 +00:00
Daniel Dunbar a7566f163a IRgen: Add CreateMemTemp, for creating an temporary memory object for a particular type, and flood fill. - CreateMemTemp sets the alignment on the alloca correctly, which fixes a great many places in IRgen where we were doing the wrong thing.
- This fixes many many more places than the test case, but my feeling is we need to audit alignment systematically so I'm not inclined to try hard to test the individual fixes in this patch. If this bothers you, patches welcome!

PR6240.

llvm-svn: 95648
2010-02-09 02:48:28 +00:00
Daniel Dunbar 8848175547 IRgen: Fix some CreateTempAlloca calls to use ConvertTypeForMem when that is
conceptually correct. Review appreciated (Chris, Eli, Anders).

llvm-svn: 95401
2010-02-05 18:56:49 +00:00
Eli Friedman d6ef69a7db Add bzero builtin; this should help codegen quality for code using this
function.

llvm-svn: 94320
2010-01-23 19:00:10 +00:00
David Chisnall 481e3a87fe Created __builtin___NSStringMakeConstantString() builtin, which generates constant Objective-C strings.
llvm-svn: 94274
2010-01-23 02:40:42 +00:00
Tanya Lattner dbfd16014a Add codgen for BI__builtin_llvm_memory_barrier.
llvm-svn: 93611
2010-01-16 01:21:14 +00:00
Anton Korobeynikov 73d50b9141 Promote arguments of frameaddr / returnaddr builtins to i32 type, when needed.
This is needed for the platforms, where bitwidth of "int" is not 32 bits
(e.g. 16 on msp430).

llvm-svn: 92176
2009-12-27 14:27:22 +00:00
Anders Carlsson 1749083e2e Fill in the return value slot in CGExprAgg::VisitCallExpr. This takes us halfway towards fixing PR5824.
llvm-svn: 92142
2009-12-24 20:40:36 +00:00
Anders Carlsson 0435ed5875 Add a ReturnValueSlot class. Change the argument order in EmitCall to match the other overload better.
llvm-svn: 92136
2009-12-24 19:08:58 +00:00
Eric Christopher c87915629b Update for the intrinsic changes in llvm: the object size intrinsic
only takes a boolean second argument now. Update tests accordingly.
Currently the builtin still accepts the full range for compatibility.

llvm-svn: 91983
2009-12-23 03:49:37 +00:00
Daniel Dunbar 91b640abfc Fix a few MSVC warnings.
llvm-svn: 91714
2009-12-18 20:58:47 +00:00
Eli Friedman 7f4933f6c7 Fix for PR5801: codegen memcpy, memmove, memset directly to LLVM intrinsics.
llvm-svn: 91573
2009-12-17 00:14:28 +00:00
Mike Stump b85ffb689e Add an addition check for undefined behavior for when we hit a
__builtin_unreachable.  WIP.

llvm-svn: 91499
2009-12-16 03:07:12 +00:00
Nate Begeman 67dfd4236a Revert mmx palignr to use an intrinsic, since mmx shuffle patterns are missing.
llvm-svn: 91269
2009-12-14 05:15:02 +00:00
Nate Begeman 72ec6bc6f4 Support x86's PALIGNR instruction without the use of a palignr intrinsic.
llvm-svn: 91264
2009-12-14 04:57:03 +00:00
Mike Stump 52d7141186 Remove obsolete fallback code for objectsize.
llvm-svn: 90780
2009-12-07 18:58:11 +00:00
Eric Christopher c377c81dcf Update for llvm intrinsics change.
llvm-svn: 90208
2009-12-01 05:00:51 +00:00
Daniel Dunbar 1dd0164bbe Explicitly use setVolatile instead of extra IRBuilder argument.
llvm-svn: 90095
2009-11-29 21:11:47 +00:00
Duncan Sands 7876dad8e7 Pass a value for the isSigned parameter of CreateIntCast, rather than
passing the name (an exotic way of specifying that the result is signed!).

llvm-svn: 88909
2009-11-16 13:11:21 +00:00
Mike Stump 68ec7ee0e8 Enable the use of the new llvm objectsize intrinsic.
llvm-svn: 86607
2009-11-09 22:40:09 +00:00
Mike Stump 876387ba4f __builtin_object_size refinements. Ensure we handle expressions with
side-effects up front, as when we switch to the llvm intrinsic call
for __builtin_object_size later, it will have two evaluations.

We also finish off the intrinsic version of the code so we can just
turn it on once llvm has the intrinsic.

llvm-svn: 85324
2009-10-27 22:09:17 +00:00
Mike Stump 7a484dd6a9 Prep for future __builtin_object_size refinements. The theory is that
someone will add an llvm intrinsic for us to use, so the optimizer can
figure out the hard cases.  WIP.

For those that want to help, double check with Eric before starting.
He has a bit of code this will plug into.

llvm-svn: 85175
2009-10-26 23:39:48 +00:00
Benjamin Kramer abd5b90e4c Simplify pointer creation with the new Type::getInt*Ptr methods.
llvm-svn: 83964
2009-10-13 10:07:13 +00:00
Chris Lattner bf20638966 Implement __builtin_unreachable(), a GCC 4.5 extension.
llvm-svn: 82433
2009-09-21 03:09:59 +00:00
Daniel Dunbar ff0553ec61 Fix subtle bug in generating LLVM function declarations for builtin functions.
The decl wasn't being passed down, which meant that function attributes were not
being set correctly. This is particularly important for ARM, since it wants to
override the calling convention. Instead we would emit the builtin with the
wrong calling convention, and instcombine would come along and merrily shred all
the calls to it. :)

llvm-svn: 81756
2009-09-14 04:33:21 +00:00
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Eli Friedman 1c277d0fe8 PR4836, part 2: CodeGen for __builtin_isnan.
llvm-svn: 80655
2009-09-01 04:19:44 +00:00
Daniel Dunbar 576d90d39b Remove TargetInfo::getTargetPrefix().
llvm-svn: 79907
2009-08-24 09:54:37 +00:00
Owen Anderson 41a750271b Update for LLVM API change.
llvm-svn: 78946
2009-08-13 21:57:51 +00:00
Owen Anderson 0b75f23b94 Update for LLVM API change.
llvm-svn: 77722
2009-07-31 20:28:54 +00:00
Owen Anderson 7ec07a573c Update for LLVM API changes.
llvm-svn: 77638
2009-07-30 23:11:26 +00:00
Owen Anderson 9793f0e4d7 Update for LLVM API change.
llvm-svn: 77514
2009-07-29 22:16:19 +00:00
Owen Anderson e05f2ed478 Update for LLVM API change.
llvm-svn: 77249
2009-07-27 21:00:51 +00:00
Daniel Dunbar e59313a298 Switch to getName()
llvm-svn: 77151
2009-07-26 09:28:40 +00:00
Owen Anderson b7a2fe6f81 Update for LLVM API change.
llvm-svn: 77012
2009-07-24 23:12:58 +00:00
Owen Anderson 170229f68d Update for LLVM API change, and contextify a bunch of related stuff.
llvm-svn: 75705
2009-07-14 23:10:40 +00:00
Owen Anderson ae86c19e68 Update for LLVM API change.
llvm-svn: 75446
2009-07-13 04:10:07 +00:00
Argyrios Kyrtzidis b4b64ca752 Remove the ASTContext parameter from the attribute-related methods of Decl.
The implementations of these methods can Use Decl::getASTContext() to get the ASTContext.

This commit touches a lot of files since call sites for these methods are everywhere.
I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it.

llvm-svn: 74501
2009-06-30 02:34:44 +00:00
Douglas Gregor 78bd61f661 Move the static DeclAttrs map into ASTContext. Fixes <rdar://problem/6983177>.
llvm-svn: 73702
2009-06-18 16:11:24 +00:00
Chris Lattner 5abdec7978 move the various builtins stuff from libast to libbasic. This
fixes a layering violation in lib/Basic/Targets.cpp.

llvm-svn: 73318
2009-06-14 01:05:48 +00:00
Eli Friedman e9ff191459 Remove a few more vector builtins.
llvm-svn: 73022
2009-06-07 09:32:56 +00:00
Eli Friedman 5a996fc0fc Now that LLVM CodeGen can handle the generic variations a bit better,
get rid of a few more clang vector builtins.

llvm-svn: 73015
2009-06-07 07:12:56 +00:00
Eli Friedman 6813eb125f Get rid of a bunch of dead builtins.
llvm-svn: 72996
2009-06-06 08:31:46 +00:00
Eli Friedman cb9d07caeb Add support for __builtin_unwind_init.
Also, committing an #if 0'ed __builtin_setjmp and __builtin_longjmp 
implementation I've had sitting in my tree for a while.  I haven't 
enabled it because the LLVM backend support isn't complete yet.

llvm-svn: 72727
2009-06-02 09:37:50 +00:00
Eli Friedman f6bd15038c If we recognize alloca, treat it as a builtin. This fixes uses of
alloca without declaring it.

llvm-svn: 72719
2009-06-02 07:10:30 +00:00
Daniel Dunbar 16f422ec86 Fix a use-of-undefined, IRgen expects the RValue for "void" to be a scalar RValue.
llvm-svn: 72504
2009-05-27 23:45:33 +00:00
Anders Carlsson 3a9463bfda Rename an EmitCallExpr function to EmitCall to make it clear that it doesn't emit an expr.
llvm-svn: 72446
2009-05-27 01:22:39 +00:00
Jay Foad 7d0479f2c2 Use v.data() instead of &v[0] when SmallVector v might be empty.
llvm-svn: 72210
2009-05-21 09:52:38 +00:00
Anders Carlsson 8dd2947696 Remove an unused builtin.
llvm-svn: 72033
2009-05-18 19:25:54 +00:00
Anders Carlsson 2081200b8c Add 'cmp' SSE builtins and get rid of a bunch of other builtins.
llvm-svn: 72032
2009-05-18 19:16:46 +00:00
Chris Lattner afde259240 implement __sync_synchronize and __sync_lock_release,
rdar://6880573

llvm-svn: 71637
2009-05-13 04:46:13 +00:00
Chris Lattner 94578cba76 add support for __sync_nand_and_fetch and __sync_fetch_and_nand,
rdar://6880573

llvm-svn: 71636
2009-05-13 04:37:52 +00:00
Chris Lattner dc04654697 reimplement __sync_* builtins to be variadic and to follow the same
semantic rules that gcc and icc use.  This implements the variadic
and concrete versions as builtins and has sema do the 
disambiguation.  There are probably a bunch of details to finish up
but this seems like a large monotonic step forward :)

llvm-svn: 71212
2009-05-08 06:58:22 +00:00
Eli Friedman 5b73b5e197 PR4134: Implement __builtin_extract_return_addr.
llvm-svn: 70794
2009-05-03 19:23:23 +00:00
Eli Friedman 1c4a175aef Remove getIntegerConstantExprValue in favor of using EvaluateAsInt.
llvm-svn: 70145
2009-04-26 19:19:15 +00:00
Chris Lattner c2e868fd14 fix incorrect lowering of __builtin_ia32_shufpd, rdar://6803924
llvm-svn: 69428
2009-04-18 07:01:54 +00:00
Daniel Dunbar 4184ac847f Update to use hasAttr() instead of getAttr().
- No functionality change.

llvm-svn: 68987
2009-04-13 21:08:27 +00:00
Anders Carlsson 80f97ab08f Add a destination type argument to EmitConstantExpr. This will be used for when the destination has a reference type. (No functionality change yet)
llvm-svn: 68593
2009-04-08 04:48:15 +00:00
Daniel Dunbar 4fab57ddea Implement __sync_{add,sub,and,or,xor}_and_fetch and
__sync_bool_compare_and_swap.
 - <rdar://problem/6762223> [sema/irgen] support
   __sync_bool_compare_and_swap and __sync_add_and_fetch

llvm-svn: 68482
2009-04-07 00:55:51 +00:00
Daniel Dunbar 8eb018ab9c Support IRgen of sqrt -> llvm.sqrt, pow -> llvm.pow.
- 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
2009-02-16 22:43:43 +00:00
Daniel Dunbar e28b359881 Fix IRgen of __builtin_memset.
- Fix test case to not only have negative tests.

llvm-svn: 64674
2009-02-16 21:52:05 +00:00
Douglas Gregor b9063fc1b3 Implicitly declare certain C library functions (malloc, strcpy, memmove,
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
2009-02-13 23:20:09 +00:00
Daniel Dunbar e9fcadd2a6 Use EmitVAListRef instead of EmitLValue directly to handle array decay
case on x86_64.

llvm-svn: 64333
2009-02-11 22:25:55 +00:00
Dale Johannesen 621c3512a3 Reapply Daniel's patch to match up with llvm 63765.
Untested, Daniel or Nate please review.

llvm-svn: 63814
2009-02-05 01:50:47 +00:00
Daniel Dunbar 400c040e01 Chase LLVM TOT in circles (i.e., revert r63773 to match revert of
r63765).

llvm-svn: 63795
2009-02-04 23:40:00 +00:00
Daniel Dunbar 91b73d441e (llvm up) Update for intrinsic lookup changes.
llvm-svn: 63773
2009-02-04 21:09:15 +00:00
Eli Friedman c69d454d5a Make the constant folder aware of
__builtin___CFStringMakeConstantString.  (We get into trouble in 
GenerateStaticBlockVarDecl if the constant folder isn't accurate.)

llvm-svn: 62949
2009-01-25 01:54:01 +00:00
Eli Friedman ddea0ade30 Slight cleanup, and fix for va_arg on architectures where va_list is a
struct.

llvm-svn: 62585
2009-01-20 17:46:04 +00:00
Eli Friedman 8687a09fd0 Do codegen correctly for va_start/end/copy on architectures where
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
2009-01-20 17:25:25 +00:00
Eli Friedman 08c5dabf1b Fix for PR3350: add special-casing for "references" to va_lists in
builtins.

Also, a minor tweak to va_copy for consistency.

llvm-svn: 62574
2009-01-20 07:46:22 +00:00
Nate Begeman b699c9bf57 Vector codegen improvements
llvm-svn: 62458
2009-01-18 06:42:49 +00:00
Anders Carlsson 0462eb270a Generate code for __builtin_ia32_pshufw
llvm-svn: 61324
2008-12-22 04:54:32 +00:00
Anders Carlsson c9687907c5 Use the new Expr::Evaluate
llvm-svn: 60321
2008-12-01 02:31:41 +00:00
Chris Lattner 67d7b9204c rename Expr::tryEvaluate to Expr::Evaluate.
llvm-svn: 59426
2008-11-16 21:24:15 +00:00
Anders Carlsson 4961890c07 Fix bug in va_copy
llvm-svn: 58680
2008-11-04 05:29:05 +00:00
Eli Friedman 5adca5f02c Fix for PR2966: va_start/va_end use the *address* of the
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
2008-10-29 04:39:20 +00:00
Mon P Wang d05269d13c Added pinsrd, pinsrq, and some other vector intrinsics
llvm-svn: 57563
2008-10-15 06:18:34 +00:00
Daniel Dunbar eca513d945 Lift EmitTargetBuiltinExpr out of EmitBuiltinExpr.
llvm-svn: 57335
2008-10-10 00:24:54 +00:00
Chris Lattner a97132a9c4 Make sema and codegen allow __builtin___CFStringMakeConstantString as a valid
constant lvalue.  Implement this in codegen by moving the code out of CGBuiltin
into EmitConstantExpr.

llvm-svn: 57163
2008-10-06 07:26:43 +00:00
Chris Lattner 24355b5240 always try to fold a builtin before emitting it. In the future
it is possible that a builtin could sometimes be folded (e.g. __builtin_clz)
if it's operand is a constant.

llvm-svn: 57161
2008-10-06 06:56:41 +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 a1518b1dfe remove some code where CGBuiltin folds constants, and use tryEvaluate to
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
2008-10-06 06:09:18 +00:00
Mon P Wang 553b4b912b Added support for sse intrinsics loadlpd, loadhpd, muldq128, and mulld128
llvm-svn: 56830
2008-09-30 05:31:27 +00:00
Daniel Dunbar b0d34c8e4a Add __builtin_object_size support.
- Currently CodeGen always returns a conservative value for this (-1
   or 0 depending on the context).

llvm-svn: 55735
2008-09-03 21:13:56 +00:00
Anders Carlsson 7e1e57103e Simplify some calls to Builder.CreateCall
llvm-svn: 55567
2008-08-30 16:17:45 +00:00
Daniel Dunbar a7c8cf6200 Change WarnUnsupported to ErrorUnsupported (in name and in practice).
- We are beyond the point where this shows up often and when it does
   generating miscompiled files is bad.

llvm-svn: 54836
2008-08-16 00:56:44 +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
Daniel Dunbar 6e8aa537f8 More #include cleaning
- 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
2008-08-11 05:35:13 +00:00
Mon P Wang b160a0d78d Updated to match new atomic names (to enable overloading for pointers to
different address spaces) for llvm r54195.

llvm-svn: 54241
2008-07-31 03:28:23 +00:00
Nate Begeman 448b0cb033 X86 builtin fixes
llvm-svn: 54049
2008-07-25 20:17:24 +00:00
Chris Lattner 28ee5b3d29 don't depend on the result of CreateNeg to be a binop
llvm-svn: 53948
2008-07-23 06:53:34 +00:00
Daniel Dunbar 327acd7a6c Implement bzero, memset, memmove builtins.
This subsumes Nico Weber's patch and implements bzero in terms
of llvm.memset to match llvm-gcc.

llvm-svn: 53888
2008-07-22 00:26:45 +00:00
Daniel Dunbar b725726c29 Implement nans, prefetch, and trap builtins.
This closes <rdar://problem/6080720>, support for __builtin_constant_p
has been filed separately.

llvm-svn: 53885
2008-07-21 22:59:13 +00:00
Daniel Dunbar 7ed03c4cdd Kill an unused variable warning
llvm-svn: 53878
2008-07-21 21:43:28 +00:00
Daniel Dunbar c2f67966f4 Add __builtin_powi[fl] support
llvm-svn: 53866
2008-07-21 18:44:41 +00:00
Daniel Dunbar d93abc3bb0 Implement ffs, parity, and popcount builtins.
+ test case

llvm-svn: 53851
2008-07-21 17:19:41 +00:00