clang  6.0.0svn
BareMetal.h
Go to the documentation of this file.
1 //===--- BareMetal.h - Bare Metal Tool and ToolChain -------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_BAREMETAL_H
11 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_BAREMETAL_H
12 
13 #include "clang/Driver/Tool.h"
14 #include "clang/Driver/ToolChain.h"
15 
16 #include <string>
17 
18 namespace clang {
19 namespace driver {
20 
21 namespace toolchains {
22 
23 class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
24 public:
25  BareMetal(const Driver &D, const llvm::Triple &Triple,
26  const llvm::opt::ArgList &Args);
27  ~BareMetal() override;
28 
29  static bool handlesTarget(const llvm::Triple &Triple);
30 protected:
31  Tool *buildLinker() const override;
32 
33 public:
34  bool useIntegratedAs() const override { return true; }
35  bool isCrossCompiling() const override { return true; }
36  bool isPICDefault() const override { return false; }
37  bool isPIEDefault() const override { return false; }
38  bool isPICDefaultForced() const override { return false; }
39  bool SupportsProfiling() const override { return false; }
40 
43  }
45  return ToolChain::CST_Libcxx;
46  }
47 
48  const char *getDefaultLinker() const override { return "ld.lld"; }
49 
50  std::string getRuntimesDir() const;
51  void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
52  llvm::opt::ArgStringList &CC1Args) const override;
53  void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
54  llvm::opt::ArgStringList &CC1Args,
55  Action::OffloadKind DeviceOffloadKind) const override;
56  std::string findLibCxxIncludePath(ToolChain::CXXStdlibType LibType) const;
57  void AddClangCXXStdlibIncludeArgs(
58  const llvm::opt::ArgList &DriverArgs,
59  llvm::opt::ArgStringList &CC1Args) const override;
60  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
61  llvm::opt::ArgStringList &CmdArgs) const override;
62  void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
63  llvm::opt::ArgStringList &CmdArgs) const;
64 };
65 
66 } // namespace toolchains
67 
68 namespace tools {
69 namespace baremetal {
70 
71 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
72 public:
73  Linker(const ToolChain &TC) : Tool("baremetal::Linker", "ld.lld", TC) {}
74  bool isLinkJob() const override { return true; }
75  bool hasIntegratedCPP() const override { return false; }
76  void ConstructJob(Compilation &C, const JobAction &JA,
77  const InputInfo &Output, const InputInfoList &Inputs,
78  const llvm::opt::ArgList &TCArgs,
79  const char *LinkingOutput) const override;
80 };
81 
82 } // namespace baremetal
83 } // namespace tools
84 
85 } // namespace driver
86 } // namespace clang
87 
88 #endif
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition: BareMetal.h:38
RuntimeLibType GetDefaultRuntimeLibType() const override
GetDefaultRuntimeLibType - Get the default runtime library variant to use.
Definition: BareMetal.h:41
bool useIntegratedAs() const override
Check if the toolchain should use the integrated assembler.
Definition: BareMetal.h:34
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:23
bool isLinkJob() const override
Definition: BareMetal.h:74
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:65
const char * getDefaultLinker() const override
GetDefaultLinker - Get the default linker to use.
Definition: BareMetal.h:48
CXXStdlibType GetDefaultCXXStdlibType() const override
Definition: BareMetal.h:44
bool isPIEDefault() const override
Test whether this toolchain defaults to PIE.
Definition: BareMetal.h:37
Dataflow Directional Tag Classes.
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: BareMetal.h:36
bool SupportsProfiling() const override
SupportsProfiling - Does this tool chain support -pg.
Definition: BareMetal.h:39
Tool - Information on a specific compilation tool.
Definition: Tool.h:34
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:34
bool hasIntegratedCPP() const override
Definition: BareMetal.h:75
bool isCrossCompiling() const override
Returns true if the toolchain is targeting a non-native architecture.
Definition: BareMetal.h:35
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:73