1212// ===----------------------------------------------------------------------===//
1313
1414#include " DeltaManager.h"
15+ #include " DeltaPass.h"
1516#include " ReducerWorkItem.h"
1617#include " TestRunner.h"
1718#include " deltas/Delta.h"
@@ -71,91 +72,64 @@ static cl::list<std::string>
7172 " default, run all delta passes." ),
7273 cl::cat(LLVMReduceOptions), cl::CommaSeparated);
7374
74- #define DELTA_PASSES \
75- do { \
76- DELTA_PASS (" strip-debug-info" , stripDebugInfoDeltaPass) \
77- DELTA_PASS (" functions" , reduceFunctionsDeltaPass) \
78- DELTA_PASS (" function-bodies" , reduceFunctionBodiesDeltaPass) \
79- DELTA_PASS (" special-globals" , reduceSpecialGlobalsDeltaPass) \
80- DELTA_PASS (" aliases" , reduceAliasesDeltaPass) \
81- DELTA_PASS (" ifuncs" , reduceIFuncsDeltaPass) \
82- DELTA_PASS (" simplify-conditionals-true" , reduceConditionalsTrueDeltaPass) \
83- DELTA_PASS (" simplify-conditionals-false" , \
84- reduceConditionalsFalseDeltaPass) \
85- DELTA_PASS (" invokes" , reduceInvokesDeltaPass) \
86- DELTA_PASS (" unreachable-basic-blocks" , \
87- reduceUnreachableBasicBlocksDeltaPass) \
88- DELTA_PASS (" basic-blocks" , reduceBasicBlocksDeltaPass) \
89- DELTA_PASS (" simplify-cfg" , reduceUsingSimplifyCFGDeltaPass) \
90- DELTA_PASS (" function-data" , reduceFunctionDataDeltaPass) \
91- DELTA_PASS (" global-values" , reduceGlobalValuesDeltaPass) \
92- DELTA_PASS (" global-objects" , reduceGlobalObjectsDeltaPass) \
93- DELTA_PASS (" global-initializers" , reduceGlobalsInitializersDeltaPass) \
94- DELTA_PASS (" global-variables" , reduceGlobalsDeltaPass) \
95- DELTA_PASS (" di-metadata" , reduceDIMetadataDeltaPass) \
96- DELTA_PASS (" dbg-records" , reduceDbgRecordDeltaPass) \
97- DELTA_PASS (" distinct-metadata" , reduceDistinctMetadataDeltaPass) \
98- DELTA_PASS (" metadata" , reduceMetadataDeltaPass) \
99- DELTA_PASS (" named-metadata" , reduceNamedMetadataDeltaPass) \
100- DELTA_PASS (" arguments" , reduceArgumentsDeltaPass) \
101- DELTA_PASS (" instructions" , reduceInstructionsDeltaPass) \
102- DELTA_PASS (" simplify-instructions" , simplifyInstructionsDeltaPass) \
103- DELTA_PASS (" ir-passes" , runIRPassesDeltaPass) \
104- DELTA_PASS (" operands-zero" , reduceOperandsZeroDeltaPass) \
105- DELTA_PASS (" operands-one" , reduceOperandsOneDeltaPass) \
106- DELTA_PASS (" operands-nan" , reduceOperandsNaNDeltaPass) \
107- DELTA_PASS (" operands-to-args" , reduceOperandsToArgsDeltaPass) \
108- DELTA_PASS (" operands-skip" , reduceOperandsSkipDeltaPass) \
109- DELTA_PASS (" operand-bundles" , reduceOperandBundesDeltaPass) \
110- DELTA_PASS (" attributes" , reduceAttributesDeltaPass) \
111- DELTA_PASS (" module-data" , reduceModuleDataDeltaPass) \
112- DELTA_PASS (" opcodes" , reduceOpcodesDeltaPass) \
113- DELTA_PASS (" volatile" , reduceVolatileInstructionsDeltaPass) \
114- DELTA_PASS (" atomic-ordering" , reduceAtomicOrderingDeltaPass) \
115- DELTA_PASS (" syncscopes" , reduceAtomicSyncScopesDeltaPass) \
116- DELTA_PASS (" instruction-flags" , reduceInstructionFlagsDeltaPass) \
117- } while (false )
118-
119- #define DELTA_PASSES_MIR \
120- do { \
121- DELTA_PASS (" instructions" , reduceInstructionsMIRDeltaPass) \
122- DELTA_PASS (" ir-instruction-references" , \
123- reduceIRInstructionReferencesDeltaPass) \
124- DELTA_PASS (" ir-block-references" , reduceIRBlockReferencesDeltaPass) \
125- DELTA_PASS (" ir-function-references" , reduceIRFunctionReferencesDeltaPass) \
126- DELTA_PASS (" instruction-flags" , reduceInstructionFlagsMIRDeltaPass) \
127- DELTA_PASS (" register-uses" , reduceRegisterUsesMIRDeltaPass) \
128- DELTA_PASS (" register-defs" , reduceRegisterDefsMIRDeltaPass) \
129- DELTA_PASS (" register-hints" , reduceVirtualRegisterHintsDeltaPass) \
130- DELTA_PASS (" register-masks" , reduceRegisterMasksMIRDeltaPass) \
131- } while (false )
75+ // Generate two separate Pass lists: IR_Passes and MIR_Passes
76+ static const DeltaPass IR_Passes[] = {
77+ #undef DELTA_PASS_IR
78+ #undef DELTA_PASS_MIR
79+ #define DELTA_PASS_IR (NAME, FUNC, DESC ) {NAME, FUNC, DESC},
80+ #include " DeltaPasses.def"
81+ #undef DELTA_PASS_IR
82+ };
83+
84+ static const DeltaPass MIR_Passes[] = {
85+ #undef DELTA_PASS_IR
86+ #undef DELTA_PASS_MIR
87+ #define DELTA_PASS_MIR (NAME, FUNC, DESC ) {NAME, FUNC, DESC},
88+ #include " DeltaPasses.def"
89+ #undef DELTA_PASS_MIR
90+ };
91+
92+ static SmallString<64 > getPassMessage (const DeltaPass &Pass) {
93+ SmallString<64 > Message = Pass.Desc ;
94+ Message += " (" ;
95+ Message += Pass.Name ;
96+ Message += ' )' ;
97+ return Message;
98+ }
13299
133100static void runAllDeltaPasses (TestRunner &Tester,
134101 const SmallStringSet &SkipPass) {
135- #define DELTA_PASS (NAME, FUNC ) \
136- if (!SkipPass.count (NAME)) { \
137- FUNC (Tester); \
138- }
139102 if (Tester.getProgram ().isMIR ()) {
140- DELTA_PASSES_MIR;
103+ for (const DeltaPass &Pass : MIR_Passes) {
104+ if (!SkipPass.count (Pass.Name )) {
105+ runDeltaPass (Tester, Pass.Func , getPassMessage (Pass));
106+ }
107+ }
141108 } else {
142- DELTA_PASSES;
109+ for (const DeltaPass &Pass : IR_Passes) {
110+ if (!SkipPass.count (Pass.Name )) {
111+ runDeltaPass (Tester, Pass.Func , getPassMessage (Pass));
112+ }
113+ }
143114 }
144- #undef DELTA_PASS
145115}
146116
147117static void runDeltaPassName (TestRunner &Tester, StringRef PassName) {
148- #define DELTA_PASS (NAME, FUNC ) \
149- if (PassName == NAME) { \
150- FUNC (Tester); \
151- return ; \
152- }
153118 if (Tester.getProgram ().isMIR ()) {
154- DELTA_PASSES_MIR;
119+ for (const DeltaPass &Pass : MIR_Passes) {
120+ if (PassName == Pass.Name ) {
121+ runDeltaPass (Tester, Pass.Func , getPassMessage (Pass));
122+ return ;
123+ }
124+ }
155125 } else {
156- DELTA_PASSES;
126+ for (const DeltaPass &Pass : IR_Passes) {
127+ if (PassName == Pass.Name ) {
128+ runDeltaPass (Tester, Pass.Func , getPassMessage (Pass));
129+ return ;
130+ }
131+ }
157132 }
158- #undef DELTA_PASS
159133
160134 // We should have errored on unrecognized passes before trying to run
161135 // anything.
@@ -164,24 +138,25 @@ static void runDeltaPassName(TestRunner &Tester, StringRef PassName) {
164138
165139void llvm::printDeltaPasses (raw_ostream &OS) {
166140 OS << " Delta passes (pass to `--delta-passes=` as a comma separated list):\n " ;
167- #define DELTA_PASS (NAME, FUNC ) OS << " " << NAME << " \n " ;
168141 OS << " IR:\n " ;
169- DELTA_PASSES;
142+ for (const DeltaPass &Pass : IR_Passes) {
143+ OS << " " << Pass.Name << ' \n ' ;
144+ }
170145 OS << " MIR:\n " ;
171- DELTA_PASSES_MIR;
172- #undef DELTA_PASS
146+ for (const DeltaPass &Pass : MIR_Passes) {
147+ OS << " " << Pass.Name << ' \n ' ;
148+ }
173149}
174150
175151// Built a set of available delta passes.
176152static void collectPassNames (const TestRunner &Tester,
177153 SmallStringSet &NameSet) {
178- # define DELTA_PASS ( NAME, FUNC ) NameSet.insert(NAME);
179- if (Tester. getProgram (). isMIR ()) {
180- DELTA_PASSES_MIR;
181- } else {
182- DELTA_PASSES ;
154+ for ( const DeltaPass &Pass : MIR_Passes) {
155+ NameSet. insert (Pass. Name );
156+ }
157+ for ( const DeltaPass &Pass : IR_Passes) {
158+ NameSet. insert (Pass. Name ) ;
183159 }
184- #undef DELTA_PASS
185160}
186161
187162// / Verify all requested or skipped passes are valid names, and return them in a
0 commit comments