2009-04-02 05:53:23 +08:00
|
|
|
//===----------- Triple.cpp - Triple unit tests ---------------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2009-04-02 05:53:23 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/ADT/Triple.h"
|
2017-06-06 19:06:56 +08:00
|
|
|
#include "gtest/gtest.h"
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
TEST(TripleTest, BasicParsing) {
|
|
|
|
Triple T;
|
|
|
|
|
|
|
|
T = Triple("");
|
2009-07-26 11:31:47 +08:00
|
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
T = Triple("-");
|
2009-07-26 11:31:47 +08:00
|
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
T = Triple("--");
|
2009-07-26 11:31:47 +08:00
|
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
T = Triple("---");
|
2009-07-26 11:31:47 +08:00
|
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
T = Triple("----");
|
2009-07-26 11:31:47 +08:00
|
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
|
|
EXPECT_EQ("-", T.getEnvironmentName().str());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
T = Triple("a");
|
2009-07-26 11:31:47 +08:00
|
|
|
EXPECT_EQ("a", T.getArchName().str());
|
|
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
T = Triple("a-b");
|
2009-07-26 11:31:47 +08:00
|
|
|
EXPECT_EQ("a", T.getArchName().str());
|
|
|
|
EXPECT_EQ("b", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
T = Triple("a-b-c");
|
2009-07-26 11:31:47 +08:00
|
|
|
EXPECT_EQ("a", T.getArchName().str());
|
|
|
|
EXPECT_EQ("b", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("c", T.getOSName().str());
|
|
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
T = Triple("a-b-c-d");
|
2009-07-26 11:31:47 +08:00
|
|
|
EXPECT_EQ("a", T.getArchName().str());
|
|
|
|
EXPECT_EQ("b", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("c", T.getOSName().str());
|
|
|
|
EXPECT_EQ("d", T.getEnvironmentName().str());
|
2009-04-02 05:53:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TripleTest, ParsedIDs) {
|
|
|
|
Triple T;
|
|
|
|
|
|
|
|
T = Triple("i386-apple-darwin");
|
2009-06-10 05:48:57 +08:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::Apple, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Darwin, T.getOS());
|
2010-09-16 16:25:48 +08:00
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
2015-10-27 15:23:59 +08:00
|
|
|
T = Triple("i386-pc-elfiamcu");
|
2015-10-25 16:07:37 +08:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
2015-10-27 15:23:59 +08:00
|
|
|
EXPECT_EQ(Triple::ELFIAMCU, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
2016-10-14 22:41:46 +08:00
|
|
|
|
|
|
|
T = Triple("i386-pc-contiki-unknown");
|
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Contiki, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
2015-10-25 16:07:37 +08:00
|
|
|
|
2018-11-29 11:23:01 +08:00
|
|
|
T = Triple("i386-pc-hurd-gnu");
|
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Hurd, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
|
|
|
|
2009-04-02 05:53:23 +08:00
|
|
|
T = Triple("x86_64-pc-linux-gnu");
|
2009-06-10 05:48:57 +08:00
|
|
|
EXPECT_EQ(Triple::x86_64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
2011-01-22 02:25:47 +08:00
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
2016-06-14 20:45:33 +08:00
|
|
|
T = Triple("x86_64-pc-linux-musl");
|
|
|
|
EXPECT_EQ(Triple::x86_64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::Musl, T.getEnvironment());
|
|
|
|
|
2012-04-03 02:31:33 +08:00
|
|
|
T = Triple("powerpc-bgp-linux");
|
|
|
|
EXPECT_EQ(Triple::ppc, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::BGP, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("powerpc-bgp-cnk");
|
|
|
|
EXPECT_EQ(Triple::ppc, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::BGP, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::CNK, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2018-02-27 18:09:58 +08:00
|
|
|
T = Triple("ppc-bgp-linux");
|
|
|
|
EXPECT_EQ(Triple::ppc, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::BGP, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("ppc32-bgp-linux");
|
|
|
|
EXPECT_EQ(Triple::ppc, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::BGP, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2012-04-03 02:31:33 +08:00
|
|
|
T = Triple("powerpc64-bgq-linux");
|
|
|
|
EXPECT_EQ(Triple::ppc64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::BGQ, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2018-02-27 18:09:58 +08:00
|
|
|
T = Triple("ppc64-bgq-linux");
|
|
|
|
EXPECT_EQ(Triple::ppc64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::BGQ, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
|
2012-10-12 19:08:57 +08:00
|
|
|
T = Triple("powerpc-ibm-aix");
|
|
|
|
EXPECT_EQ(Triple::ppc, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::IBM, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::AIX, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("powerpc64-ibm-aix");
|
|
|
|
EXPECT_EQ(Triple::ppc64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::IBM, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::AIX, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2009-04-02 05:53:23 +08:00
|
|
|
T = Triple("powerpc-dunno-notsure");
|
2009-06-10 05:48:57 +08:00
|
|
|
EXPECT_EQ(Triple::ppc, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
2010-09-16 16:25:48 +08:00
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
2011-02-02 18:08:38 +08:00
|
|
|
T = Triple("arm-none-none-eabi");
|
2011-01-22 02:25:47 +08:00
|
|
|
EXPECT_EQ(Triple::arm, T.getArch());
|
2011-02-02 18:08:38 +08:00
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
2011-01-22 02:25:47 +08:00
|
|
|
EXPECT_EQ(Triple::EABI, T.getEnvironment());
|
|
|
|
|
2016-06-25 05:14:33 +08:00
|
|
|
T = Triple("arm-none-linux-musleabi");
|
|
|
|
EXPECT_EQ(Triple::arm, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::MuslEABI, T.getEnvironment());
|
|
|
|
|
2015-05-05 17:29:43 +08:00
|
|
|
T = Triple("armv6hl-none-linux-gnueabi");
|
|
|
|
EXPECT_EQ(Triple::arm, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("armv7hl-none-linux-gnueabi");
|
|
|
|
EXPECT_EQ(Triple::arm, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
|
|
|
|
|
2014-09-20 03:52:11 +08:00
|
|
|
T = Triple("amdil-unknown-unknown");
|
|
|
|
EXPECT_EQ(Triple::amdil, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
|
|
|
|
|
|
T = Triple("amdil64-unknown-unknown");
|
|
|
|
EXPECT_EQ(Triple::amdil64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
|
|
|
|
|
|
T = Triple("hsail-unknown-unknown");
|
|
|
|
EXPECT_EQ(Triple::hsail, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
|
|
|
|
|
|
T = Triple("hsail64-unknown-unknown");
|
|
|
|
EXPECT_EQ(Triple::hsail64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
|
|
|
2015-04-30 03:15:08 +08:00
|
|
|
T = Triple("sparcel-unknown-unknown");
|
|
|
|
EXPECT_EQ(Triple::sparcel, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
|
|
|
2014-09-20 03:52:11 +08:00
|
|
|
T = Triple("spir-unknown-unknown");
|
|
|
|
EXPECT_EQ(Triple::spir, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
|
|
|
|
|
|
T = Triple("spir64-unknown-unknown");
|
|
|
|
EXPECT_EQ(Triple::spir64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
|
|
|
2017-06-25 16:19:37 +08:00
|
|
|
T = Triple("x86_64-unknown-ananas");
|
|
|
|
EXPECT_EQ(Triple::x86_64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Ananas, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2015-03-10 02:40:45 +08:00
|
|
|
T = Triple("x86_64-unknown-cloudabi");
|
|
|
|
EXPECT_EQ(Triple::x86_64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::CloudABI, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2016-10-06 13:17:26 +08:00
|
|
|
T = Triple("x86_64-unknown-fuchsia");
|
|
|
|
EXPECT_EQ(Triple::x86_64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Fuchsia, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2018-08-25 09:08:18 +08:00
|
|
|
T = Triple("x86_64-unknown-hermit");
|
|
|
|
EXPECT_EQ(Triple::x86_64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::HermitCore, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2015-06-30 11:52:25 +08:00
|
|
|
T = Triple("wasm32-unknown-unknown");
|
2015-06-30 07:51:55 +08:00
|
|
|
EXPECT_EQ(Triple::wasm32, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
2015-06-30 11:52:25 +08:00
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
2015-06-30 07:51:55 +08:00
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2019-01-16 13:23:52 +08:00
|
|
|
T = Triple("wasm32-unknown-wasi-musl");
|
2019-01-15 14:58:13 +08:00
|
|
|
EXPECT_EQ(Triple::wasm32, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
2019-01-16 13:23:52 +08:00
|
|
|
EXPECT_EQ(Triple::WASI, T.getOS());
|
2019-01-15 14:58:13 +08:00
|
|
|
EXPECT_EQ(Triple::Musl, T.getEnvironment());
|
|
|
|
|
2015-06-30 11:52:25 +08:00
|
|
|
T = Triple("wasm64-unknown-unknown");
|
2015-06-30 07:51:55 +08:00
|
|
|
EXPECT_EQ(Triple::wasm64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
2015-06-30 11:52:25 +08:00
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
2015-06-30 07:51:55 +08:00
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2019-01-16 13:23:52 +08:00
|
|
|
T = Triple("wasm64-unknown-wasi-musl");
|
2019-01-15 14:58:13 +08:00
|
|
|
EXPECT_EQ(Triple::wasm64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
2019-01-16 13:23:52 +08:00
|
|
|
EXPECT_EQ(Triple::WASI, T.getOS());
|
2019-01-15 14:58:13 +08:00
|
|
|
EXPECT_EQ(Triple::Musl, T.getEnvironment());
|
|
|
|
|
2015-10-16 11:10:30 +08:00
|
|
|
T = Triple("avr-unknown-unknown");
|
|
|
|
EXPECT_EQ(Triple::avr, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("avr");
|
|
|
|
EXPECT_EQ(Triple::avr, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2016-02-12 01:16:20 +08:00
|
|
|
T = Triple("lanai-unknown-unknown");
|
|
|
|
EXPECT_EQ(Triple::lanai, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("lanai");
|
|
|
|
EXPECT_EQ(Triple::lanai, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
2016-02-13 09:56:21 +08:00
|
|
|
|
|
|
|
T = Triple("amdgcn-mesa-mesa3d");
|
|
|
|
EXPECT_EQ(Triple::amdgcn, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::Mesa, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Mesa3D, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("amdgcn-amd-amdhsa");
|
|
|
|
EXPECT_EQ(Triple::amdgcn, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::AMD, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::AMDHSA, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
2016-02-12 01:16:20 +08:00
|
|
|
|
2017-09-29 17:48:12 +08:00
|
|
|
T = Triple("amdgcn-amd-amdpal");
|
|
|
|
EXPECT_EQ(Triple::amdgcn, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::AMD, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::AMDPAL, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2016-11-02 00:47:54 +08:00
|
|
|
T = Triple("riscv32-unknown-unknown");
|
|
|
|
EXPECT_EQ(Triple::riscv32, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("riscv64-unknown-linux");
|
|
|
|
EXPECT_EQ(Triple::riscv64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("riscv64-unknown-freebsd");
|
|
|
|
EXPECT_EQ(Triple::riscv64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::FreeBSD, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2017-04-24 19:18:29 +08:00
|
|
|
T = Triple("armv7hl-suse-linux-gnueabi");
|
|
|
|
EXPECT_EQ(Triple::arm, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::SUSE, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
|
|
|
|
|
2017-08-18 18:35:42 +08:00
|
|
|
T = Triple("i586-pc-haiku");
|
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Haiku, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("x86_64-unknown-haiku");
|
|
|
|
EXPECT_EQ(Triple::x86_64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Haiku, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2017-09-14 01:36:16 +08:00
|
|
|
T = Triple("mips-mti-linux-gnu");
|
|
|
|
EXPECT_EQ(Triple::mips, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::MipsTechnologies, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("mipsel-img-linux-gnu");
|
|
|
|
EXPECT_EQ(Triple::mipsel, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::ImaginationTechnologies, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("mips64-mti-linux-gnu");
|
|
|
|
EXPECT_EQ(Triple::mips64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::MipsTechnologies, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("mips64el-img-linux-gnu");
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::ImaginationTechnologies, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
|
|
|
|
2017-09-14 14:50:05 +08:00
|
|
|
T = Triple("mips64el-img-linux-gnuabin32");
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::ImaginationTechnologies, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
|
|
|
|
|
2017-09-14 01:36:16 +08:00
|
|
|
T = Triple("mips64el-unknown-linux-gnuabi64");
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
|
2018-09-27 16:51:18 +08:00
|
|
|
EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
|
2018-09-18 05:21:57 +08:00
|
|
|
T = Triple("mips64el");
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
|
2018-09-27 16:51:18 +08:00
|
|
|
EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
|
2018-09-18 05:21:57 +08:00
|
|
|
|
|
|
|
T = Triple("mips64-unknown-linux-gnuabi64");
|
|
|
|
EXPECT_EQ(Triple::mips64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
|
2018-09-27 16:51:18 +08:00
|
|
|
EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
|
2018-09-18 05:21:57 +08:00
|
|
|
T = Triple("mips64");
|
|
|
|
EXPECT_EQ(Triple::mips64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
|
2018-09-27 16:51:18 +08:00
|
|
|
EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
|
|
|
|
|
|
|
|
T = Triple("mipsisa64r6el-unknown-linux-gnuabi64");
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
|
|
|
T = Triple("mips64r6el");
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
|
|
|
T = Triple("mipsisa64r6el");
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
|
|
|
|
|
|
|
T = Triple("mipsisa64r6-unknown-linux-gnuabi64");
|
|
|
|
EXPECT_EQ(Triple::mips64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
|
|
|
T = Triple("mips64r6");
|
|
|
|
EXPECT_EQ(Triple::mips64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
|
|
|
T = Triple("mipsisa64r6");
|
|
|
|
EXPECT_EQ(Triple::mips64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
2018-09-18 05:21:57 +08:00
|
|
|
|
|
|
|
T = Triple("mips64el-unknown-linux-gnuabin32");
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
|
2018-09-27 16:51:18 +08:00
|
|
|
EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
|
2018-09-18 05:21:57 +08:00
|
|
|
T = Triple("mipsn32el");
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
|
2018-09-27 16:51:18 +08:00
|
|
|
EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
|
2018-09-18 05:21:57 +08:00
|
|
|
|
|
|
|
T = Triple("mips64-unknown-linux-gnuabin32");
|
|
|
|
EXPECT_EQ(Triple::mips64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
|
2018-09-27 16:51:18 +08:00
|
|
|
EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
|
2018-09-18 05:21:57 +08:00
|
|
|
T = Triple("mipsn32");
|
|
|
|
EXPECT_EQ(Triple::mips64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
|
2018-09-27 16:51:18 +08:00
|
|
|
EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
|
|
|
|
|
|
|
|
T = Triple("mipsisa64r6el-unknown-linux-gnuabin32");
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
|
|
|
T = Triple("mipsn32r6el");
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
|
|
|
|
|
|
|
T = Triple("mipsisa64r6-unknown-linux-gnuabin32");
|
|
|
|
EXPECT_EQ(Triple::mips64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
|
|
|
T = Triple("mipsn32r6");
|
|
|
|
EXPECT_EQ(Triple::mips64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
2018-09-18 05:21:57 +08:00
|
|
|
|
|
|
|
T = Triple("mipsel-unknown-linux-gnu");
|
|
|
|
EXPECT_EQ(Triple::mipsel, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
2018-09-27 16:51:18 +08:00
|
|
|
EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
|
2018-09-18 05:21:57 +08:00
|
|
|
T = Triple("mipsel");
|
|
|
|
EXPECT_EQ(Triple::mipsel, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
2018-09-27 16:51:18 +08:00
|
|
|
EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
|
2018-09-18 05:21:57 +08:00
|
|
|
|
|
|
|
T = Triple("mips-unknown-linux-gnu");
|
|
|
|
EXPECT_EQ(Triple::mips, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
2018-09-27 16:51:18 +08:00
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
2018-09-18 05:21:57 +08:00
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
2018-09-27 16:51:18 +08:00
|
|
|
EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
|
2018-09-18 05:21:57 +08:00
|
|
|
T = Triple("mips");
|
|
|
|
EXPECT_EQ(Triple::mips, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
2018-09-27 16:51:18 +08:00
|
|
|
EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
|
|
|
|
|
|
|
|
T = Triple("mipsisa32r6el-unknown-linux-gnu");
|
|
|
|
EXPECT_EQ(Triple::mipsel, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
|
|
|
T = Triple("mipsr6el");
|
|
|
|
EXPECT_EQ(Triple::mipsel, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
|
|
|
T = Triple("mipsisa32r6el");
|
|
|
|
EXPECT_EQ(Triple::mipsel, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
|
|
|
|
|
|
|
T = Triple("mipsisa32r6-unknown-linux-gnu");
|
|
|
|
EXPECT_EQ(Triple::mips, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
|
|
|
T = Triple("mipsr6");
|
|
|
|
EXPECT_EQ(Triple::mips, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
|
|
|
T = Triple("mipsisa32r6");
|
|
|
|
EXPECT_EQ(Triple::mips, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
|
|
|
EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
|
2018-07-06 07:41:17 +08:00
|
|
|
|
|
|
|
T = Triple("arm-oe-linux-gnueabi");
|
|
|
|
EXPECT_EQ(Triple::arm, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::OpenEmbedded, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
|
2017-09-14 01:36:16 +08:00
|
|
|
|
2018-07-20 02:10:03 +08:00
|
|
|
T = Triple("aarch64-oe-linux");
|
|
|
|
EXPECT_EQ(Triple::aarch64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::OpenEmbedded, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2009-04-02 05:53:23 +08:00
|
|
|
T = Triple("huh");
|
2009-06-10 05:48:57 +08:00
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getArch());
|
2010-08-12 19:31:39 +08:00
|
|
|
}
|
2009-08-19 03:26:55 +08:00
|
|
|
|
2010-08-12 19:31:39 +08:00
|
|
|
static std::string Join(StringRef A, StringRef B, StringRef C) {
|
2018-08-09 06:23:57 +08:00
|
|
|
std::string Str = A;
|
|
|
|
Str += '-';
|
|
|
|
Str += B;
|
|
|
|
Str += '-';
|
|
|
|
Str += C;
|
2010-08-12 19:31:39 +08:00
|
|
|
return Str;
|
|
|
|
}
|
2009-08-19 03:26:55 +08:00
|
|
|
|
2010-08-12 19:31:39 +08:00
|
|
|
static std::string Join(StringRef A, StringRef B, StringRef C, StringRef D) {
|
2018-08-09 06:23:57 +08:00
|
|
|
std::string Str = A;
|
|
|
|
Str += '-';
|
|
|
|
Str += B;
|
|
|
|
Str += '-';
|
|
|
|
Str += C;
|
|
|
|
Str += '-';
|
|
|
|
Str += D;
|
|
|
|
return Str;
|
2010-08-12 19:31:39 +08:00
|
|
|
}
|
2009-08-19 03:26:55 +08:00
|
|
|
|
2010-08-12 19:31:39 +08:00
|
|
|
TEST(TripleTest, Normalization) {
|
2011-01-22 02:25:47 +08:00
|
|
|
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("unknown", Triple::normalize(""));
|
|
|
|
EXPECT_EQ("unknown-unknown", Triple::normalize("-"));
|
|
|
|
EXPECT_EQ("unknown-unknown-unknown", Triple::normalize("--"));
|
|
|
|
EXPECT_EQ("unknown-unknown-unknown-unknown", Triple::normalize("---"));
|
|
|
|
EXPECT_EQ("unknown-unknown-unknown-unknown-unknown",
|
|
|
|
Triple::normalize("----"));
|
2010-08-12 19:31:39 +08:00
|
|
|
|
|
|
|
EXPECT_EQ("a", Triple::normalize("a"));
|
|
|
|
EXPECT_EQ("a-b", Triple::normalize("a-b"));
|
|
|
|
EXPECT_EQ("a-b-c", Triple::normalize("a-b-c"));
|
|
|
|
EXPECT_EQ("a-b-c-d", Triple::normalize("a-b-c-d"));
|
|
|
|
|
|
|
|
EXPECT_EQ("i386-b-c", Triple::normalize("i386-b-c"));
|
|
|
|
EXPECT_EQ("i386-a-c", Triple::normalize("a-i386-c"));
|
|
|
|
EXPECT_EQ("i386-a-b", Triple::normalize("a-b-i386"));
|
2010-09-16 16:25:48 +08:00
|
|
|
EXPECT_EQ("i386-a-b-c", Triple::normalize("a-b-c-i386"));
|
2010-08-12 19:31:39 +08:00
|
|
|
|
|
|
|
EXPECT_EQ("a-pc-c", Triple::normalize("a-pc-c"));
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("unknown-pc-b-c", Triple::normalize("pc-b-c"));
|
2010-08-12 19:31:39 +08:00
|
|
|
EXPECT_EQ("a-pc-b", Triple::normalize("a-b-pc"));
|
2010-09-16 16:25:48 +08:00
|
|
|
EXPECT_EQ("a-pc-b-c", Triple::normalize("a-b-c-pc"));
|
2010-08-12 19:31:39 +08:00
|
|
|
|
|
|
|
EXPECT_EQ("a-b-linux", Triple::normalize("a-b-linux"));
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("unknown-unknown-linux-b-c", Triple::normalize("linux-b-c"));
|
|
|
|
EXPECT_EQ("a-unknown-linux-c", Triple::normalize("a-linux-c"));
|
2010-08-12 19:31:39 +08:00
|
|
|
|
|
|
|
EXPECT_EQ("i386-pc-a", Triple::normalize("a-pc-i386"));
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("i386-pc-unknown", Triple::normalize("-pc-i386"));
|
|
|
|
EXPECT_EQ("unknown-pc-linux-c", Triple::normalize("linux-pc-c"));
|
|
|
|
EXPECT_EQ("unknown-pc-linux", Triple::normalize("linux-pc-"));
|
2010-08-12 19:31:39 +08:00
|
|
|
|
|
|
|
EXPECT_EQ("i386", Triple::normalize("i386"));
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("unknown-pc", Triple::normalize("pc"));
|
|
|
|
EXPECT_EQ("unknown-unknown-linux", Triple::normalize("linux"));
|
2010-08-12 19:31:39 +08:00
|
|
|
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("x86_64-unknown-linux-gnu", Triple::normalize("x86_64-gnu-linux"));
|
2011-01-22 02:25:47 +08:00
|
|
|
|
2010-08-12 19:31:39 +08:00
|
|
|
// Check that normalizing a permutated set of valid components returns a
|
|
|
|
// triple with the unpermuted components.
|
[ADT] Make the triple test 1000x faster through more focused test cases.
The current approach isn't a long-term viable pattern. Given the set of
architectures A, vendors V, operating systems O, and environments E, it
does |A| * |V| * |O| * |E| * 4! tests. As LLVM grows, this test keeps
getting slower, despite my working very hard to make it get some
"optimizations" even in -O0 builds in order to lower the constant
factors. Fundamentally, we're doing an unreasonable amount of work.i
Looking at the specific thing being tested -- the goal seems very
clearly to be testing the *permutations*, not the *combinations*. The
combinations are driving up the complexity much more than anything else.
Instead, test every possible value for a given triple entry in every
permutation of *some* triple. This really seems to cover the core goal
of the test. Every single possible triple component is tested in every
position. But because we keep the rest of the triple constant, it does
so in a dramatically more scalable amount of time. With this model we do
(|A| + |V| + |O| + |E|) * 4! tests.
For me on a debug build, this goes from running for 19 seconds to 19
milliseconds, or a 1000x improvement. This makes a world of difference
for the critical path of 'ninja check-llvm' and other extremely common
workflows.
Thanks to Renato, Dean, and David for the helpful review comments and
helping me refine the explanation of the change.
Differential Revision: https://reviews.llvm.org/D23156
llvm-svn: 277912
2016-08-06 14:00:50 +08:00
|
|
|
//
|
|
|
|
// We don't check every possible combination. For the set of architectures A,
|
|
|
|
// vendors V, operating systems O, and environments E, that would require |A|
|
|
|
|
// * |V| * |O| * |E| * 4! tests. Instead we check every option for any given
|
|
|
|
// slot and make sure it gets normalized to the correct position from every
|
|
|
|
// permutation. This should cover the core logic while being a tractable
|
|
|
|
// number of tests at (|A| + |V| + |O| + |E|) * 4!.
|
|
|
|
auto FirstArchType = Triple::ArchType(Triple::UnknownArch + 1);
|
|
|
|
auto FirstVendorType = Triple::VendorType(Triple::UnknownVendor + 1);
|
|
|
|
auto FirstOSType = Triple::OSType(Triple::UnknownOS + 1);
|
|
|
|
auto FirstEnvType = Triple::EnvironmentType(Triple::UnknownEnvironment + 1);
|
|
|
|
StringRef InitialC[] = {Triple::getArchTypeName(FirstArchType),
|
|
|
|
Triple::getVendorTypeName(FirstVendorType),
|
|
|
|
Triple::getOSTypeName(FirstOSType),
|
|
|
|
Triple::getEnvironmentTypeName(FirstEnvType)};
|
|
|
|
for (int Arch = FirstArchType; Arch <= Triple::LastArchType; ++Arch) {
|
|
|
|
StringRef C[] = {InitialC[0], InitialC[1], InitialC[2], InitialC[3]};
|
2010-08-12 19:31:39 +08:00
|
|
|
C[0] = Triple::getArchTypeName(Triple::ArchType(Arch));
|
[ADT] Make the triple test 1000x faster through more focused test cases.
The current approach isn't a long-term viable pattern. Given the set of
architectures A, vendors V, operating systems O, and environments E, it
does |A| * |V| * |O| * |E| * 4! tests. As LLVM grows, this test keeps
getting slower, despite my working very hard to make it get some
"optimizations" even in -O0 builds in order to lower the constant
factors. Fundamentally, we're doing an unreasonable amount of work.i
Looking at the specific thing being tested -- the goal seems very
clearly to be testing the *permutations*, not the *combinations*. The
combinations are driving up the complexity much more than anything else.
Instead, test every possible value for a given triple entry in every
permutation of *some* triple. This really seems to cover the core goal
of the test. Every single possible triple component is tested in every
position. But because we keep the rest of the triple constant, it does
so in a dramatically more scalable amount of time. With this model we do
(|A| + |V| + |O| + |E|) * 4! tests.
For me on a debug build, this goes from running for 19 seconds to 19
milliseconds, or a 1000x improvement. This makes a world of difference
for the critical path of 'ninja check-llvm' and other extremely common
workflows.
Thanks to Renato, Dean, and David for the helpful review comments and
helping me refine the explanation of the change.
Differential Revision: https://reviews.llvm.org/D23156
llvm-svn: 277912
2016-08-06 14:00:50 +08:00
|
|
|
std::string E = Join(C[0], C[1], C[2]);
|
|
|
|
int I[] = {0, 1, 2};
|
|
|
|
do {
|
|
|
|
EXPECT_EQ(E, Triple::normalize(Join(C[I[0]], C[I[1]], C[I[2]])));
|
|
|
|
} while (std::next_permutation(std::begin(I), std::end(I)));
|
|
|
|
std::string F = Join(C[0], C[1], C[2], C[3]);
|
|
|
|
int J[] = {0, 1, 2, 3};
|
|
|
|
do {
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[J[0]], C[J[1]], C[J[2]], C[J[3]])));
|
|
|
|
} while (std::next_permutation(std::begin(J), std::end(J)));
|
|
|
|
}
|
|
|
|
for (int Vendor = FirstVendorType; Vendor <= Triple::LastVendorType;
|
|
|
|
++Vendor) {
|
|
|
|
StringRef C[] = {InitialC[0], InitialC[1], InitialC[2], InitialC[3]};
|
|
|
|
C[1] = Triple::getVendorTypeName(Triple::VendorType(Vendor));
|
|
|
|
std::string E = Join(C[0], C[1], C[2]);
|
|
|
|
int I[] = {0, 1, 2};
|
|
|
|
do {
|
|
|
|
EXPECT_EQ(E, Triple::normalize(Join(C[I[0]], C[I[1]], C[I[2]])));
|
|
|
|
} while (std::next_permutation(std::begin(I), std::end(I)));
|
|
|
|
std::string F = Join(C[0], C[1], C[2], C[3]);
|
|
|
|
int J[] = {0, 1, 2, 3};
|
|
|
|
do {
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[J[0]], C[J[1]], C[J[2]], C[J[3]])));
|
|
|
|
} while (std::next_permutation(std::begin(J), std::end(J)));
|
|
|
|
}
|
|
|
|
for (int OS = FirstOSType; OS <= Triple::LastOSType; ++OS) {
|
|
|
|
if (OS == Triple::Win32)
|
|
|
|
continue;
|
|
|
|
StringRef C[] = {InitialC[0], InitialC[1], InitialC[2], InitialC[3]};
|
|
|
|
C[2] = Triple::getOSTypeName(Triple::OSType(OS));
|
|
|
|
std::string E = Join(C[0], C[1], C[2]);
|
|
|
|
int I[] = {0, 1, 2};
|
|
|
|
do {
|
|
|
|
EXPECT_EQ(E, Triple::normalize(Join(C[I[0]], C[I[1]], C[I[2]])));
|
|
|
|
} while (std::next_permutation(std::begin(I), std::end(I)));
|
|
|
|
std::string F = Join(C[0], C[1], C[2], C[3]);
|
|
|
|
int J[] = {0, 1, 2, 3};
|
|
|
|
do {
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[J[0]], C[J[1]], C[J[2]], C[J[3]])));
|
|
|
|
} while (std::next_permutation(std::begin(J), std::end(J)));
|
|
|
|
}
|
|
|
|
for (int Env = FirstEnvType; Env <= Triple::LastEnvironmentType; ++Env) {
|
|
|
|
StringRef C[] = {InitialC[0], InitialC[1], InitialC[2], InitialC[3]};
|
|
|
|
C[3] = Triple::getEnvironmentTypeName(Triple::EnvironmentType(Env));
|
|
|
|
std::string F = Join(C[0], C[1], C[2], C[3]);
|
|
|
|
int J[] = {0, 1, 2, 3};
|
|
|
|
do {
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[J[0]], C[J[1]], C[J[2]], C[J[3]])));
|
|
|
|
} while (std::next_permutation(std::begin(J), std::end(J)));
|
2010-08-12 19:31:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Various real-world funky triples. The value returned by GCC's config.sub
|
|
|
|
// is given in the comment.
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("i386-unknown-windows-gnu",
|
|
|
|
Triple::normalize("i386-mingw32")); // i386-pc-mingw32
|
|
|
|
EXPECT_EQ("x86_64-unknown-linux-gnu",
|
|
|
|
Triple::normalize("x86_64-linux-gnu")); // x86_64-pc-linux-gnu
|
|
|
|
EXPECT_EQ("i486-unknown-linux-gnu",
|
|
|
|
Triple::normalize("i486-linux-gnu")); // i486-pc-linux-gnu
|
|
|
|
EXPECT_EQ("i386-redhat-linux",
|
|
|
|
Triple::normalize("i386-redhat-linux")); // i386-redhat-linux-gnu
|
|
|
|
EXPECT_EQ("i686-unknown-linux",
|
|
|
|
Triple::normalize("i686-linux")); // i686-pc-linux-gnu
|
|
|
|
EXPECT_EQ("arm-none-unknown-eabi",
|
|
|
|
Triple::normalize("arm-none-eabi")); // arm-none-eabi
|
2009-04-02 05:53:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TripleTest, MutateName) {
|
|
|
|
Triple T;
|
2009-06-10 05:48:57 +08:00
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
2010-09-16 16:25:48 +08:00
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
T.setArchName("i386");
|
2009-06-10 05:48:57 +08:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ("i386--", T.getTriple());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
T.setVendorName("pc");
|
2009-06-10 05:48:57 +08:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ("i386-pc-", T.getTriple());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
T.setOSName("linux");
|
2009-06-10 05:48:57 +08:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ("i386-pc-linux", T.getTriple());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
T.setEnvironmentName("gnu");
|
2009-06-10 05:48:57 +08:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ("i386-pc-linux-gnu", T.getTriple());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
T.setOSName("freebsd");
|
2009-06-10 05:48:57 +08:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::FreeBSD, T.getOS());
|
|
|
|
EXPECT_EQ("i386-pc-freebsd-gnu", T.getTriple());
|
2009-04-02 05:53:23 +08:00
|
|
|
|
|
|
|
T.setOSAndEnvironmentName("darwin");
|
2009-06-10 05:48:57 +08:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Darwin, T.getOS());
|
|
|
|
EXPECT_EQ("i386-pc-darwin", T.getTriple());
|
2009-04-02 05:53:23 +08:00
|
|
|
}
|
|
|
|
|
2012-01-31 12:52:32 +08:00
|
|
|
TEST(TripleTest, BitWidthPredicates) {
|
|
|
|
Triple T;
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::arm);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::hexagon);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::mips);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::mips64);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::msp430);
|
|
|
|
EXPECT_TRUE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::ppc);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::ppc64);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::x86);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::x86_64);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
2014-09-20 03:52:11 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::amdil);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::amdil64);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::hsail);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::hsail64);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::spir);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::spir64);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
2015-04-30 03:15:08 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::sparc);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::sparcel);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::sparcv9);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
2015-06-30 07:51:55 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::wasm32);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::wasm64);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
2015-10-16 11:10:30 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::avr);
|
|
|
|
EXPECT_TRUE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
2016-02-12 01:16:20 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::lanai);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
2016-11-02 00:47:54 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::riscv32);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::riscv64);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
2012-01-31 12:52:32 +08:00
|
|
|
}
|
|
|
|
|
2012-02-07 04:46:33 +08:00
|
|
|
TEST(TripleTest, BitWidthArchVariants) {
|
|
|
|
Triple T;
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::UnknownArch);
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::mips);
|
|
|
|
EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::mipsel);
|
|
|
|
EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::ppc);
|
|
|
|
EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
|
|
|
|
|
2012-05-25 05:38:21 +08:00
|
|
|
T.setArch(Triple::nvptx);
|
|
|
|
EXPECT_EQ(Triple::nvptx, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::nvptx64, T.get64BitArchVariant().getArch());
|
2012-02-07 04:46:33 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::sparc);
|
|
|
|
EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::x86);
|
|
|
|
EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::mips64);
|
|
|
|
EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::mips64el);
|
|
|
|
EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::ppc64);
|
|
|
|
EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
|
|
|
|
|
2012-05-25 05:38:21 +08:00
|
|
|
T.setArch(Triple::nvptx64);
|
|
|
|
EXPECT_EQ(Triple::nvptx, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::nvptx64, T.get64BitArchVariant().getArch());
|
2012-02-07 04:46:33 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::sparcv9);
|
|
|
|
EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::x86_64);
|
|
|
|
EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
|
2014-09-20 03:52:11 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::amdil);
|
|
|
|
EXPECT_EQ(Triple::amdil, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::amdil64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::amdil64);
|
|
|
|
EXPECT_EQ(Triple::amdil, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::amdil64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::hsail);
|
|
|
|
EXPECT_EQ(Triple::hsail, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::hsail64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::hsail64);
|
|
|
|
EXPECT_EQ(Triple::hsail, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::hsail64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::spir);
|
|
|
|
EXPECT_EQ(Triple::spir, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::spir64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::spir64);
|
|
|
|
EXPECT_EQ(Triple::spir, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::spir64, T.get64BitArchVariant().getArch());
|
2015-06-30 07:51:55 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::wasm32);
|
|
|
|
EXPECT_EQ(Triple::wasm32, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::wasm64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::wasm64);
|
|
|
|
EXPECT_EQ(Triple::wasm32, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::wasm64, T.get64BitArchVariant().getArch());
|
2016-11-02 00:47:54 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::riscv32);
|
|
|
|
EXPECT_EQ(Triple::riscv32, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::riscv64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::riscv64);
|
|
|
|
EXPECT_EQ(Triple::riscv32, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::riscv64, T.get64BitArchVariant().getArch());
|
2017-02-05 02:20:20 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::thumbeb);
|
|
|
|
EXPECT_EQ(Triple::thumbeb, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::aarch64_be, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::thumb);
|
|
|
|
EXPECT_EQ(Triple::thumb, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::aarch64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::aarch64);
|
|
|
|
EXPECT_EQ(Triple::arm, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::aarch64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::aarch64_be);
|
|
|
|
EXPECT_EQ(Triple::armeb, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::aarch64_be, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::renderscript32);
|
|
|
|
EXPECT_EQ(Triple::renderscript32, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::renderscript64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::renderscript64);
|
|
|
|
EXPECT_EQ(Triple::renderscript32, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::renderscript64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::le32);
|
|
|
|
EXPECT_EQ(Triple::le32, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::le64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::le64);
|
|
|
|
EXPECT_EQ(Triple::le32, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::le64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::armeb);
|
|
|
|
EXPECT_EQ(Triple::armeb, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::aarch64_be, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::arm);
|
|
|
|
EXPECT_EQ(Triple::arm, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::aarch64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::systemz);
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::systemz, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::xcore);
|
|
|
|
EXPECT_EQ(Triple::xcore, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
|
2012-02-07 04:46:33 +08:00
|
|
|
}
|
|
|
|
|
2015-07-07 07:58:14 +08:00
|
|
|
TEST(TripleTest, EndianArchVariants) {
|
|
|
|
Triple T;
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::UnknownArch);
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::aarch64_be);
|
|
|
|
EXPECT_EQ(Triple::aarch64_be, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::aarch64, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::aarch64);
|
|
|
|
EXPECT_EQ(Triple::aarch64_be, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::aarch64, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::armeb);
|
|
|
|
EXPECT_EQ(Triple::armeb, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::arm);
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::arm, T.getLittleEndianArchVariant().getArch());
|
2016-06-30 04:01:39 +08:00
|
|
|
T = Triple("arm");
|
|
|
|
EXPECT_TRUE(T.isLittleEndian());
|
|
|
|
T = Triple("thumb");
|
|
|
|
EXPECT_TRUE(T.isLittleEndian());
|
|
|
|
T = Triple("armeb");
|
|
|
|
EXPECT_FALSE(T.isLittleEndian());
|
|
|
|
T = Triple("thumbeb");
|
|
|
|
EXPECT_FALSE(T.isLittleEndian());
|
2015-07-07 07:58:14 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::bpfeb);
|
|
|
|
EXPECT_EQ(Triple::bpfeb, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::bpfel, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::bpfel);
|
|
|
|
EXPECT_EQ(Triple::bpfeb, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::bpfel, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::mips64);
|
|
|
|
EXPECT_EQ(Triple::mips64, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::mips64el);
|
|
|
|
EXPECT_EQ(Triple::mips64, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::mips);
|
|
|
|
EXPECT_EQ(Triple::mips, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::mipsel, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::mipsel);
|
|
|
|
EXPECT_EQ(Triple::mips, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::mipsel, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::ppc);
|
|
|
|
EXPECT_EQ(Triple::ppc, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::ppc64);
|
|
|
|
EXPECT_EQ(Triple::ppc64, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::ppc64le, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::ppc64le);
|
|
|
|
EXPECT_EQ(Triple::ppc64, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::ppc64le, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::sparc);
|
|
|
|
EXPECT_EQ(Triple::sparc, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::sparcel, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::sparcel);
|
|
|
|
EXPECT_EQ(Triple::sparc, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::sparcel, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::thumb);
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::thumb, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::thumbeb);
|
|
|
|
EXPECT_EQ(Triple::thumbeb, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
|
2016-02-12 01:16:20 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::lanai);
|
|
|
|
EXPECT_EQ(Triple::lanai, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
|
2017-02-05 01:04:50 +08:00
|
|
|
|
|
|
|
T.setArch(Triple::tcele);
|
|
|
|
EXPECT_EQ(Triple::tce, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::tcele, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::tce);
|
|
|
|
EXPECT_EQ(Triple::tce, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::tcele, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::le32);
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::le32, T.getLittleEndianArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::le64);
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::le64, T.getLittleEndianArchVariant().getArch());
|
2015-07-07 07:58:14 +08:00
|
|
|
}
|
|
|
|
|
2012-05-10 03:31:41 +08:00
|
|
|
TEST(TripleTest, getOSVersion) {
|
|
|
|
Triple T;
|
|
|
|
unsigned Major, Minor, Micro;
|
|
|
|
|
|
|
|
T = Triple("i386-apple-darwin9");
|
2013-01-31 07:48:13 +08:00
|
|
|
EXPECT_TRUE(T.isMacOSX());
|
|
|
|
EXPECT_FALSE(T.isiOS());
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
2012-05-10 03:31:41 +08:00
|
|
|
T.getMacOSXVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)10, Major);
|
|
|
|
EXPECT_EQ((unsigned)5, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
T.getiOSVersion(Major, Minor, Micro);
|
2013-12-10 19:53:16 +08:00
|
|
|
EXPECT_EQ((unsigned)5, Major);
|
2012-05-10 03:31:41 +08:00
|
|
|
EXPECT_EQ((unsigned)0, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
|
|
|
|
T = Triple("x86_64-apple-darwin9");
|
2013-01-31 07:48:13 +08:00
|
|
|
EXPECT_TRUE(T.isMacOSX());
|
|
|
|
EXPECT_FALSE(T.isiOS());
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
2012-05-10 03:31:41 +08:00
|
|
|
T.getMacOSXVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)10, Major);
|
|
|
|
EXPECT_EQ((unsigned)5, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
T.getiOSVersion(Major, Minor, Micro);
|
2013-12-10 19:53:16 +08:00
|
|
|
EXPECT_EQ((unsigned)5, Major);
|
2012-05-10 03:31:41 +08:00
|
|
|
EXPECT_EQ((unsigned)0, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
|
|
|
|
T = Triple("x86_64-apple-macosx");
|
2013-01-31 07:48:13 +08:00
|
|
|
EXPECT_TRUE(T.isMacOSX());
|
|
|
|
EXPECT_FALSE(T.isiOS());
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
2012-05-10 03:31:41 +08:00
|
|
|
T.getMacOSXVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)10, Major);
|
|
|
|
EXPECT_EQ((unsigned)4, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
T.getiOSVersion(Major, Minor, Micro);
|
2013-12-10 19:53:16 +08:00
|
|
|
EXPECT_EQ((unsigned)5, Major);
|
2012-05-10 03:31:41 +08:00
|
|
|
EXPECT_EQ((unsigned)0, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
|
|
|
|
T = Triple("x86_64-apple-macosx10.7");
|
2013-01-31 07:48:13 +08:00
|
|
|
EXPECT_TRUE(T.isMacOSX());
|
|
|
|
EXPECT_FALSE(T.isiOS());
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
2012-05-10 03:31:41 +08:00
|
|
|
T.getMacOSXVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)10, Major);
|
|
|
|
EXPECT_EQ((unsigned)7, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
T.getiOSVersion(Major, Minor, Micro);
|
2013-12-10 19:53:16 +08:00
|
|
|
EXPECT_EQ((unsigned)5, Major);
|
2012-05-10 03:31:41 +08:00
|
|
|
EXPECT_EQ((unsigned)0, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
|
|
|
|
T = Triple("armv7-apple-ios");
|
2013-01-31 07:48:13 +08:00
|
|
|
EXPECT_FALSE(T.isMacOSX());
|
|
|
|
EXPECT_TRUE(T.isiOS());
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
2012-05-10 03:31:41 +08:00
|
|
|
T.getMacOSXVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)10, Major);
|
|
|
|
EXPECT_EQ((unsigned)4, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
T.getiOSVersion(Major, Minor, Micro);
|
2013-12-10 19:53:16 +08:00
|
|
|
EXPECT_EQ((unsigned)5, Major);
|
2012-05-10 03:31:41 +08:00
|
|
|
EXPECT_EQ((unsigned)0, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
|
2013-12-10 19:53:16 +08:00
|
|
|
T = Triple("armv7-apple-ios7.0");
|
2013-01-31 07:48:13 +08:00
|
|
|
EXPECT_FALSE(T.isMacOSX());
|
|
|
|
EXPECT_TRUE(T.isiOS());
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
2012-05-10 03:31:41 +08:00
|
|
|
T.getMacOSXVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)10, Major);
|
|
|
|
EXPECT_EQ((unsigned)4, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
T.getiOSVersion(Major, Minor, Micro);
|
2013-12-10 19:53:16 +08:00
|
|
|
EXPECT_EQ((unsigned)7, Major);
|
2012-05-10 03:31:41 +08:00
|
|
|
EXPECT_EQ((unsigned)0, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
2017-10-24 05:51:50 +08:00
|
|
|
EXPECT_FALSE(T.isSimulatorEnvironment());
|
|
|
|
|
|
|
|
T = Triple("x86_64-apple-ios10.3-simulator");
|
|
|
|
EXPECT_TRUE(T.isiOS());
|
|
|
|
T.getiOSVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)10, Major);
|
|
|
|
EXPECT_EQ((unsigned)3, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
EXPECT_TRUE(T.isSimulatorEnvironment());
|
2012-05-10 03:31:41 +08:00
|
|
|
}
|
|
|
|
|
2014-03-07 04:47:11 +08:00
|
|
|
TEST(TripleTest, FileFormat) {
|
|
|
|
EXPECT_EQ(Triple::ELF, Triple("i686-unknown-linux-gnu").getObjectFormat());
|
|
|
|
EXPECT_EQ(Triple::ELF, Triple("i686-unknown-freebsd").getObjectFormat());
|
|
|
|
EXPECT_EQ(Triple::ELF, Triple("i686-unknown-netbsd").getObjectFormat());
|
|
|
|
EXPECT_EQ(Triple::ELF, Triple("i686--win32-elf").getObjectFormat());
|
|
|
|
EXPECT_EQ(Triple::ELF, Triple("i686---elf").getObjectFormat());
|
|
|
|
|
|
|
|
EXPECT_EQ(Triple::MachO, Triple("i686-apple-macosx").getObjectFormat());
|
|
|
|
EXPECT_EQ(Triple::MachO, Triple("i686-apple-ios").getObjectFormat());
|
|
|
|
EXPECT_EQ(Triple::MachO, Triple("i686---macho").getObjectFormat());
|
|
|
|
|
|
|
|
EXPECT_EQ(Triple::COFF, Triple("i686--win32").getObjectFormat());
|
|
|
|
|
2014-03-30 15:19:31 +08:00
|
|
|
EXPECT_EQ(Triple::ELF, Triple("i686-pc-windows-msvc-elf").getObjectFormat());
|
2014-04-01 00:34:41 +08:00
|
|
|
EXPECT_EQ(Triple::ELF, Triple("i686-pc-cygwin-elf").getObjectFormat());
|
2014-03-30 15:19:31 +08:00
|
|
|
|
2018-02-13 07:47:38 +08:00
|
|
|
EXPECT_EQ(Triple::Wasm, Triple("wasm32-unknown-unknown").getObjectFormat());
|
|
|
|
EXPECT_EQ(Triple::Wasm, Triple("wasm64-unknown-unknown").getObjectFormat());
|
2019-01-16 13:23:52 +08:00
|
|
|
EXPECT_EQ(Triple::Wasm, Triple("wasm32-unknown-wasi-musl").getObjectFormat());
|
|
|
|
EXPECT_EQ(Triple::Wasm, Triple("wasm64-unknown-wasi-musl").getObjectFormat());
|
2018-02-13 07:47:38 +08:00
|
|
|
|
2018-02-16 02:05:16 +08:00
|
|
|
EXPECT_EQ(Triple::Wasm,
|
|
|
|
Triple("wasm32-unknown-unknown-wasm").getObjectFormat());
|
|
|
|
EXPECT_EQ(Triple::Wasm,
|
|
|
|
Triple("wasm64-unknown-unknown-wasm").getObjectFormat());
|
2019-01-15 14:58:13 +08:00
|
|
|
EXPECT_EQ(Triple::Wasm,
|
2019-01-16 13:23:52 +08:00
|
|
|
Triple("wasm32-unknown-wasi-musl-wasm").getObjectFormat());
|
2019-01-15 14:58:13 +08:00
|
|
|
EXPECT_EQ(Triple::Wasm,
|
2019-01-16 13:23:52 +08:00
|
|
|
Triple("wasm64-unknown-wasi-musl-wasm").getObjectFormat());
|
2018-02-16 02:05:16 +08:00
|
|
|
|
2014-04-01 00:34:41 +08:00
|
|
|
Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
|
|
|
|
EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
|
|
|
|
|
|
|
|
Triple GNUWindowsNormalized(Triple::normalize("i686-pc-windows-gnu-elf"));
|
|
|
|
EXPECT_EQ(Triple::ELF, GNUWindowsNormalized.getObjectFormat());
|
|
|
|
|
|
|
|
Triple CygnusNormalised(Triple::normalize("i686-pc-windows-cygnus-elf"));
|
|
|
|
EXPECT_EQ(Triple::ELF, CygnusNormalised.getObjectFormat());
|
|
|
|
|
|
|
|
Triple CygwinNormalized(Triple::normalize("i686-pc-cygwin-elf"));
|
|
|
|
EXPECT_EQ(Triple::ELF, CygwinNormalized.getObjectFormat());
|
2014-03-30 15:19:31 +08:00
|
|
|
|
2014-03-07 04:47:11 +08:00
|
|
|
Triple T = Triple("");
|
|
|
|
T.setObjectFormat(Triple::ELF);
|
|
|
|
EXPECT_EQ(Triple::ELF, T.getObjectFormat());
|
2017-02-05 06:49:22 +08:00
|
|
|
|
|
|
|
T.setObjectFormat(Triple::MachO);
|
|
|
|
EXPECT_EQ(Triple::MachO, T.getObjectFormat());
|
2014-03-07 04:47:11 +08:00
|
|
|
}
|
|
|
|
|
2014-03-28 06:50:05 +08:00
|
|
|
TEST(TripleTest, NormalizeWindows) {
|
|
|
|
EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-win32"));
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("i686-unknown-windows-msvc", Triple::normalize("i686-win32"));
|
2014-03-28 06:50:05 +08:00
|
|
|
EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-mingw32"));
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("i686-unknown-windows-gnu", Triple::normalize("i686-mingw32"));
|
2014-03-28 06:50:05 +08:00
|
|
|
EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-mingw32-w64"));
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("i686-unknown-windows-gnu", Triple::normalize("i686-mingw32-w64"));
|
2014-03-28 06:50:05 +08:00
|
|
|
EXPECT_EQ("i686-pc-windows-cygnus", Triple::normalize("i686-pc-cygwin"));
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("i686-unknown-windows-cygnus", Triple::normalize("i686-cygwin"));
|
2014-03-28 06:50:05 +08:00
|
|
|
|
|
|
|
EXPECT_EQ("x86_64-pc-windows-msvc", Triple::normalize("x86_64-pc-win32"));
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("x86_64-unknown-windows-msvc", Triple::normalize("x86_64-win32"));
|
2014-03-28 06:50:05 +08:00
|
|
|
EXPECT_EQ("x86_64-pc-windows-gnu", Triple::normalize("x86_64-pc-mingw32"));
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("x86_64-unknown-windows-gnu", Triple::normalize("x86_64-mingw32"));
|
|
|
|
EXPECT_EQ("x86_64-pc-windows-gnu",
|
|
|
|
Triple::normalize("x86_64-pc-mingw32-w64"));
|
|
|
|
EXPECT_EQ("x86_64-unknown-windows-gnu",
|
|
|
|
Triple::normalize("x86_64-mingw32-w64"));
|
2014-03-28 06:50:05 +08:00
|
|
|
|
|
|
|
EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-win32-elf"));
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("i686-unknown-windows-elf", Triple::normalize("i686-win32-elf"));
|
2014-03-28 06:50:05 +08:00
|
|
|
EXPECT_EQ("i686-pc-windows-macho", Triple::normalize("i686-pc-win32-macho"));
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("i686-unknown-windows-macho",
|
|
|
|
Triple::normalize("i686-win32-macho"));
|
2014-03-28 06:50:05 +08:00
|
|
|
|
|
|
|
EXPECT_EQ("x86_64-pc-windows-elf", Triple::normalize("x86_64-pc-win32-elf"));
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("x86_64-unknown-windows-elf",
|
|
|
|
Triple::normalize("x86_64-win32-elf"));
|
|
|
|
EXPECT_EQ("x86_64-pc-windows-macho",
|
|
|
|
Triple::normalize("x86_64-pc-win32-macho"));
|
|
|
|
EXPECT_EQ("x86_64-unknown-windows-macho",
|
|
|
|
Triple::normalize("x86_64-win32-macho"));
|
2014-03-28 06:50:05 +08:00
|
|
|
|
2014-04-01 00:34:41 +08:00
|
|
|
EXPECT_EQ("i686-pc-windows-cygnus",
|
|
|
|
Triple::normalize("i686-pc-windows-cygnus"));
|
|
|
|
EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-windows-gnu"));
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("i686-pc-windows-itanium",
|
|
|
|
Triple::normalize("i686-pc-windows-itanium"));
|
2014-03-30 15:19:31 +08:00
|
|
|
EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-windows-msvc"));
|
2014-04-01 00:34:41 +08:00
|
|
|
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("i686-pc-windows-elf",
|
|
|
|
Triple::normalize("i686-pc-windows-elf-elf"));
|
2014-03-28 06:50:05 +08:00
|
|
|
}
|
2014-07-12 05:44:54 +08:00
|
|
|
|
|
|
|
TEST(TripleTest, getARMCPUForArch) {
|
2015-05-20 23:05:07 +08:00
|
|
|
// Platform specific defaults.
|
2015-03-27 05:58:46 +08:00
|
|
|
{
|
|
|
|
llvm::Triple Triple("arm--nacl");
|
2015-08-30 15:51:04 +08:00
|
|
|
EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch());
|
2015-03-27 05:58:46 +08:00
|
|
|
}
|
2017-03-01 01:28:35 +08:00
|
|
|
{
|
|
|
|
llvm::Triple Triple("arm--openbsd");
|
|
|
|
EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch());
|
|
|
|
}
|
2015-05-08 20:52:02 +08:00
|
|
|
{
|
2015-05-20 23:05:07 +08:00
|
|
|
llvm::Triple Triple("armv6-unknown-freebsd");
|
2015-08-30 15:51:04 +08:00
|
|
|
EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
|
2015-05-08 20:52:02 +08:00
|
|
|
}
|
2015-05-28 03:49:53 +08:00
|
|
|
{
|
|
|
|
llvm::Triple Triple("thumbv6-unknown-freebsd");
|
2015-08-30 15:51:04 +08:00
|
|
|
EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
|
2015-05-28 03:49:53 +08:00
|
|
|
}
|
|
|
|
{
|
|
|
|
llvm::Triple Triple("armebv6-unknown-freebsd");
|
2015-08-30 15:51:04 +08:00
|
|
|
EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
|
2015-05-28 03:49:53 +08:00
|
|
|
}
|
2015-05-08 20:52:02 +08:00
|
|
|
{
|
2015-05-20 23:05:07 +08:00
|
|
|
llvm::Triple Triple("arm--win32");
|
2015-08-30 15:51:04 +08:00
|
|
|
EXPECT_EQ("cortex-a9", Triple.getARMCPUForArch());
|
2015-05-08 20:52:02 +08:00
|
|
|
}
|
2015-05-20 23:05:07 +08:00
|
|
|
// Some alternative architectures
|
2016-02-12 07:49:08 +08:00
|
|
|
{
|
|
|
|
llvm::Triple Triple("armv7k-apple-ios9");
|
|
|
|
EXPECT_EQ("cortex-a7", Triple.getARMCPUForArch());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
llvm::Triple Triple("armv7k-apple-watchos3");
|
|
|
|
EXPECT_EQ("cortex-a7", Triple.getARMCPUForArch());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
llvm::Triple Triple("armv7k-apple-tvos9");
|
|
|
|
EXPECT_EQ("cortex-a7", Triple.getARMCPUForArch());
|
|
|
|
}
|
2015-05-08 20:52:02 +08:00
|
|
|
// armeb is permitted, but armebeb is not
|
|
|
|
{
|
|
|
|
llvm::Triple Triple("armeb-none-eabi");
|
2015-08-30 15:51:04 +08:00
|
|
|
EXPECT_EQ("arm7tdmi", Triple.getARMCPUForArch());
|
2015-05-08 20:52:02 +08:00
|
|
|
}
|
|
|
|
{
|
|
|
|
llvm::Triple Triple("armebeb-none-eabi");
|
2015-08-30 15:51:04 +08:00
|
|
|
EXPECT_EQ("", Triple.getARMCPUForArch());
|
2015-05-08 20:52:02 +08:00
|
|
|
}
|
2015-05-20 23:05:07 +08:00
|
|
|
{
|
|
|
|
llvm::Triple Triple("armebv6eb-none-eabi");
|
2015-08-30 15:51:04 +08:00
|
|
|
EXPECT_EQ("", Triple.getARMCPUForArch());
|
2015-05-20 23:05:07 +08:00
|
|
|
}
|
2015-05-08 20:52:02 +08:00
|
|
|
// xscaleeb is permitted, but armebxscale is not
|
|
|
|
{
|
|
|
|
llvm::Triple Triple("xscaleeb-none-eabi");
|
2015-08-30 15:51:04 +08:00
|
|
|
EXPECT_EQ("xscale", Triple.getARMCPUForArch());
|
2015-05-08 20:52:02 +08:00
|
|
|
}
|
|
|
|
{
|
|
|
|
llvm::Triple Triple("armebxscale-none-eabi");
|
2015-08-30 15:51:04 +08:00
|
|
|
EXPECT_EQ("", Triple.getARMCPUForArch());
|
2015-05-08 20:52:02 +08:00
|
|
|
}
|
2014-07-12 05:44:54 +08:00
|
|
|
}
|
2015-01-26 19:41:48 +08:00
|
|
|
|
|
|
|
TEST(TripleTest, NormalizeARM) {
|
2018-08-09 06:23:57 +08:00
|
|
|
EXPECT_EQ("armv6-unknown-netbsd-eabi",
|
|
|
|
Triple::normalize("armv6-netbsd-eabi"));
|
|
|
|
EXPECT_EQ("armv7-unknown-netbsd-eabi",
|
|
|
|
Triple::normalize("armv7-netbsd-eabi"));
|
|
|
|
EXPECT_EQ("armv6eb-unknown-netbsd-eabi",
|
|
|
|
Triple::normalize("armv6eb-netbsd-eabi"));
|
|
|
|
EXPECT_EQ("armv7eb-unknown-netbsd-eabi",
|
|
|
|
Triple::normalize("armv7eb-netbsd-eabi"));
|
|
|
|
EXPECT_EQ("armv6-unknown-netbsd-eabihf",
|
|
|
|
Triple::normalize("armv6-netbsd-eabihf"));
|
|
|
|
EXPECT_EQ("armv7-unknown-netbsd-eabihf",
|
|
|
|
Triple::normalize("armv7-netbsd-eabihf"));
|
|
|
|
EXPECT_EQ("armv6eb-unknown-netbsd-eabihf",
|
|
|
|
Triple::normalize("armv6eb-netbsd-eabihf"));
|
|
|
|
EXPECT_EQ("armv7eb-unknown-netbsd-eabihf",
|
|
|
|
Triple::normalize("armv7eb-netbsd-eabihf"));
|
2015-01-26 19:41:48 +08:00
|
|
|
|
2017-06-04 06:31:06 +08:00
|
|
|
EXPECT_EQ("armv7-suse-linux-gnueabihf",
|
2017-06-18 18:15:57 +08:00
|
|
|
Triple::normalize("armv7-suse-linux-gnueabi"));
|
2017-06-04 06:31:06 +08:00
|
|
|
|
2015-01-26 19:41:48 +08:00
|
|
|
Triple T;
|
|
|
|
T = Triple("armv6--netbsd-eabi");
|
|
|
|
EXPECT_EQ(Triple::arm, T.getArch());
|
|
|
|
T = Triple("armv6eb--netbsd-eabi");
|
|
|
|
EXPECT_EQ(Triple::armeb, T.getArch());
|
2017-06-04 06:31:06 +08:00
|
|
|
T = Triple("armv7-suse-linux-gnueabihf");
|
|
|
|
EXPECT_EQ(Triple::GNUEABIHF, T.getEnvironment());
|
2015-01-26 19:41:48 +08:00
|
|
|
}
|
2015-05-02 02:51:06 +08:00
|
|
|
|
2015-05-21 21:52:20 +08:00
|
|
|
TEST(TripleTest, ParseARMArch) {
|
|
|
|
// ARM
|
|
|
|
{
|
|
|
|
Triple T = Triple("arm");
|
|
|
|
EXPECT_EQ(Triple::arm, T.getArch());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
Triple T = Triple("armeb");
|
|
|
|
EXPECT_EQ(Triple::armeb, T.getArch());
|
|
|
|
}
|
|
|
|
// THUMB
|
|
|
|
{
|
|
|
|
Triple T = Triple("thumb");
|
|
|
|
EXPECT_EQ(Triple::thumb, T.getArch());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
Triple T = Triple("thumbeb");
|
|
|
|
EXPECT_EQ(Triple::thumbeb, T.getArch());
|
|
|
|
}
|
|
|
|
// AARCH64
|
|
|
|
{
|
|
|
|
Triple T = Triple("arm64");
|
|
|
|
EXPECT_EQ(Triple::aarch64, T.getArch());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
Triple T = Triple("aarch64");
|
|
|
|
EXPECT_EQ(Triple::aarch64, T.getArch());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
Triple T = Triple("aarch64_be");
|
|
|
|
EXPECT_EQ(Triple::aarch64_be, T.getArch());
|
|
|
|
}
|
|
|
|
}
|
2015-05-02 02:51:06 +08:00
|
|
|
} // end anonymous namespace
|