1295016Sjkim//===--- Types.h - Input & Temporary Driver Types ---------------*- C++ -*-===//
2109998Smarkm//
3109998Smarkm// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4109998Smarkm// See https://llvm.org/LICENSE.txt for license information.
5109998Smarkm// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6109998Smarkm//
7109998Smarkm//===----------------------------------------------------------------------===//
8109998Smarkm
9109998Smarkm#ifndef LLVM_CLANG_DRIVER_TYPES_H
10109998Smarkm#define LLVM_CLANG_DRIVER_TYPES_H
11109998Smarkm
12109998Smarkm#include "clang/Driver/Phases.h"
13109998Smarkm#include "llvm/ADT/SmallVector.h"
14109998Smarkm#include "llvm/Option/ArgList.h"
15109998Smarkm
16109998Smarkmnamespace llvm {
17109998Smarkmclass StringRef;
18109998Smarkm}
19109998Smarkmnamespace clang {
20109998Smarkmnamespace driver {
21109998Smarkmclass Driver;
22109998Smarkmnamespace types {
23109998Smarkm  enum ID {
24109998Smarkm    TY_INVALID,
25109998Smarkm#define TYPE(NAME, ID, PP_TYPE, TEMP_SUFFIX, ...) TY_##ID,
26109998Smarkm#include "clang/Driver/Types.def"
27109998Smarkm#undef TYPE
28109998Smarkm    TY_LAST
29109998Smarkm  };
30109998Smarkm
31109998Smarkm  /// getTypeName - Return the name of the type for \p Id.
32109998Smarkm  const char *getTypeName(ID Id);
33109998Smarkm
34109998Smarkm  /// getPreprocessedType - Get the ID of the type for this input when
35109998Smarkm  /// it has been preprocessed, or INVALID if this input is not
36109998Smarkm  /// preprocessed.
37109998Smarkm  ID getPreprocessedType(ID Id);
38109998Smarkm
39109998Smarkm  /// getPrecompiledType - Get the ID of the type for this input when
40109998Smarkm  /// it has been precompiled, or INVALID if this input is not
41109998Smarkm  /// precompiled.
42238405Sjkim  ID getPrecompiledType(ID Id);
43280304Sjkim
44109998Smarkm  /// getTypeTempSuffix - Return the suffix to use when creating a
45109998Smarkm  /// temp file of this type, or null if unspecified.
46109998Smarkm  const char *getTypeTempSuffix(ID Id, bool CLStyle = false);
47109998Smarkm
48109998Smarkm  /// onlyPrecompileType - Should this type only be precompiled.
49109998Smarkm  bool onlyPrecompileType(ID Id);
50109998Smarkm
51109998Smarkm  /// canTypeBeUserSpecified - Can this type be specified on the
52109998Smarkm  /// command line (by the type name); this is used when forwarding
53162911Ssimon  /// commands to gcc.
54109998Smarkm  bool canTypeBeUserSpecified(ID Id);
55109998Smarkm
56109998Smarkm  /// appendSuffixForType - When generating outputs of this type,
57109998Smarkm  /// should the suffix be appended (instead of replacing the existing
58109998Smarkm  /// suffix).
59109998Smarkm  bool appendSuffixForType(ID Id);
60109998Smarkm
61109998Smarkm  /// canLipoType - Is this type acceptable as the output of a
62109998Smarkm  /// universal build (currently, just the Nothing, Image, and Object
63109998Smarkm  /// types).
64109998Smarkm  bool canLipoType(ID Id);
65109998Smarkm
66109998Smarkm  /// isAcceptedByClang - Can clang handle this input type.
67109998Smarkm  bool isAcceptedByClang(ID Id);
68109998Smarkm
69109998Smarkm  /// isAcceptedByFlang - Can flang handle this input type.
70109998Smarkm  bool isAcceptedByFlang(ID Id);
71109998Smarkm
72109998Smarkm  /// isDerivedFromC - Is the input derived from C.
73109998Smarkm  ///
74109998Smarkm  /// That is, does the lexer follow the rules of
75109998Smarkm  /// TokenConcatenation::AvoidConcat. If this is the case, the preprocessor may
76109998Smarkm  /// add and remove whitespace between tokens. Used to determine whether the
77109998Smarkm  /// input can be processed by -fminimize-whitespace.
78109998Smarkm  bool isDerivedFromC(ID Id);
79109998Smarkm
80109998Smarkm  /// isCXX - Is this a "C++" input (C++ and Obj-C++ sources and headers).
81109998Smarkm  bool isCXX(ID Id);
82109998Smarkm
83109998Smarkm  /// Is this LLVM IR.
84109998Smarkm  bool isLLVMIR(ID Id);
85109998Smarkm
86109998Smarkm  /// isCuda - Is this a CUDA input.
87109998Smarkm  bool isCuda(ID Id);
88109998Smarkm
89109998Smarkm  /// isHIP - Is this a HIP input.
90109998Smarkm  bool isHIP(ID Id);
91109998Smarkm
92109998Smarkm  /// isObjC - Is this an "ObjC" input (Obj-C and Obj-C++ sources and headers).
93109998Smarkm  bool isObjC(ID Id);
94109998Smarkm
95109998Smarkm  /// isOpenCL - Is this an "OpenCL" input.
96109998Smarkm  bool isOpenCL(ID Id);
97109998Smarkm
98109998Smarkm  /// isHLSL - Is this an HLSL input.
99109998Smarkm  bool isHLSL(ID Id);
100109998Smarkm
101109998Smarkm  /// isSrcFile - Is this a source file, i.e. something that still has to be
102109998Smarkm  /// preprocessed. The logic behind this is the same that decides if the first
103109998Smarkm  /// compilation phase is a preprocessing one.
104109998Smarkm  bool isSrcFile(ID Id);
105109998Smarkm
106109998Smarkm  /// lookupTypeForExtension - Lookup the type to use for the file
107109998Smarkm  /// extension \p Ext.
108109998Smarkm  ID lookupTypeForExtension(llvm::StringRef Ext);
109109998Smarkm
110109998Smarkm  /// lookupTypeForTypSpecifier - Lookup the type to use for a user
111109998Smarkm  /// specified type name.
112109998Smarkm  ID lookupTypeForTypeSpecifier(const char *Name);
113109998Smarkm
114109998Smarkm  /// getCompilationPhases - Get the list of compilation phases ('Phases') to be
115109998Smarkm  /// done for type 'Id' up until including LastPhase.
116109998Smarkm  llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases>
117109998Smarkm  getCompilationPhases(ID Id, phases::ID LastPhase = phases::IfsMerge);
118109998Smarkm  llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases>
119109998Smarkm  getCompilationPhases(const clang::driver::Driver &Driver,
120109998Smarkm                       llvm::opt::DerivedArgList &DAL, ID Id);
121109998Smarkm
122109998Smarkm  /// lookupCXXTypeForCType - Lookup CXX input type that corresponds to given
123109998Smarkm  /// C type (used for clang++ emulation of g++ behaviour)
124109998Smarkm  ID lookupCXXTypeForCType(ID Id);
125109998Smarkm
126109998Smarkm  /// Lookup header file input type that corresponds to given
127109998Smarkm  /// source file type (used for clang-cl emulation of \Yc).
128109998Smarkm  ID lookupHeaderTypeForSourceType(ID Id);
129109998Smarkm
130109998Smarkm} // end namespace types
131109998Smarkm} // end namespace driver
132109998Smarkm} // end namespace clang
133109998Smarkm
134109998Smarkm#endif
135109998Smarkm