diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2023-08-26 01:42:34 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-25 10:42:34 -0700 |
| commit | ef4c9f1f1c297f1a33be95795a7a7561e0cc3bde (patch) | |
| tree | 9ea81689432040905772aeec447adad88f212e01 /source/slang/slang-ast-dump.cpp | |
| parent | 036abc85ba1db9c8c06289f0a0492e9a95a228b9 (diff) | |
Initial version of spirv_asm block (#3151)
* Initial version of spirv_asm block
* Correct indentation of parent instruction dumping
* neater dumping for spirv_asm instructions
* Add $$ DollarDollar token
* Allow passing addresses to spirv_asm blocks
* spirv OpUndef
* String literals in spirv asm
* OpName for spirv_asm ids
* Correct failure in lower spirv_asm
* correct position for spirv_asm idents
* comment correct
* several more tests for spirv_asm blocks
* Fill out some unimplemented functions for spirv_asm expressions
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-ast-dump.cpp')
| -rw-r--r-- | source/slang/slang-ast-dump.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/source/slang/slang-ast-dump.cpp b/source/slang/slang-ast-dump.cpp index d016d1c15..7dba55c52 100644 --- a/source/slang/slang-ast-dump.cpp +++ b/source/slang/slang-ast-dump.cpp @@ -644,6 +644,55 @@ struct ASTDumpContext m_writer->emit(")"); } + void dump(const SPIRVAsmOperand& operand) + { + switch(operand.flavor) + { + case SPIRVAsmOperand::Id: + m_writer->emit("%"); + break; + case SPIRVAsmOperand::Literal: + case SPIRVAsmOperand::NamedValue: + break; + case SPIRVAsmOperand::SlangValue: + m_writer->emit("$"); + break; + case SPIRVAsmOperand::SlangValueAddr: + m_writer->emit("&"); + break; + case SPIRVAsmOperand::SlangType: + m_writer->emit("$$"); + break; + default: + SLANG_UNREACHABLE("Unhandled case in ast dump for SPIRVAsmOperand"); + } + if(operand.expr) + dump(operand.expr); + else + dump(operand.token); + } + + void dump(const SPIRVAsmInst& inst) + { + dump(inst.opcode); + for(const auto& o : inst.operands) + dump(o); + } + + void dump(const SPIRVAsmExpr& expr) + { + m_writer->emit("spirv_asm\n"); + m_writer->emit("{\n"); + m_writer->indent(); + for(const auto& i : expr.insts) + { + dump(i); + m_writer->emit(";\n"); + } + m_writer->dedent(); + m_writer->emit("}"); + } + void dumpObjectFull(NodeBase* node); ASTDumpContext(SourceWriter* writer, ASTDumpUtil::Flags flags, ASTDumpUtil::Style dumpStyle): |
