@@ -9,14 +9,15 @@ SPDX-License-Identifier: MIT
99#include " BinaryEncodingIGA.h"
1010#include " GTGPU_RT_ASM_Interface.h"
1111#include " iga/IGALibrary/api/igaEncoderWrapper.hpp"
12+ #include " iga/IGALibrary/Frontend/FormatterJSON.hpp"
1213#include " Timer.h"
1314#include " BuildIR.h"
1415#include " Common_ISA_framework.h"
1516
17+ #include < fstream>
1618#include < map>
1719#include < utility>
1820
19-
2021using namespace iga ;
2122using namespace vISA ;
2223
@@ -45,6 +46,8 @@ class BinaryEncodingIGA
4546 // translates and encodes (formerly "DoAll")
4647 void Encode ();
4748
49+ void EmitJSON (int dumpJSON);
50+
4851 // /////////////////////////////////////////////////////////////////////////
4952 // these function translate G4 IR to IGA IR
5053 Instruction *translateInstruction (G4_INST *g4inst, Block*& bbNew);
@@ -1034,6 +1037,19 @@ void BinaryEncodingIGA::Encode()
10341037 kernel.fg .builder ->getJitInfo ()->offsetToSkipSetFFIDGP1 =
10351038 kernel.getComputeFFIDGP1NextOff ();
10361039 }
1040+
1041+ int dumpJSON = kernel.fg .builder ->getuint32Option (vISA_dumpIgaJson);
1042+ if (dumpJSON) {
1043+ EmitJSON (dumpJSON);
1044+ }
1045+ }
1046+
1047+ void BinaryEncodingIGA::EmitJSON (int dumpJSON) {
1048+ std::string jsonFileName = fileName + " .json" ;
1049+ std::ofstream ofs (jsonFileName, std::ofstream::out);
1050+ FormatOpts fos (*platformModel);
1051+ fos.printJson = true ;
1052+ FormatJSON (ofs, fos, *IGAKernel, nullptr );
10371053}
10381054
10391055Instruction *BinaryEncodingIGA::translateInstruction (
@@ -1991,4 +2007,3 @@ bool vISA::InstSupportsSrcModifierIGA(TARGET_PLATFORM p, const G4_INST &i, const
19912007 return false ;
19922008 }
19932009}
1994-
0 commit comments