llvm.org GIT mirror llvm / 4f08478
Add a new Simulator entry for the target triple environment. Apple's iOS, tvOS and watchOS simulator platforms have never been clearly distinguished in the target triples. Even though they are intended to behave similarly to the corresponding device platforms, they have separate SDKs and are really separate platforms from the compiler's perspective. Clang now defines a macro when building for one of these simulator platforms (r297866) but that relies on the very indirect mechanism of checking to see which option was used to specify the minimum deployment target. That is not so great. Swift would also like to distinguish these simulator platforms in a similar way, but unlike Clang, Swift does not use a separate option to specify the minimum deployment target -- it uses a -target option to specify the target triple directly, including the OS version number. Using a different target triple for the simulator platforms is a much more direct and obvious way to specify this. Putting the "simulator" in the environment component of the triple means the OS values can stay the same and existing code the looks at the OS field will not be affected. https://reviews.llvm.org/D39143 rdar://problem/34729432 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316380 91177308-0d34-0410-b5e6-96231b3b80d8 Bob Wilson 1 year, 9 months ago
3 changed file(s) with 17 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
204204 AMDOpenCL,
205205 CoreCLR,
206206 OpenCL,
207 LastEnvironmentType = OpenCL
207 Simulator, // Simulator variants of other systems, e.g., Apple's iOS
208 LastEnvironmentType = Simulator
208209 };
209210 enum ObjectFormatType {
210211 UnknownObjectFormat,
469470 return isMacOSX() || isiOS() || isWatchOS();
470471 }
473 bool isSimulatorEnvironment() const {
474 return getEnvironment() == Triple::Simulator;
475 }
472477 bool isOSNetBSD() const {
473478 return getOS() == Triple::NetBSD;
474479 }
234234 case AMDOpenCL: return "amdopencl";
235235 case CoreCLR: return "coreclr";
236236 case OpenCL: return "opencl";
237 case Simulator: return "simulator";
237238 }
239240 llvm_unreachable("Invalid EnvironmentType!");
524525 .StartsWith("amdopencl", Triple::AMDOpenCL)
525526 .StartsWith("coreclr", Triple::CoreCLR)
526527 .StartsWith("opencl", Triple::OpenCL)
528 .StartsWith("simulator", Triple::Simulator)
527529 .Default(Triple::UnknownEnvironment);
528530 }
999999 EXPECT_EQ((unsigned)7, Major);
10001000 EXPECT_EQ((unsigned)0, Minor);
10011001 EXPECT_EQ((unsigned)0, Micro);
1002 EXPECT_FALSE(T.isSimulatorEnvironment());
1004 T = Triple("x86_64-apple-ios10.3-simulator");
1005 EXPECT_TRUE(T.isiOS());
1006 T.getiOSVersion(Major, Minor, Micro);
1007 EXPECT_EQ((unsigned)10, Major);
1008 EXPECT_EQ((unsigned)3, Minor);
1009 EXPECT_EQ((unsigned)0, Micro);
1010 EXPECT_TRUE(T.isSimulatorEnvironment());
10021011 }
10041013 TEST(TripleTest, FileFormat) {