10b57cec5SDimitry Andric //===--- Tool.h - Compilation Tools -----------------------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #ifndef LLVM_CLANG_DRIVER_TOOL_H
100b57cec5SDimitry Andric #define LLVM_CLANG_DRIVER_TOOL_H
110b57cec5SDimitry Andric 
120b57cec5SDimitry Andric #include "clang/Basic/LLVM.h"
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric namespace llvm {
150b57cec5SDimitry Andric namespace opt {
160b57cec5SDimitry Andric   class ArgList;
170b57cec5SDimitry Andric }
180b57cec5SDimitry Andric }
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric namespace clang {
210b57cec5SDimitry Andric namespace driver {
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric   class Compilation;
240b57cec5SDimitry Andric   class InputInfo;
250b57cec5SDimitry Andric   class Job;
260b57cec5SDimitry Andric   class JobAction;
270b57cec5SDimitry Andric   class ToolChain;
280b57cec5SDimitry Andric 
290b57cec5SDimitry Andric   typedef SmallVector<InputInfo, 4> InputInfoList;
300b57cec5SDimitry Andric 
310b57cec5SDimitry Andric /// Tool - Information on a specific compilation tool.
320b57cec5SDimitry Andric class Tool {
330b57cec5SDimitry Andric   /// The tool name (for debugging).
340b57cec5SDimitry Andric   const char *Name;
350b57cec5SDimitry Andric 
360b57cec5SDimitry Andric   /// The human readable name for the tool, for use in diagnostics.
370b57cec5SDimitry Andric   const char *ShortName;
380b57cec5SDimitry Andric 
390b57cec5SDimitry Andric   /// The tool chain this tool is a part of.
400b57cec5SDimitry Andric   const ToolChain &TheToolChain;
410b57cec5SDimitry Andric 
420b57cec5SDimitry Andric public:
435ffd83dbSDimitry Andric   Tool(const char *Name, const char *ShortName, const ToolChain &TC);
440b57cec5SDimitry Andric 
450b57cec5SDimitry Andric public:
460b57cec5SDimitry Andric   virtual ~Tool();
470b57cec5SDimitry Andric 
getName()480b57cec5SDimitry Andric   const char *getName() const { return Name; }
490b57cec5SDimitry Andric 
getShortName()500b57cec5SDimitry Andric   const char *getShortName() const { return ShortName; }
510b57cec5SDimitry Andric 
getToolChain()520b57cec5SDimitry Andric   const ToolChain &getToolChain() const { return TheToolChain; }
530b57cec5SDimitry Andric 
hasIntegratedAssembler()540b57cec5SDimitry Andric   virtual bool hasIntegratedAssembler() const { return false; }
hasIntegratedBackend()550eae32dcSDimitry Andric   virtual bool hasIntegratedBackend() const { return true; }
canEmitIR()560b57cec5SDimitry Andric   virtual bool canEmitIR() const { return false; }
570b57cec5SDimitry Andric   virtual bool hasIntegratedCPP() const = 0;
isLinkJob()580b57cec5SDimitry Andric   virtual bool isLinkJob() const { return false; }
isDsymutilJob()590b57cec5SDimitry Andric   virtual bool isDsymutilJob() const { return false; }
600b57cec5SDimitry Andric 
610b57cec5SDimitry Andric   /// Does this tool have "good" standardized diagnostics, or should the
620b57cec5SDimitry Andric   /// driver add an additional "command failed" diagnostic on failures.
hasGoodDiagnostics()630b57cec5SDimitry Andric   virtual bool hasGoodDiagnostics() const { return false; }
640b57cec5SDimitry Andric 
650b57cec5SDimitry Andric   /// ConstructJob - Construct jobs to perform the action \p JA,
660b57cec5SDimitry Andric   /// writing to \p Output and with \p Inputs, and add the jobs to
670b57cec5SDimitry Andric   /// \p C.
680b57cec5SDimitry Andric   ///
690b57cec5SDimitry Andric   /// \param TCArgs - The argument list for this toolchain, with any
700b57cec5SDimitry Andric   /// tool chain specific translations applied.
710b57cec5SDimitry Andric   /// \param LinkingOutput - If this output will eventually feed the
720b57cec5SDimitry Andric   /// linker, then this is the final output name of the linked image.
730b57cec5SDimitry Andric   virtual void ConstructJob(Compilation &C, const JobAction &JA,
740b57cec5SDimitry Andric                             const InputInfo &Output,
750b57cec5SDimitry Andric                             const InputInfoList &Inputs,
760b57cec5SDimitry Andric                             const llvm::opt::ArgList &TCArgs,
770b57cec5SDimitry Andric                             const char *LinkingOutput) const = 0;
780b57cec5SDimitry Andric   /// Construct jobs to perform the action \p JA, writing to the \p Outputs and
790b57cec5SDimitry Andric   /// with \p Inputs, and add the jobs to \p C. The default implementation
800b57cec5SDimitry Andric   /// assumes a single output and is expected to be overloaded for the tools
810b57cec5SDimitry Andric   /// that support multiple inputs.
820b57cec5SDimitry Andric   ///
830b57cec5SDimitry Andric   /// \param TCArgs The argument list for this toolchain, with any
840b57cec5SDimitry Andric   /// tool chain specific translations applied.
850b57cec5SDimitry Andric   /// \param LinkingOutput If this output will eventually feed the
860b57cec5SDimitry Andric   /// linker, then this is the final output name of the linked image.
870b57cec5SDimitry Andric   virtual void ConstructJobMultipleOutputs(Compilation &C, const JobAction &JA,
880b57cec5SDimitry Andric                                            const InputInfoList &Outputs,
890b57cec5SDimitry Andric                                            const InputInfoList &Inputs,
900b57cec5SDimitry Andric                                            const llvm::opt::ArgList &TCArgs,
910b57cec5SDimitry Andric                                            const char *LinkingOutput) const;
920b57cec5SDimitry Andric };
930b57cec5SDimitry Andric 
940b57cec5SDimitry Andric } // end namespace driver
950b57cec5SDimitry Andric } // end namespace clang
960b57cec5SDimitry Andric 
970b57cec5SDimitry Andric #endif
98