10b57cec5SDimitry Andric //===--- Hexagon.h - Hexagon ToolChain Implementations ----------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H 100b57cec5SDimitry Andric #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H 110b57cec5SDimitry Andric 120b57cec5SDimitry Andric #include "Linux.h" 130b57cec5SDimitry Andric #include "clang/Driver/Tool.h" 140b57cec5SDimitry Andric #include "clang/Driver/ToolChain.h" 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric namespace clang { 170b57cec5SDimitry Andric namespace driver { 180b57cec5SDimitry Andric namespace tools { 190b57cec5SDimitry Andric namespace hexagon { 200b57cec5SDimitry Andric // For Hexagon, we do not need to instantiate tools for PreProcess, PreCompile 210b57cec5SDimitry Andric // and Compile. 220b57cec5SDimitry Andric // We simply use "clang -cc1" for those actions. 23*5f757f3fSDimitry Andric class LLVM_LIBRARY_VISIBILITY Assembler final : public Tool { 240b57cec5SDimitry Andric public: 250b57cec5SDimitry Andric Assembler(const ToolChain &TC) 265ffd83dbSDimitry Andric : Tool("hexagon::Assembler", "hexagon-as", TC) {} 270b57cec5SDimitry Andric 280b57cec5SDimitry Andric bool hasIntegratedCPP() const override { return false; } 290b57cec5SDimitry Andric 300b57cec5SDimitry Andric void RenderExtraToolArgs(const JobAction &JA, 310b57cec5SDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 320b57cec5SDimitry Andric void ConstructJob(Compilation &C, const JobAction &JA, 330b57cec5SDimitry Andric const InputInfo &Output, const InputInfoList &Inputs, 340b57cec5SDimitry Andric const llvm::opt::ArgList &TCArgs, 350b57cec5SDimitry Andric const char *LinkingOutput) const override; 360b57cec5SDimitry Andric }; 370b57cec5SDimitry Andric 38*5f757f3fSDimitry Andric class LLVM_LIBRARY_VISIBILITY Linker final : public Tool { 390b57cec5SDimitry Andric public: 405ffd83dbSDimitry Andric Linker(const ToolChain &TC) : Tool("hexagon::Linker", "hexagon-ld", TC) {} 410b57cec5SDimitry Andric 420b57cec5SDimitry Andric bool hasIntegratedCPP() const override { return false; } 430b57cec5SDimitry Andric bool isLinkJob() const override { return true; } 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric virtual void RenderExtraToolArgs(const JobAction &JA, 460b57cec5SDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 470b57cec5SDimitry Andric void ConstructJob(Compilation &C, const JobAction &JA, 480b57cec5SDimitry Andric const InputInfo &Output, const InputInfoList &Inputs, 490b57cec5SDimitry Andric const llvm::opt::ArgList &TCArgs, 500b57cec5SDimitry Andric const char *LinkingOutput) const override; 510b57cec5SDimitry Andric }; 520b57cec5SDimitry Andric 5306c3fb27SDimitry Andric void getHexagonTargetFeatures(const Driver &D, const llvm::Triple &Triple, 5406c3fb27SDimitry Andric const llvm::opt::ArgList &Args, 550b57cec5SDimitry Andric std::vector<StringRef> &Features); 560b57cec5SDimitry Andric 570b57cec5SDimitry Andric } // end namespace hexagon. 580b57cec5SDimitry Andric } // end namespace tools 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric namespace toolchains { 610b57cec5SDimitry Andric 620b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY HexagonToolChain : public Linux { 630b57cec5SDimitry Andric protected: 640b57cec5SDimitry Andric GCCVersion GCCLibAndIncVersion; 650b57cec5SDimitry Andric Tool *buildAssembler() const override; 660b57cec5SDimitry Andric Tool *buildLinker() const override; 670b57cec5SDimitry Andric 680b57cec5SDimitry Andric unsigned getOptimizationLevel(const llvm::opt::ArgList &DriverArgs) const; 690b57cec5SDimitry Andric 700b57cec5SDimitry Andric public: 710b57cec5SDimitry Andric HexagonToolChain(const Driver &D, const llvm::Triple &Triple, 720b57cec5SDimitry Andric const llvm::opt::ArgList &Args); 730b57cec5SDimitry Andric ~HexagonToolChain() override; 740b57cec5SDimitry Andric 750b57cec5SDimitry Andric void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, 760b57cec5SDimitry Andric llvm::opt::ArgStringList &CC1Args, 770b57cec5SDimitry Andric Action::OffloadKind DeviceOffloadKind) const override; 780b57cec5SDimitry Andric void 790b57cec5SDimitry Andric AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, 800b57cec5SDimitry Andric llvm::opt::ArgStringList &CC1Args) const override; 810b57cec5SDimitry Andric void addLibStdCxxIncludePaths( 820b57cec5SDimitry Andric const llvm::opt::ArgList &DriverArgs, 830b57cec5SDimitry Andric llvm::opt::ArgStringList &CC1Args) const override; 840b57cec5SDimitry Andric 855ffd83dbSDimitry Andric void addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, 865ffd83dbSDimitry Andric llvm::opt::ArgStringList &CC1Args) const override; 875ffd83dbSDimitry Andric 885ffd83dbSDimitry Andric const char *getDefaultLinker() const override { 895ffd83dbSDimitry Andric return getTriple().isMusl() ? "ld.lld" : "hexagon-link"; 905ffd83dbSDimitry Andric } 910b57cec5SDimitry Andric 920b57cec5SDimitry Andric CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override; 930b57cec5SDimitry Andric 945ffd83dbSDimitry Andric void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, 955ffd83dbSDimitry Andric llvm::opt::ArgStringList &CmdArgs) const override; 965ffd83dbSDimitry Andric 970b57cec5SDimitry Andric StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; } 980b57cec5SDimitry Andric 990b57cec5SDimitry Andric std::string getHexagonTargetDir( 1000b57cec5SDimitry Andric const std::string &InstalledDir, 1010b57cec5SDimitry Andric const SmallVectorImpl<std::string> &PrefixDirs) const; 1020b57cec5SDimitry Andric void getHexagonLibraryPaths(const llvm::opt::ArgList &Args, 1030b57cec5SDimitry Andric ToolChain::path_list &LibPaths) const; 1040b57cec5SDimitry Andric 105349cc55cSDimitry Andric std::string getCompilerRTPath() const override; 106349cc55cSDimitry Andric 1070b57cec5SDimitry Andric static bool isAutoHVXEnabled(const llvm::opt::ArgList &Args); 108349cc55cSDimitry Andric static StringRef GetDefaultCPU(); 109349cc55cSDimitry Andric static StringRef GetTargetCPUVersion(const llvm::opt::ArgList &Args); 1100b57cec5SDimitry Andric 111bdd1243dSDimitry Andric static std::optional<unsigned> 112bdd1243dSDimitry Andric getSmallDataThreshold(const llvm::opt::ArgList &Args); 1130b57cec5SDimitry Andric }; 1140b57cec5SDimitry Andric 1150b57cec5SDimitry Andric } // end namespace toolchains 1160b57cec5SDimitry Andric } // end namespace driver 1170b57cec5SDimitry Andric } // end namespace clang 1180b57cec5SDimitry Andric 1190b57cec5SDimitry Andric #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H 120