clang: include/clang/Basic/OpenCLOptions.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CLANG_BASIC_OPENCLOPTIONS_H

15#define LLVM_CLANG_BASIC_OPENCLOPTIONS_H

16

18#include "llvm/ADT/StringMap.h"

19

21

22class DiagnosticsEngine;

23class TargetInfo;

24

25namespace {

26

27

28

29enum OpenCLVersionID : unsigned int {

30 OCL_C_10 = 0x1,

31 OCL_C_11 = 0x2,

32 OCL_C_12 = 0x4,

33 OCL_C_20 = 0x8,

34 OCL_C_30 = 0x10,

35 OCL_C_ALL = 0x1f,

36 OCL_C_11P = OCL_C_ALL ^ OCL_C_10,

37 OCL_C_12P = OCL_C_ALL ^ (OCL_C_10 | OCL_C_11),

38};

39

40static inline OpenCLVersionID encodeOpenCLVersion(unsigned OpenCLVersion) {

41 switch (OpenCLVersion) {

42 default:

43 llvm_unreachable("Unknown OpenCL version code");

44 case 100:

45 return OCL_C_10;

46 case 110:

47 return OCL_C_11;

48 case 120:

49 return OCL_C_12;

50 case 200:

51 return OCL_C_20;

52 case 300:

53 return OCL_C_30;

54 }

55}

56

57

58

59static inline bool isOpenCLVersionContainedInMask(const LangOptions &LO,

60 unsigned Mask) {

61 auto CLVer = LO.getOpenCLCompatibleVersion();

62 OpenCLVersionID Code = encodeOpenCLVersion(CLVer);

63 return Mask & Code;

64}

65

66}

67

68

70

71public:

72

73

74

75

76

77

78

79

80

84 isSupported("__opencl_c_program_scope_global_variables", Opts));

85 }

86

88

90

91

93

94

96

97

99

100

102

103

105

108 unsigned OptV)

110

112

114

115

117

119 }

120

121

123 return isAvailableIn(LO) && isOpenCLVersionContainedInMask(LO, Core);

124 }

125

126

128 return isAvailableIn(LO) && isOpenCLVersionContainedInMask(LO, Opt);

129 }

130 };

131

132 bool isKnown(llvm::StringRef Ext) const;

133

134

135

136

138

139 bool isWithPragma(llvm::StringRef Ext) const;

140

141

142

144

145

146

148

149

150

153

154

155

158

159

160

162

163

164

165

166 void acceptsPragma(llvm::StringRef Ext, bool V = true);

167

168 void enable(llvm::StringRef Ext, bool V = true);

169

170

171

172

173 void support(llvm::StringRef Ext, bool V = true);

174

176

177

178 void addSupport(const llvm::StringMap &FeaturesMap,

180

181

183

186

188

189 template <typename... Args>

192 }

193

194 template <typename... Args>

196 Args &&... args) {

198 }

199

200

201

204

205

206

209

210private:

211

212 bool isEnabled(llvm::StringRef Ext) const;

213

215};

216

217}

218

219#endif

static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag)

Defines the clang::LangOptions interface.

Reads an AST files chain containing the contents of a translation unit.

Writes an AST file containing the contents of a translation unit.

Concrete class used by the front-end to report problems and issues.

Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...

unsigned getOpenCLCompatibleVersion() const

Return the OpenCL version that kernel language is compatible with.

OpenCL supported extensions and optional core features.

bool isAvailableOption(llvm::StringRef Ext, const LangOptions &LO) const

static bool diagnoseUnsupportedFeatureDependencies(const TargetInfo &TI, DiagnosticsEngine &Diags)

bool isSupportedExtension(llvm::StringRef Ext, const LangOptions &LO) const

void enable(llvm::StringRef Ext, bool V=true)

bool isWithPragma(llvm::StringRef Ext) const

bool isSupportedCore(llvm::StringRef Ext, const LangOptions &LO) const

static bool diagnoseFeatureExtensionDifferences(const TargetInfo &TI, DiagnosticsEngine &Diags)

bool isSupportedCoreOrOptionalCore(llvm::StringRef Ext, const LangOptions &LO) const

bool isSupportedOptionalCore(llvm::StringRef Ext, const LangOptions &LO) const

void addSupport(const llvm::StringMap< bool > &FeaturesMap, const LangOptions &Opts)

llvm::StringMap< OpenCLOptionInfo > OpenCLOptionInfoMap

bool isSupported(llvm::StringRef Ext, const LangOptions &LO) const

void acceptsPragma(llvm::StringRef Ext, bool V=true)

bool areProgramScopeVariablesSupported(const LangOptions &Opts) const

bool isKnown(llvm::StringRef Ext) const

static bool isOpenCLOptionCoreIn(const LangOptions &LO, Args &&... args)

static bool isOpenCLOptionAvailableIn(const LangOptions &LO, Args &&... args)

Exposes information about the current target.

The JSON file list parser is used to communicate input to InstallAPI.

bool isOptionalCoreIn(const LangOptions &LO) const

bool isCoreIn(const LangOptions &LO) const

bool isOptionalCore() const

OpenCLOptionInfo(bool Pragma, unsigned AvailV, unsigned CoreV, unsigned OptV)

OpenCLOptionInfo()=default

bool isAvailableIn(const LangOptions &LO) const