17330f729Sjoerg //===--- BareMetal.h - Bare Metal Tool and ToolChain -------------*- C++ -*-===// 27330f729Sjoerg // 37330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 47330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information. 57330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 67330f729Sjoerg // 77330f729Sjoerg //===----------------------------------------------------------------------===// 87330f729Sjoerg 97330f729Sjoerg #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_BAREMETAL_H 107330f729Sjoerg #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_BAREMETAL_H 117330f729Sjoerg 127330f729Sjoerg #include "clang/Driver/Tool.h" 137330f729Sjoerg #include "clang/Driver/ToolChain.h" 147330f729Sjoerg 157330f729Sjoerg #include <string> 167330f729Sjoerg 177330f729Sjoerg namespace clang { 187330f729Sjoerg namespace driver { 197330f729Sjoerg 207330f729Sjoerg namespace toolchains { 217330f729Sjoerg 227330f729Sjoerg class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain { 237330f729Sjoerg public: 247330f729Sjoerg BareMetal(const Driver &D, const llvm::Triple &Triple, 257330f729Sjoerg const llvm::opt::ArgList &Args); 26*e038c9c4Sjoerg ~BareMetal() override = default; 277330f729Sjoerg 287330f729Sjoerg static bool handlesTarget(const llvm::Triple &Triple); 29*e038c9c4Sjoerg 30*e038c9c4Sjoerg void findMultilibs(const Driver &D, const llvm::Triple &Triple, 31*e038c9c4Sjoerg const llvm::opt::ArgList &Args); 32*e038c9c4Sjoerg 337330f729Sjoerg protected: 347330f729Sjoerg Tool *buildLinker() const override; 357330f729Sjoerg 36*e038c9c4Sjoerg std::string buildCompilerRTBasename(const llvm::opt::ArgList &Args, 37*e038c9c4Sjoerg StringRef Component, 38*e038c9c4Sjoerg FileType Type = ToolChain::FT_Static, 39*e038c9c4Sjoerg bool AddArch = true) const override; 40*e038c9c4Sjoerg 417330f729Sjoerg public: useIntegratedAs()427330f729Sjoerg bool useIntegratedAs() const override { return true; } isCrossCompiling()437330f729Sjoerg bool isCrossCompiling() const override { return true; } isPICDefault()447330f729Sjoerg bool isPICDefault() const override { return false; } isPIEDefault()457330f729Sjoerg bool isPIEDefault() const override { return false; } isPICDefaultForced()467330f729Sjoerg bool isPICDefaultForced() const override { return false; } SupportsProfiling()477330f729Sjoerg bool SupportsProfiling() const override { return false; } 487330f729Sjoerg getOSLibName()49*e038c9c4Sjoerg StringRef getOSLibName() const override { return "baremetal"; } 50*e038c9c4Sjoerg 51*e038c9c4Sjoerg std::string getCompilerRTPath() const override; 52*e038c9c4Sjoerg GetDefaultRuntimeLibType()537330f729Sjoerg RuntimeLibType GetDefaultRuntimeLibType() const override { 547330f729Sjoerg return ToolChain::RLT_CompilerRT; 557330f729Sjoerg } GetDefaultCXXStdlibType()567330f729Sjoerg CXXStdlibType GetDefaultCXXStdlibType() const override { 577330f729Sjoerg return ToolChain::CST_Libcxx; 587330f729Sjoerg } 597330f729Sjoerg getDefaultLinker()607330f729Sjoerg const char *getDefaultLinker() const override { return "ld.lld"; } 617330f729Sjoerg 627330f729Sjoerg std::string getRuntimesDir() const; 637330f729Sjoerg void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, 647330f729Sjoerg llvm::opt::ArgStringList &CC1Args) const override; 657330f729Sjoerg void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, 667330f729Sjoerg llvm::opt::ArgStringList &CC1Args, 677330f729Sjoerg Action::OffloadKind DeviceOffloadKind) const override; 687330f729Sjoerg void AddClangCXXStdlibIncludeArgs( 697330f729Sjoerg const llvm::opt::ArgList &DriverArgs, 707330f729Sjoerg llvm::opt::ArgStringList &CC1Args) const override; 717330f729Sjoerg void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, 727330f729Sjoerg llvm::opt::ArgStringList &CmdArgs) const override; 737330f729Sjoerg void AddLinkRuntimeLib(const llvm::opt::ArgList &Args, 747330f729Sjoerg llvm::opt::ArgStringList &CmdArgs) const; 75*e038c9c4Sjoerg std::string computeSysRoot() const override; 767330f729Sjoerg }; 777330f729Sjoerg 787330f729Sjoerg } // namespace toolchains 797330f729Sjoerg 807330f729Sjoerg namespace tools { 817330f729Sjoerg namespace baremetal { 827330f729Sjoerg 837330f729Sjoerg class LLVM_LIBRARY_VISIBILITY Linker : public Tool { 847330f729Sjoerg public: Linker(const ToolChain & TC)857330f729Sjoerg Linker(const ToolChain &TC) : Tool("baremetal::Linker", "ld.lld", TC) {} isLinkJob()867330f729Sjoerg bool isLinkJob() const override { return true; } hasIntegratedCPP()877330f729Sjoerg bool hasIntegratedCPP() const override { return false; } 887330f729Sjoerg void ConstructJob(Compilation &C, const JobAction &JA, 897330f729Sjoerg const InputInfo &Output, const InputInfoList &Inputs, 907330f729Sjoerg const llvm::opt::ArgList &TCArgs, 917330f729Sjoerg const char *LinkingOutput) const override; 927330f729Sjoerg }; 937330f729Sjoerg 947330f729Sjoerg } // namespace baremetal 957330f729Sjoerg } // namespace tools 967330f729Sjoerg 977330f729Sjoerg } // namespace driver 987330f729Sjoerg } // namespace clang 997330f729Sjoerg 1007330f729Sjoerg #endif 101