Fix for PR4051. When 2address pass delete an instruction, update kill info when neces...
[llvm/msp430.git] / unittests / ADT / TripleTest.cpp
blob771d1c75d9124b8fd96433d103bcdc14aaf19aa8
1 //===----------- Triple.cpp - Triple unit tests ---------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
10 #include "gtest/gtest.h"
11 #include "llvm/ADT/Triple.h"
13 using namespace llvm;
15 namespace {
17 TEST(TripleTest, BasicParsing) {
18 Triple T;
20 T = Triple("");
21 EXPECT_EQ(T.getArchName(), "");
22 EXPECT_EQ(T.getVendorName(), "");
23 EXPECT_EQ(T.getOSName(), "");
24 EXPECT_EQ(T.getEnvironmentName(), "");
26 T = Triple("-");
27 EXPECT_EQ(T.getArchName(), "");
28 EXPECT_EQ(T.getVendorName(), "");
29 EXPECT_EQ(T.getOSName(), "");
30 EXPECT_EQ(T.getEnvironmentName(), "");
32 T = Triple("--");
33 EXPECT_EQ(T.getArchName(), "");
34 EXPECT_EQ(T.getVendorName(), "");
35 EXPECT_EQ(T.getOSName(), "");
36 EXPECT_EQ(T.getEnvironmentName(), "");
38 T = Triple("---");
39 EXPECT_EQ(T.getArchName(), "");
40 EXPECT_EQ(T.getVendorName(), "");
41 EXPECT_EQ(T.getOSName(), "");
42 EXPECT_EQ(T.getEnvironmentName(), "");
44 T = Triple("----");
45 EXPECT_EQ(T.getArchName(), "");
46 EXPECT_EQ(T.getVendorName(), "");
47 EXPECT_EQ(T.getOSName(), "");
48 EXPECT_EQ(T.getEnvironmentName(), "-");
50 T = Triple("a");
51 EXPECT_EQ(T.getArchName(), "a");
52 EXPECT_EQ(T.getVendorName(), "");
53 EXPECT_EQ(T.getOSName(), "");
54 EXPECT_EQ(T.getEnvironmentName(), "");
56 T = Triple("a-b");
57 EXPECT_EQ(T.getArchName(), "a");
58 EXPECT_EQ(T.getVendorName(), "b");
59 EXPECT_EQ(T.getOSName(), "");
60 EXPECT_EQ(T.getEnvironmentName(), "");
62 T = Triple("a-b-c");
63 EXPECT_EQ(T.getArchName(), "a");
64 EXPECT_EQ(T.getVendorName(), "b");
65 EXPECT_EQ(T.getOSName(), "c");
66 EXPECT_EQ(T.getEnvironmentName(), "");
68 T = Triple("a-b-c-d");
69 EXPECT_EQ(T.getArchName(), "a");
70 EXPECT_EQ(T.getVendorName(), "b");
71 EXPECT_EQ(T.getOSName(), "c");
72 EXPECT_EQ(T.getEnvironmentName(), "d");
75 TEST(TripleTest, ParsedIDs) {
76 Triple T;
78 T = Triple("i386-apple-darwin");
79 EXPECT_EQ(T.getArch(), Triple::x86);
80 EXPECT_EQ(T.getVendor(), Triple::Apple);
81 EXPECT_EQ(T.getOS(), Triple::Darwin);
83 T = Triple("x86_64-pc-linux-gnu");
84 EXPECT_EQ(T.getArch(), Triple::x86_64);
85 EXPECT_EQ(T.getVendor(), Triple::PC);
86 EXPECT_EQ(T.getOS(), Triple::Linux);
88 T = Triple("powerpc-dunno-notsure");
89 EXPECT_EQ(T.getArch(), Triple::ppc);
90 EXPECT_EQ(T.getVendor(), Triple::UnknownVendor);
91 EXPECT_EQ(T.getOS(), Triple::UnknownOS);
93 T = Triple("huh");
94 EXPECT_EQ(T.getArch(), Triple::UnknownArch);
97 TEST(TripleTest, MutateName) {
98 Triple T;
99 EXPECT_EQ(T.getArch(), Triple::UnknownArch);
100 EXPECT_EQ(T.getVendor(), Triple::UnknownVendor);
101 EXPECT_EQ(T.getOS(), Triple::UnknownOS);
103 T.setArchName("i386");
104 EXPECT_EQ(T.getArch(), Triple::x86);
105 EXPECT_EQ(T.getTriple(), "i386--");
107 T.setVendorName("pc");
108 EXPECT_EQ(T.getArch(), Triple::x86);
109 EXPECT_EQ(T.getVendor(), Triple::PC);
110 EXPECT_EQ(T.getTriple(), "i386-pc-");
112 T.setOSName("linux");
113 EXPECT_EQ(T.getArch(), Triple::x86);
114 EXPECT_EQ(T.getVendor(), Triple::PC);
115 EXPECT_EQ(T.getOS(), Triple::Linux);
116 EXPECT_EQ(T.getTriple(), "i386-pc-linux");
118 T.setEnvironmentName("gnu");
119 EXPECT_EQ(T.getArch(), Triple::x86);
120 EXPECT_EQ(T.getVendor(), Triple::PC);
121 EXPECT_EQ(T.getOS(), Triple::Linux);
122 EXPECT_EQ(T.getTriple(), "i386-pc-linux-gnu");
124 T.setOSName("freebsd");
125 EXPECT_EQ(T.getArch(), Triple::x86);
126 EXPECT_EQ(T.getVendor(), Triple::PC);
127 EXPECT_EQ(T.getOS(), Triple::FreeBSD);
128 EXPECT_EQ(T.getTriple(), "i386-pc-freebsd-gnu");
130 T.setOSAndEnvironmentName("darwin");
131 EXPECT_EQ(T.getArch(), Triple::x86);
132 EXPECT_EQ(T.getVendor(), Triple::PC);
133 EXPECT_EQ(T.getOS(), Triple::Darwin);
134 EXPECT_EQ(T.getTriple(), "i386-pc-darwin");