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

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

Issue 7717004: Add PNaCl TargetInfo to Clang (Closed) Base URL: http://llvm.org/svn/llvm-project/cfe/trunk/
Patch Set: test long double as well Created 9 years, 3 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 | test/Driver/le32-unknown-nacl.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 2825 matching lines...) Expand 10 before | Expand all | Expand 10 after
2836 MacroBuilder &Builder) const { 2836 MacroBuilder &Builder) const {
2837 DefineStd(Builder, "mips", Opts); 2837 DefineStd(Builder, "mips", Opts);
2838 Builder.defineMacro("_mips"); 2838 Builder.defineMacro("_mips");
2839 DefineStd(Builder, "MIPSEL", Opts); 2839 DefineStd(Builder, "MIPSEL", Opts);
2840 Builder.defineMacro("_MIPSEL"); 2840 Builder.defineMacro("_MIPSEL");
2841 Builder.defineMacro("__REGISTER_PREFIX__", ""); 2841 Builder.defineMacro("__REGISTER_PREFIX__", "");
2842 getArchDefines(Opts, Builder); 2842 getArchDefines(Opts, Builder);
2843 } 2843 }
2844 } // end anonymous namespace. 2844 } // end anonymous namespace.
2845 2845
2846 namespace {
2847 class PNaClTargetInfo : public TargetInfo {
2848 public:
2849 PNaClTargetInfo(const std::string& triple) : TargetInfo(triple) {
2850 this->UserLabelPrefix = "";
2851 this->LongAlign = 32;
2852 this->LongWidth = 32;
2853 this->PointerAlign = 32;
2854 this->PointerWidth = 32;
2855 this->IntMaxType = TargetInfo::SignedLongLong;
2856 this->UIntMaxType = TargetInfo::UnsignedLongLong;
2857 this->Int64Type = TargetInfo::SignedLongLong;
2858 this->SizeType = TargetInfo::UnsignedInt;
2859 DescriptionString = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
2860 "f32:32:32-f64:64:64-p:32:32:32-v128:32:32";
2861 }
2862
2863 void getDefaultFeatures(const std::string &CPU,
2864 llvm::StringMap<bool> &Features) const {
2865 }
2866 virtual void getArchDefines(const LangOptions &Opts,
2867 MacroBuilder &Builder) const {
2868 Builder.defineMacro("__le32__");
2869 Builder.defineMacro("__pnacl__");
2870 }
2871 virtual void getTargetDefines(const LangOptions &Opts,
2872 MacroBuilder &Builder) const {
2873 Builder.defineMacro("__native_client__");
2874 getArchDefines(Opts, Builder);
2875 }
2876 virtual void getTargetBuiltins(const Builtin::Info *&Records,
2877 unsigned &NumRecords) const {
2878 }
2879 virtual const char *getVAListDeclaration() const {
2880 return "typedef struct __va_list_tag {"
2881 " void* ptr;"
2882 " void* padding1;"
2883 " void* padding2;"
2884 " void* padding3;"
2885 "} __builtin_va_list[1];";
2886 }
2887 virtual void getGCCRegNames(const char * const *&Names,
2888 unsigned &NumNames) const;
2889 virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
2890 unsigned &NumAliases) const;
2891 virtual bool validateAsmConstraint(const char *&Name,
2892 TargetInfo::ConstraintInfo &Info) const {
2893 return false;
2894 }
2895
2896 virtual const char *getClobbers() const {
2897 return "";
2898 }
2899 };
2900
2901 void PNaClTargetInfo::getGCCRegNames(const char * const *&Names,
2902 unsigned &NumNames) const {
2903 Names = NULL;
2904 NumNames = 0;
2905 }
2906
2907 void PNaClTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases,
2908 unsigned &NumAliases) const {
2909 Aliases = NULL;
2910 NumAliases = 0;
2911 }
2912 } // end anonymous namespace.
2913
2914
2846 //===----------------------------------------------------------------------===// 2915 //===----------------------------------------------------------------------===//
2847 // Driver code 2916 // Driver code
2848 //===----------------------------------------------------------------------===// 2917 //===----------------------------------------------------------------------===//
2849 2918
2850 static TargetInfo *AllocateTarget(const std::string &T) { 2919 static TargetInfo *AllocateTarget(const std::string &T) {
2851 llvm::Triple Triple(T); 2920 llvm::Triple Triple(T);
2852 llvm::Triple::OSType os = Triple.getOS(); 2921 llvm::Triple::OSType os = Triple.getOS();
2853 2922
2854 switch (Triple.getArch()) { 2923 switch (Triple.getArch()) {
2855 default: 2924 default:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 case llvm::Triple::RTEMS: 2975 case llvm::Triple::RTEMS:
2907 return new RTEMSTargetInfo<MipselTargetInfo>(T); 2976 return new RTEMSTargetInfo<MipselTargetInfo>(T);
2908 case llvm::Triple::FreeBSD: 2977 case llvm::Triple::FreeBSD:
2909 return new FreeBSDTargetInfo<MipselTargetInfo>(T); 2978 return new FreeBSDTargetInfo<MipselTargetInfo>(T);
2910 case llvm::Triple::NetBSD: 2979 case llvm::Triple::NetBSD:
2911 return new NetBSDTargetInfo<MipselTargetInfo>(T); 2980 return new NetBSDTargetInfo<MipselTargetInfo>(T);
2912 default: 2981 default:
2913 return new MipsTargetInfo(T); 2982 return new MipsTargetInfo(T);
2914 } 2983 }
2915 2984
2985 case llvm::Triple::le32:
2986 switch (os) {
2987 case llvm::Triple::NativeClient:
2988 return new PNaClTargetInfo(T);
2989 default:
2990 return NULL;
2991 }
2992
2916 case llvm::Triple::ppc: 2993 case llvm::Triple::ppc:
2917 if (Triple.isOSDarwin()) 2994 if (Triple.isOSDarwin())
2918 return new DarwinPPC32TargetInfo(T); 2995 return new DarwinPPC32TargetInfo(T);
2919 switch (os) { 2996 switch (os) {
2920 case llvm::Triple::FreeBSD: 2997 case llvm::Triple::FreeBSD:
2921 return new FreeBSDTargetInfo<PPC32TargetInfo>(T); 2998 return new FreeBSDTargetInfo<PPC32TargetInfo>(T);
2922 case llvm::Triple::NetBSD: 2999 case llvm::Triple::NetBSD:
2923 return new NetBSDTargetInfo<PPC32TargetInfo>(T); 3000 return new NetBSDTargetInfo<PPC32TargetInfo>(T);
2924 case llvm::Triple::RTEMS: 3001 case llvm::Triple::RTEMS:
2925 return new RTEMSTargetInfo<PPC32TargetInfo>(T); 3002 return new RTEMSTargetInfo<PPC32TargetInfo>(T);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
3092 // need to pass the minuses. 3169 // need to pass the minuses.
3093 Opts.Features.clear(); 3170 Opts.Features.clear();
3094 for (llvm::StringMap<bool>::const_iterator it = Features.begin(), 3171 for (llvm::StringMap<bool>::const_iterator it = Features.begin(),
3095 ie = Features.end(); it != ie; ++it) 3172 ie = Features.end(); it != ie; ++it)
3096 Opts.Features.push_back(std::string(it->second ? "+" : "-") + 3173 Opts.Features.push_back(std::string(it->second ? "+" : "-") +
3097 it->first().str()); 3174 it->first().str());
3098 Target->HandleTargetFeatures(Opts.Features); 3175 Target->HandleTargetFeatures(Opts.Features);
3099 3176
3100 return Target.take(); 3177 return Target.take();
3101 } 3178 }
OLDNEW
« no previous file with comments | « no previous file | test/Driver/le32-unknown-nacl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698