12
12
// ===----------------------------------------------------------------------===//
13
13
14
14
#include " DeltaManager.h"
15
- #include " ReducerWorkItem .h"
15
+ #include " DeltaPass .h"
16
16
#include " TestRunner.h"
17
- #include " deltas/Delta.h"
18
17
#include " deltas/ReduceAliases.h"
19
18
#include " deltas/ReduceArguments.h"
20
19
#include " deltas/ReduceAttributes.h"
@@ -71,91 +70,56 @@ static cl::list<std::string>
71
70
" default, run all delta passes." ),
72
71
cl::cat(LLVMReduceOptions), cl::CommaSeparated);
73
72
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 )
73
+ // Generate two separate Pass lists: IR_Passes and MIR_Passes
74
+ static const DeltaPass IR_Passes[] = {
75
+ #undef DELTA_PASS_IR
76
+ #undef DELTA_PASS_MIR
77
+ #define DELTA_PASS_IR (NAME, FUNC, DESC ) {NAME, FUNC, DESC},
78
+ #include " DeltaPasses.def"
79
+ #undef DELTA_PASS_IR
80
+ };
81
+
82
+ static const DeltaPass MIR_Passes[] = {
83
+ #undef DELTA_PASS_IR
84
+ #undef DELTA_PASS_MIR
85
+ #define DELTA_PASS_MIR (NAME, FUNC, DESC ) {NAME, FUNC, DESC},
86
+ #include " DeltaPasses.def"
87
+ #undef DELTA_PASS_MIR
88
+ };
132
89
133
90
static void runAllDeltaPasses (TestRunner &Tester,
134
91
const SmallStringSet &SkipPass) {
135
- #define DELTA_PASS (NAME, FUNC ) \
136
- if (!SkipPass.count (NAME)) { \
137
- FUNC (Tester); \
138
- }
139
92
if (Tester.getProgram ().isMIR ()) {
140
- DELTA_PASSES_MIR;
93
+ for (const DeltaPass &Pass : MIR_Passes) {
94
+ if (!SkipPass.count (Pass.Name )) {
95
+ runDeltaPass (Tester, Pass);
96
+ }
97
+ }
141
98
} else {
142
- DELTA_PASSES;
99
+ for (const DeltaPass &Pass : IR_Passes) {
100
+ if (!SkipPass.count (Pass.Name )) {
101
+ runDeltaPass (Tester, Pass);
102
+ }
103
+ }
143
104
}
144
- #undef DELTA_PASS
145
105
}
146
106
147
107
static void runDeltaPassName (TestRunner &Tester, StringRef PassName) {
148
- #define DELTA_PASS (NAME, FUNC ) \
149
- if (PassName == NAME) { \
150
- FUNC (Tester); \
151
- return ; \
152
- }
153
108
if (Tester.getProgram ().isMIR ()) {
154
- DELTA_PASSES_MIR;
109
+ for (const DeltaPass &Pass : MIR_Passes) {
110
+ if (PassName == Pass.Name ) {
111
+ runDeltaPass (Tester, Pass);
112
+ return ;
113
+ }
114
+ }
155
115
} else {
156
- DELTA_PASSES;
116
+ for (const DeltaPass &Pass : IR_Passes) {
117
+ if (PassName == Pass.Name ) {
118
+ runDeltaPass (Tester, Pass);
119
+ return ;
120
+ }
121
+ }
157
122
}
158
- #undef DELTA_PASS
159
123
160
124
// We should have errored on unrecognized passes before trying to run
161
125
// anything.
@@ -164,24 +128,25 @@ static void runDeltaPassName(TestRunner &Tester, StringRef PassName) {
164
128
165
129
void llvm::printDeltaPasses (raw_ostream &OS) {
166
130
OS << " Delta passes (pass to `--delta-passes=` as a comma separated list):\n " ;
167
- #define DELTA_PASS (NAME, FUNC ) OS << " " << NAME << " \n " ;
168
131
OS << " IR:\n " ;
169
- DELTA_PASSES;
132
+ for (const DeltaPass &Pass : IR_Passes) {
133
+ OS << " " << Pass.Name << ' \n ' ;
134
+ }
170
135
OS << " MIR:\n " ;
171
- DELTA_PASSES_MIR;
172
- #undef DELTA_PASS
136
+ for (const DeltaPass &Pass : MIR_Passes) {
137
+ OS << " " << Pass.Name << ' \n ' ;
138
+ }
173
139
}
174
140
175
141
// Built a set of available delta passes.
176
142
static void collectPassNames (const TestRunner &Tester,
177
143
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 ;
144
+ for ( const DeltaPass &Pass : MIR_Passes) {
145
+ NameSet. insert (Pass. Name );
146
+ }
147
+ for ( const DeltaPass &Pass : IR_Passes) {
148
+ NameSet. insert (Pass. Name ) ;
183
149
}
184
- #undef DELTA_PASS
185
150
}
186
151
187
152
// / Verify all requested or skipped passes are valid names, and return them in a
0 commit comments