File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 4
4
#include " slang-ir-util.h"
5
5
6
6
#include " ../core/slang-basic.h"
7
+ #include " ../core/slang-writer.h"
7
8
8
9
#include " slang-ir-dominators.h"
9
10
@@ -8605,6 +8606,25 @@ namespace Slang
8605
8606
}
8606
8607
}
8607
8608
8609
+ void IRInst::dump ()
8610
+ {
8611
+ if (auto intLit = as<IRIntLit>(this ))
8612
+ {
8613
+ std::cout << intLit->getValue () << std::endl;
8614
+ }
8615
+ else if (auto stringLit = as<IRStringLit>(this ))
8616
+ {
8617
+ std::cout << stringLit->getStringSlice ().begin () << std::endl;
8618
+ }
8619
+ else
8620
+ {
8621
+ StringBuilder sb;
8622
+ IRDumpOptions options;
8623
+ StringWriter writer (&sb, Slang::WriterFlag::AutoFlush);
8624
+ dumpIR (this , options, nullptr , &writer);
8625
+ std::cout << sb.toString ().begin () << std::endl;
8626
+ }
8627
+ }
8608
8628
} // namespace Slang
8609
8629
8610
8630
#if SLANG_VC
Original file line number Diff line number Diff line change @@ -838,6 +838,10 @@ struct IRInst
838
838
// / If both `inPrev` and `inNext` are null, then `inParent` must have no (raw) children.
839
839
// /
840
840
void _insertAt (IRInst* inPrev, IRInst* inNext, IRInst* inParent);
841
+
842
+ // / Print the IR to stdout for debugging purposes
843
+ // /
844
+ void dump ();
841
845
};
842
846
843
847
enum class IRDynamicCastBehavior
You can’t perform that action at this time.
0 commit comments