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

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: fix hardcoded path Created 9 years, 4 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 void* __builtin_va_list;";
jvoung - send to chromium... 2011/08/24 18:04:11 Should va_list be something more like what is docu
krasin 2011/08/24 18:06:15 I believe so. In fact, I have derived this particu
krasin 2011/08/24 19:33:17 Done.
2881 }
2882 virtual void getGCCRegNames(const char * const *&Names,
2883 unsigned &NumNames) const;
2884 virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
2885 unsigned &NumAliases) const;
2886 virtual bool validateAsmConstraint(const char *&Name,
2887 TargetInfo::ConstraintInfo &Info) const {
2888 return false;
2889 }
2890
2891 virtual const char *getClobbers() const {
2892 return "";
2893 }
2894 };
2895
2896 void PNaClTargetInfo::getGCCRegNames(const char * const *&Names,
2897 unsigned &NumNames) const {
2898 Names = NULL;
2899 NumNames = 0;
2900 }
2901
2902 void PNaClTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases,
2903 unsigned &NumAliases) const {
2904 Aliases = NULL;
2905 NumAliases = 0;
2906 }
2907 } // end anonymous namespace.
2908
2909
2846 //===----------------------------------------------------------------------===// 2910 //===----------------------------------------------------------------------===//
2847 // Driver code 2911 // Driver code
2848 //===----------------------------------------------------------------------===// 2912 //===----------------------------------------------------------------------===//
2849 2913
2850 static TargetInfo *AllocateTarget(const std::string &T) { 2914 static TargetInfo *AllocateTarget(const std::string &T) {
2851 llvm::Triple Triple(T); 2915 llvm::Triple Triple(T);
2852 llvm::Triple::OSType os = Triple.getOS(); 2916 llvm::Triple::OSType os = Triple.getOS();
2853 2917
2854 switch (Triple.getArch()) { 2918 switch (Triple.getArch()) {
2855 default: 2919 default:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 case llvm::Triple::RTEMS: 2970 case llvm::Triple::RTEMS:
2907 return new RTEMSTargetInfo<MipselTargetInfo>(T); 2971 return new RTEMSTargetInfo<MipselTargetInfo>(T);
2908 case llvm::Triple::FreeBSD: 2972 case llvm::Triple::FreeBSD:
2909 return new FreeBSDTargetInfo<MipselTargetInfo>(T); 2973 return new FreeBSDTargetInfo<MipselTargetInfo>(T);
2910 case llvm::Triple::NetBSD: 2974 case llvm::Triple::NetBSD:
2911 return new NetBSDTargetInfo<MipselTargetInfo>(T); 2975 return new NetBSDTargetInfo<MipselTargetInfo>(T);
2912 default: 2976 default:
2913 return new MipsTargetInfo(T); 2977 return new MipsTargetInfo(T);
2914 } 2978 }
2915 2979
2980 case llvm::Triple::le32:
2981 switch (os) {
2982 case llvm::Triple::NativeClient:
2983 return new PNaClTargetInfo(T);
2984 default:
2985 return NULL;
2986 }
2987
2916 case llvm::Triple::ppc: 2988 case llvm::Triple::ppc:
2917 if (Triple.isOSDarwin()) 2989 if (Triple.isOSDarwin())
2918 return new DarwinPPC32TargetInfo(T); 2990 return new DarwinPPC32TargetInfo(T);
2919 switch (os) { 2991 switch (os) {
2920 case llvm::Triple::FreeBSD: 2992 case llvm::Triple::FreeBSD:
2921 return new FreeBSDTargetInfo<PPC32TargetInfo>(T); 2993 return new FreeBSDTargetInfo<PPC32TargetInfo>(T);
2922 case llvm::Triple::NetBSD: 2994 case llvm::Triple::NetBSD:
2923 return new NetBSDTargetInfo<PPC32TargetInfo>(T); 2995 return new NetBSDTargetInfo<PPC32TargetInfo>(T);
2924 case llvm::Triple::RTEMS: 2996 case llvm::Triple::RTEMS:
2925 return new RTEMSTargetInfo<PPC32TargetInfo>(T); 2997 return new RTEMSTargetInfo<PPC32TargetInfo>(T);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
3092 // need to pass the minuses. 3164 // need to pass the minuses.
3093 Opts.Features.clear(); 3165 Opts.Features.clear();
3094 for (llvm::StringMap<bool>::const_iterator it = Features.begin(), 3166 for (llvm::StringMap<bool>::const_iterator it = Features.begin(),
3095 ie = Features.end(); it != ie; ++it) 3167 ie = Features.end(); it != ie; ++it)
3096 Opts.Features.push_back(std::string(it->second ? "+" : "-") + 3168 Opts.Features.push_back(std::string(it->second ? "+" : "-") +
3097 it->first().str()); 3169 it->first().str());
3098 Target->HandleTargetFeatures(Opts.Features); 3170 Target->HandleTargetFeatures(Opts.Features);
3099 3171
3100 return Target.take(); 3172 return Target.take();
3101 } 3173 }
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