@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
+ #include " p4test.h"
18
+
17
19
#include < fstream> // IWYU pragma: keep
18
20
#include < iostream>
19
21
@@ -35,57 +37,56 @@ limitations under the License.
35
37
#include " lib/nullstream.h"
36
38
#include " midend.h"
37
39
38
- using namespace P4 ;
39
-
40
- class P4TestOptions : public CompilerOptions {
41
- public:
42
- bool parseOnly = false ;
43
- bool validateOnly = false ;
44
- bool loadIRFromJson = false ;
45
- P4TestOptions () {
46
- registerOption (
47
- " --listMidendPasses" , nullptr ,
48
- [this ](const char *) {
49
- listMidendPasses = true ;
50
- loadIRFromJson = false ;
51
- P4Test::MidEnd MidEnd (*this , outStream);
52
- exit (0 );
53
- return false ;
54
- },
55
- " [p4test] Lists exact name of all midend passes.\n " );
56
- registerOption (
57
- " --parse-only" , nullptr ,
58
- [this ](const char *) {
59
- parseOnly = true ;
60
- return true ;
61
- },
62
- " only parse the P4 input, without any further processing" );
63
- registerOption (
64
- " --validate" , nullptr ,
65
- [this ](const char *) {
66
- validateOnly = true ;
67
- return true ;
68
- },
69
- " Validate the P4 input, running just the front-end" );
70
- registerOption (
71
- " --fromJSON" , " file" ,
72
- [this ](const char *arg) {
73
- loadIRFromJson = true ;
74
- file = arg;
75
- return true ;
76
- },
77
- " read previously dumped json instead of P4 source code" );
78
- registerOption (
79
- " --turn-off-logn" , nullptr ,
80
- [](const char *) {
81
- ::P4::Log::Detail::enableLoggingGlobally = false ;
82
- return true ;
83
- },
84
- " Turn off LOGN() statements in the compiler.\n "
85
- " Use '@__debug' annotation to enable LOGN on "
86
- " the annotated P4 object within the source code.\n " );
87
- }
88
- };
40
+ P4TestOptions::P4TestOptions () {
41
+ registerOption (
42
+ " --listMidendPasses" , nullptr ,
43
+ [this ](const char *) {
44
+ listMidendPasses = true ;
45
+ loadIRFromJson = false ;
46
+ P4Test::MidEnd MidEnd (*this , outStream);
47
+ exit (0 );
48
+ return false ;
49
+ },
50
+ " [p4test] Lists exact name of all midend passes.\n " );
51
+ registerOption (
52
+ " --parse-only" , nullptr ,
53
+ [this ](const char *) {
54
+ parseOnly = true ;
55
+ return true ;
56
+ },
57
+ " only parse the P4 input, without any further processing" );
58
+ registerOption (
59
+ " --validate" , nullptr ,
60
+ [this ](const char *) {
61
+ validateOnly = true ;
62
+ return true ;
63
+ },
64
+ " Validate the P4 input, running just the front-end" );
65
+ registerOption (
66
+ " --fromJSON" , " file" ,
67
+ [this ](const char *arg) {
68
+ loadIRFromJson = true ;
69
+ file = arg;
70
+ return true ;
71
+ },
72
+ " read previously dumped json instead of P4 source code" );
73
+ registerOption (
74
+ " --turn-off-logn" , nullptr ,
75
+ [](const char *) {
76
+ ::P4::Log::Detail::enableLoggingGlobally = false ;
77
+ return true ;
78
+ },
79
+ " Turn off LOGN() statements in the compiler.\n "
80
+ " Use '@__debug' annotation to enable LOGN on "
81
+ " the annotated P4 object within the source code.\n " );
82
+ registerOption (
83
+ " --preferSwitch" , nullptr ,
84
+ [this ](const char *) {
85
+ preferSwitch = true ;
86
+ return true ;
87
+ },
88
+ " use passes that use general switch instead of action_run" );
89
+ }
89
90
90
91
class P4TestPragmas : public P4 ::P4COptionPragmaParser {
91
92
std::optional<IOptionPragmaParser::CommandLineOptions> tryToParse (
0 commit comments