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

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: aligment 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 | no next file » | 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->LongWidth = this->LongAlign =
2852 this->PointerWidth = this->PointerAlign = 32;
nlewycky 2011/08/23 21:22:26 I don't think this is worth saving two lines :)
krasin 2011/08/23 22:12:30 Done.
2853 this->IntMaxType = TargetInfo::SignedLongLong;
2854 this->UIntMaxType = TargetInfo::UnsignedLongLong;
2855 this->Int64Type = TargetInfo::SignedLongLong;
2856 this->SizeType = TargetInfo::UnsignedInt;
2857 DescriptionString = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
2858 "f32:32:32-f64:64:64-p:32:32:32-v128:32:32";
2859 }
2860
2861 void getDefaultFeatures(const std::string &CPU,
2862 llvm::StringMap<bool> &Features) const {
2863 }
2864 virtual void getArchDefines(const LangOptions &Opts,
nlewycky 2011/08/23 21:22:26 Do you really want to leave this blank? __PNACL32_
krasin 2011/08/23 22:12:30 You're right. PNaCl gcc defines __pnacl__. Clang a
2865 MacroBuilder &Builder) const {
nlewycky 2011/08/23 21:22:26 whitespace
krasin 2011/08/23 22:12:30 Done.
2866 }
2867 virtual void getTargetDefines(const LangOptions &Opts,
2868 MacroBuilder &Builder) const {
2869 Builder.defineMacro("__native_client__");
2870 }
2871 virtual void getTargetBuiltins(const Builtin::Info *&Records,
2872 unsigned &NumRecords) const {
2873 }
2874 virtual const char *getVAListDeclaration() const {
2875 return "typedef void* __builtin_va_list;";
2876 }
2877 virtual void getGCCRegNames(const char * const *&Names,
2878 unsigned &NumNames) const;
2879 virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
2880 unsigned &NumAliases) const;
2881 virtual bool validateAsmConstraint(const char *&Name,
2882 TargetInfo::ConstraintInfo &Info) const {
2883 return false;
2884 }
2885
2886 virtual const char *getClobbers() const {
2887 return "";
2888 }
2889 };
2890
2891 void PNaClTargetInfo::getGCCRegNames(const char * const *&Names,
2892 unsigned &NumNames) const {
nlewycky 2011/08/23 21:22:26 whitespace
krasin 2011/08/23 22:12:30 Done.
2893 Names = NULL;
2894 NumNames = 0;
2895 }
2896
2897 void PNaClTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases,
2898 unsigned &NumAliases) const {
nlewycky 2011/08/23 21:22:26 whitespace
krasin 2011/08/23 22:12:30 Done.
2899 Aliases = NULL;
2900 NumAliases = 0;
2901 }
2902 } // end anonymous namespace.
2903
2904
2846 //===----------------------------------------------------------------------===// 2905 //===----------------------------------------------------------------------===//
2847 // Driver code 2906 // Driver code
2848 //===----------------------------------------------------------------------===// 2907 //===----------------------------------------------------------------------===//
2849 2908
2850 static TargetInfo *AllocateTarget(const std::string &T) { 2909 static TargetInfo *AllocateTarget(const std::string &T) {
2851 llvm::Triple Triple(T); 2910 llvm::Triple Triple(T);
2852 llvm::Triple::OSType os = Triple.getOS(); 2911 llvm::Triple::OSType os = Triple.getOS();
2853 2912
2854 switch (Triple.getArch()) { 2913 switch (Triple.getArch()) {
2855 default: 2914 default:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2905 return new LinuxTargetInfo<MipselTargetInfo>(T); 2964 return new LinuxTargetInfo<MipselTargetInfo>(T);
2906 case llvm::Triple::RTEMS: 2965 case llvm::Triple::RTEMS:
2907 return new RTEMSTargetInfo<MipselTargetInfo>(T); 2966 return new RTEMSTargetInfo<MipselTargetInfo>(T);
2908 case llvm::Triple::FreeBSD: 2967 case llvm::Triple::FreeBSD:
2909 return new FreeBSDTargetInfo<MipselTargetInfo>(T); 2968 return new FreeBSDTargetInfo<MipselTargetInfo>(T);
2910 case llvm::Triple::NetBSD: 2969 case llvm::Triple::NetBSD:
2911 return new NetBSDTargetInfo<MipselTargetInfo>(T); 2970 return new NetBSDTargetInfo<MipselTargetInfo>(T);
2912 default: 2971 default:
2913 return new MipsTargetInfo(T); 2972 return new MipsTargetInfo(T);
2914 } 2973 }
2974 case llvm::Triple::le32:
nlewycky 2011/08/23 21:22:26 Please add a blank line above.
krasin 2011/08/23 22:12:30 Done.
2975 switch (os) {
2976 case llvm::Triple::NativeClient:
2977 return new PNaClTargetInfo(T);
2978 default:
2979 return NULL;
2980 }
2915 2981
2916 case llvm::Triple::ppc: 2982 case llvm::Triple::ppc:
2917 if (Triple.isOSDarwin()) 2983 if (Triple.isOSDarwin())
2918 return new DarwinPPC32TargetInfo(T); 2984 return new DarwinPPC32TargetInfo(T);
2919 switch (os) { 2985 switch (os) {
2920 case llvm::Triple::FreeBSD: 2986 case llvm::Triple::FreeBSD:
2921 return new FreeBSDTargetInfo<PPC32TargetInfo>(T); 2987 return new FreeBSDTargetInfo<PPC32TargetInfo>(T);
2922 case llvm::Triple::NetBSD: 2988 case llvm::Triple::NetBSD:
2923 return new NetBSDTargetInfo<PPC32TargetInfo>(T); 2989 return new NetBSDTargetInfo<PPC32TargetInfo>(T);
2924 case llvm::Triple::RTEMS: 2990 case llvm::Triple::RTEMS:
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
3092 // need to pass the minuses. 3158 // need to pass the minuses.
3093 Opts.Features.clear(); 3159 Opts.Features.clear();
3094 for (llvm::StringMap<bool>::const_iterator it = Features.begin(), 3160 for (llvm::StringMap<bool>::const_iterator it = Features.begin(),
3095 ie = Features.end(); it != ie; ++it) 3161 ie = Features.end(); it != ie; ++it)
3096 Opts.Features.push_back(std::string(it->second ? "+" : "-") + 3162 Opts.Features.push_back(std::string(it->second ? "+" : "-") +
3097 it->first().str()); 3163 it->first().str());
3098 Target->HandleTargetFeatures(Opts.Features); 3164 Target->HandleTargetFeatures(Opts.Features);
3099 3165
3100 return Target.take(); 3166 return Target.take();
3101 } 3167 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698