[TargetVersion] Only enable on RISC-V and AArch64 (#115991)
[llvm-project.git] / flang / examples / FeatureList / FeatureList.cpp
blobfe7fee97bc78e55566df6cfd8c73822905b8f96f
1 //===-- FeatureList.cpp ---------------------------------------------------===//
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 // A plugin that counts the amount of times a particular parse tree node
10 // occurs. This plugin should cover each feature covered in dump-parse-tree.h
12 //===----------------------------------------------------------------------===//
14 #include "flang/Frontend/FrontendActions.h"
15 #include "flang/Frontend/FrontendPluginRegistry.h"
16 #include "flang/Parser/parse-tree-visitor.h"
17 #include "flang/Parser/parse-tree.h"
18 #include "flang/Parser/parsing.h"
20 #include <algorithm>
21 #include <cstring>
22 #include <unordered_map>
23 #include <utility>
24 #include <vector>
26 using namespace Fortran::common;
27 using namespace Fortran::frontend;
28 using namespace Fortran::parser;
29 using namespace Fortran;
31 #define READ_FEATURE_CUST(classname, n) \
32 bool Pre(const classname &) { \
33 record(#n); \
34 return true; \
35 } \
36 void Post(const classname &) {}
38 #define READ_FEATURE(classname) READ_FEATURE_CUST(classname, classname)
40 struct NodeVisitor {
41 private:
42 std::unordered_map<const char *, unsigned int> frequencies;
44 void record(const char *name) {
45 auto [it, ins] = frequencies.insert({name, 1});
46 if (!ins) {
47 it->second++;
51 public:
52 const std::unordered_map<const char *, unsigned int> &getFrequencies() const {
53 return frequencies;
56 READ_FEATURE_CUST(format::ControlEditDesc, ControlEditDesc)
57 READ_FEATURE_CUST(format::DerivedTypeDataEditDesc, DerivedTypeDataEditDesc)
58 READ_FEATURE_CUST(format::FormatItem, FormatItem)
59 READ_FEATURE_CUST(format::FormatSpecification, FormatSpecification)
60 READ_FEATURE_CUST(
61 format::IntrinsicTypeDataEditDesc, IntrinsicTypeDataEditDesc)
62 READ_FEATURE(Abstract)
63 READ_FEATURE(AccAtomicCapture)
64 READ_FEATURE(AccAtomicCapture::Stmt1)
65 READ_FEATURE(AccAtomicCapture::Stmt2)
66 READ_FEATURE(AccAtomicRead)
67 READ_FEATURE(AccAtomicUpdate)
68 READ_FEATURE(AccAtomicWrite)
69 READ_FEATURE(AccBeginBlockDirective)
70 READ_FEATURE(AccBeginCombinedDirective)
71 READ_FEATURE(AccBeginLoopDirective)
72 READ_FEATURE(AccBlockDirective)
73 READ_FEATURE(AccClause)
74 READ_FEATURE(AccBindClause)
75 READ_FEATURE(AccDefaultClause)
76 READ_FEATURE(AccClauseList)
77 READ_FEATURE(AccCombinedDirective)
78 READ_FEATURE(AccDataModifier)
79 READ_FEATURE(AccDataModifier::Modifier)
80 READ_FEATURE(AccDeclarativeDirective)
81 READ_FEATURE(AccEndAtomic)
82 READ_FEATURE(AccEndBlockDirective)
83 READ_FEATURE(AccEndCombinedDirective)
84 READ_FEATURE(AccGangArg)
85 READ_FEATURE(AccObject)
86 READ_FEATURE(AccObjectList)
87 READ_FEATURE(AccObjectListWithModifier)
88 READ_FEATURE(AccObjectListWithReduction)
89 READ_FEATURE(AccSizeExpr)
90 READ_FEATURE(AccSizeExprList)
91 READ_FEATURE(AccSelfClause)
92 READ_FEATURE(AccStandaloneDirective)
93 READ_FEATURE(AccDeviceTypeExpr)
94 READ_FEATURE(AccDeviceTypeExprList)
95 READ_FEATURE(AccTileExpr)
96 READ_FEATURE(AccTileExprList)
97 READ_FEATURE(AccLoopDirective)
98 READ_FEATURE(AccWaitArgument)
99 READ_FEATURE(AcImpliedDo)
100 READ_FEATURE(AcImpliedDoControl)
101 READ_FEATURE(AcValue)
102 READ_FEATURE(AccessStmt)
103 READ_FEATURE(AccessId)
104 READ_FEATURE(AccessSpec)
105 READ_FEATURE(AccessSpec::Kind)
106 READ_FEATURE(AcSpec)
107 READ_FEATURE(ActionStmt)
108 READ_FEATURE(ActualArg)
109 READ_FEATURE(ActualArg::PercentRef)
110 READ_FEATURE(ActualArg::PercentVal)
111 READ_FEATURE(ActualArgSpec)
112 READ_FEATURE(AcValue::Triplet)
113 READ_FEATURE(AllocOpt)
114 READ_FEATURE(AllocOpt::Mold)
115 READ_FEATURE(AllocOpt::Source)
116 READ_FEATURE(Allocatable)
117 READ_FEATURE(AllocatableStmt)
118 READ_FEATURE(AllocateCoarraySpec)
119 READ_FEATURE(AllocateObject)
120 READ_FEATURE(AllocateShapeSpec)
121 READ_FEATURE(AllocateStmt)
122 READ_FEATURE(Allocation)
123 READ_FEATURE(AltReturnSpec)
124 READ_FEATURE(ArithmeticIfStmt)
125 READ_FEATURE(ArrayConstructor)
126 READ_FEATURE(ArrayElement)
127 READ_FEATURE(ArraySpec)
128 READ_FEATURE(AssignStmt)
129 READ_FEATURE(AssignedGotoStmt)
130 READ_FEATURE(AssignmentStmt)
131 READ_FEATURE(AssociateConstruct)
132 READ_FEATURE(AssociateStmt)
133 READ_FEATURE(Association)
134 READ_FEATURE(AssumedImpliedSpec)
135 READ_FEATURE(AssumedRankSpec)
136 READ_FEATURE(AssumedShapeSpec)
137 READ_FEATURE(AssumedSizeSpec)
138 READ_FEATURE(Asynchronous)
139 READ_FEATURE(AsynchronousStmt)
140 READ_FEATURE(AttrSpec)
141 READ_FEATURE(BOZLiteralConstant)
142 READ_FEATURE(BackspaceStmt)
143 READ_FEATURE(BasedPointer)
144 READ_FEATURE(BasedPointerStmt)
145 READ_FEATURE(BindAttr)
146 READ_FEATURE(BindAttr::Deferred)
147 READ_FEATURE(BindAttr::Non_Overridable)
148 READ_FEATURE(BindEntity)
149 READ_FEATURE(BindEntity::Kind)
150 READ_FEATURE(BindStmt)
151 READ_FEATURE(Block)
152 READ_FEATURE(BlockConstruct)
153 READ_FEATURE(BlockData)
154 READ_FEATURE(BlockDataStmt)
155 READ_FEATURE(BlockSpecificationPart)
156 READ_FEATURE(BlockStmt)
157 READ_FEATURE(BoundsRemapping)
158 READ_FEATURE(BoundsSpec)
159 READ_FEATURE(Call)
160 READ_FEATURE(CallStmt)
161 READ_FEATURE(CaseConstruct)
162 READ_FEATURE(CaseConstruct::Case)
163 READ_FEATURE(CaseSelector)
164 READ_FEATURE(CaseStmt)
165 READ_FEATURE(CaseValueRange)
166 READ_FEATURE(CaseValueRange::Range)
167 READ_FEATURE(ChangeTeamConstruct)
168 READ_FEATURE(ChangeTeamStmt)
169 READ_FEATURE(CharLength)
170 READ_FEATURE(CharLiteralConstant)
171 READ_FEATURE(CharLiteralConstantSubstring)
172 READ_FEATURE(CharSelector)
173 READ_FEATURE(CharSelector::LengthAndKind)
174 READ_FEATURE(CloseStmt)
175 READ_FEATURE(CloseStmt::CloseSpec)
176 READ_FEATURE(CoarrayAssociation)
177 READ_FEATURE(CoarraySpec)
178 READ_FEATURE(CodimensionDecl)
179 READ_FEATURE(CodimensionStmt)
180 READ_FEATURE(CoindexedNamedObject)
181 READ_FEATURE(CommonBlockObject)
182 READ_FEATURE(CommonStmt)
183 READ_FEATURE(CommonStmt::Block)
184 READ_FEATURE(CompilerDirective)
185 READ_FEATURE(CompilerDirective::IgnoreTKR)
186 READ_FEATURE(CompilerDirective::LoopCount)
187 READ_FEATURE(CompilerDirective::NameValue)
188 READ_FEATURE(ComplexLiteralConstant)
189 READ_FEATURE(ComplexPart)
190 READ_FEATURE(ComponentArraySpec)
191 READ_FEATURE(ComponentAttrSpec)
192 READ_FEATURE(ComponentDataSource)
193 READ_FEATURE(ComponentDecl)
194 READ_FEATURE(FillDecl)
195 READ_FEATURE(ComponentOrFill)
196 READ_FEATURE(ComponentDefStmt)
197 READ_FEATURE(ComponentSpec)
198 READ_FEATURE(ComputedGotoStmt)
199 READ_FEATURE(ConcurrentControl)
200 READ_FEATURE(ConcurrentHeader)
201 READ_FEATURE(ConnectSpec)
202 READ_FEATURE(ConnectSpec::CharExpr)
203 READ_FEATURE(ConnectSpec::CharExpr::Kind)
204 READ_FEATURE(ConnectSpec::Newunit)
205 READ_FEATURE(ConnectSpec::Recl)
206 READ_FEATURE(ContainsStmt)
207 READ_FEATURE(Contiguous)
208 READ_FEATURE(ContiguousStmt)
209 READ_FEATURE(ContinueStmt)
210 READ_FEATURE(CriticalConstruct)
211 READ_FEATURE(CriticalStmt)
212 READ_FEATURE(CycleStmt)
213 READ_FEATURE(DataComponentDefStmt)
214 READ_FEATURE(DataIDoObject)
215 READ_FEATURE(DataImpliedDo)
216 READ_FEATURE(DataRef)
217 READ_FEATURE(DataStmt)
218 READ_FEATURE(DataStmtConstant)
219 READ_FEATURE(DataStmtObject)
220 READ_FEATURE(DataStmtRepeat)
221 READ_FEATURE(DataStmtSet)
222 READ_FEATURE(DataStmtValue)
223 READ_FEATURE(DeallocateStmt)
224 READ_FEATURE(DeclarationConstruct)
225 READ_FEATURE(DeclarationTypeSpec)
226 READ_FEATURE(DeclarationTypeSpec::Class)
227 READ_FEATURE(DeclarationTypeSpec::ClassStar)
228 READ_FEATURE(DeclarationTypeSpec::Record)
229 READ_FEATURE(DeclarationTypeSpec::Type)
230 READ_FEATURE(DeclarationTypeSpec::TypeStar)
231 READ_FEATURE(Default)
232 READ_FEATURE(DeferredCoshapeSpecList)
233 READ_FEATURE(DeferredShapeSpecList)
234 READ_FEATURE(DefinedOpName)
235 READ_FEATURE(DefinedOperator)
236 READ_FEATURE(DefinedOperator::IntrinsicOperator)
237 READ_FEATURE(DerivedTypeDef)
238 READ_FEATURE(DerivedTypeSpec)
239 READ_FEATURE(DerivedTypeStmt)
240 READ_FEATURE(Designator)
241 READ_FEATURE(DimensionStmt)
242 READ_FEATURE(DimensionStmt::Declaration)
243 READ_FEATURE(DoConstruct)
244 READ_FEATURE(DummyArg)
245 READ_FEATURE(ElseIfStmt)
246 READ_FEATURE(ElseStmt)
247 READ_FEATURE(ElsewhereStmt)
248 READ_FEATURE(EndAssociateStmt)
249 READ_FEATURE(EndBlockDataStmt)
250 READ_FEATURE(EndBlockStmt)
251 READ_FEATURE(EndChangeTeamStmt)
252 READ_FEATURE(EndCriticalStmt)
253 READ_FEATURE(EndDoStmt)
254 READ_FEATURE(EndEnumStmt)
255 READ_FEATURE(EndForallStmt)
256 READ_FEATURE(EndFunctionStmt)
257 READ_FEATURE(EndIfStmt)
258 READ_FEATURE(EndInterfaceStmt)
259 READ_FEATURE(EndLabel)
260 READ_FEATURE(EndModuleStmt)
261 READ_FEATURE(EndMpSubprogramStmt)
262 READ_FEATURE(EndProgramStmt)
263 READ_FEATURE(EndSelectStmt)
264 READ_FEATURE(EndSubmoduleStmt)
265 READ_FEATURE(EndSubroutineStmt)
266 READ_FEATURE(EndTypeStmt)
267 READ_FEATURE(EndWhereStmt)
268 READ_FEATURE(EndfileStmt)
269 READ_FEATURE(EntityDecl)
270 READ_FEATURE(EntryStmt)
271 READ_FEATURE(EnumDef)
272 READ_FEATURE(EnumDefStmt)
273 READ_FEATURE(Enumerator)
274 READ_FEATURE(EnumeratorDefStmt)
275 READ_FEATURE(EorLabel)
276 READ_FEATURE(EquivalenceObject)
277 READ_FEATURE(EquivalenceStmt)
278 READ_FEATURE(ErrLabel)
279 READ_FEATURE(ErrorRecovery)
280 READ_FEATURE(EventPostStmt)
281 READ_FEATURE(EventWaitStmt)
282 READ_FEATURE(EventWaitSpec)
283 READ_FEATURE(ExecutableConstruct)
284 READ_FEATURE(ExecutionPart)
285 READ_FEATURE(ExecutionPartConstruct)
286 READ_FEATURE(ExitStmt)
287 READ_FEATURE(ExplicitCoshapeSpec)
288 READ_FEATURE(ExplicitShapeSpec)
289 READ_FEATURE(Expr)
290 READ_FEATURE(Expr::Parentheses)
291 READ_FEATURE(Expr::UnaryPlus)
292 READ_FEATURE(Expr::Negate)
293 READ_FEATURE(Expr::NOT)
294 READ_FEATURE(Expr::PercentLoc)
295 READ_FEATURE(Expr::DefinedUnary)
296 READ_FEATURE(Expr::Power)
297 READ_FEATURE(Expr::Multiply)
298 READ_FEATURE(Expr::Divide)
299 READ_FEATURE(Expr::Add)
300 READ_FEATURE(Expr::Subtract)
301 READ_FEATURE(Expr::Concat)
302 READ_FEATURE(Expr::LT)
303 READ_FEATURE(Expr::LE)
304 READ_FEATURE(Expr::EQ)
305 READ_FEATURE(Expr::NE)
306 READ_FEATURE(Expr::GE)
307 READ_FEATURE(Expr::GT)
308 READ_FEATURE(Expr::AND)
309 READ_FEATURE(Expr::OR)
310 READ_FEATURE(Expr::EQV)
311 READ_FEATURE(Expr::NEQV)
312 READ_FEATURE(Expr::DefinedBinary)
313 READ_FEATURE(Expr::ComplexConstructor)
314 READ_FEATURE(External)
315 READ_FEATURE(ExternalStmt)
316 READ_FEATURE(FailImageStmt)
317 READ_FEATURE(FileUnitNumber)
318 READ_FEATURE(FinalProcedureStmt)
319 READ_FEATURE(FlushStmt)
320 READ_FEATURE(ForallAssignmentStmt)
321 READ_FEATURE(ForallBodyConstruct)
322 READ_FEATURE(ForallConstruct)
323 READ_FEATURE(ForallConstructStmt)
324 READ_FEATURE(ForallStmt)
325 READ_FEATURE(FormTeamStmt)
326 READ_FEATURE(FormTeamStmt::FormTeamSpec)
327 READ_FEATURE(Format)
328 READ_FEATURE(FormatStmt)
329 READ_FEATURE(FunctionReference)
330 READ_FEATURE(FunctionStmt)
331 READ_FEATURE(FunctionSubprogram)
332 READ_FEATURE(GenericSpec)
333 READ_FEATURE(GenericSpec::Assignment)
334 READ_FEATURE(GenericSpec::ReadFormatted)
335 READ_FEATURE(GenericSpec::ReadUnformatted)
336 READ_FEATURE(GenericSpec::WriteFormatted)
337 READ_FEATURE(GenericSpec::WriteUnformatted)
338 READ_FEATURE(GenericStmt)
339 READ_FEATURE(GotoStmt)
340 READ_FEATURE(HollerithLiteralConstant)
341 READ_FEATURE(IdExpr)
342 READ_FEATURE(IdVariable)
343 READ_FEATURE(IfConstruct)
344 READ_FEATURE(IfConstruct::ElseBlock)
345 READ_FEATURE(IfConstruct::ElseIfBlock)
346 READ_FEATURE(IfStmt)
347 READ_FEATURE(IfThenStmt)
348 READ_FEATURE(TeamValue)
349 READ_FEATURE(ImageSelector)
350 READ_FEATURE(ImageSelectorSpec)
351 READ_FEATURE(ImageSelectorSpec::Stat)
352 READ_FEATURE(ImageSelectorSpec::Team_Number)
353 READ_FEATURE(ImplicitPart)
354 READ_FEATURE(ImplicitPartStmt)
355 READ_FEATURE(ImplicitSpec)
356 READ_FEATURE(ImplicitStmt)
357 READ_FEATURE(ImplicitStmt::ImplicitNoneNameSpec)
358 READ_FEATURE(ImpliedShapeSpec)
359 READ_FEATURE(ImportStmt)
360 READ_FEATURE(Initialization)
361 READ_FEATURE(InputImpliedDo)
362 READ_FEATURE(InputItem)
363 READ_FEATURE(InquireSpec)
364 READ_FEATURE(InquireSpec::CharVar)
365 READ_FEATURE(InquireSpec::CharVar::Kind)
366 READ_FEATURE(InquireSpec::IntVar)
367 READ_FEATURE(InquireSpec::IntVar::Kind)
368 READ_FEATURE(InquireSpec::LogVar)
369 READ_FEATURE(InquireSpec::LogVar::Kind)
370 READ_FEATURE(InquireStmt)
371 READ_FEATURE(InquireStmt::Iolength)
372 READ_FEATURE(IntegerTypeSpec)
373 READ_FEATURE(IntentSpec)
374 READ_FEATURE(IntentSpec::Intent)
375 READ_FEATURE(IntentStmt)
376 READ_FEATURE(InterfaceBlock)
377 READ_FEATURE(InterfaceBody)
378 READ_FEATURE(InterfaceBody::Function)
379 READ_FEATURE(InterfaceBody::Subroutine)
380 READ_FEATURE(InterfaceSpecification)
381 READ_FEATURE(InterfaceStmt)
382 READ_FEATURE(InternalSubprogram)
383 READ_FEATURE(InternalSubprogramPart)
384 READ_FEATURE(Intrinsic)
385 READ_FEATURE(IntrinsicStmt)
386 READ_FEATURE(IntrinsicTypeSpec)
387 READ_FEATURE(IntrinsicTypeSpec::Character)
388 READ_FEATURE(IntrinsicTypeSpec::Complex)
389 READ_FEATURE(IntrinsicTypeSpec::DoubleComplex)
390 READ_FEATURE(IntrinsicTypeSpec::DoublePrecision)
391 READ_FEATURE(IntrinsicTypeSpec::Logical)
392 READ_FEATURE(IntrinsicTypeSpec::Real)
393 READ_FEATURE(IoControlSpec)
394 READ_FEATURE(IoControlSpec::Asynchronous)
395 READ_FEATURE(IoControlSpec::CharExpr)
396 READ_FEATURE(IoControlSpec::CharExpr::Kind)
397 READ_FEATURE(IoControlSpec::Pos)
398 READ_FEATURE(IoControlSpec::Rec)
399 READ_FEATURE(IoControlSpec::Size)
400 READ_FEATURE(IoUnit)
401 READ_FEATURE(Keyword)
402 READ_FEATURE(KindParam)
403 READ_FEATURE(KindSelector)
404 READ_FEATURE(KindSelector::StarSize)
405 READ_FEATURE(LabelDoStmt)
406 READ_FEATURE(LanguageBindingSpec)
407 READ_FEATURE(LengthSelector)
408 READ_FEATURE(LetterSpec)
409 READ_FEATURE(LiteralConstant)
410 READ_FEATURE(IntLiteralConstant)
411 READ_FEATURE(ReductionOperator)
412 READ_FEATURE(ReductionOperator::Operator)
413 READ_FEATURE(LocalitySpec)
414 READ_FEATURE(LocalitySpec::DefaultNone)
415 READ_FEATURE(LocalitySpec::Local)
416 READ_FEATURE(LocalitySpec::LocalInit)
417 READ_FEATURE(LocalitySpec::Reduce)
418 READ_FEATURE(LocalitySpec::Shared)
419 READ_FEATURE(LockStmt)
420 READ_FEATURE(LockStmt::LockStat)
421 READ_FEATURE(LogicalLiteralConstant)
422 READ_FEATURE(LoopControl)
423 READ_FEATURE(LoopControl::Concurrent)
424 READ_FEATURE(MainProgram)
425 READ_FEATURE(Map)
426 READ_FEATURE(Map::EndMapStmt)
427 READ_FEATURE(Map::MapStmt)
428 READ_FEATURE(MaskedElsewhereStmt)
429 READ_FEATURE(Module)
430 READ_FEATURE(ModuleStmt)
431 READ_FEATURE(ModuleSubprogram)
432 READ_FEATURE(ModuleSubprogramPart)
433 READ_FEATURE(MpSubprogramStmt)
434 READ_FEATURE(MsgVariable)
435 READ_FEATURE(Name)
436 READ_FEATURE(NamedConstant)
437 READ_FEATURE(NamedConstantDef)
438 READ_FEATURE(NamelistStmt)
439 READ_FEATURE(NamelistStmt::Group)
440 READ_FEATURE(NonLabelDoStmt)
441 READ_FEATURE(NoPass)
442 READ_FEATURE(NotifyWaitStmt)
443 READ_FEATURE(NullifyStmt)
444 READ_FEATURE(NullInit)
445 READ_FEATURE(ObjectDecl)
446 READ_FEATURE(OldParameterStmt)
447 READ_FEATURE(OmpAlignedClause)
448 READ_FEATURE(OmpAtomic)
449 READ_FEATURE(OmpAtomicCapture)
450 READ_FEATURE(OmpAtomicCapture::Stmt1)
451 READ_FEATURE(OmpAtomicCapture::Stmt2)
452 READ_FEATURE(OmpAtomicRead)
453 READ_FEATURE(OmpAtomicUpdate)
454 READ_FEATURE(OmpAtomicWrite)
455 READ_FEATURE(OmpBeginBlockDirective)
456 READ_FEATURE(OmpBeginLoopDirective)
457 READ_FEATURE(OmpBeginSectionsDirective)
458 READ_FEATURE(OmpBlockDirective)
459 READ_FEATURE(OmpCancelType)
460 READ_FEATURE(OmpCancelType::Type)
461 READ_FEATURE(OmpClause)
462 READ_FEATURE(OmpClauseList)
463 READ_FEATURE(OmpCriticalDirective)
464 READ_FEATURE(OmpDeclareTargetSpecifier)
465 READ_FEATURE(OmpDeclareTargetWithClause)
466 READ_FEATURE(OmpDeclareTargetWithList)
467 READ_FEATURE(OmpDefaultClause)
468 READ_FEATURE(OmpDefaultClause::Type)
469 READ_FEATURE(OmpDefaultmapClause)
470 READ_FEATURE(OmpDefaultmapClause::ImplicitBehavior)
471 READ_FEATURE(OmpDefaultmapClause::VariableCategory)
472 READ_FEATURE(OmpDependClause)
473 READ_FEATURE(OmpDependClause::TaskDep)
474 READ_FEATURE(OmpDoacross::Sink)
475 READ_FEATURE(OmpDoacross::Source)
476 READ_FEATURE(OmpDoacrossClause)
477 READ_FEATURE(OmpDependenceType)
478 READ_FEATURE(OmpDependenceType::Value)
479 READ_FEATURE(OmpTaskDependenceType)
480 READ_FEATURE(OmpTaskDependenceType::Value)
481 READ_FEATURE(OmpIteration)
482 READ_FEATURE(OmpIterationOffset)
483 READ_FEATURE(OmpIterationVector)
484 READ_FEATURE(OmpEndAllocators)
485 READ_FEATURE(OmpEndAtomic)
486 READ_FEATURE(OmpEndBlockDirective)
487 READ_FEATURE(OmpEndCriticalDirective)
488 READ_FEATURE(OmpEndLoopDirective)
489 READ_FEATURE(OmpEndSectionsDirective)
490 READ_FEATURE(OmpGrainsizeClause)
491 READ_FEATURE(OmpGrainsizeClause::Prescriptiveness)
492 READ_FEATURE(OmpIfClause)
493 READ_FEATURE(OmpIfClause::DirectiveNameModifier)
494 READ_FEATURE(OmpLinearClause)
495 READ_FEATURE(OmpLinearClause::WithModifier)
496 READ_FEATURE(OmpLinearClause::WithoutModifier)
497 READ_FEATURE(OmpLinearModifier)
498 READ_FEATURE(OmpLinearModifier::Value)
499 READ_FEATURE(OmpLoopDirective)
500 READ_FEATURE(OmpMapClause)
501 READ_FEATURE(OmpMapClause::TypeModifier)
502 READ_FEATURE(OmpMapClause::Type)
503 READ_FEATURE(OmpNumTasksClause)
504 READ_FEATURE(OmpNumTasksClause::Prescriptiveness)
505 READ_FEATURE(OmpObject)
506 READ_FEATURE(OmpObjectList)
507 READ_FEATURE(OmpOrderClause)
508 READ_FEATURE(OmpOrderClause::Type)
509 READ_FEATURE(OmpOrderModifier)
510 READ_FEATURE(OmpOrderModifier::Kind)
511 READ_FEATURE(OmpProcBindClause)
512 READ_FEATURE(OmpProcBindClause::Type)
513 READ_FEATURE(OmpReductionClause)
514 READ_FEATURE(OmpInReductionClause)
515 READ_FEATURE(OmpReductionCombiner)
516 READ_FEATURE(OmpReductionCombiner::FunctionCombiner)
517 READ_FEATURE(OmpReductionInitializerClause)
518 READ_FEATURE(OmpReductionIdentifier)
519 READ_FEATURE(OmpAllocateClause)
520 READ_FEATURE(OmpAllocateClause::AllocateModifier)
521 READ_FEATURE(OmpAllocateClause::AllocateModifier::Allocator)
522 READ_FEATURE(OmpAllocateClause::AllocateModifier::ComplexModifier)
523 READ_FEATURE(OmpAllocateClause::AllocateModifier::Align)
524 READ_FEATURE(OmpScheduleClause)
525 READ_FEATURE(OmpScheduleClause::ScheduleType)
526 READ_FEATURE(OmpDeviceClause)
527 READ_FEATURE(OmpDeviceClause::DeviceModifier)
528 READ_FEATURE(OmpDeviceTypeClause)
529 READ_FEATURE(OmpDeviceTypeClause::Type)
530 READ_FEATURE(OmpScheduleModifier)
531 READ_FEATURE(OmpScheduleModifier::Modifier1)
532 READ_FEATURE(OmpScheduleModifier::Modifier2)
533 READ_FEATURE(OmpScheduleModifierType)
534 READ_FEATURE(OmpScheduleModifierType::ModType)
535 READ_FEATURE(OmpSectionBlocks)
536 READ_FEATURE(OmpSectionsDirective)
537 READ_FEATURE(OmpSimpleStandaloneDirective)
538 READ_FEATURE(Only)
539 READ_FEATURE(OpenACCAtomicConstruct)
540 READ_FEATURE(OpenACCBlockConstruct)
541 READ_FEATURE(OpenACCCacheConstruct)
542 READ_FEATURE(OpenACCCombinedConstruct)
543 READ_FEATURE(OpenACCConstruct)
544 READ_FEATURE(OpenACCDeclarativeConstruct)
545 READ_FEATURE(OpenACCLoopConstruct)
546 READ_FEATURE(OpenACCRoutineConstruct)
547 READ_FEATURE(OpenACCStandaloneDeclarativeConstruct)
548 READ_FEATURE(OpenACCStandaloneConstruct)
549 READ_FEATURE(OpenACCWaitConstruct)
550 READ_FEATURE(OpenMPAtomicConstruct)
551 READ_FEATURE(OpenMPBlockConstruct)
552 READ_FEATURE(OpenMPCancelConstruct)
553 READ_FEATURE(OpenMPCancelConstruct::If)
554 READ_FEATURE(OpenMPCancellationPointConstruct)
555 READ_FEATURE(OpenMPConstruct)
556 READ_FEATURE(OpenMPCriticalConstruct)
557 READ_FEATURE(OpenMPDeclarativeAllocate)
558 READ_FEATURE(OpenMPDeclarativeConstruct)
559 READ_FEATURE(OpenMPDeclareReductionConstruct)
560 READ_FEATURE(OpenMPDeclareSimdConstruct)
561 READ_FEATURE(OpenMPDeclareTargetConstruct)
562 READ_FEATURE(OmpMemoryOrderClause)
563 READ_FEATURE(OmpAtomicClause)
564 READ_FEATURE(OmpAtomicClauseList)
565 READ_FEATURE(OmpAtomicDefaultMemOrderClause)
566 READ_FEATURE(OmpAtomicDefaultMemOrderType)
567 READ_FEATURE(OpenMPFlushConstruct)
568 READ_FEATURE(OpenMPLoopConstruct)
569 READ_FEATURE(OpenMPExecutableAllocate)
570 READ_FEATURE(OpenMPAllocatorsConstruct)
571 READ_FEATURE(OpenMPRequiresConstruct)
572 READ_FEATURE(OpenMPSimpleStandaloneConstruct)
573 READ_FEATURE(OpenMPStandaloneConstruct)
574 READ_FEATURE(OpenMPSectionConstruct)
575 READ_FEATURE(OpenMPSectionsConstruct)
576 READ_FEATURE(OpenMPThreadprivate)
577 READ_FEATURE(OpenStmt)
578 READ_FEATURE(Optional)
579 READ_FEATURE(OptionalStmt)
580 READ_FEATURE(OtherSpecificationStmt)
581 READ_FEATURE(OutputImpliedDo)
582 READ_FEATURE(OutputItem)
583 READ_FEATURE(Parameter)
584 READ_FEATURE(ParameterStmt)
585 READ_FEATURE(ParentIdentifier)
586 READ_FEATURE(Pass)
587 READ_FEATURE(PauseStmt)
588 READ_FEATURE(Pointer)
589 READ_FEATURE(PointerAssignmentStmt)
590 READ_FEATURE(PointerAssignmentStmt::Bounds)
591 READ_FEATURE(PointerDecl)
592 READ_FEATURE(PointerObject)
593 READ_FEATURE(PointerStmt)
594 READ_FEATURE(PositionOrFlushSpec)
595 READ_FEATURE(PrefixSpec)
596 READ_FEATURE(PrefixSpec::Elemental)
597 READ_FEATURE(PrefixSpec::Impure)
598 READ_FEATURE(PrefixSpec::Module)
599 READ_FEATURE(PrefixSpec::Non_Recursive)
600 READ_FEATURE(PrefixSpec::Pure)
601 READ_FEATURE(PrefixSpec::Recursive)
602 READ_FEATURE(PrintStmt)
603 READ_FEATURE(PrivateStmt)
604 READ_FEATURE(PrivateOrSequence)
605 READ_FEATURE(ProcAttrSpec)
606 READ_FEATURE(ProcComponentAttrSpec)
607 READ_FEATURE(ProcComponentDefStmt)
608 READ_FEATURE(ProcComponentRef)
609 READ_FEATURE(ProcDecl)
610 READ_FEATURE(ProcInterface)
611 READ_FEATURE(ProcPointerInit)
612 READ_FEATURE(ProcedureDeclarationStmt)
613 READ_FEATURE(ProcedureDesignator)
614 READ_FEATURE(ProcedureStmt)
615 READ_FEATURE(ProcedureStmt::Kind)
616 READ_FEATURE(Program)
617 READ_FEATURE(ProgramStmt)
618 READ_FEATURE(ProgramUnit)
619 READ_FEATURE(Protected)
620 READ_FEATURE(ProtectedStmt)
621 READ_FEATURE(ReadStmt)
622 READ_FEATURE(RealLiteralConstant)
623 READ_FEATURE(RealLiteralConstant::Real)
624 READ_FEATURE(Rename)
625 READ_FEATURE(Rename::Names)
626 READ_FEATURE(Rename::Operators)
627 READ_FEATURE(ReturnStmt)
628 READ_FEATURE(RewindStmt)
629 READ_FEATURE(Save)
630 READ_FEATURE(SaveStmt)
631 READ_FEATURE(SavedEntity)
632 READ_FEATURE(SavedEntity::Kind)
633 READ_FEATURE(SectionSubscript)
634 READ_FEATURE(SelectCaseStmt)
635 READ_FEATURE(SelectRankCaseStmt)
636 READ_FEATURE(SelectRankCaseStmt::Rank)
637 READ_FEATURE(SelectRankConstruct)
638 READ_FEATURE(SelectRankConstruct::RankCase)
639 READ_FEATURE(SelectRankStmt)
640 READ_FEATURE(SelectTypeConstruct)
641 READ_FEATURE(SelectTypeConstruct::TypeCase)
642 READ_FEATURE(SelectTypeStmt)
643 READ_FEATURE(Selector)
644 READ_FEATURE(SeparateModuleSubprogram)
645 READ_FEATURE(SequenceStmt)
646 READ_FEATURE(Sign)
647 READ_FEATURE(SignedComplexLiteralConstant)
648 READ_FEATURE(SignedIntLiteralConstant)
649 READ_FEATURE(SignedRealLiteralConstant)
650 READ_FEATURE(SpecificationConstruct)
651 READ_FEATURE(SpecificationExpr)
652 READ_FEATURE(SpecificationPart)
653 READ_FEATURE(Star)
654 READ_FEATURE(StatOrErrmsg)
655 READ_FEATURE(StatVariable)
656 READ_FEATURE(StatusExpr)
657 READ_FEATURE(StmtFunctionStmt)
658 READ_FEATURE(StopCode)
659 READ_FEATURE(StopStmt)
660 READ_FEATURE(StopStmt::Kind)
661 READ_FEATURE(StructureComponent)
662 READ_FEATURE(StructureConstructor)
663 READ_FEATURE(StructureDef)
664 READ_FEATURE(StructureDef::EndStructureStmt)
665 READ_FEATURE(StructureField)
666 READ_FEATURE(StructureStmt)
667 READ_FEATURE(Submodule)
668 READ_FEATURE(SubmoduleStmt)
669 READ_FEATURE(SubroutineStmt)
670 READ_FEATURE(SubroutineSubprogram)
671 READ_FEATURE(SubscriptTriplet)
672 READ_FEATURE(Substring)
673 READ_FEATURE(SubstringInquiry)
674 READ_FEATURE(SubstringRange)
675 READ_FEATURE(Suffix)
676 READ_FEATURE(SyncAllStmt)
677 READ_FEATURE(SyncImagesStmt)
678 READ_FEATURE(SyncImagesStmt::ImageSet)
679 READ_FEATURE(SyncMemoryStmt)
680 READ_FEATURE(SyncTeamStmt)
681 READ_FEATURE(Target)
682 READ_FEATURE(TargetStmt)
683 READ_FEATURE(TypeAttrSpec)
684 READ_FEATURE(TypeAttrSpec::BindC)
685 READ_FEATURE(TypeAttrSpec::Extends)
686 READ_FEATURE(TypeBoundGenericStmt)
687 READ_FEATURE(TypeBoundProcBinding)
688 READ_FEATURE(TypeBoundProcDecl)
689 READ_FEATURE(TypeBoundProcedurePart)
690 READ_FEATURE(TypeBoundProcedureStmt)
691 READ_FEATURE(TypeBoundProcedureStmt::WithInterface)
692 READ_FEATURE(TypeBoundProcedureStmt::WithoutInterface)
693 READ_FEATURE(TypeDeclarationStmt)
694 READ_FEATURE(TypeGuardStmt)
695 READ_FEATURE(TypeGuardStmt::Guard)
696 READ_FEATURE(TypeParamDecl)
697 READ_FEATURE(TypeParamDefStmt)
698 READ_FEATURE(common::TypeParamAttr)
699 READ_FEATURE(TypeParamSpec)
700 READ_FEATURE(TypeParamValue)
701 READ_FEATURE(TypeParamValue::Deferred)
702 READ_FEATURE(TypeSpec)
703 READ_FEATURE(Union)
704 READ_FEATURE(Union::EndUnionStmt)
705 READ_FEATURE(Union::UnionStmt)
706 READ_FEATURE(UnlockStmt)
707 READ_FEATURE(UseStmt)
708 READ_FEATURE(UseStmt::ModuleNature)
709 READ_FEATURE(Value)
710 READ_FEATURE(ValueStmt)
711 READ_FEATURE(Variable)
712 READ_FEATURE(Verbatim)
713 READ_FEATURE(Volatile)
714 READ_FEATURE(VolatileStmt)
715 READ_FEATURE(WaitSpec)
716 READ_FEATURE(WaitStmt)
717 READ_FEATURE(WhereBodyConstruct)
718 READ_FEATURE(WhereConstruct)
719 READ_FEATURE(WhereConstruct::Elsewhere)
720 READ_FEATURE(WhereConstruct::MaskedElsewhere)
721 READ_FEATURE(WhereConstructStmt)
722 READ_FEATURE(WhereStmt)
723 READ_FEATURE(WriteStmt)
725 READ_FEATURE(llvm::omp::Directive)
726 READ_FEATURE(llvm::omp::Clause)
727 READ_FEATURE(llvm::acc::Directive)
728 READ_FEATURE(llvm::acc::DefaultValue)
730 template <typename A> bool Pre(const A &) { return true; }
731 template <typename A> void Post(const A &) {}
733 template <typename T> bool Pre(const Statement<T> &) { return true; }
734 template <typename T> void Post(const Statement<T> &) {}
736 template <typename T> bool Pre(const UnlabeledStatement<T> &) { return true; }
737 template <typename T> void Post(const UnlabeledStatement<T> &) {}
739 template <typename T> bool Pre(const common::Indirection<T> &) {
740 return true;
742 template <typename T> void Post(const common::Indirection<T> &) {}
744 template <typename A> bool Pre(const Scalar<A> &) { return true; }
745 template <typename A> void Post(const Scalar<A> &) {}
747 template <typename A> bool Pre(const Constant<A> &) { return true; }
748 template <typename A> void Post(const Constant<A> &) {}
750 template <typename A> bool Pre(const Integer<A> &) { return true; }
751 template <typename A> void Post(const Integer<A> &) {}
753 template <typename A> bool Pre(const Logical<A> &) { return true; }
754 template <typename A> void Post(const Logical<A> &) {}
756 template <typename A> bool Pre(const DefaultChar<A> &) { return true; }
757 template <typename A> void Post(const DefaultChar<A> &) {}
759 template <typename... A> bool Pre(const std::tuple<A...> &) { return true; }
760 template <typename... A> void Post(const std::tuple<A...> &) {}
762 template <typename... A> bool Pre(const std::variant<A...> &) { return true; }
763 template <typename... A> void Post(const std::variant<A...> &) {}
766 bool sortNodes(std::pair<const char *, int> a, std::pair<const char *, int> b) {
767 return (a.second == b.second) ? (std::strcmp(a.first, b.first) < 0)
768 : a.second > b.second;
771 class FeatureListAction : public PluginParseTreeAction {
772 void executeAction() override {
773 NodeVisitor visitor;
774 Fortran::parser::Walk(getParsing().parseTree(), visitor);
776 const auto &frequencyMap = visitor.getFrequencies();
777 std::vector<std::pair<const char *, int>> frequencies(
778 frequencyMap.begin(), frequencyMap.end());
780 std::sort(frequencies.begin(), frequencies.end(), sortNodes);
781 for (auto const &[feature, frequency] : frequencies) {
782 llvm::outs() << feature << ": " << frequency << "\n";
786 bool beginSourceFileAction() override {
787 return runPrescan() && runParse(/*emitMessages=*/true);
791 static FrontendPluginRegistry::Add<FeatureListAction> X(
792 "feature-list", "List program features");