llvm.org GIT mirror llvm / 859f818
Clang was not parsing target triples involving EABI and was generating wrong IR (wrong PCS) and passing the wrong information down llc via the target-triple printed in IR. I've fixed this by adding the parsing of EABI into LLVM's Triple class and using it to choose the correct PCS in Clang's Tools. A Clang patch is on its way to use this infrastructure. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123990 91177308-0d34-0410-b5e6-96231b3b80d8 Renato Golin 9 years ago
3 changed file(s) with 56 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
7171 UnknownVendor,
7272
7373 Apple,
74 PC
74 PC,
75 NoVendor
7576 };
7677 enum OSType {
7778 UnknownOS,
9192 Solaris,
9293 Win32,
9394 Haiku,
94 Minix
95 Minix,
96 NoOS
9597 };
9698 enum EnvironmentType {
97 UnknownEnvironment
99 UnknownEnvironment,
100
101 GNU,
102 GNUEABI,
103 EABI
98104 };
99105
100106 private:
8383
8484 case Apple: return "apple";
8585 case PC: return "pc";
86 case NoVendor: return "none";
8687 }
8788
8889 return "";
108109 case Win32: return "win32";
109110 case Haiku: return "haiku";
110111 case Minix: return "minix";
112 case NoOS: return "none";
111113 }
112114
113115 return "";
116118 const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) {
117119 switch (Kind) {
118120 case UnknownEnvironment: return "unknown";
121 case GNU: return "gnu";
122 case GNUEABI: return "gnueabi";
123 case EABI: return "eabi";
119124 }
120125
121126 return "";
292297 return Apple;
293298 else if (VendorName == "pc")
294299 return PC;
300 else if (VendorName == "none")
301 return NoVendor;
295302 else
296303 return UnknownVendor;
297304 }
329336 return Haiku;
330337 else if (OSName.startswith("minix"))
331338 return Minix;
339 else if (OSName.startswith("eabi"))
340 return NoOS;
332341 else
333342 return UnknownOS;
334343 }
335344
336345 Triple::EnvironmentType Triple::ParseEnvironment(StringRef EnvironmentName) {
337 return UnknownEnvironment;
346 if (EnvironmentName.startswith("eabi"))
347 return EABI;
348 else if (EnvironmentName.startswith("gnueabi"))
349 return GNUEABI;
350 else if (EnvironmentName.startswith("gnu"))
351 return GNU;
352 else
353 return UnknownEnvironment;
338354 }
339355
340356 void Triple::Parse() const {
343359 Arch = ParseArch(getArchName());
344360 Vendor = ParseVendor(getVendorName());
345361 OS = ParseOS(getOSName());
346 Environment = ParseEnvironment(getEnvironmentName());
362 if (OS == NoOS) {
363 // Some targets don't have an OS (embedded systems)
364 Environment = ParseEnvironment(getOSName());
365 } else {
366 Environment = ParseEnvironment(getEnvironmentName());
367 }
347368
348369 assert(isInitialized() && "Failed to initialize!");
349370 }
410431 break;
411432 case 2:
412433 OS = ParseOS(Comp);
413 Valid = OS != UnknownOS;
434 // Some targets don't have an OS (embedded systems)
435 if (OS == NoOS) {
436 Environment = ParseEnvironment(Comp);
437 Valid = Environment != UnknownEnvironment;
438 } else {
439 Valid = OS != UnknownOS;
440 }
414441 break;
415442 case 3:
416443 Environment = ParseEnvironment(Comp);
449476 for (unsigned i = Idx; i < Components.size(); ++i) {
450477 // Skip over any fixed components.
451478 while (i < array_lengthof(Found) && Found[i]) ++i;
479 // Fix problem when Components vector is not big enough
480 if (i >= Components.size())
481 Components.push_back(StringRef(""));
452482 // Place the component at the new position, getting the component
453483 // that was at this position - it will be moved right.
454484 std::swap(CurrentComponent, Components[i]);
8484 EXPECT_EQ(Triple::x86_64, T.getArch());
8585 EXPECT_EQ(Triple::PC, T.getVendor());
8686 EXPECT_EQ(Triple::Linux, T.getOS());
87 // When environments are defined, change this test to verify the "gnu"
88 // environment.
89 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
87 EXPECT_EQ(Triple::GNU, T.getEnvironment());
9088
9189 T = Triple("powerpc-dunno-notsure");
9290 EXPECT_EQ(Triple::ppc, T.getArch());
9492 EXPECT_EQ(Triple::UnknownOS, T.getOS());
9593 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
9694
95 T = Triple("arm-none-eabi");
96 EXPECT_EQ(Triple::arm, T.getArch());
97 EXPECT_EQ(Triple::NoVendor, T.getVendor());
98 EXPECT_EQ(Triple::NoOS, T.getOS());
99 EXPECT_EQ(Triple::EABI, T.getEnvironment());
100
97101 T = Triple("huh");
98102 EXPECT_EQ(Triple::UnknownArch, T.getArch());
99103 }
109113 }
110114
111115 TEST(TripleTest, Normalization) {
116
112117 EXPECT_EQ("", Triple::normalize(""));
113118 EXPECT_EQ("-", Triple::normalize("-"));
114119 EXPECT_EQ("--", Triple::normalize("--"));
142147 EXPECT_EQ("i386", Triple::normalize("i386"));
143148 EXPECT_EQ("-pc", Triple::normalize("pc"));
144149 EXPECT_EQ("--linux", Triple::normalize("linux"));
150
151 EXPECT_EQ("x86_64--linux-gnu", Triple::normalize("x86_64-gnu-linux"));
145152
146153 // Check that normalizing a permutated set of valid components returns a
147154 // triple with the unpermuted components.
250257 EXPECT_EQ(Triple::PC, T.getVendor());
251258 EXPECT_EQ(Triple::Darwin, T.getOS());
252259 EXPECT_EQ("i386-pc-darwin", T.getTriple());
253 }
254
255 }
260
261 }
262
263 }