[llvm-branch-commits] [cfe-branch] r352360 - Merging r352105:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jan 28 05:54:23 PST 2019
Author: hans
Date: Mon Jan 28 05:54:22 2019
New Revision: 352360
URL: http://llvm.org/viewvc/llvm-project?rev=352360&view=rev
Log:
Merging r352105:
Redirecting to URL 'https://llvm.org/svn/llvm-project/cfe/trunk':
------------------------------------------------------------------------
r352105 | djg | 2019-01-24 22:05:11 +0100 (Thu, 24 Jan 2019) | 7 lines
[WebAssembly] Add a __wasi__ target macro
This adds a `__wasi__` macro for the wasi OS, similar to `__linux__` etc. for
other OS's.
Differential Revision: https://reviews.llvm.org/D57155
------------------------------------------------------------------------
Modified:
cfe/branches/release_80/ (props changed)
cfe/branches/release_80/lib/Basic/Targets.cpp
cfe/branches/release_80/lib/Basic/Targets/OSTargets.h
cfe/branches/release_80/test/Preprocessor/init.c
Propchange: cfe/branches/release_80/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 28 05:54:22 2019
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:351334,351340,351344,351360,351457,351459,351531,351579-351580,352040,352079,352099,352102,352323
+/cfe/trunk:351334,351340,351344,351360,351457,351459,351531,351579-351580,352040,352079,352099,352102,352105,352323
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_80/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/lib/Basic/Targets.cpp?rev=352360&r1=352359&r2=352360&view=diff
==============================================================================
--- cfe/branches/release_80/lib/Basic/Targets.cpp (original)
+++ cfe/branches/release_80/lib/Basic/Targets.cpp Mon Jan 28 05:54:22 2019
@@ -570,19 +570,27 @@ TargetInfo *AllocateTarget(const llvm::T
Triple.getVendor() != llvm::Triple::UnknownVendor ||
!Triple.isOSBinFormatWasm())
return nullptr;
- if (Triple.getOS() != llvm::Triple::UnknownOS &&
- Triple.getOS() != llvm::Triple::WASI)
- return nullptr;
- return new WebAssemblyOSTargetInfo<WebAssembly32TargetInfo>(Triple, Opts);
+ switch (Triple.getOS()) {
+ case llvm::Triple::WASI:
+ return new WASITargetInfo<WebAssembly32TargetInfo>(Triple, Opts);
+ case llvm::Triple::UnknownOS:
+ return new WebAssemblyOSTargetInfo<WebAssembly32TargetInfo>(Triple, Opts);
+ default:
+ return nullptr;
+ }
case llvm::Triple::wasm64:
if (Triple.getSubArch() != llvm::Triple::NoSubArch ||
Triple.getVendor() != llvm::Triple::UnknownVendor ||
!Triple.isOSBinFormatWasm())
return nullptr;
- if (Triple.getOS() != llvm::Triple::UnknownOS &&
- Triple.getOS() != llvm::Triple::WASI)
- return nullptr;
- return new WebAssemblyOSTargetInfo<WebAssembly64TargetInfo>(Triple, Opts);
+ switch (Triple.getOS()) {
+ case llvm::Triple::WASI:
+ return new WASITargetInfo<WebAssembly64TargetInfo>(Triple, Opts);
+ case llvm::Triple::UnknownOS:
+ return new WebAssemblyOSTargetInfo<WebAssembly64TargetInfo>(Triple, Opts);
+ default:
+ return nullptr;
+ }
case llvm::Triple::renderscript32:
return new LinuxTargetInfo<RenderScript32TargetInfo>(Triple, Opts);
Modified: cfe/branches/release_80/lib/Basic/Targets/OSTargets.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/lib/Basic/Targets/OSTargets.h?rev=352360&r1=352359&r2=352360&view=diff
==============================================================================
--- cfe/branches/release_80/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/branches/release_80/lib/Basic/Targets/OSTargets.h Mon Jan 28 05:54:22 2019
@@ -764,8 +764,9 @@ public:
template <typename Target>
class LLVM_LIBRARY_VISIBILITY WebAssemblyOSTargetInfo
: public OSTargetInfo<Target> {
+protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
- MacroBuilder &Builder) const final {
+ MacroBuilder &Builder) const {
// A common platform macro.
if (Opts.POSIXThreads)
Builder.defineMacro("_REENTRANT");
@@ -783,6 +784,21 @@ public:
}
};
+// WASI target
+template <typename Target>
+class LLVM_LIBRARY_VISIBILITY WASITargetInfo
+ : public WebAssemblyOSTargetInfo<Target> {
+ void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+ MacroBuilder &Builder) const final {
+ WebAssemblyOSTargetInfo<Target>::getOSDefines(Opts, Triple, Builder);
+ Builder.defineMacro("__wasi__");
+ }
+
+public:
+ explicit WASITargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+ : WebAssemblyOSTargetInfo<Target>(Triple, Opts) {}
+};
+
} // namespace targets
} // namespace clang
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_OSTARGETS_H
Modified: cfe/branches/release_80/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/test/Preprocessor/init.c?rev=352360&r1=352359&r2=352360&view=diff
==============================================================================
--- cfe/branches/release_80/test/Preprocessor/init.c (original)
+++ cfe/branches/release_80/test/Preprocessor/init.c Mon Jan 28 05:54:22 2019
@@ -9114,6 +9114,12 @@
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=wasm64-unknown-unknown \
// RUN: < /dev/null \
// RUN: | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY64 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=wasm32-unknown-wasi \
+// RUN: < /dev/null \
+// RUN: | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY32,WEBASSEMBLY-WASI %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=wasm64-unknown-wasi \
+// RUN: < /dev/null \
+// RUN: | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY64,WEBASSEMBLY-WASI %s
//
// WEBASSEMBLY32:#define _ILP32 1
// WEBASSEMBLY32-NOT:#define _LP64
@@ -9467,6 +9473,7 @@
// WEBASSEMBLY-NEXT:#define __llvm__ 1
// WEBASSEMBLY-NOT:#define __unix
// WEBASSEMBLY-NOT:#define __unix__
+// WEBASSEMBLY-WASI-NEXT:#define __wasi__ 1
// WEBASSEMBLY-NOT:#define __wasm_simd128__
// WEBASSEMBLY-NOT:#define __wasm_simd256__
// WEBASSEMBLY-NOT:#define __wasm_simd512__
More information about the llvm-branch-commits
mailing list