clang 10.0.0git

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
40 RuntimeLibType GetDefaultRuntimeLibType() const override {
41 return ToolChain::RLT_CompilerRT;
42 }
43 CXXStdlibType GetDefaultCXXStdlibType() const override {
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
clang::driver::toolchains::BareMetal::isPICDefaultForced
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition: BareMetal.h:37
Tool.h
clang::driver::toolchains::BareMetal::GetDefaultRuntimeLibType
RuntimeLibType GetDefaultRuntimeLibType() const override
GetDefaultRuntimeLibType - Get the default runtime library variant to use.
Definition: BareMetal.h:40
clang::driver::toolchains::BareMetal::useIntegratedAs
bool useIntegratedAs() const override
Check if the toolchain should use the integrated assembler.
Definition: BareMetal.h:33
clang::driver::ToolChain::CXXStdlibType
CXXStdlibType
Definition: ToolChain.h:92
clang::driver::JobAction
Definition: Action.h:375
clang::driver::ToolChain::CST_Libcxx
Definition: ToolChain.h:93
clang::driver::InputInfo
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
clang::driver::ToolChain::RuntimeLibType
RuntimeLibType
Definition: ToolChain.h:97
clang::driver::tools::baremetal::Linker::isLinkJob
bool isLinkJob() const override
Definition: BareMetal.h:72
clang::driver::Driver
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:59
clang::driver::toolchains::BareMetal::getDefaultLinker
const char * getDefaultLinker() const override
GetDefaultLinker - Get the default linker to use.
Definition: BareMetal.h:47
clang::driver::toolchains::BareMetal::GetDefaultCXXStdlibType
CXXStdlibType GetDefaultCXXStdlibType() const override
Definition: BareMetal.h:43
clang::driver::toolchains::BareMetal::isPIEDefault
bool isPIEDefault() const override
Test whether this toolchain defaults to PIE.
Definition: BareMetal.h:36
ToolChain.h
llvm::SmallVector
Definition: LLVM.h:35
clang::driver::ToolChain::RLT_CompilerRT
Definition: ToolChain.h:98
clang::driver::Action::OffloadKind
OffloadKind
Definition: Action.h:84
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::driver::toolchains::BareMetal::isPICDefault
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: BareMetal.h:35
clang::driver::toolchains::BareMetal::SupportsProfiling
bool SupportsProfiling() const override
SupportsProfiling - Does this tool chain support -pg.
Definition: BareMetal.h:38
clang::driver::Tool
Tool - Information on a specific compilation tool.
Definition: Tool.h:33
clang::driver::tools::baremetal::Linker
Definition: BareMetal.h:69
clang::driver::Compilation
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
clang::driver::tools::baremetal::Linker::hasIntegratedCPP
bool hasIntegratedCPP() const override
Definition: BareMetal.h:73
clang::driver::toolchains::BareMetal
Definition: BareMetal.h:22
clang::driver::toolchains::BareMetal::isCrossCompiling
bool isCrossCompiling() const override
Returns true if the toolchain is targeting a non-native architecture.
Definition: BareMetal.h:34
clang::driver::tools::baremetal::Linker::Linker
Linker(const ToolChain &TC)
Definition: BareMetal.h:71
clang::driver::ToolChain
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:88