• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//===-- ACC.td - OpenACC directive definition file ---------*- tablegen -*-===//
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// This is the definition file for OpenACC 3.1 directives and clauses.
10//
11//===----------------------------------------------------------------------===//
12
13include "llvm/Frontend/Directive/DirectiveBase.td"
14
15//===----------------------------------------------------------------------===//
16// Definition of general OpenACC information
17//===----------------------------------------------------------------------===//
18
19def OpenACC : DirectiveLanguage {
20  let name = "OpenACC";
21  let cppNamespace = "acc"; // final namespace will be llvm::acc
22  let directivePrefix = "ACCD_";
23  let clausePrefix = "ACCC_";
24  let makeEnumAvailableInNamespace = true;
25  let enableBitmaskEnumInNamespace = true;
26  let includeHeader = "llvm/Frontend/OpenACC/ACC.h.inc";
27  let clauseEnumSetClass = "AccClauseSet";
28  let flangClauseBaseClass = "AccClause";
29}
30
31//===----------------------------------------------------------------------===//
32// Definition of OpenACC clauses
33//===----------------------------------------------------------------------===//
34
35// 2.16.1
36def ACCC_Async : Clause<"async"> {
37  let flangClassValue = "ScalarIntExpr";
38  let isValueOptional = true;
39}
40
41// 2.9.7
42def ACCC_Auto : Clause<"auto"> {}
43
44// 2.7.12
45def ACCC_Attach : Clause<"attach"> {
46  let flangClassValue = "AccObjectList";
47}
48
49// 2.15.1
50def ACCC_Bind : Clause<"bind"> {
51  let flangClassValue = "Name";
52}
53
54// 2.12
55def ACCC_Capture : Clause<"capture"> {
56}
57
58// 2.9.1
59def ACCC_Collapse : Clause<"collapse"> {
60  let flangClassValue = "ScalarIntConstantExpr";
61}
62
63// 2.7.6
64def ACCC_Copy : Clause<"copy"> {
65  let flangClassValue = "AccObjectList";
66}
67// 2.7.7
68def ACCC_Copyin : Clause<"copyin"> {
69  let flangClassValue = "AccObjectListWithModifier";
70}
71
72// 2.7.8
73def ACCC_Copyout : Clause<"copyout"> {
74  let flangClassValue = "AccObjectListWithModifier";
75}
76
77// 2.7.9
78def ACCC_Create : Clause<"create"> {
79  let flangClassValue = "AccObjectListWithModifier";
80}
81
82// 2.5.15
83def ACCC_Default : Clause<"default"> {
84  let flangClassValue = "AccDefaultClause";
85}
86
87// 2.14.3
88def ACCC_DefaultAsync : Clause<"default_async"> {
89  let flangClassValue = "ScalarIntExpr";
90}
91
92// 2.7.11
93def ACCC_Delete : Clause<"delete"> {
94  let flangClassValue = "AccObjectList";
95}
96
97// 2.7.13
98def ACCC_Detach : Clause<"detach"> {
99  let flangClassValue = "AccObjectList";
100}
101
102// 2.14.4
103def ACCC_Device : Clause<"device"> {
104  let flangClassValue = "AccObjectList";
105}
106
107// 2.14.1 - 2.14.2
108def ACCC_DeviceNum : Clause<"device_num">  {
109  let flangClassValue = "ScalarIntExpr";
110}
111
112// 2.7.4
113def ACCC_DevicePtr : Clause<"deviceptr"> {
114  let flangClassValue = "AccObjectList";
115}
116
117// 2.13.1
118def ACCC_DeviceResident : Clause<"device_resident"> {
119  let flangClassValue = "AccObjectList";
120}
121
122// 2.4
123def ACCC_DeviceType : Clause<"device_type"> {
124  let flangClassValue = "ScalarIntExpr";
125  let defaultValue = "*";
126  let isValueOptional = true;
127  let isValueList = true;
128}
129
130// 2.6.6
131def ACCC_Finalize : Clause<"finalize"> {}
132
133// 2.5.13
134def ACCC_FirstPrivate : Clause<"firstprivate"> {
135  let flangClassValue = "AccObjectList";
136}
137
138// 2.9.2
139def ACCC_Gang : Clause<"gang"> {
140  let flangClassValue = "AccGangArgument";
141  let isValueOptional = true;
142}
143
144// 2.14.4
145def ACCC_Host : Clause<"host"> {
146  let flangClassValue = "AccObjectList";
147}
148
149// 2.5.5
150def ACCC_If : Clause <"if"> {
151  let flangClassValue = "ScalarLogicalExpr";
152}
153
154// 2.14.4
155def ACCC_IfPresent : Clause<"if_present"> {}
156
157// 2.9.6
158def ACCC_Independent : Clause<"independent"> {}
159
160// 2.13.3
161def ACCC_Link : Clause<"link"> {
162  let flangClassValue = "AccObjectList";
163}
164
165// 2.7.10
166def ACCC_NoCreate : Clause<"no_create"> {
167  let flangClassValue = "AccObjectList";
168}
169
170// 2.15.1
171def ACCC_NoHost : Clause<"nohost"> {}
172
173// 2.5.9
174def ACCC_NumGangs : Clause<"num_gangs"> {
175  let flangClassValue = "ScalarIntExpr";
176}
177
178// 2.5.10
179def ACCC_NumWorkers : Clause<"num_workers"> {
180  let flangClassValue = "ScalarIntExpr";
181}
182
183// 2.7.5
184def ACCC_Present : Clause<"present"> {
185  let flangClassValue = "AccObjectList";
186}
187
188// 2.5.12
189def ACCC_Private : Clause<"private"> {
190  let flangClassValue = "AccObjectList";
191}
192
193// 2.9.8
194def ACCC_Tile : Clause <"tile"> {
195  let flangClassValue = "AccTileExprList";
196}
197
198// 2.8.1
199def ACCC_UseDevice : Clause <"use_device"> {
200  let flangClassValue = "AccObjectList";
201}
202
203// 2.12
204def ACCC_Read : Clause<"read"> {}
205
206// 2.5.14
207def ACCC_Reduction : Clause<"reduction"> {
208  let flangClassValue = "AccObjectListWithReduction";
209}
210
211// 2.5.6
212def ACCC_Self : Clause<"self"> {
213  let flangClassValue = "AccSelfClause";
214}
215
216// 2.9.5
217def ACCC_Seq : Clause<"seq"> {}
218
219// 2.9.4
220def ACCC_Vector : Clause<"vector"> {
221  let flangClassValue = "ScalarIntExpr";
222  let isValueOptional = true;
223}
224
225// 2.5.11
226def ACCC_VectorLength : Clause<"vector_length"> {
227  let flangClassValue = "ScalarIntExpr";
228}
229
230// 2.16.2
231def ACCC_Wait : Clause<"wait"> {
232  let flangClassValue = "AccWaitArgument";
233  let isValueOptional = true;
234}
235
236// 2.9.3
237def ACCC_Worker: Clause<"worker"> {
238  let flangClassValue = "ScalarIntExpr";
239  let isValueOptional = true;
240}
241
242// 2.12
243def ACCC_Write : Clause<"write"> {}
244
245def ACCC_Unknown : Clause<"unknown"> {
246  let isDefault = true;
247}
248
249//===----------------------------------------------------------------------===//
250// Definition of OpenACC directives
251//===----------------------------------------------------------------------===//
252
253// 2.12
254def ACC_Atomic : Directive<"atomic"> {}
255
256// 2.6.5
257def ACC_Data : Directive<"data"> {
258  let allowedOnceClauses = [
259    VersionedClause<ACCC_If>,
260    VersionedClause<ACCC_Default>
261  ];
262  let requiredClauses = [
263    VersionedClause<ACCC_Attach>,
264    VersionedClause<ACCC_Copy>,
265    VersionedClause<ACCC_Copyin>,
266    VersionedClause<ACCC_Copyout>,
267    VersionedClause<ACCC_Create>,
268    VersionedClause<ACCC_Default>,
269    VersionedClause<ACCC_DevicePtr>,
270    VersionedClause<ACCC_NoCreate>,
271    VersionedClause<ACCC_Present>
272  ];
273}
274
275// 2.13
276def ACC_Declare : Directive<"declare"> {
277  let allowedClauses = [
278    VersionedClause<ACCC_Copy>,
279    VersionedClause<ACCC_Copyin>,
280    VersionedClause<ACCC_Copyout>,
281    VersionedClause<ACCC_Create>,
282    VersionedClause<ACCC_Present>,
283    VersionedClause<ACCC_DevicePtr>,
284    VersionedClause<ACCC_DeviceResident>,
285    VersionedClause<ACCC_Link>
286  ];
287}
288
289// 2.5.3
290def ACC_Kernels : Directive<"kernels"> {
291  let allowedClauses = [
292    VersionedClause<ACCC_Attach>,
293    VersionedClause<ACCC_Copy>,
294    VersionedClause<ACCC_Copyin>,
295    VersionedClause<ACCC_Copyout>,
296    VersionedClause<ACCC_Create>,
297    VersionedClause<ACCC_DeviceType>,
298    VersionedClause<ACCC_NoCreate>,
299    VersionedClause<ACCC_Present>,
300    VersionedClause<ACCC_DevicePtr>,
301    VersionedClause<ACCC_Wait>
302  ];
303  let allowedOnceClauses = [
304    VersionedClause<ACCC_Async>,
305    VersionedClause<ACCC_Default>,
306    VersionedClause<ACCC_If>,
307    VersionedClause<ACCC_NumGangs>,
308    VersionedClause<ACCC_NumWorkers>,
309    VersionedClause<ACCC_Self>,
310    VersionedClause<ACCC_VectorLength>
311  ];
312}
313
314// 2.5.1
315def ACC_Parallel : Directive<"parallel"> {
316  let allowedClauses = [
317    VersionedClause<ACCC_Attach>,
318    VersionedClause<ACCC_Copy>,
319    VersionedClause<ACCC_Copyin>,
320    VersionedClause<ACCC_Copyout>,
321    VersionedClause<ACCC_Create>,
322    VersionedClause<ACCC_DevicePtr>,
323    VersionedClause<ACCC_DeviceType>,
324    VersionedClause<ACCC_NoCreate>,
325    VersionedClause<ACCC_Present>,
326    VersionedClause<ACCC_Private>,
327    VersionedClause<ACCC_FirstPrivate>,
328    VersionedClause<ACCC_Wait>
329  ];
330  let allowedOnceClauses = [
331    VersionedClause<ACCC_Async>,
332    VersionedClause<ACCC_Default>,
333    VersionedClause<ACCC_If>,
334    VersionedClause<ACCC_NumGangs>,
335    VersionedClause<ACCC_NumWorkers>,
336    VersionedClause<ACCC_Reduction>,
337    VersionedClause<ACCC_Self>,
338    VersionedClause<ACCC_VectorLength>
339  ];
340}
341
342// 2.5.2
343def ACC_Serial : Directive<"serial"> {
344  let allowedClauses = [
345    VersionedClause<ACCC_Attach>,
346    VersionedClause<ACCC_Copy>,
347    VersionedClause<ACCC_Copyin>,
348    VersionedClause<ACCC_Copyout>,
349    VersionedClause<ACCC_Create>,
350    VersionedClause<ACCC_DevicePtr>,
351    VersionedClause<ACCC_DeviceType>,
352    VersionedClause<ACCC_FirstPrivate>,
353    VersionedClause<ACCC_NoCreate>,
354    VersionedClause<ACCC_Present>,
355    VersionedClause<ACCC_Private>,
356    VersionedClause<ACCC_Wait>
357  ];
358  let allowedOnceClauses = [
359    VersionedClause<ACCC_Async>,
360    VersionedClause<ACCC_Default>,
361    VersionedClause<ACCC_If>,
362    VersionedClause<ACCC_Reduction>,
363    VersionedClause<ACCC_Self>
364  ];
365}
366
367// 2.9
368def ACC_Loop : Directive<"loop"> {
369  let allowedClauses = [
370    VersionedClause<ACCC_DeviceType>,
371    VersionedClause<ACCC_Private>
372  ];
373  let allowedOnceClauses = [
374    VersionedClause<ACCC_Collapse>,
375    VersionedClause<ACCC_Gang>,
376    VersionedClause<ACCC_Reduction>,
377    VersionedClause<ACCC_Tile>,
378    VersionedClause<ACCC_Vector>,
379    VersionedClause<ACCC_Worker>
380  ];
381  let allowedExclusiveClauses = [
382    VersionedClause<ACCC_Auto>,
383    VersionedClause<ACCC_Independent>,
384    VersionedClause<ACCC_Seq>
385  ];
386}
387
388// 2.10
389def ACC_Cache : Directive<"cache"> {}
390
391// 2.14.1
392def ACC_Init : Directive<"init"> {
393  let allowedOnceClauses = [
394    VersionedClause<ACCC_DeviceNum>,
395    VersionedClause<ACCC_DeviceType>,
396    VersionedClause<ACCC_If>
397  ];
398}
399
400// 2.15.1
401def ACC_Routine : Directive<"routine"> {
402  let allowedOnceClauses = [
403    VersionedClause<ACCC_Bind>,
404    VersionedClause<ACCC_DeviceType>,
405    VersionedClause<ACCC_NoHost>
406  ];
407  let requiredClauses = [
408    VersionedClause<ACCC_Gang>,
409    VersionedClause<ACCC_Seq>,
410    VersionedClause<ACCC_Vector>,
411    VersionedClause<ACCC_Worker>
412  ];
413}
414
415// 2.14.3
416def ACC_Set : Directive<"set"> {
417  let allowedOnceClauses = [
418    VersionedClause<ACCC_DefaultAsync>,
419    VersionedClause<ACCC_DeviceNum>,
420    VersionedClause<ACCC_DeviceType>,
421    VersionedClause<ACCC_If>
422  ];
423  let requiredClauses = [
424    // The three following clauses are also in allowedOnceClauses list due to
425    // restriction 2255 - Two instances of the same clause may not appear on the
426    // same directive.
427    VersionedClause<ACCC_DefaultAsync>,
428    VersionedClause<ACCC_DeviceNum>,
429    VersionedClause<ACCC_DeviceType>
430  ];
431}
432
433// 2.14.2
434def ACC_Shutdown : Directive<"shutdown"> {
435  let allowedOnceClauses = [
436    VersionedClause<ACCC_DeviceNum>,
437    VersionedClause<ACCC_DeviceType>,
438    VersionedClause<ACCC_If>
439  ];
440}
441
442// 2.14.4
443def ACC_Update : Directive<"update"> {
444  let allowedClauses = [
445    VersionedClause<ACCC_DeviceType>,
446    VersionedClause<ACCC_Wait>
447  ];
448  let allowedOnceClauses = [
449    VersionedClause<ACCC_Async>,
450    VersionedClause<ACCC_If>,
451    VersionedClause<ACCC_IfPresent>
452  ];
453  let requiredClauses = [
454    VersionedClause<ACCC_Device>,
455    VersionedClause<ACCC_Host>,
456    VersionedClause<ACCC_Self>
457  ];
458}
459
460// 2.16.3
461def ACC_Wait : Directive<"wait"> {
462  let allowedOnceClauses = [
463    VersionedClause<ACCC_Async>,
464    VersionedClause<ACCC_If>
465  ];
466}
467
468// 2.14.6
469def ACC_EnterData : Directive<"enter data"> {
470  let allowedOnceClauses = [
471    VersionedClause<ACCC_Async>,
472    VersionedClause<ACCC_If>,
473    VersionedClause<ACCC_Wait>
474  ];
475  let requiredClauses = [
476    VersionedClause<ACCC_Attach>,
477    VersionedClause<ACCC_Create>,
478    VersionedClause<ACCC_Copyin>
479  ];
480}
481
482// 2.14.7
483def ACC_ExitData : Directive<"exit data"> {
484  let allowedClauses = [
485    VersionedClause<ACCC_Async>,
486    VersionedClause<ACCC_If>,
487    VersionedClause<ACCC_Wait>,
488    VersionedClause<ACCC_Finalize>
489  ];
490  let requiredClauses = [
491    VersionedClause<ACCC_Copyout>,
492    VersionedClause<ACCC_Delete>,
493    VersionedClause<ACCC_Detach>
494  ];
495}
496
497// 2.8
498def ACC_HostData : Directive<"host_data"> {
499  let allowedClauses = [
500    VersionedClause<ACCC_If>,
501    VersionedClause<ACCC_IfPresent>
502  ];
503  let requiredClauses = [
504    VersionedClause<ACCC_UseDevice>
505  ];
506}
507
508// 2.11
509def ACC_KernelsLoop : Directive<"kernels loop"> {
510  let allowedClauses = [
511    VersionedClause<ACCC_Copy>,
512    VersionedClause<ACCC_Copyin>,
513    VersionedClause<ACCC_Copyout>,
514    VersionedClause<ACCC_Create>,
515    VersionedClause<ACCC_DeviceType>,
516    VersionedClause<ACCC_NoCreate>,
517    VersionedClause<ACCC_Present>,
518    VersionedClause<ACCC_Private>,
519    VersionedClause<ACCC_DevicePtr>,
520    VersionedClause<ACCC_Attach>
521  ];
522  let allowedOnceClauses = [
523    VersionedClause<ACCC_Async>,
524    VersionedClause<ACCC_Collapse>,
525    VersionedClause<ACCC_Default>,
526    VersionedClause<ACCC_Gang>,
527    VersionedClause<ACCC_If>,
528    VersionedClause<ACCC_NumGangs>,
529    VersionedClause<ACCC_NumWorkers>,
530    VersionedClause<ACCC_Reduction>,
531    VersionedClause<ACCC_Self>,
532    VersionedClause<ACCC_Tile>,
533    VersionedClause<ACCC_Vector>,
534    VersionedClause<ACCC_VectorLength>,
535    VersionedClause<ACCC_Wait>,
536    VersionedClause<ACCC_Worker>
537  ];
538  let allowedExclusiveClauses = [
539    VersionedClause<ACCC_Auto>,
540    VersionedClause<ACCC_Independent>,
541    VersionedClause<ACCC_Seq>
542  ];
543}
544
545// 2.11
546def ACC_ParallelLoop : Directive<"parallel loop"> {
547  let allowedClauses = [
548    VersionedClause<ACCC_Attach>,
549    VersionedClause<ACCC_Copy>,
550    VersionedClause<ACCC_Copyin>,
551    VersionedClause<ACCC_Copyout>,
552    VersionedClause<ACCC_Create>,
553    VersionedClause<ACCC_DevicePtr>,
554    VersionedClause<ACCC_DeviceType>,
555    VersionedClause<ACCC_FirstPrivate>,
556    VersionedClause<ACCC_NoCreate>,
557    VersionedClause<ACCC_Present>,
558    VersionedClause<ACCC_Private>,
559    VersionedClause<ACCC_Tile>,
560    VersionedClause<ACCC_Wait>
561  ];
562  let allowedOnceClauses = [
563    VersionedClause<ACCC_Async>,
564    VersionedClause<ACCC_Collapse>,
565    VersionedClause<ACCC_Default>,
566    VersionedClause<ACCC_Gang>,
567    VersionedClause<ACCC_If>,
568    VersionedClause<ACCC_NumGangs>,
569    VersionedClause<ACCC_NumWorkers>,
570    VersionedClause<ACCC_Reduction>,
571    VersionedClause<ACCC_Self>,
572    VersionedClause<ACCC_Vector>,
573    VersionedClause<ACCC_VectorLength>,
574    VersionedClause<ACCC_Worker>
575  ];
576  let allowedExclusiveClauses = [
577    VersionedClause<ACCC_Auto>,
578    VersionedClause<ACCC_Independent>,
579    VersionedClause<ACCC_Seq>
580  ];
581}
582
583// 2.11
584def ACC_SerialLoop : Directive<"serial loop"> {
585  let allowedClauses = [
586    VersionedClause<ACCC_Attach>,
587    VersionedClause<ACCC_Copy>,
588    VersionedClause<ACCC_Copyin>,
589    VersionedClause<ACCC_Copyout>,
590    VersionedClause<ACCC_Create>,
591    VersionedClause<ACCC_DevicePtr>,
592    VersionedClause<ACCC_DeviceType>,
593    VersionedClause<ACCC_FirstPrivate>,
594    VersionedClause<ACCC_NoCreate>,
595    VersionedClause<ACCC_Present>,
596    VersionedClause<ACCC_Private>,
597    VersionedClause<ACCC_Wait>
598  ];
599  let allowedOnceClauses = [
600    VersionedClause<ACCC_Async>,
601    VersionedClause<ACCC_Collapse>,
602    VersionedClause<ACCC_Default>,
603    VersionedClause<ACCC_Gang>,
604    VersionedClause<ACCC_If>,
605    VersionedClause<ACCC_Reduction>,
606    VersionedClause<ACCC_Self>,
607    VersionedClause<ACCC_Tile>,
608    VersionedClause<ACCC_Vector>,
609    VersionedClause<ACCC_Worker>
610  ];
611  let allowedExclusiveClauses = [
612    VersionedClause<ACCC_Auto>,
613    VersionedClause<ACCC_Independent>,
614    VersionedClause<ACCC_Seq>
615  ];
616}
617
618def ACC_Unknown : Directive<"unknown"> {
619  let isDefault = true;
620}
621