diff options
| author | David Tweed <david.tweed@arm.com> | 2013-09-09 09:17:24 +0000 |
|---|---|---|
| committer | David Tweed <david.tweed@arm.com> | 2013-09-09 09:17:24 +0000 |
| commit | 8bc56022db2d9b16aab25ce3b6fccda9dd8991fc (patch) | |
| tree | f6b06f696f8e399e7317fc905d6a1448a067ee68 /lib/Basic/TargetInfo.cpp | |
| parent | 35451d9a00b2a3b40689f6e4d4e259a6d786b395 (diff) | |
| download | clang-8bc56022db2d9b16aab25ce3b6fccda9dd8991fc.tar.gz clang-8bc56022db2d9b16aab25ce3b6fccda9dd8991fc.tar.bz2 clang-8bc56022db2d9b16aab25ce3b6fccda9dd8991fc.tar.xz | |
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
Diffstat (limited to 'lib/Basic/TargetInfo.cpp')
| -rw-r--r-- | lib/Basic/TargetInfo.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp index 20ec599960..38cb411787 100644 --- a/lib/Basic/TargetInfo.cpp +++ b/lib/Basic/TargetInfo.cpp @@ -233,6 +233,35 @@ void TargetInfo::setForcedLangOptions(LangOptions &Opts) { UseBitFieldTypeAlignment = false; if (Opts.ShortWChar) WCharType = UnsignedShort; + + if (Opts.OpenCL) { + // OpenCL C requires specific widths for types, irrespective of + // what these normally are for the target. + // We also define long long and long double here, although the + // OpenCL standard only mentions these as "reserved". + IntWidth = IntAlign = 32; + LongWidth = LongAlign = 64; + LongLongWidth = LongLongAlign = 128; + HalfWidth = HalfAlign = 16; + FloatWidth = FloatAlign = 32; + DoubleWidth = DoubleAlign = 64; + LongDoubleWidth = LongDoubleAlign = 128; + + assert(PointerWidth == 32 || PointerWidth == 64); + bool is32BitArch = PointerWidth == 32; + SizeType = is32BitArch ? UnsignedInt : UnsignedLong; + PtrDiffType = is32BitArch ? SignedInt : SignedLong; + IntPtrType = is32BitArch ? SignedInt : SignedLong; + + IntMaxType = SignedLongLong; + UIntMaxType = UnsignedLongLong; + Int64Type = SignedLong; + + HalfFormat = &llvm::APFloat::IEEEhalf; + FloatFormat = &llvm::APFloat::IEEEsingle; + DoubleFormat = &llvm::APFloat::IEEEdouble; + LongDoubleFormat = &llvm::APFloat::IEEEquad; + } } //===----------------------------------------------------------------------===// |
