[cfe-commits] [cfe-dev] [patch] fix for TCE support

Chris Lattner clattner at apple.com
Wed Mar 3 13:08:11 PST 2010


On Mar 1, 2010, at 6:12 AM, Pekka Jääskeläinen wrote:

> Hello,
> 
> Attached patch fixes TCE support of Clang for the current
> trunk version. Tests pass.

Hi Pekka, the patch looks good to me, please commit.  If you don't have commit access, please send it to me as a non-inline attachment and I'll apply it for you, thanks.

-Chris

> 
> Best regards,
> -- 
> Pekka
> http://tce.cs.tut.fi
> Index: include/clang/Driver/HostInfo.h
> ===================================================================
> --- include/clang/Driver/HostInfo.h	(revision 97443)
> +++ include/clang/Driver/HostInfo.h	(working copy)
> @@ -80,6 +80,8 @@
>                                         const llvm::Triple& Triple);
> const HostInfo *createLinuxHostInfo(const Driver &D,
>                                     const llvm::Triple& Triple);
> +const HostInfo *createTCEHostInfo(const Driver &D, 
> +                                  const llvm::Triple& Triple);
> const HostInfo *createUnknownHostInfo(const Driver &D,
>                                       const llvm::Triple& Triple);
> 
> Index: lib/Basic/Targets.cpp
> ===================================================================
> --- lib/Basic/Targets.cpp	(revision 97443)
> +++ lib/Basic/Targets.cpp	(working copy)
> @@ -1892,9 +1892,10 @@
>       FloatFormat = &llvm::APFloat::IEEEsingle;
>       DoubleFormat = &llvm::APFloat::IEEEsingle;
>       LongDoubleFormat = &llvm::APFloat::IEEEsingle;
> -      DescriptionString = "E-p:32:32:32-a0:32:32"
> -                          "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64"
> -                          "-f32:32:32-f64:32:64-n32";
> +      DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:32-"
> +                          "i16:16:32-i32:32:32-i64:32:64-"
> +                          "f32:32:32-f64:64:64-v64:64:64-"
> +                          "v128:128:128-a0:0:64";
>     }
> 
>     virtual void getTargetDefines(const LangOptions &Opts,
> Index: lib/Driver/ToolChains.cpp
> ===================================================================
> --- lib/Driver/ToolChains.cpp	(revision 97443)
> +++ lib/Driver/ToolChains.cpp	(working copy)
> @@ -728,6 +728,67 @@
>   return new DerivedArgList(Args, true);
> }
> 
> +
> +/// TCEToolChain - A tool chain using the llvm bitcode tools to perform
> +/// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
> +/// Currently does not support anything else but compilation.
> +
> +TCEToolChain::TCEToolChain(const HostInfo &Host, const llvm::Triple& Triple)
> +  : ToolChain(Host, Triple) 
> +{
> +  // Path mangling to find libexec
> +  std::string Path(getDriver().Dir);
> +
> +  Path += "/../libexec";
> +  getProgramPaths().push_back(Path);
> +}
> +
> +TCEToolChain::~TCEToolChain() {
> +  for (llvm::DenseMap<unsigned, Tool*>::iterator
> +           it = Tools.begin(), ie = Tools.end(); it != ie; ++it)
> +      delete it->second;
> +}
> +
> +bool TCEToolChain::IsMathErrnoDefault() const { 
> +  return true; 
> +}
> +
> +bool TCEToolChain::IsUnwindTablesDefault() const {
> +  return false;
> +}
> +
> +const char *TCEToolChain::GetDefaultRelocationModel() const {
> +  return "static";
> +}
> +
> +const char *TCEToolChain::GetForcedPicModel() const {
> +  return 0;
> +}
> +
> +Tool &TCEToolChain::SelectTool(const Compilation &C, 
> +                            const JobAction &JA) const {
> +  Action::ActionClass Key;
> +  Key = Action::AnalyzeJobClass;
> +
> +  Tool *&T = Tools[Key];
> +  if (!T) {
> +    switch (Key) {
> +    case Action::PreprocessJobClass:
> +      T = new tools::gcc::Preprocess(*this); break;
> +    case Action::AnalyzeJobClass:
> +      T = new tools::Clang(*this); break;
> +    default:
> +     assert(false && "Unsupported action for TCE target.");
> +    }
> +  }
> +  return *T;
> +}
> +
> +DerivedArgList *TCEToolChain::TranslateArgs(InputArgList &Args,
> +                                            const char *BoundArch) const {
> +  return new DerivedArgList(Args, true);
> +}
> +
> /// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly.
> 
> OpenBSD::OpenBSD(const HostInfo &Host, const llvm::Triple& Triple)
> Index: lib/Driver/ToolChains.h
> ===================================================================
> --- lib/Driver/ToolChains.h	(revision 97443)
> +++ lib/Driver/ToolChains.h	(working copy)
> @@ -267,6 +267,26 @@
> };
> 
> 
> +/// TCEToolChain - A tool chain using the llvm bitcode tools to perform
> +/// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
> +class VISIBILITY_HIDDEN TCEToolChain : public ToolChain {
> +public:
> +  TCEToolChain(const HostInfo &Host, const llvm::Triple& Triple);
> +  ~TCEToolChain();
> +
> +  virtual DerivedArgList *TranslateArgs(InputArgList &Args,
> +                                        const char *BoundArch) const;
> +  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
> +  bool IsMathErrnoDefault() const;
> +  bool IsUnwindTablesDefault() const;
> +  const char* GetDefaultRelocationModel() const;
> +  const char* GetForcedPicModel() const;
> +
> +private:
> +  mutable llvm::DenseMap<unsigned, Tool*> Tools;
> +
> +};
> +
> } // end namespace toolchains
> } // end namespace driver
> } // end namespace clang
> Index: lib/Driver/HostInfo.cpp
> ===================================================================
> --- lib/Driver/HostInfo.cpp	(revision 97443)
> +++ lib/Driver/HostInfo.cpp	(working copy)
> @@ -157,6 +157,46 @@
>   return TC;
> }
> 
> +// TCE Host Info
> +
> +/// TCEHostInfo - TCE host information implementation (see http://tce.cs.tut.fi)
> +class TCEHostInfo : public HostInfo {
> +
> +public:
> +  TCEHostInfo(const Driver &D, const llvm::Triple &Triple);
> +  ~TCEHostInfo() {};
> +
> +  virtual bool useDriverDriver() const;
> +
> +  virtual types::ID lookupTypeForExtension(const char *Ext) const {
> +    types::ID Ty = types::lookupTypeForExtension(Ext);
> +
> +    if (Ty == types::TY_PP_Asm)
> +      return types::TY_Asm;
> +
> +    return Ty;
> +  }
> +
> +  virtual ToolChain *CreateToolChain(const ArgList &Args, 
> +                                     const char *ArchName) const;
> +};
> +
> +TCEHostInfo::TCEHostInfo(const Driver &D, const llvm::Triple& Triple)
> +  : HostInfo(D, Triple) {
> +}
> +
> +bool TCEHostInfo::useDriverDriver() const { 
> +  return false;
> +}
> +
> +ToolChain *TCEHostInfo::CreateToolChain(const ArgList &Args, 
> +                                        const char *ArchName) const {
> +  llvm::Triple TCTriple(getTriple());
> +//  TCTriple.setArchName(ArchName);
> +  return new toolchains::TCEToolChain(*this, TCTriple);
> +}
> +
> +
> // Unknown Host Info
> 
> /// UnknownHostInfo - Generic host information to use for unknown hosts.
> @@ -536,6 +576,12 @@
> }
> 
> const HostInfo *
> +clang::driver::createTCEHostInfo(const Driver &D,
> +                                   const llvm::Triple& Triple) {
> +  return new TCEHostInfo(D, Triple);
> +}
> +
> +const HostInfo *
> clang::driver::createUnknownHostInfo(const Driver &D,
>                                      const llvm::Triple& Triple) {
>   return new UnknownHostInfo(D, Triple);
> Index: lib/Driver/Driver.cpp
> ===================================================================
> --- lib/Driver/Driver.cpp	(revision 97443)
> +++ lib/Driver/Driver.cpp	(working copy)
> @@ -1145,6 +1145,10 @@
>   llvm::PrettyStackTraceString CrashInfo("Constructing host");
>   llvm::Triple Triple(TripleStr);
> 
> +  // TCE is an osless target
> +  if (Triple.getArchName() == "tce")
> +    return createTCEHostInfo(*this, Triple); 
> +
>   switch (Triple.getOS()) {
>   case llvm::Triple::AuroraUX:
>     return createAuroraUXHostInfo(*this, Triple);
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-commits mailing list