Commit Graph

131 Commits

Author SHA1 Message Date
Alexey Bataev 76af433873 [OPENMP] Introduced type trait "__builtin_omp_required_simd_align" for default simd alignment.
Adds type trait "__builtin_omp_required_simd_align" after discussions here http://reviews.llvm.org/D9894
Differential Revision: http://reviews.llvm.org/D10597


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241237 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-02 03:40:19 +00:00
Bradley Smith db683c0a2b Revert code changes made under r235976.
This issue was fixed elsewhere in r235396 in a more general way, hence these
changes no longer do anything. Keep the testcase however, to ensure that we
don't regress this for ARM.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236104 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 14:32:06 +00:00
Bradley Smith 2085f1eed3 [ARM/AArch64] Enforce alignment for bitfielded structs
When creating a global variable with a type of a struct with bitfields, we must
forcibly set the alignment of the global from the RecordDecl. We must do this so
that the proper bitfield alignment makes its way down to LLVM, since clang will
mangle the bitfields into one large type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235976 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 11:24:54 +00:00
Ulrich Weigand d85ab2e6f3 Implement target-specific __attribute__((aligned)) value
The GCC construct __attribute__((aligned)) is defined to set alignment
to "the default alignment for the target architecture" according to
the GCC documentation:

  The default alignment is sufficient for all scalar types, but may not be
  enough for all vector types on a target that supports vector operations.
  The default alignment is fixed for a particular target ABI.

clang currently hard-coded an alignment of 16 bytes for that construct,
which is correct on some platforms (including X86), but wrong on others
(including SystemZ).  Since this value is ABI-relevant, it is important
to get correct for compatibility purposes.

This patch adds a new TargetInfo member "DefaultAlignForAttributeAligned"
that targets can set to the appropriate default __attribute__((aligned))
value.

Note that I'm deliberately *not* using the existing "SuitableAlign"
value, which is used to set the pre-defined macro __BIGGEST_ALIGNMENT__,
since those two values may not be the same on all platforms.  In fact,
on X86, __attribute__((aligned)) always uses 16-byte alignment, while
__BIGGEST_ALIGNMENT__ may be larger if AVX-2 or AVX-512 are supported.
(This is actually not yet correctly implemented in clang either.)

The patch provides a value for DefaultAlignForAttributeAligned only for
SystemZ, and leaves the default for all other targets at 16, which means
no visible change in behavior on all other targets.  (The value is still
wrong for some other targets, but I'd prefer to leave it to the target
maintainers for those platforms to fix.)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235397 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-21 17:29:35 +00:00
Zoran Jovanovic fd6b1499b2 Fixed typo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230253 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-23 20:20:49 +00:00
Zoran Jovanovic f4ae8457c4 Change representation of member function pointers for MIPS targets
Differential Revision: http://reviews.llvm.org/D7148


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229680 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-18 15:21:35 +00:00
David Majnemer f53640dd1f Sema: Relax parsing of '#' in constraints
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225942 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 05:11:09 +00:00
David Majnemer 30e99c2392 Basic: Numeric constraints are multidigit
Clang would treat the digits in an "11m" input constraint separately as
if it was handling constraint 1 twice instead of constraint 11.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225606 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-11 10:22:41 +00:00
David Majnemer e6253b8c09 Basic: [asmSymbolicName] follows the same rule as numbers in asm inputs
Input constraints like "0" and "[foo]" should be treated the same when
it comes to their corresponding output constraint.

This fixes PR21850.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225605 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-11 09:57:13 +00:00
David Majnemer 72db1396ff Basic: The asm constraint '#m' isn't valid, reject it
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225603 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-11 09:39:03 +00:00
David Majnemer afd75deb8f Basic: The asm constraint '+#r' isn't valid, reject it
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225600 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-11 08:52:38 +00:00
David Majnemer a2cf25d8f4 Sema: The asm constraint '+&m' isn't valid, reject it
Don't permit '+&m' to make it to CodeGen, it's invalid.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225586 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-10 10:43:19 +00:00
Saleem Abdulrasool 9e0e86b228 Sema: analyze I,J,K,M,N,O constraints
Add additional constraint checking for target specific behaviour for inline
assembly constraints.  We would previously silently let all arguments through
for these constraints.  In cases where the constraints were violated, we could
end up failing to select instructions and triggering assertions or worse,
silently ignoring instructions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225244 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-06 04:26:34 +00:00
Olivier Goffart b7c04bc256 Fix assertion on asm register that are "%"
Name might be empty again after we removed the '%' prefix
and Name[0] would assert.

Found on code like
register int foo asm("%" MACRO);
where MACRO was supposed to be defined in a header file that was not found.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215834 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-17 13:19:48 +00:00
Joerg Sonnenberger d0ae335e2b Change __INTx_TYPE__ to be always signed. This changes the value for
char-based types from "char" to "signed char". Adjust stdint.h to use
__INTx_TYPE__ directly without prefixing it with signed and to use
__UINTx_TYPE__ for unsigned ones.

The value of __INTx_TYPE__ now matches GCC.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214119 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-28 21:06:22 +00:00
Joerg Sonnenberger 0d120a47c7 If char/short are shorter than int, do not use U as suffix for
constants. Comparing int against a constant of the given type like
UINT8_MAX will otherwise force a promotion to unsigned int, which is
typically not expected.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213301 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-17 20:12:32 +00:00
Joerg Sonnenberger 70138bc888 Provide builtin macros as template for PRIab and SCNab, matching the
underlaying types.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213063 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-15 11:30:00 +00:00
Joerg Sonnenberger cdc24891b0 Drop separate UIntMaxType and just derive it from IntMaxType.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212987 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-14 21:00:38 +00:00
Alp Toker f7445e6c6f Constify a read-only parameter and give function a better name
This makes it clear that TargetInfo doesn't capture the LangOptions object,
rather uses it to apply adjustments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212386 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-06 05:14:24 +00:00
JF Bastien 41c9813dab Implement predefined stdint macros
Add predefined stdint macros that match the given patterns:

U?INT{_,_FAST,_LEAST}{8,16,32,64}_{MAX,TYPE}
U?INT{PTR,MAX}_{MAX,TYPE}

http://reviews.llvm.org/D4141

Author: binji

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211657 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-25 01:31:33 +00:00
Craig Topper 603e37c3dd [C++11] Use 'nullptr'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208280 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-08 06:41:40 +00:00
Saleem Abdulrasool 1e57f17deb Use the new Windows environment for target detection
This follows the LLVM change to canonicalise the Windows target triple
spellings.  Rather than treating each Windows environment as a single entity,
the environments are now modelled properly as an environment.  This is a
mechanical change to convert the triple use to reflect that change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204978 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-27 22:50:18 +00:00
Hans Wennborg 11b1b8ab36 Remove the -cxx-abi command-line flag.
This makes the C++ ABI depend entirely on the target: MS ABI for -win32 triples,
Itanium otherwise. It's no longer possible to do weird combinations.

To be able to run a test with a specific ABI without constraining it to a
specific triple, new substitutions are added to lit: %itanium_abi_triple and
%ms_abi_triple can be used to get the current target triple adjusted to the
desired ABI. For example, if the test suite is running with the i686-pc-win32
target, %itanium_abi_triple will expand to i686-pc-mingw32.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199250 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-14 19:35:09 +00:00
Pekka Jaaskelainen 4799606af5 OpenCL: Do not force 64 bit floats for (embedded) targets with only 32bit floats.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197592 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-18 18:15:03 +00:00
Duncan P. N. Exon Smith ff1554738d Stop crashing on empty asm input constraints
An empty string for an ASM input constraint is invalid, and will crash
during clang CodeGen.  Change TargetInfo::validateInputConstraint to
reject an empty string.

<rdar://problem/15552191>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197362 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-16 03:20:06 +00:00
Rafael Espindola 88ebb795e4 Every target sets DescriptionString. Assert that.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197268 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-13 19:56:31 +00:00
David Tweed 1eef85246b Certain multi-platform languages, such as OpenCL, have the concept of
address spaces which is both (1) a "semantic" concept and
(2) possibly a hardware level restriction. It is desirable to
be able to discard/merge the LLVM-level address spaces on arguments for which
there is no difference to the current backend while keeping
track of the semantic address spaces in a funciton prototype. To do this
enable addition of the address space into the name-mangling process. Add
some tests to document this behaviour against inadvertent changes.

Patch by Michele Scandale!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190684 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-13 12:04:22 +00:00
David Tweed 1e24463067 Fix minor coding style issue in r190296 pointed out by Richard Smith.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190390 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10 08:00:34 +00:00
David Tweed 8bc56022db The OpenCL standard specifies the sizes and alignments of various types than other C-family
languages, as well as specifying errno is not set by the math functions. Make the
clang front-end set those appropriately when the OpenCL language option is set.

Patch by Erik Schnetter!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190296 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-09 09:17:24 +00:00
Stepan Dyatkovskiy 35451d9a00 Additional fix for PR16752 and for commit 190044:
-- For TargetInfo::getRealTypeByWidth also added support for IEEEQuad float type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190294 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-09 07:46:54 +00:00
Stepan Dyatkovskiy 7b7bef1ec3 Add new methods for TargetInfo:
getRealTypeByWidth and getIntTypeByWidth
  for ASTContext names are almost same(invokes new methods from TargetInfo):
     getIntTypeForBitwidth and getRealTypeForBitwidth.

As first commit for PR16752 fix: 'mode' attribute for unusual targets doesn't work properly
Description:
Troubles could be happened due to some assumptions in handleModeAttr function (see SemaDeclAttr.cpp).
For example, it assumes that 32 bit integer is 'int', while it could be 16 bit only.
Instead of asking target: 'which type do you want to use for int32_t ?' it just hardcodes general opinion. That doesn't looks pretty correct.
Please consider the next solution:
1. In Basic/TargetInfo add getIntTypeByWidth and getRealTypeByWidth virtual methods. By default current behaviour could be implemented here.
2. Fix handleModeAttr according to new methods in TargetInfo.
This approach is implemented in the patch attached to this post.

Fixes:
1st Commit (Current): Add new methods for TargetInfo:
     getRealTypeByWidth and getIntTypeByWidth
  for ASTContext names are almost same(invokes new methods from TargetInfo):
     getIntTypeForBitwidth and getRealTypeForBitwidth

2nd Commit (Next): Fix SemaDeclAttr, handleModeAttr function.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190044 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-05 11:23:21 +00:00
Benjamin Kramer 9df0823a4b Driver: Push triple objects around instead of going to std::string all the time.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185261 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-29 16:37:14 +00:00
Ulrich Weigand 6b20351a1d Allow targets to define minimum alignment for global variables
This patch adds a new common code feature that allows platform code to
request minimum alignment of global symbols.  The background for this is
that on SystemZ, the most efficient way to load addresses of global symbol
is the LOAD ADDRESS RELATIVE LONG (LARL) instruction.  This instruction
provides PC-relative addressing, but only to *even* addresses.  For this
reason, existing compilers will guarantee that global symbols are always
aligned to at least 2.  [ Since symbols would otherwise already use a
default alignment based on their type, this will usually only affect global
objects of character type or character arrays. ]  GCC also allows creating
symbols without that extra alignment by using explicit "aligned" attributes
(which then need to be used on both definition and each use of the symbol).

To enable support for this with Clang, this patch adds a
TargetInfo::MinGlobalAlign variable that provides a global minimum for the
alignment of every global object (unless overridden via explicit alignment
attribute), and adds code to respect this setting.  Within this patch, no
platform actually sets the value to anything but the default 1, resulting
in no change in behaviour on any existing target.

This version of the patch incorporates feedback from reviews by
Eric Christopher and John McCall.  Thanks to all reviewers!

Patch by Richard Sandiford.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181210 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-06 16:23:57 +00:00
Benjamin Kramer 6576a0d1e2 Add comment to describe cleverness.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179806 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-18 22:49:48 +00:00
Benjamin Kramer 5ddf70f1e7 Reject asm output constraints that consist of modifiers only.
Fixes PR15759.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179756 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-18 13:23:23 +00:00
Jordan Rose 3f6f51e282 Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.
Nearly all of these changes are one-to-one replacements; the few that
aren't have to do with custom identifier validation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174768 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-08 22:30:41 +00:00
John McCall b8b2c9da87 First pass at abstracting out a class for the target C++ ABI.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173514 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-25 22:30:49 +00:00
Chandler Carruth 55fc873017 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169237 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 09:13:33 +00:00
Eli Friedman 6902e4146d Fix the definition of the vfork() builtin on Haiku. PR14378.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168674 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-27 02:58:24 +00:00
Ulrich Weigand e6b3dbae38 Handle '*' and '#' asm constraint modifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166924 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-29 12:20:54 +00:00
Douglas Gregor 9a022bb007 Teach TargetInfo to hold on to the TargetOptions with which it was
created.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165943 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-15 16:45:32 +00:00
Chad Rosier f9e9af7df0 Add a per target max vector alignment field (e.g., 32-byte alignment for x86 due to
AVX).  Currently, if no aligned attribute is specified the alignment of a vector is
inferred from its size.  Thus, very large vectors will be over-aligned with no 
benefit.  Target owners should set this target max.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160209 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-13 23:57:43 +00:00
Fariborz Jahanian 93a49944e0 objective-c modern translator: buildit objc bool
type for rewriter project will be BoolTy.
// rdar://11231426. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154861 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-16 21:03:30 +00:00
Eli Friedman e6a24e83e7 Add support for bitcasts to vector type in Evaluate.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147137 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-22 03:51:45 +00:00
Nick Lewycky 7ec59c78f1 Add the value of "suitably aligned" from the C++11 standard to Basic/TargetInfo.
This is equal to alignof(std::max_align_t) on the platform and equal to the
alignment provided by malloc. (Platform owners please double-check your
platform's value.)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146762 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-16 22:34:14 +00:00
Anders Carlsson eea6480255 In x86_64, when calling an Objective-C method that returns a _Complex long double, make sure to use the objc_msgSend_fp2ret function which ensures that the return value will be {0, 0} if the receiver is nil.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143350 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-31 16:27:11 +00:00
Anton Korobeynikov aa4a99b4a6 Provide half floating point support as a storage only type.
Lack of half FP was a regression compared to llvm-gcc.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142016 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 23:23:15 +00:00
Eli Friedman 2be4607239 Misc fixes for atomics. Biggest fix is doing alignment correctly for _Atomic types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142002 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 20:59:01 +00:00
David Blaikie 9fe8c74a93 Fix missing includes for llvm_unreachable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140368 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-23 05:35:21 +00:00
David Blaikie b219cfc4d7 Switch assert(0/false) llvm_unreachable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140367 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-23 05:06:16 +00:00