From 49991683091dd4affa4264b38ad41abb6312c57b Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Thu, 21 Feb 2008 16:29:08 +0000 Subject: [PATCH] Added classes SolarisTargetInfo and SolarisSparcV8TargetInfo to be able to handle "sparc-" triple prefixes. Please be aware that this is a minimal kludge, that pretty much duplicates the features of DarwinPowerPCTargetInfo, and also incorrectly uses stuff from the PPC namespace. But in result "make test" now passes a lot of tests, the notable exceptions being the objc rewrite tests and mandel.c. llvm-svn: 47436 --- clang/Basic/Targets.cpp | 67 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/clang/Basic/Targets.cpp b/clang/Basic/Targets.cpp index fec849986612..6888d44f5efc 100644 --- a/clang/Basic/Targets.cpp +++ b/clang/Basic/Targets.cpp @@ -65,6 +65,31 @@ public: } }; + + +class SolarisTargetInfo : public TargetInfoImpl { +public: + SolarisTargetInfo(const std::string& triple) : TargetInfoImpl(triple) {} + + virtual void getTargetDefines(std::vector &Defs) const { +// FIXME: we need a real target configuration system. For now, only define +// __SUN__ if the host has it. +#ifdef __SUN__ + Define(Defs, "__SUN__"); + Define(Defs, "__SOLARIS__"); +#endif + + if (1) {// -fobjc-gc controls this. + Define(Defs, "__weak", ""); + Define(Defs, "__strong", ""); + } else { + Define(Defs, "__weak", "__attribute__((objc_gc(weak)))"); + Define(Defs, "__strong", "__attribute__((objc_gc(strong)))"); + Define(Defs, "__OBJC_GC__"); + } + } + +}; } // end anonymous namespace. @@ -632,6 +657,46 @@ public: }; } // end anonymous namespace. +namespace { +class SolarisSparcV8TargetInfo : public SolarisTargetInfo { +public: + SolarisSparcV8TargetInfo(const std::string& triple) : SolarisTargetInfo(triple) {} + + virtual void getTargetDefines(std::vector &Defines) const { + SolarisTargetInfo::getTargetDefines(Defines); +// getSparcDefines(Defines, false); + Define(Defines, "__sparc"); + Define(Defines, "__sparcv8"); + } + virtual void getTargetBuiltins(const Builtin::Info *&Records, + unsigned &NumRecords) const { + PPC::getBuiltins(Records, NumRecords); + } + virtual const char *getVAListDeclaration() const { + return getPPCVAListDeclaration(); + } + virtual const char *getTargetPrefix() const { + return PPC::getTargetPrefix(); + } + virtual void getGCCRegNames(const char * const *&Names, + unsigned &NumNames) const { + PPC::getGCCRegNames(Names, NumNames); + } + virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, + unsigned &NumAliases) const { + PPC::getGCCRegAliases(Aliases, NumAliases); + } + virtual bool validateAsmConstraint(char c, + TargetInfo::ConstraintInfo &info) const { + return PPC::validateAsmConstraint(c, info); + } + virtual const char *getClobbers() const { + return PPC::getClobbers(); + } +}; + +} // end anonymous namespace. + namespace { class LinuxTargetInfo : public DarwinTargetInfo { public: @@ -690,6 +755,8 @@ static TargetInfoImpl *CreateTarget(const std::string& T) { return new DarwinPPCTargetInfo(T); else if (T.find("ppc64-") == 0 || T.find("powerpc64-") == 0) return new DarwinPPC64TargetInfo(T); + else if (T.find("sparc-") == 0) + return new SolarisSparcV8TargetInfo(T); // ugly hack else if (T.find("x86_64-") == 0) return new DarwinX86_64TargetInfo(T); else if (IsX86(T))