Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: lib/Basic/Targets.cpp

Issue 10982073: X86_64ABIInfo support for x86_64 targets with 32-bit pointers. (Closed) Base URL: http://llvm.org/git/clang.git@master
Patch Set: rebase, add comment Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/CodeGen/TargetInfo.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===--- Targets.cpp - Implement -arch option and targets -----------------===// 1 //===--- Targets.cpp - Implement -arch option and targets -----------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements construction of a TargetInfo object from a 10 // This file implements construction of a TargetInfo object from a
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 } 1542 }
1543 virtual void getTargetDefines(const LangOptions &Opts, 1543 virtual void getTargetDefines(const LangOptions &Opts,
1544 MacroBuilder &Builder) const; 1544 MacroBuilder &Builder) const;
1545 virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features, 1545 virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
1546 StringRef Name, 1546 StringRef Name,
1547 bool Enabled) const; 1547 bool Enabled) const;
1548 virtual void getDefaultFeatures(llvm::StringMap<bool> &Features) const; 1548 virtual void getDefaultFeatures(llvm::StringMap<bool> &Features) const;
1549 virtual bool hasFeature(StringRef Feature) const; 1549 virtual bool hasFeature(StringRef Feature) const;
1550 virtual void HandleTargetFeatures(std::vector<std::string> &Features); 1550 virtual void HandleTargetFeatures(std::vector<std::string> &Features);
1551 virtual const char* getABI() const { 1551 virtual const char* getABI() const {
1552 if (PointerWidth == 64 && SSELevel >= AVX) 1552 if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX)
1553 return "avx"; 1553 return "avx";
1554 else if (PointerWidth == 32 && MMX3DNowLevel == NoMMX3DNow) 1554 else if (getTriple().getArch() == llvm::Triple::x86 &&
1555 MMX3DNowLevel == NoMMX3DNow)
1555 return "no-mmx"; 1556 return "no-mmx";
1556 return ""; 1557 return "";
1557 } 1558 }
1558 virtual bool setCPU(const std::string &Name) { 1559 virtual bool setCPU(const std::string &Name) {
1559 CPU = llvm::StringSwitch<CPUKind>(Name) 1560 CPU = llvm::StringSwitch<CPUKind>(Name)
1560 .Case("i386", CK_i386) 1561 .Case("i386", CK_i386)
1561 .Case("i486", CK_i486) 1562 .Case("i486", CK_i486)
1562 .Case("winchip-c6", CK_WinChipC6) 1563 .Case("winchip-c6", CK_WinChipC6)
1563 .Case("winchip2", CK_WinChip2) 1564 .Case("winchip2", CK_WinChip2)
1564 .Case("c3", CK_C3) 1565 .Case("c3", CK_C3)
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 case CK_K6: 1639 case CK_K6:
1639 case CK_K6_2: 1640 case CK_K6_2:
1640 case CK_K6_3: 1641 case CK_K6_3:
1641 case CK_Athlon: 1642 case CK_Athlon:
1642 case CK_AthlonThunderbird: 1643 case CK_AthlonThunderbird:
1643 case CK_Athlon4: 1644 case CK_Athlon4:
1644 case CK_AthlonXP: 1645 case CK_AthlonXP:
1645 case CK_AthlonMP: 1646 case CK_AthlonMP:
1646 case CK_Geode: 1647 case CK_Geode:
1647 // Only accept certain architectures when compiling in 32-bit mode. 1648 // Only accept certain architectures when compiling in 32-bit mode.
1648 if (PointerWidth != 32) 1649 if (getTriple().getArch() != llvm::Triple::x86)
1649 return false; 1650 return false;
1650 1651
1651 // Fallthrough 1652 // Fallthrough
1652 case CK_Nocona: 1653 case CK_Nocona:
1653 case CK_Core2: 1654 case CK_Core2:
1654 case CK_Penryn: 1655 case CK_Penryn:
1655 case CK_Atom: 1656 case CK_Atom:
1656 case CK_Corei7: 1657 case CK_Corei7:
1657 case CK_Corei7AVX: 1658 case CK_Corei7AVX:
1658 case CK_CoreAVXi: 1659 case CK_CoreAVXi:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 Features["bmi"] = false; 1710 Features["bmi"] = false;
1710 Features["bmi2"] = false; 1711 Features["bmi2"] = false;
1711 Features["popcnt"] = false; 1712 Features["popcnt"] = false;
1712 Features["fma4"] = false; 1713 Features["fma4"] = false;
1713 Features["fma"] = false; 1714 Features["fma"] = false;
1714 Features["xop"] = false; 1715 Features["xop"] = false;
1715 1716
1716 // FIXME: This *really* should not be here. 1717 // FIXME: This *really* should not be here.
1717 1718
1718 // X86_64 always has SSE2. 1719 // X86_64 always has SSE2.
1719 if (PointerWidth == 64) 1720 if (getTriple().getArch() == llvm::Triple::x86_64)
1720 Features["sse2"] = Features["sse"] = Features["mmx"] = true; 1721 Features["sse2"] = Features["sse"] = Features["mmx"] = true;
1721 1722
1722 switch (CPU) { 1723 switch (CPU) {
1723 case CK_Generic: 1724 case CK_Generic:
1724 case CK_i386: 1725 case CK_i386:
1725 case CK_i486: 1726 case CK_i486:
1726 case CK_i586: 1727 case CK_i586:
1727 case CK_Pentium: 1728 case CK_Pentium:
1728 case CK_i686: 1729 case CK_i686:
1729 case CK_PentiumPro: 1730 case CK_PentiumPro:
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 it = std::find(Features.begin(), Features.end(), "-mmx"); 2083 it = std::find(Features.begin(), Features.end(), "-mmx");
2083 if (it != Features.end()) 2084 if (it != Features.end())
2084 Features.erase(it); 2085 Features.erase(it);
2085 } 2086 }
2086 2087
2087 /// X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro 2088 /// X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro
2088 /// definitions for this particular subtarget. 2089 /// definitions for this particular subtarget.
2089 void X86TargetInfo::getTargetDefines(const LangOptions &Opts, 2090 void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
2090 MacroBuilder &Builder) const { 2091 MacroBuilder &Builder) const {
2091 // Target identification. 2092 // Target identification.
2092 if (PointerWidth == 64) { 2093 if (getTriple().getArch() == llvm::Triple::x86_64) {
2093 Builder.defineMacro("__amd64__"); 2094 Builder.defineMacro("__amd64__");
2094 Builder.defineMacro("__amd64"); 2095 Builder.defineMacro("__amd64");
2095 Builder.defineMacro("__x86_64"); 2096 Builder.defineMacro("__x86_64");
2096 Builder.defineMacro("__x86_64__"); 2097 Builder.defineMacro("__x86_64__");
2097 } else { 2098 } else {
2098 DefineStd(Builder, "i386", Opts); 2099 DefineStd(Builder, "i386", Opts);
2099 } 2100 }
2100 2101
2101 // Subtarget options. 2102 // Subtarget options.
2102 // FIXME: We are hard-coding the tune parameters based on the CPU, but they 2103 // FIXME: We are hard-coding the tune parameters based on the CPU, but they
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 case SSE2: 2279 case SSE2:
2279 Builder.defineMacro("__SSE2__"); 2280 Builder.defineMacro("__SSE2__");
2280 Builder.defineMacro("__SSE2_MATH__"); // -mfp-math=sse always implied. 2281 Builder.defineMacro("__SSE2_MATH__"); // -mfp-math=sse always implied.
2281 case SSE1: 2282 case SSE1:
2282 Builder.defineMacro("__SSE__"); 2283 Builder.defineMacro("__SSE__");
2283 Builder.defineMacro("__SSE_MATH__"); // -mfp-math=sse always implied. 2284 Builder.defineMacro("__SSE_MATH__"); // -mfp-math=sse always implied.
2284 case NoSSE: 2285 case NoSSE:
2285 break; 2286 break;
2286 } 2287 }
2287 2288
2288 if (Opts.MicrosoftExt && PointerWidth == 32) { 2289 if (Opts.MicrosoftExt && getTriple().getArch() == llvm::Triple::x86) {
2289 switch (SSELevel) { 2290 switch (SSELevel) {
2290 case AVX2: 2291 case AVX2:
2291 case AVX: 2292 case AVX:
2292 case SSE42: 2293 case SSE42:
2293 case SSE41: 2294 case SSE41:
2294 case SSSE3: 2295 case SSSE3:
2295 case SSE3: 2296 case SSE3:
2296 case SSE2: 2297 case SSE2:
2297 Builder.defineMacro("_M_IX86_FP", Twine(2)); 2298 Builder.defineMacro("_M_IX86_FP", Twine(2));
2298 break; 2299 break;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 .Case("pclmul", HasPCLMUL) 2335 .Case("pclmul", HasPCLMUL)
2335 .Case("popcnt", HasPOPCNT) 2336 .Case("popcnt", HasPOPCNT)
2336 .Case("sse", SSELevel >= SSE1) 2337 .Case("sse", SSELevel >= SSE1)
2337 .Case("sse2", SSELevel >= SSE2) 2338 .Case("sse2", SSELevel >= SSE2)
2338 .Case("sse3", SSELevel >= SSE3) 2339 .Case("sse3", SSELevel >= SSE3)
2339 .Case("ssse3", SSELevel >= SSSE3) 2340 .Case("ssse3", SSELevel >= SSSE3)
2340 .Case("sse41", SSELevel >= SSE41) 2341 .Case("sse41", SSELevel >= SSE41)
2341 .Case("sse42", SSELevel >= SSE42) 2342 .Case("sse42", SSELevel >= SSE42)
2342 .Case("sse4a", HasSSE4a) 2343 .Case("sse4a", HasSSE4a)
2343 .Case("x86", true) 2344 .Case("x86", true)
2344 .Case("x86_32", PointerWidth == 32) 2345 .Case("x86_32", getTriple().getArch() == llvm::Triple::x86)
2345 .Case("x86_64", PointerWidth == 64) 2346 .Case("x86_64", getTriple().getArch() == llvm::Triple::x86_64)
2346 .Case("xop", HasXOP) 2347 .Case("xop", HasXOP)
2347 .Default(false); 2348 .Default(false);
2348 } 2349 }
2349 2350
2350 bool 2351 bool
2351 X86TargetInfo::validateAsmConstraint(const char *&Name, 2352 X86TargetInfo::validateAsmConstraint(const char *&Name,
2352 TargetInfo::ConstraintInfo &Info) const { 2353 TargetInfo::ConstraintInfo &Info) const {
2353 switch (*Name) { 2354 switch (*Name) {
2354 default: return false; 2355 default: return false;
2355 case 'Y': // first letter of a pair: 2356 case 'Y': // first letter of a pair:
(...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after
4540 // FIXME: If we are completely confident that we have the right set, we only 4541 // FIXME: If we are completely confident that we have the right set, we only
4541 // need to pass the minuses. 4542 // need to pass the minuses.
4542 Opts.Features.clear(); 4543 Opts.Features.clear();
4543 for (llvm::StringMap<bool>::const_iterator it = Features.begin(), 4544 for (llvm::StringMap<bool>::const_iterator it = Features.begin(),
4544 ie = Features.end(); it != ie; ++it) 4545 ie = Features.end(); it != ie; ++it)
4545 Opts.Features.push_back((it->second ? "+" : "-") + it->first().str()); 4546 Opts.Features.push_back((it->second ? "+" : "-") + it->first().str());
4546 Target->HandleTargetFeatures(Opts.Features); 4547 Target->HandleTargetFeatures(Opts.Features);
4547 4548
4548 return Target.take(); 4549 return Target.take();
4549 } 4550 }
OLDNEW
« no previous file with comments | « no previous file | lib/CodeGen/TargetInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698