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 | 2da64389698fcd6bc9dedd6ca47b8fb669d4e927 (patch) | |
tree | aa845219c5155e9d5b74e2a277b716713ae5cacd /clang/lib/Basic/TargetInfo.cpp | |
parent | cf02f171a98e706ffa3a7deb45a03fcb622106d3 (diff) | |
download | bcm5719-llvm-2da64389698fcd6bc9dedd6ca47b8fb669d4e927.tar.gz bcm5719-llvm-2da64389698fcd6bc9dedd6ca47b8fb669d4e927.zip |
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!
llvm-svn: 190296
Diffstat (limited to 'clang/lib/Basic/TargetInfo.cpp')
-rw-r--r-- | clang/lib/Basic/TargetInfo.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp index 20ec599960d..38cb4117876 100644 --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/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; + } } //===----------------------------------------------------------------------===// |