66// ===----------------------------------------------------------------------===//
77
88#include " aie/Dialect/AIE/IR/AIEDialect.h"
9+ #include " aie/Dialect/AIEX/AIEUtils.h"
910#include " aie/Dialect/AIEX/IR/AIEXDialect.h"
1011#include " aie/Dialect/AIEX/Transforms/AIEXPasses.h"
1112
@@ -264,15 +265,10 @@ struct AIELowerScratchpadParametersPass
264265 }
265266 }
266267
267- // Emit a single params.txt for the whole module.
268- //
269- // Format (one entry per line, easily parsed with std::ifstream >>):
270- // <num_parameters>
271- // <name> <state_table_idx> <type> <kind>
272- // ...
273- // where kind is "core" (shift-2 encoded, for read_scratchpad_parameter) or
274- // "addr" (raw, for offset_parameter on DMA ops).
275- LogicalResult emitParamsFile (ArrayRef<ScratchpadParameterOp> allParams) {
268+ // Emit a single params.txt for the whole module to `outputParamsFile`.
269+ // The actual serialization lives in the shared `emitScratchpadParamsFile`
270+ // helper so the aiecc graph and this pass stay in sync.
271+ LogicalResult emitParamsFile () {
276272 if (outputParamsFile.empty ())
277273 return success ();
278274
@@ -284,18 +280,7 @@ struct AIELowerScratchpadParametersPass
284280 << outputParamsFile << " ': " << ec.message ();
285281 }
286282
287- out << allParams.size () << " \n " ;
288- for (auto p : allParams) {
289- std::string typeStr;
290- llvm::raw_string_ostream os (typeStr);
291- p.getType ().print (os);
292- StringRef kindStr = p.getKind ().value () == ScratchpadParameterKind::Addr
293- ? " addr"
294- : " core" ;
295- out << p.getSymName () << " "
296- << static_cast <unsigned >(p.getStateTableIdx ().value ()) << " "
297- << typeStr << " " << kindStr << " \n " ;
298- }
283+ emitScratchpadParamsFile (getOperation (), out);
299284 return success ();
300285 }
301286
@@ -445,7 +430,7 @@ struct AIELowerScratchpadParametersPass
445430 }
446431
447432 // Step 5: emit the single params.txt for the module.
448- if (failed (emitParamsFile (allParams ))) {
433+ if (failed (emitParamsFile ())) {
449434 return signalPassFailure ();
450435 }
451436 }
0 commit comments