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