From: Petar Jovanovic Date: Sat, 21 Sep 2013 01:27:01 +0000 (+0000) Subject: [Mips] Allocate NaClTargetInfo for MIPSEL NaCl X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bbac9aacc4742102765c1538130d09c079b14c71;p=clang [Mips] Allocate NaClTargetInfo for MIPSEL NaCl A patch to AllocateTarget function to recognize llvm::Triple::NaCl for MIPSEL and return NaClTargetInfo. Additional test has been added to check if the expected macros get defined. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191124 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 2f4aeb93be..0e8b7659cf 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -5376,6 +5376,8 @@ static TargetInfo *AllocateTarget(const llvm::Triple &Triple) { return new FreeBSDTargetInfo(Triple); case llvm::Triple::NetBSD: return new NetBSDTargetInfo(Triple); + case llvm::Triple::NaCl: + return new NaClTargetInfo(Triple); default: return new Mips32ELTargetInfo(Triple); } diff --git a/test/Driver/mipsel-nacl-defines.cpp b/test/Driver/mipsel-nacl-defines.cpp new file mode 100644 index 0000000000..0f63d7659e --- /dev/null +++ b/test/Driver/mipsel-nacl-defines.cpp @@ -0,0 +1,45 @@ +// RUN: %clang -target mipsel-unknown-nacl -### %s -emit-llvm-only -c -o %t.o 2>&1 | FileCheck %s -check-prefix=ECHO +// RUN: %clang -target mipsel-unknown-nacl %s -emit-llvm -S -c -o - | FileCheck %s +// RUN: %clang -target mipsel-unknown-nacl %s -emit-llvm -S -c -pthread -o - | FileCheck %s -check-prefix=THREADS + +// ECHO: {{.*}} "-cc1" {{.*}}mipsel-nacl-defines.c + +// Check platform defines + +// CHECK: _MIPSELdefined +#ifdef _MIPSEL +void _MIPSELdefined() {} +#endif + +// CHECK: _mipsdefined +#ifdef _mips +void _mipsdefined() {} +#endif + +// CHECK: __native_client__defined +#ifdef __native_client__ +void __native_client__defined() {} +#endif + +// CHECK: unixdefined +#ifdef unix +void unixdefined() {} +#endif + +// CHECK: __ELF__defined +#ifdef __ELF__ +void __ELF__defined() {} +#endif + +// CHECK: _GNU_SOURCEdefined +#ifdef _GNU_SOURCE +void _GNU_SOURCEdefined() {} +#endif + +// THREADS: _REENTRANTdefined +// CHECK: _REENTRANTundefined +#ifdef _REENTRANT +void _REENTRANTdefined() {} +#else +void _REENTRANTundefined() {} +#endif