P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
P4::ApplyOptionsPragmas Class Reference
Inheritance diagram for P4::ApplyOptionsPragmas:

Public Member Functions

 ApplyOptionsPragmas (IOptionPragmaParser &parser)
 
void end_apply () override
 
bool preorder (const IR::Annotation *annotation) override
 

Detailed Description

Find P4-14 pragmas or P4-16 annotations which specify compiler or diagnostic options and generate a sequence of command-line-like arguments which can be processed by CompilerOptions or its subclasses.

The analysis of the pragmas themselves is delegated to an IOptionPragmaParser object which can be customized by backends as needed.

Although P4-16 annotations are attached to a specific program construct, this pass doesn't care what they're attached to; only their order in the program matters. This allows these annotations to be used as if they were top-level, standalone directives, and provides a natural translation path from P4-14, where truly standalone pragmas are often used. Annotations which really are specific to a certain program construct should be handled using a different approach.