Commit Graph

501 Commits

Author SHA1 Message Date
Reid Kleckner 6df5254d6f intrin.h: Fix up bugs in the cr3 and msr intrinsics
Don't include input and output regs in clobbers.  Prefix some
identifiers with __.  Add a memory constraint to __readcr3 to prevent
reordering.  This constraint is heavy handed, but conservatively
correct.

Thanks to PaX Team for the suggestions.

llvm-svn: 205778
2014-04-08 17:49:16 +00:00
Reid Kleckner 592dc61acf intrin.h: Implement __readmsr, __readcr3, and __writecr3
Fixes PR19301.

Based on a patch from Steven Graf!

llvm-svn: 205751
2014-04-08 00:28:22 +00:00
Alexey Volkov ae43aae96a Added _rdtsc intrinsics by Robert Khasanov
Differential Revision: http://llvm-reviews.chandlerc.com/D3212

llvm-svn: 205172
2014-03-31 08:08:46 +00:00
Tim Northover fe7a445bf7 Install: add arm_neon.h header back
I'd gone too far pruning aarch64_simd.h this time and took out one
instance of arm_neon.h. This should restore us to the status quo.

llvm-svn: 205111
2014-03-29 17:35:34 +00:00
Tim Northover dca92dbc82 Remove stray references to aarch64_simd.h
They were causing the autotools builds to fail.

llvm-svn: 205103
2014-03-29 15:21:06 +00:00
Tim Northover a2ee433c8d ARM64: initial clang support commit.
This adds Clang support for the ARM64 backend. There are definitely
still some rough edges, so please bring up any issues you see with
this patch.

As with the LLVM commit though, we think it'll be more useful for
merging with AArch64 from within the tree.

llvm-svn: 205100
2014-03-29 15:09:45 +00:00
Reid Kleckner 7dd8bc0a84 Intrin.h: Implement _InterlockedExchangePointer
llvm-svn: 204827
2014-03-26 16:09:48 +00:00
Hans Wennborg a316933e09 MS intrinsics: __interlockedbittestandset(64) (PR19054)
llvm-svn: 203816
2014-03-13 17:05:09 +00:00
Hans Wennborg d9be72ec44 MS intrinsics: implement the __movs and __stos intrinsics (PR19054)
llvm-svn: 203722
2014-03-12 22:00:32 +00:00
Hans Wennborg a4421e03fa MS intrinsics: implement __readgs{byte,word,dword,qword} (PR19054)
llvm-svn: 203715
2014-03-12 21:09:05 +00:00
Hans Wennborg dd0f5304f6 MS intrinsics: don't declare __readeflags and __writeeflags in Intrin.h
They're already defined in ia32intrin.h, and this would cause including Intrin.h
in 64-bit mode to fail because of conflicting types. Update ms-intrin.cpp to
also run in 64-bit mode to catch things like this.

llvm-svn: 203714
2014-03-12 21:09:03 +00:00
David Majnemer 1e57976ec0 Headers: Provide an ABI compatible max_align_t when _MSC_VER is defined
Summary:
Our usual definition of max_align_t wouldn't match up with MSVC if it
was used in a template argument.

Reviewers: chandlerc, rsmith, rnk

Reviewed By: chandlerc

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2924

llvm-svn: 202911
2014-03-04 23:43:48 +00:00
Roman Divacky b8322b13f8 The wmmintrin.h header includes two different sub-headers: one for AES support
and one for PCLMUL support.  The current immintrin.h header only includes
wmmintrin.h if AES support is enabled.  It should include it if either AES or
PCLMUL is enabled (GCC's version of immintrin.h does this).

Patch by John Baldwin!

llvm-svn: 202871
2014-03-04 18:26:12 +00:00
Argyrios Kyrtzidis 7ffeea4ef3 [CMake] Add the newly introduced compiler header.
llvm-svn: 202792
2014-03-04 06:28:23 +00:00
Alexey Bataev af02c1c003 Fix for r202778 - Implement __readeflags and __writeeflags intrinsics (renamed res to __res)
llvm-svn: 202784
2014-03-04 03:42:58 +00:00
Alexey Bataev 7cab007902 Implement __readeflags and __writeeflags intrinsics
llvm-svn: 202778
2014-03-04 03:03:03 +00:00
Warren Hunt 0dc28ea301 [_mm_prefetch] Returning previously deleted comment.
No functional change.  It's unclear if the word FIXME is relevant given 
that the macro behaves as intended.

llvm-svn: 201920
2014-02-22 00:47:24 +00:00
Warren Hunt 20e4a5d2af Reapply 201734 but with appropriate gcc compatibility
Because GCC incorrectly defines _mm_prefetch to take anything that casts 
to void*, people have started using that behavior.  The previous patch 
that made _mm_prefetch actually take a const char * broke compatibility 
with existing code.  This update to the patch leaves the macro that 
defines _mm_prefetch with the (void*) cast when _MSC_VER is not defined.

llvm-svn: 201901
2014-02-21 23:08:53 +00:00
Daniel Jasper 2f0f297bdb Revert r201734 and r201742.
This breaks backwards compatibility with existing code. Previously, this
was defined as

  #define _mm_prefetch(a, sel) (__builtin_prefetch((void *)(a), 0, (sel)))

Which basically accepts any pointer. Changing this to char* simply
breaks a lot of existing code. I have tried changing char* to
"const void*", which seems to be the right thing as per Intel
specification this should work on basically any pointer. However,
apparently this breaks windows compatibility (because of a conflicting
declaration in windows.h).

So, we probably need to #ifdef this based on whether clang is compiling
for windows. According to Chandler, this might be done by introducing an
additional symbol to a fake type in BuiltinsX86.def and then condition
the type expansion on the platform.

llvm-svn: 201775
2014-02-20 11:10:48 +00:00
Chandler Carruth 7ce956ded4 Fix two pedantic issues with our builtin headers. The __STDC_VERSION__
for C99 is '199901L' and we shouldn't be comparing it with anything
else.

Neither of these should have had any impact in practice.

llvm-svn: 201738
2014-02-19 23:38:18 +00:00
Warren Hunt 40d6f29ad8 Add _mm_prefetch and some others as MS builtins
This patch adds several built-ins that are required for ms 
compatibility. _mm_prefetch must be a built-in because it takes a 
compile-time constant argument and our prior approach of using a #define 
to the current built-in doesn't work in the presence of re-declaration 
of _mm_prefetch. The others can be obtained by including the windows 
system headers. If a user includes the windows system headers but not 
intrin.h they still need to work and therefore must be built-in because 
we don't get a chance to implement them in intrin.h in this case.

llvm-svn: 201734
2014-02-19 23:20:20 +00:00
Richard Smith 294e59a33b Remove a broken attempt to cope with someone #undef'ing __has_include_next.
This was broken because __has_include_next(...) would not be valid in a
preprocessor condition if __has_include_next is not defined.

llvm-svn: 201731
2014-02-19 22:53:42 +00:00
Chandler Carruth e813984b43 Teach Clang to provide ::max_align_t in C11 and C++11 modes.
This definition is not chosen idly. There is an unfortunate reality with
max_align_t -- the specific nature of its definition leaks into the ABI
almost immediately. Because it is part of C11 and C++11 it becomes
essential for it to match with other systems on that ABI. There is an
effort to discourage any further use of this construct as a consequence
-- using max_align_t introduces an immediate ABI problem. We can never
update it to have larger alignment even as the microarchitecture changes
to necessitate higher alignment. =/

The particular definition here exactly matches the ABI of GCC's chosen
::max_align_t definition, for better or worse. This was written with the
help of Richard Smith who was decoding the exact ABI implications of the
selected definition in GCC. Notably, in-register arguments are impacted
by the particular definition chosen. =/

No one is under the illusion that this is a "good" or "useful"
definition of max_align_t, and we are working with the standards
committee to specify a more useful interface to address this need.

llvm-svn: 201729
2014-02-19 22:35:01 +00:00
Hans Wennborg 12fb89ec51 MS Intrin.h: implement __cpuidex and simplify __cpuid
The two identical implementations of __cpuid for X86 / X86_64 were
leftovers from my first iteration on the patch that implemented it.

llvm-svn: 200568
2014-01-31 19:44:55 +00:00
Hans Wennborg 1fd6dd3616 Intrin.h: include setjmp.h to get a jmp_buf definition
This makes sure that the ms-intrin.cpp test passes by providing
a mock setjmp.h as a test input.

llvm-svn: 200344
2014-01-28 23:01:59 +00:00
Hans Wennborg 740a4d6e46 Intrin.h: implement __rdtsc and __halt
llvm-svn: 200343
2014-01-28 22:55:01 +00:00
Reid Kleckner 33630907d6 Revert "intrin.h: include setjmp.h to get a jmp_buf definition"
This failed the ms-intrin.cpp test.

This reverts commit r200237.

This also comments out the _setjmpex declaration for now so that
intrin.h will work on x64 targets.

llvm-svn: 200243
2014-01-27 19:32:42 +00:00
Reid Kleckner f08d658d48 Add implementations of some MSVC intrinsics
Adds an implementation for _InterlockedCompareExchangePointer() and
__faststorefence().

Patch by David Ziman!

llvm-svn: 200239
2014-01-27 19:16:35 +00:00
Reid Kleckner 9b8dcebbca intrin.h: include setjmp.h to get a jmp_buf definition
This fixes an error on our _setjmpex declaration for 64-bit code and
allows us to declare _setjmp for 32-bit code.

llvm-svn: 200237
2014-01-27 19:14:09 +00:00
Reid Kleckner 924eb2afdc Add 'static __inline__' to MSVC intrinsics with implementations
This avoids warnings visible with -Wsystem-headers.

llvm-svn: 200235
2014-01-27 18:48:02 +00:00
Eric Christopher 58b404398e One more intrinsic.
llvm-svn: 200061
2014-01-25 01:38:30 +00:00
Eric Christopher 439137ea32 Add missing intrinsics, fix a couple of typos in intrinsic names,
and remove duplicate declarations.

llvm-svn: 199992
2014-01-24 12:13:47 +00:00
Hans Wennborg 74ca0c4105 Add implementations of __readfs{byte,word,dword,qword} to Intrin.h
Differential Revision: http://llvm-reviews.chandlerc.com/D2606

llvm-svn: 199958
2014-01-24 00:52:39 +00:00
Hans Wennborg 2ed8880346 Intrin.h: fix definitions of _Interlocked{In,De}crement16
The declarations seem correct, but the definitions were using
chars instead of shorts.

llvm-svn: 199923
2014-01-23 19:15:39 +00:00
NAKAMURA Takumi c28a9a2c33 [CMake] Deprecate CLANG_RUNTIME_OUTPUT_INTDIR and CLANG_LIBRARY_OUTPUT_INTDIR.
LLVM_*_OUTPUT_INTDIR should be available everywhere. It was my mistake when I introduced INTDIR stuff.

llvm-svn: 199597
2014-01-19 13:00:01 +00:00
Hans Wennborg 854f7d34ec Add implementations of _cpuid and _xgetbv to Intrin.h
The _cpuid() implementation is the same as in lib/Headers/cpuid.h
with the parameter names adjusted to match the interface.

_xgetbv just does what the Intel manual says.

Differential Revision: http://llvm-reviews.chandlerc.com/D2564

llvm-svn: 199439
2014-01-16 23:39:35 +00:00
NAKAMURA Takumi baa9f533fe [CMake][VS][XCode] Restruct the output directory layout more comfortable, ${BINARY_DIR}/${BUILD_MODE}/(bin|lib)
We have been seeing nasty directory layout with CMake multiconfig, such as,
  bin/Release/clang.exe
  lib/clang/3.x/...
  lib/Release/clang/3.x/.. (duplicated)

Move the layout similar to autoconf's;
  Release/bin/clang.exe
  Release/lib/clang/3.x/...

Checked on Visual Studio 10. Could you guys please confirm my change on XCode(and other multiconfig builders)?

Note: Don't set variables CMAKE_*_OUTPUT_DIRECTORY any more, or a certain builder, for eaxample, msbuild.exe, would be confused.
llvm-svn: 198205
2013-12-30 06:48:30 +00:00
NAKAMURA Takumi 38b8c938e8 [CMake] clang/lib/Headers: Install just-generated ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h, instead of copied arm_neon.h.
llvm-svn: 197852
2013-12-21 01:56:00 +00:00
NAKAMURA Takumi ea0c73b84e clang/lib/Headers/CMakeLists.txt: Revert part of r197395. It should not be staged yet.
llvm-svn: 197441
2013-12-17 00:02:38 +00:00
Nico Weber ef9a766555 Add bit_FXSAVE as an alias for bit_FXSR, for gcc compat.
llvm-svn: 197399
2013-12-16 17:54:57 +00:00
NAKAMURA Takumi a8c958de47 [CMake] Introduce CLANG_RUNTIME_OUTPUT_INTDIR and CLANG_LIBRARY_OUTPUT_INTDIR.
llvm-svn: 197395
2013-12-16 16:03:21 +00:00
Alp Toker d480b1bf34 Fix a SSE2 intrinsics typo
Full discourse at:

  http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20131104/092514.html
  http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-November/068124.html

Patch by Dimitry Andric and Alexey Dokuchaev!

llvm-svn: 195558
2013-11-23 22:11:57 +00:00
JF Bastien 1334d0aedf Define [U]LLONG_{MIN,MAX} for C++11, add tests.
Add tests for limits.h, not just [U]LLONG_{MIN,MAX}.

llvm-svn: 193506
2013-10-27 19:00:49 +00:00
Manman Ren c94122e05b Intrinsics: fix extract & insert when index is out of bound.
Now, all extract & insert intrinsics should have the correct and operation
to ignore higher bits.

rdar://15250497

llvm-svn: 193267
2013-10-23 20:33:14 +00:00
Manman Ren be38b9e15f _mm_extract_epi16: use "& 7" when index is out of bound.
This is in line with implementation of _mm_extract_pi16.
rdar://15250497

llvm-svn: 193187
2013-10-22 19:24:42 +00:00
Reid Kleckner 00d33a5cb1 Add implementations of the MSVC barrier intrinsics
Summary:
These are deprecated in VS 2012 according to MSDN.  They don't actually
compile down to any code.  They prevent the compiler from reordering
memory accesses across the barrier, which is what a memory-clobbering
volatile asm does.

Reviewers: echristo

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1954

llvm-svn: 192860
2013-10-17 01:29:48 +00:00
Ted Kremenek 854cc293a7 Suppress useless -Wshadow warning when using _mm* macros from emmintrin.h
Fixes <rdar://problem/10679282>.

I'm not completely satisfied with this patch.  Sprinkling "diagnostic ignored"
_Pragmas throughout this file is gross, but I couldn't suppress
it for the entire file.

llvm-svn: 192143
2013-10-07 23:51:11 +00:00
Craig Topper d335c9da22 Use logical/arithmetic operations instead of builtins in tbmintrin.h. This way we can remove the intrinsic support from the backend.
llvm-svn: 192036
2013-10-05 17:08:42 +00:00
Craig Topper d867805739 Change __builtin_ia32_bextri_u64 to take an i64imm to match up with LLVM backend changes.
An explicit cast is still needed in tbmintrin.h to convert any big integer down to i32imm.

Patch from Yunzhong Gao.

llvm-svn: 191872
2013-10-03 04:21:19 +00:00
Warren Hunt 2731e3e4ef Fixing implementation of bittestandset in Intrin.h.
llvm-svn: 191783
2013-10-01 17:12:40 +00:00