1 //===--- AVR.h - AVR Tool and ToolChain Implementations ---------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AVR_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AVR_H
11 
12 #include "Gnu.h"
13 #include "clang/Driver/InputInfo.h"
14 #include "clang/Driver/ToolChain.h"
15 #include "clang/Driver/Tool.h"
16 
17 namespace clang {
18 namespace driver {
19 namespace toolchains {
20 
21 class LLVM_LIBRARY_VISIBILITY AVRToolChain : public Generic_ELF {
22 public:
23   AVRToolChain(const Driver &D, const llvm::Triple &Triple,
24                const llvm::opt::ArgList &Args);
25   void
26   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
27                             llvm::opt::ArgStringList &CC1Args) const override;
28 
29 protected:
30   Tool *buildLinker() const override;
31 
32 private:
33   /// Whether libgcc, libct, and friends should be linked.
34   ///
35   /// This is not done if the user does not specify a
36   /// microcontroller on the command line.
37   bool LinkStdlib;
38 
39   llvm::Optional<std::string> findAVRLibcInstallation() const;
40 };
41 
42 } // end namespace toolchains
43 
44 namespace tools {
45 namespace AVR {
46 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
47 public:
Linker(const llvm::Triple & Triple,const ToolChain & TC,bool LinkStdlib)48   Linker(const llvm::Triple &Triple, const ToolChain &TC, bool LinkStdlib)
49       : Tool("AVR::Linker", "avr-ld", TC), Triple(Triple),
50         LinkStdlib(LinkStdlib) {}
51 
hasIntegratedCPP()52   bool hasIntegratedCPP() const override { return false; }
isLinkJob()53   bool isLinkJob() const override { return true; }
54   void ConstructJob(Compilation &C, const JobAction &JA,
55                     const InputInfo &Output, const InputInfoList &Inputs,
56                     const llvm::opt::ArgList &TCArgs,
57                     const char *LinkingOutput) const override;
58 
59 protected:
60   const llvm::Triple &Triple;
61   bool LinkStdlib;
62 };
63 } // end namespace AVR
64 } // end namespace tools
65 } // end namespace driver
66 } // end namespace clang
67 
68 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AVR_H
69