Skip to content

Commit e36c8dc

Browse files
kparzyszclementval
andauthored
[Frontend] Introduce getDirectiveCategory for ACC/OMP directives (#94689)
The categories are primarily meant for OpenMP, where the spec assigns a category to each directive. It's one of declarative, executable, informational, meta, subsidiary, and utility. These will be used in clang to avoid listing directives belonging to certain categories by hand. --------- Co-authored-by: Valentin Clement (バレンタイン クレメン) <clementval@gmail.com>
1 parent 2cf1439 commit e36c8dc

File tree

7 files changed

+225
-3
lines changed

7 files changed

+225
-3
lines changed

llvm/include/llvm/Frontend/Directive/DirectiveBase.td

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ def AS_FromLeaves : Association<"FromLeaves"> {} // See below
156156
// The name "AS_FromLeaves" is recognized by TableGen, and there is no enum
157157
// generated for it.
158158

159+
// Kinds of directive categories.
160+
class Category<string n> {
161+
string name = n; // Name of the enum value in enum class Category.
162+
}
163+
164+
def CA_Declarative: Category<"Declarative"> {}
165+
def CA_Executable: Category<"Executable"> {}
166+
def CA_Informational: Category<"Informational"> {}
167+
def CA_Meta: Category<"Meta"> {}
168+
def CA_Subsidiary: Category<"Subsidiary"> {}
169+
def CA_Utility: Category<"Utility"> {}
170+
159171
// Information about a specific directive.
160172
class Directive<string d> {
161173
// Name of the directive. Can be composite directive sepearted by whitespace.
@@ -190,4 +202,7 @@ class Directive<string d> {
190202

191203
// What the directive is associated with.
192204
Association association = AS_FromLeaves;
205+
206+
// The category of the directive.
207+
Category category = ?;
193208
}

llvm/include/llvm/Frontend/OpenACC/ACC.td

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ def ACCC_Unknown : Clause<"unknown"> {
268268
// 2.12
269269
def ACC_Atomic : Directive<"atomic"> {
270270
let association = AS_Block;
271+
let category = CA_Executable;
271272
}
272273

273274
// 2.6.5
@@ -293,6 +294,7 @@ def ACC_Data : Directive<"data"> {
293294
VersionedClause<ACCC_Present>
294295
];
295296
let association = AS_Block;
297+
let category = CA_Executable;
296298
}
297299

298300
// 2.13
@@ -308,6 +310,7 @@ def ACC_Declare : Directive<"declare"> {
308310
VersionedClause<ACCC_Link>
309311
];
310312
let association = AS_None;
313+
let category = CA_Declarative;
311314
}
312315

313316
// 2.5.3
@@ -334,6 +337,7 @@ def ACC_Kernels : Directive<"kernels"> {
334337
VersionedClause<ACCC_VectorLength>
335338
];
336339
let association = AS_Block;
340+
let category = CA_Executable;
337341
}
338342

339343
// 2.5.1
@@ -363,6 +367,7 @@ def ACC_Parallel : Directive<"parallel"> {
363367
VersionedClause<ACCC_Self>
364368
];
365369
let association = AS_Block;
370+
let category = CA_Executable;
366371
}
367372

368373
// 2.5.2
@@ -391,6 +396,7 @@ def ACC_Serial : Directive<"serial"> {
391396
VersionedClause<ACCC_Self>
392397
];
393398
let association = AS_Block;
399+
let category = CA_Executable;
394400
}
395401

396402
// 2.9
@@ -411,11 +417,13 @@ def ACC_Loop : Directive<"loop"> {
411417
VersionedClause<ACCC_Seq>
412418
];
413419
let association = AS_Loop;
420+
let category = CA_Executable;
414421
}
415422

416423
// 2.10
417424
def ACC_Cache : Directive<"cache"> {
418425
let association = AS_None;
426+
let category = CA_Executable;
419427
}
420428

421429
// 2.14.1
@@ -426,6 +434,7 @@ def ACC_Init : Directive<"init"> {
426434
VersionedClause<ACCC_If>
427435
];
428436
let association = AS_None;
437+
let category = CA_Executable;
429438
}
430439

431440
// 2.15.1
@@ -442,6 +451,7 @@ def ACC_Routine : Directive<"routine"> {
442451
VersionedClause<ACCC_NoHost>
443452
];
444453
let association = AS_Declaration;
454+
let category = CA_Declarative;
445455
}
446456

447457
// 2.14.3
@@ -461,6 +471,7 @@ def ACC_Set : Directive<"set"> {
461471
VersionedClause<ACCC_DeviceType>
462472
];
463473
let association = AS_None;
474+
let category = CA_Executable;
464475
}
465476

466477
// 2.14.2
@@ -471,6 +482,7 @@ def ACC_Shutdown : Directive<"shutdown"> {
471482
VersionedClause<ACCC_If>
472483
];
473484
let association = AS_None;
485+
let category = CA_Executable;
474486
}
475487

476488
// 2.14.4
@@ -490,6 +502,7 @@ def ACC_Update : Directive<"update"> {
490502
VersionedClause<ACCC_Self>
491503
];
492504
let association = AS_None;
505+
let category = CA_Executable;
493506
}
494507

495508
// 2.16.3
@@ -499,6 +512,7 @@ def ACC_Wait : Directive<"wait"> {
499512
VersionedClause<ACCC_If>
500513
];
501514
let association = AS_None;
515+
let category = CA_Executable;
502516
}
503517

504518
// 2.14.6
@@ -516,6 +530,7 @@ def ACC_EnterData : Directive<"enter data"> {
516530
VersionedClause<ACCC_Copyin>
517531
];
518532
let association = AS_None;
533+
let category = CA_Executable;
519534
}
520535

521536
// 2.14.7
@@ -534,6 +549,7 @@ def ACC_ExitData : Directive<"exit data"> {
534549
VersionedClause<ACCC_Detach>
535550
];
536551
let association = AS_None;
552+
let category = CA_Executable;
537553
}
538554

539555
// 2.8
@@ -546,6 +562,7 @@ def ACC_HostData : Directive<"host_data"> {
546562
VersionedClause<ACCC_UseDevice>
547563
];
548564
let association = AS_Block;
565+
let category = CA_Executable;
549566
}
550567

551568
// 2.11
@@ -584,6 +601,7 @@ def ACC_KernelsLoop : Directive<"kernels loop"> {
584601
VersionedClause<ACCC_Seq>
585602
];
586603
let leafConstructs = [ACC_Kernels, ACC_Loop];
604+
let category = CA_Executable;
587605
}
588606

589607
// 2.11
@@ -623,6 +641,7 @@ def ACC_ParallelLoop : Directive<"parallel loop"> {
623641
VersionedClause<ACCC_Seq>
624642
];
625643
let leafConstructs = [ACC_Parallel, ACC_Loop];
644+
let category = CA_Executable;
626645
}
627646

628647
// 2.11
@@ -659,9 +678,11 @@ def ACC_SerialLoop : Directive<"serial loop"> {
659678
VersionedClause<ACCC_Seq>
660679
];
661680
let leafConstructs = [ACC_Serial, ACC_Loop];
681+
let category = CA_Executable;
662682
}
663683

664684
def ACC_Unknown : Directive<"unknown"> {
665685
let isDefault = true;
666686
let association = AS_None;
687+
let category = CA_Utility;
667688
}

0 commit comments

Comments
 (0)