From 4bf59f73f00679ffecc8d0b4004eb5b8e05212b7 Mon Sep 17 00:00:00 2001 From: dhower-qc <134728312+dhower-qc@users.noreply.github.com> Date: Thu, 18 Jul 2024 17:03:18 -0400 Subject: [PATCH] Many updates: (#4) * Many updates: * Added pruning pass to remove dead/unreachable code * Added backend to generate an extension-specific document * Removed dependence on riscv-opcodes; all instruction .yaml files have their encoding now * Updated schema to be more version-centric with extensions * Started process of refactoring so that AstNodes don't have any irrelevant SyntaxNodes * Added some unit tests for the IDL compiler * Numerous bug fixes --- .github/workflows/regress.yml | 2 + .rubocop.yml | 2 + Gemfile | 3 + Gemfile.lock | 52 + arch/csr/mtval.yaml | 2 +- arch/csr/stval.yaml | 2 +- arch/csr/vstval.yaml | 96 + arch/ext/A.yaml | 1 + arch/ext/B.yaml | 1 + arch/ext/C.yaml | 1 + arch/ext/D.yaml | 1 + arch/ext/F.yaml | 1 + arch/ext/H.yaml | 1 + arch/ext/I.yaml | 1 + arch/ext/M.yaml | 1 + arch/ext/S.yaml | 3 +- arch/ext/Smaia.yaml | 1 + arch/ext/Smcdeleg.yaml | 1 + arch/ext/Smcntrpmf.yaml | 1 + arch/ext/Ssaia.yaml | 1 + arch/ext/Ssccfg.yaml | 1 + arch/ext/Sscofpmf.yaml | 1 + arch/ext/Sstc.yaml | 1 + arch/ext/Sv32.yaml | 1 + arch/ext/Sv39.yaml | 1 + arch/ext/Sv48.yaml | 1 + arch/ext/Sv57.yaml | 1 + arch/ext/U.yaml | 1 + arch/ext/Zaamo.yaml | 1 + arch/ext/Zalrsc.yaml | 1 + arch/ext/Zba.yaml | 1 + arch/ext/Zbb.yaml | 1 + arch/ext/Zbc.yaml | 1 + arch/ext/Zicbom.yaml | 1 + arch/ext/Zicboz.yaml | 1 + arch/ext/Zicntr.yaml | 1 + arch/ext/Zicsr.yaml | 1 + arch/ext/Zihpm.yaml | 1 + arch/ext/Zmmul.yaml | 1 + arch/inst/B/add.uw.yaml | 16 +- arch/inst/B/andn.yaml | 11 + arch/inst/B/bclr.yaml | 11 + arch/inst/B/bclri.yaml | 23 + arch/inst/B/bext.yaml | 13 + arch/inst/B/bexti.yaml | 23 + arch/inst/B/binv.yaml | 13 + arch/inst/B/binvi.yaml | 23 + arch/inst/B/bset.yaml | 13 + arch/inst/B/bseti.yaml | 23 + arch/inst/B/clmul.yaml | 13 + arch/inst/B/clmulh.yaml | 13 + arch/inst/B/clmulr.yaml | 13 + arch/inst/B/clz.yaml | 11 + arch/inst/B/clzw.yaml | 11 + arch/inst/B/cpop.yaml | 11 + arch/inst/B/cpopw.yaml | 11 + arch/inst/B/ctz.yaml | 11 + arch/inst/B/ctzw.yaml | 11 + arch/inst/B/max.yaml | 13 + arch/inst/B/maxu.yaml | 13 + arch/inst/B/min.yaml | 13 + arch/inst/B/minu.yaml | 13 + arch/inst/B/orc.b.yaml | 11 + arch/inst/B/orn.yaml | 13 + arch/inst/B/rev8.yaml | 22 +- arch/inst/B/rol.yaml | 13 + arch/inst/B/rolw.yaml | 13 + arch/inst/B/ror.yaml | 13 + arch/inst/B/rori.yaml | 23 + arch/inst/B/roriw.yaml | 13 + arch/inst/B/rorw.yaml | 13 + arch/inst/B/sext.b.yaml | 11 + arch/inst/B/sext.h.yaml | 11 + arch/inst/B/sh1add.uw.yaml | 13 + arch/inst/B/sh1add.yaml | 13 + arch/inst/B/sh2add.uw.yaml | 13 + arch/inst/B/sh2add.yaml | 13 + arch/inst/B/sh3add.uw.yaml | 13 + arch/inst/B/sh3add.yaml | 13 + arch/inst/B/slli.uw.yaml | 13 + arch/inst/B/xnor.yaml | 13 + arch/inst/B/zext.h.yaml | 12 +- arch/inst/F/fmv.w.x.yaml | 7 + arch/inst/I/add.yaml | 11 +- arch/inst/I/addi.yaml | 9 + arch/inst/I/addiw.yaml | 9 + arch/inst/I/addw.yaml | 9 + arch/inst/I/and.yaml | 9 + arch/inst/I/andi.yaml | 9 + arch/inst/I/auipc.yaml | 8 + arch/inst/I/beq.yaml | 10 + arch/inst/I/bge.yaml | 10 + arch/inst/I/bgeu.yaml | 10 + arch/inst/I/blt.yaml | 10 + arch/inst/I/bltu.yaml | 10 + arch/inst/I/bne.yaml | 10 + arch/inst/I/ebreak.yaml | 4 +- arch/inst/I/ecall.yaml | 8 +- arch/inst/I/fence.yaml | 13 + arch/inst/I/jal.yaml | 4 +- arch/inst/I/jalr.yaml | 9 + arch/inst/I/lb.yaml | 9 + arch/inst/I/lbu.yaml | 9 + arch/inst/I/ld.yaml | 9 + arch/inst/I/lh.yaml | 9 + arch/inst/I/lhu.yaml | 9 + arch/inst/I/lui.yaml | 8 + arch/inst/I/lw.yaml | 9 + arch/inst/I/lwu.yaml | 9 + arch/inst/I/mret.yaml | 2 + arch/inst/I/or.yaml | 9 + arch/inst/I/ori.yaml | 9 + arch/inst/I/sb.yaml | 9 + arch/inst/I/sd.yaml | 4 +- arch/inst/I/sh.yaml | 9 + arch/inst/I/sll.yaml | 11 +- arch/inst/I/slli.yaml | 19 + arch/inst/I/slliw.yaml | 9 + arch/inst/I/sllw.yaml | 9 + arch/inst/I/slt.yaml | 9 + arch/inst/I/slti.yaml | 9 + arch/inst/I/sltiu.yaml | 9 + arch/inst/I/sltu.yaml | 9 + arch/inst/I/sra.yaml | 11 +- arch/inst/I/srai.yaml | 19 + arch/inst/I/sraiw.yaml | 9 + arch/inst/I/sraw.yaml | 9 + arch/inst/I/srl.yaml | 9 + arch/inst/I/srli.yaml | 19 + arch/inst/I/srliw.yaml | 9 + arch/inst/I/srlw.yaml | 9 + arch/inst/I/sub.yaml | 9 + arch/inst/I/subw.yaml | 9 + arch/inst/I/sw.yaml | 9 + arch/inst/I/wfi.yaml | 10 +- arch/inst/I/xor.yaml | 9 + arch/inst/I/xori.yaml | 9 + arch/inst/M/div.yaml | 13 + arch/inst/M/divu.yaml | 13 + arch/inst/M/divuw.yaml | 13 + arch/inst/M/divw.yaml | 13 + arch/inst/M/mul.yaml | 13 + arch/inst/M/mulh.yaml | 19 +- arch/inst/M/mulhsu.yaml | 19 +- arch/inst/M/mulhu.yaml | 19 +- arch/inst/M/mulw.yaml | 13 + arch/inst/M/rem.yaml | 13 + arch/inst/M/remu.yaml | 13 + arch/inst/M/remuw.yaml | 13 + arch/inst/M/remw.yaml | 13 + arch/inst/S/sfence.vma.yaml | 7 + arch/inst/S/sret.yaml | 22 +- arch/inst/Zicbom/cbo.clean.yaml | 5 + arch/inst/Zicbom/cbo.flush.yaml | 5 + arch/inst/Zicbom/cbo.inval.yaml | 5 + arch/inst/Zicboz/cbo.zero.yaml | 5 + arch/inst/Zicsr/csrrs.yaml | 9 + arch/inst/Zicsr/csrrw.yaml | 9 + arch/inst/Zicsr/csrrwi.yaml | 11 +- arch/isa/globals.isa | 312 +- arch/prose/idl.adoc | 6 +- cfgs/config_validation.rb | 30 + .../arch_overlay/ext/Xcustom.yaml | 1 + cfgs/generic_rv64/params.yaml | 42 +- docs/ruby/ArchDef.html | 510 ++-- docs/ruby/ArchDefObject.html | 42 +- docs/ruby/ArchGen.html | 74 +- docs/ruby/Csr.html | 248 +- docs/ruby/CsrField.html | 166 +- docs/ruby/CsrField/Alias.html | 10 +- docs/ruby/DecodeField.html | 118 +- docs/ruby/DecodeVariable.html | 158 +- docs/ruby/EncodingField.html | 2 +- docs/ruby/Extension.html | 175 +- docs/ruby/ExtensionVersion.html | 270 +- docs/ruby/Idl.html | 8 +- docs/ruby/Idl/ArrayLiteralAst.html | 175 +- ...ryAccess.html => AryAccessSyntaxNode.html} | 76 +- docs/ruby/Idl/AryElementAccessAst.html | 462 ++- docs/ruby/Idl/AryElementAssignmentAst.html | 447 ++- .../Idl/AryElementAssignmentSyntaxNode.html | 194 ++ docs/ruby/Idl/AryRangeAccessAst.html | 581 +++- docs/ruby/Idl/AryRangeAssignmentAst.html | 114 +- docs/ruby/Idl/AssignmentAst.html | 20 +- docs/ruby/Idl/AstNode.html | 126 +- docs/ruby/Idl/AstNode/InternalError.html | 40 +- docs/ruby/Idl/AstNode/TypeError.html | 40 +- docs/ruby/Idl/AstNode/ValueError.html | 30 +- docs/ruby/Idl/AstNodeFuncs.html | 146 +- docs/ruby/Idl/BinaryExpressionAst.html | 818 ++++-- ...l => BinaryExpressionRightSyntaxNode.html} | 105 +- .../ruby/Idl/BitfieldAccessExpressionAst.html | 245 +- docs/ruby/Idl/BitfieldDefinitionAst.html | 195 +- docs/ruby/Idl/BitfieldType.html | 60 +- docs/ruby/Idl/BitsCastAst.html | 209 +- docs/ruby/Idl/BuiltinEnumDefinitionAst.html | 22 +- docs/ruby/Idl/BuiltinTypeNameAst.html | 302 +- docs/ruby/Idl/BuiltinTypeNameSyntaxNode.html | 202 ++ docs/ruby/Idl/BuiltinVariableAst.html | 527 ++++ docs/ruby/Idl/BuiltinVariableSyntaxNode.html | 194 ++ docs/ruby/Idl/Compiler.html | 375 ++- docs/ruby/Idl/ConcatenationExpressionAst.html | 207 +- .../Idl/ConditionalReturnStatementAst.html | 98 +- docs/ruby/Idl/ConditionalStatementAst.html | 469 ++- .../Idl/ConditionalStatementSyntaxNode.html | 194 ++ docs/ruby/Idl/CsrFieldReadExpressionAst.html | 325 ++- docs/ruby/Idl/CsrReadExpressionAst.html | 439 ++- docs/ruby/Idl/CsrSoftwareReadAst.html | 276 +- docs/ruby/Idl/CsrSoftwareWriteAst.html | 172 +- docs/ruby/Idl/CsrType.html | 26 +- docs/ruby/Idl/CsrWriteAst.html | 372 ++- docs/ruby/Idl/Declaration.html | 232 ++ docs/ruby/Idl/DontCareLvalueAst.html | 151 +- docs/ruby/Idl/DontCareReturnAst.html | 252 +- docs/ruby/Idl/DontCareReturnSyntaxNode.html | 194 ++ docs/ruby/Idl/ElseIfAst.html | 733 +++++ docs/ruby/Idl/EnumDefinitionAst.html | 199 +- docs/ruby/Idl/EnumRefAst.html | 418 ++- docs/ruby/Idl/EnumRefSyntaxNode.html | 194 ++ docs/ruby/Idl/EnumerationType.html | 78 +- docs/ruby/Idl/Executable.html | 10 +- docs/ruby/Idl/ExecutionCommentAst.html | 6 +- docs/ruby/Idl/FieldAssignmentAst.html | 132 +- docs/ruby/Idl/FieldNameAst.html | 91 +- docs/ruby/Idl/ForLoopAst.html | 760 ++++- docs/ruby/Idl/ForLoopSyntaxNode.html | 206 ++ docs/ruby/Idl/FunctionBodyAst.html | 482 ++- docs/ruby/Idl/FunctionBodySyntaxNode.html | 194 ++ docs/ruby/Idl/FunctionCallExpressionAst.html | 672 +++-- .../Idl/FunctionCallExpressionSyntaxNode.html | 202 ++ docs/ruby/Idl/FunctionDefAst.html | 830 +++--- docs/ruby/Idl/FunctionStatementAst.html | 1037 ------- docs/ruby/Idl/FunctionType.html | 314 +- docs/ruby/Idl/GlobalAst.html | 18 +- .../ruby/Idl/GlobalWithInitializationAst.html | 36 +- docs/ruby/Idl/IdAst.html | 322 +- docs/ruby/Idl/IdSyntaxNode.html | 190 ++ docs/ruby/Idl/IfAst.html | 1147 ++++++-- docs/ruby/Idl/IfBodyAst.html | 877 ++++++ docs/ruby/Idl/IfSyntaxNode.html | 248 ++ docs/ruby/Idl/InstructionOperationAst.html | 74 +- .../Idl/InstructionOperationSyntaxNode.html | 211 ++ docs/ruby/Idl/IntAst.html | 1296 --------- docs/ruby/Idl/IntLiteralAst.html | 1871 ++++++++++++ docs/ruby/Idl/IntLiteralSyntaxNode.html | 174 ++ docs/ruby/Idl/IsaAst.html | 134 +- docs/ruby/Idl/MultiVariableAssignmentAst.html | 110 +- .../ruby/Idl/MultiVariableDeclarationAst.html | 122 +- .../Idl/{BitsTypeAst.html => NoopAst.html} | 209 +- docs/ruby/Idl/ParenExpressionAst.html | 368 ++- docs/ruby/Idl/ParenExpressionSyntaxNode.html | 194 ++ docs/ruby/Idl/PostDecrementExpressionAst.html | 42 +- docs/ruby/Idl/PostIncrementExpressionAst.html | 44 +- docs/ruby/Idl/ReplicationExpressionAst.html | 470 ++- .../Idl/ReplicationExpressionSyntaxNode.html | 194 ++ docs/ruby/Idl/ReturnStatementAst.html | 338 ++- docs/ruby/Idl/Returns.html | 76 +- docs/ruby/Idl/Rvalue.html | 133 +- docs/ruby/Idl/SignCastAst.html | 382 ++- docs/ruby/Idl/SignCastSyntaxNode.html | 194 ++ docs/ruby/Idl/StatementAst.html | 389 ++- docs/ruby/Idl/StatementSyntaxNode.html | 200 ++ docs/ruby/Idl/SymbolTable.html | 943 +++++- .../Idl/SymbolTable/DuplicateSymError.html | 2 +- docs/ruby/Idl/TemplateFunctionType.html | 376 --- .../Idl/TernaryOperatorExpressionAst.html | 602 +++- .../TernaryOperatorExpressionSyntaxNode.html | 194 ++ docs/ruby/Idl/Type.html | 458 +-- docs/ruby/Idl/UnaryOperatorExpressionAst.html | 321 +- docs/ruby/Idl/UserTypeNameAst.html | 26 +- docs/ruby/Idl/Var.html | 343 ++- docs/ruby/Idl/VarReadExpressionAst.html | 455 --- docs/ruby/Idl/VariableAssignmentAst.html | 295 +- .../Idl/VariableAssignmentSyntaxNode.html | 194 ++ docs/ruby/Idl/VariableDeclarationAst.html | 233 +- ...iableDeclarationWithInitializationAst.html | 811 +++++- ...clarationWithInitializationSyntaxNode.html | 202 ++ docs/ruby/Idl/XregType.html | 26 +- docs/ruby/Instruction.html | 1565 ++++++++-- docs/ruby/Instruction/Encoding.html | 76 +- docs/ruby/Instruction/Encoding/Field.html | 36 +- docs/ruby/MockArchDef.html | 245 ++ docs/ruby/MockExtension.html | 296 ++ docs/ruby/Opcodes.html | 18 +- docs/ruby/RiscvOpcodes.html | 2 +- docs/ruby/TestExpressions.html | 613 ++++ docs/ruby/TestMixin.html | 183 ++ docs/ruby/TestVariables.html | 269 ++ docs/ruby/Treetop.html | 4 +- docs/ruby/Treetop/Runtime.html | 4 +- docs/ruby/Treetop/Runtime/CompiledParser.html | 2 +- docs/ruby/Treetop/Runtime/SyntaxNode.html | 486 ++-- docs/ruby/Validator.html | 2 +- docs/ruby/Validator/SchemaError.html | 2 +- docs/ruby/Validator/ValidationError.html | 2 +- docs/ruby/_index.html | 217 +- docs/ruby/class_list.html | 2 +- docs/ruby/file.README.html | 67 +- docs/ruby/index.html | 67 +- docs/ruby/method_list.html | 2590 ++++++++++++----- docs/ruby/top-level-namespace.html | 6 +- docs/schema/arch_schema.html | 1 - docs/schema/arch_schema.md | 1908 ------------ docs/schema/csr_schema.html | 2 - docs/schema/csr_schema.md | 783 ----- docs/schema/exception_code_schema.html | 1 - docs/schema/exception_code_schema.md | 10 - docs/schema/extension_schema.html | 1 - docs/schema/extension_schema.md | 360 --- docs/schema/extensions.schema.html | 1 - docs/schema/extensions.schema.md | 249 -- docs/schema/inst_schema.html | 1 - docs/schema/inst_schema.md | 307 -- docs/schema/schema_doc.css | 181 -- docs/schema/schema_doc.min.js | 1 - lib/arch_def.rb | 438 +-- lib/arch_gen.rb | 68 +- lib/idl.rb | 85 +- lib/idl/ast.rb | 1786 +++++++++--- lib/idl/idl.treetop | 134 +- lib/idl/passes/gen_adoc.rb | 250 +- lib/idl/passes/prune.rb | 223 ++ lib/idl/symbol_table.rb | 2 +- lib/idl/tests/helpers.rb | 23 + lib/idl/tests/test_expressions.rb | 129 + lib/idl/tests/test_variables.rb | 22 + lib/idl/type.rb | 41 +- lib/opcodes.rb | 11 +- schemas/config_schema.json | 208 +- schemas/ext_schema.json | 92 +- schemas/inst_schema.json | 47 +- schemas/schema_defs.json | 34 +- tasks/adoc_gen.rake | 2 + tasks/ext_pdf_gen.rake | 95 + tasks/html_gen.rake | 16 +- tasks/top.rake | 6 + views/adoc/csr.adoc.erb | 2 +- views/adoc/ext.adoc.erb | 6 +- views/adoc/ext_pdf.adoc.erb | 193 ++ views/adoc/func.adoc.erb | 19 +- views/adoc/inst.adoc.erb | 26 +- views/adoc/toc.adoc.erb | 6 +- 342 files changed, 35091 insertions(+), 14390 deletions(-) create mode 100644 arch/csr/vstval.yaml rename docs/ruby/Idl/{AryAccess.html => AryAccessSyntaxNode.html} (89%) create mode 100644 docs/ruby/Idl/AryElementAssignmentSyntaxNode.html rename docs/ruby/Idl/{BinaryExpressionRightAst.html => BinaryExpressionRightSyntaxNode.html} (62%) create mode 100644 docs/ruby/Idl/BuiltinTypeNameSyntaxNode.html create mode 100644 docs/ruby/Idl/BuiltinVariableAst.html create mode 100644 docs/ruby/Idl/BuiltinVariableSyntaxNode.html create mode 100644 docs/ruby/Idl/ConditionalStatementSyntaxNode.html create mode 100644 docs/ruby/Idl/Declaration.html create mode 100644 docs/ruby/Idl/DontCareReturnSyntaxNode.html create mode 100644 docs/ruby/Idl/ElseIfAst.html create mode 100644 docs/ruby/Idl/EnumRefSyntaxNode.html create mode 100644 docs/ruby/Idl/ForLoopSyntaxNode.html create mode 100644 docs/ruby/Idl/FunctionBodySyntaxNode.html create mode 100644 docs/ruby/Idl/FunctionCallExpressionSyntaxNode.html delete mode 100644 docs/ruby/Idl/FunctionStatementAst.html create mode 100644 docs/ruby/Idl/IdSyntaxNode.html create mode 100644 docs/ruby/Idl/IfBodyAst.html create mode 100644 docs/ruby/Idl/IfSyntaxNode.html create mode 100644 docs/ruby/Idl/InstructionOperationSyntaxNode.html delete mode 100644 docs/ruby/Idl/IntAst.html create mode 100644 docs/ruby/Idl/IntLiteralAst.html create mode 100644 docs/ruby/Idl/IntLiteralSyntaxNode.html rename docs/ruby/Idl/{BitsTypeAst.html => NoopAst.html} (57%) create mode 100644 docs/ruby/Idl/ParenExpressionSyntaxNode.html create mode 100644 docs/ruby/Idl/ReplicationExpressionSyntaxNode.html create mode 100644 docs/ruby/Idl/SignCastSyntaxNode.html create mode 100644 docs/ruby/Idl/StatementSyntaxNode.html delete mode 100644 docs/ruby/Idl/TemplateFunctionType.html create mode 100644 docs/ruby/Idl/TernaryOperatorExpressionSyntaxNode.html delete mode 100644 docs/ruby/Idl/VarReadExpressionAst.html create mode 100644 docs/ruby/Idl/VariableAssignmentSyntaxNode.html create mode 100644 docs/ruby/Idl/VariableDeclarationWithInitializationSyntaxNode.html create mode 100644 docs/ruby/MockArchDef.html create mode 100644 docs/ruby/MockExtension.html create mode 100644 docs/ruby/TestExpressions.html create mode 100644 docs/ruby/TestMixin.html create mode 100644 docs/ruby/TestVariables.html delete mode 100644 docs/schema/arch_schema.html delete mode 100644 docs/schema/arch_schema.md delete mode 100644 docs/schema/csr_schema.html delete mode 100644 docs/schema/csr_schema.md delete mode 100644 docs/schema/exception_code_schema.html delete mode 100644 docs/schema/exception_code_schema.md delete mode 100644 docs/schema/extension_schema.html delete mode 100644 docs/schema/extension_schema.md delete mode 100644 docs/schema/extensions.schema.html delete mode 100644 docs/schema/extensions.schema.md delete mode 100644 docs/schema/inst_schema.html delete mode 100644 docs/schema/inst_schema.md delete mode 100644 docs/schema/schema_doc.css delete mode 100644 docs/schema/schema_doc.min.js create mode 100644 lib/idl/passes/prune.rb create mode 100644 lib/idl/tests/helpers.rb create mode 100644 lib/idl/tests/test_expressions.rb create mode 100644 lib/idl/tests/test_variables.rb create mode 100644 tasks/ext_pdf_gen.rake create mode 100644 views/adoc/ext_pdf.adoc.erb diff --git a/.github/workflows/regress.yml b/.github/workflows/regress.yml index fb132d4b2..15c5cfaad 100644 --- a/.github/workflows/regress.yml +++ b/.github/workflows/regress.yml @@ -31,5 +31,7 @@ jobs: run: ./bin/build_container - name: Setup project run: ./bin/setup + - name: Run IDL tests + run: ./do idl_test - name: Build html documentation for generic_rv64 run: ./do gen:html[generic_rv64] diff --git a/.rubocop.yml b/.rubocop.yml index bc0890133..ca2d2a8fd 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +require: rubocop-minitest + AllCops: TargetRubyVersion: 3.2.3 diff --git a/Gemfile b/Gemfile index 13598962a..e2d8a24e7 100644 --- a/Gemfile +++ b/Gemfile @@ -6,9 +6,11 @@ source "https://rubygems.org" gem "asciidoctor-diagram", "~> 2.2" gem "asciidoctor-multipage" +gem "asciidoctor-pdf" gem "base64" gem "bigdecimal" gem "json_schemer", "~> 1.0" +gem "minitest" gem "rake", "~> 13.0" gem "slim", "~> 5.1" gem "treetop", "1.6.12" @@ -17,4 +19,5 @@ gem "yard" group :development do gem "solargraph" + gem 'rubocop-minitest' end diff --git a/Gemfile.lock b/Gemfile.lock index c42a4f193..aee88f915 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,10 @@ GEM remote: https://rubygems.org/ specs: + Ascii85 (1.1.1) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + afm (0.2.2) asciidoctor (2.0.23) asciidoctor-diagram (2.3.0) asciidoctor (>= 1.5.7, < 3.x) @@ -13,14 +17,28 @@ GEM asciidoctor-diagram-batik (~> 1.17) asciidoctor-multipage (0.0.19) asciidoctor (>= 2.0.11, < 2.1) + asciidoctor-pdf (2.3.14) + asciidoctor (~> 2.0) + concurrent-ruby (~> 1.1) + matrix (~> 0.4) + prawn (~> 2.4.0) + prawn-icon (~> 3.0.0) + prawn-svg (~> 0.34.0) + prawn-table (~> 0.2.0) + prawn-templates (~> 0.1.0) + treetop (~> 1.6.0) ast (2.4.2) backport (1.2.0) base64 (0.2.0) benchmark (0.3.0) bigdecimal (3.1.8) + concurrent-ruby (1.3.3) + css_parser (1.17.1) + addressable diff-lcs (1.5.1) e2mmap (0.1.0) hana (1.3.7) + hashery (2.1.2) jaro_winkler (1.6.0) json (2.7.2) json_schemer (1.0.3) @@ -32,13 +50,38 @@ GEM kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) language_server-protocol (3.17.0.3) + matrix (0.4.2) + minitest (5.24.1) nokogiri (1.16.5-x86_64-linux) racc (~> 1.4) parallel (1.24.0) parser (3.3.2.0) ast (~> 2.4.1) racc + pdf-core (0.9.0) + pdf-reader (2.12.0) + Ascii85 (~> 1.0) + afm (~> 0.2.1) + hashery (~> 2.0) + ruby-rc4 + ttfunk polyglot (0.3.5) + prawn (2.4.0) + pdf-core (~> 0.9.0) + ttfunk (~> 1.7) + prawn-icon (3.0.0) + prawn (>= 1.1.0, < 3.0.0) + prawn-svg (0.34.2) + css_parser (~> 1.6) + matrix (~> 0.4.2) + prawn (>= 0.11.1, < 3) + rexml (~> 3.2) + prawn-table (0.2.2) + prawn (>= 1.3.0, < 3.0.0) + prawn-templates (0.1.2) + pdf-reader (~> 2.0) + prawn (~> 2.2) + public_suffix (6.0.0) racc (1.8.0) rainbow (3.1.1) rake (13.2.1) @@ -61,7 +104,11 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.31.3) parser (>= 3.3.1.0) + rubocop-minitest (0.35.1) + rubocop (>= 1.61, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (1.13.0) + ruby-rc4 (0.1.5) simpleidn (0.2.3) slim (5.2.1) temple (~> 0.10.0) @@ -88,6 +135,8 @@ GEM tilt (2.3.0) treetop (1.6.12) polyglot (~> 0.3) + ttfunk (1.8.0) + bigdecimal (~> 3.1) unicode-display_width (2.5.0) webrick (1.8.1) yard (0.9.36) @@ -98,10 +147,13 @@ PLATFORMS DEPENDENCIES asciidoctor-diagram (~> 2.2) asciidoctor-multipage + asciidoctor-pdf base64 bigdecimal json_schemer (~> 1.0) + minitest rake (~> 13.0) + rubocop-minitest slim (~> 5.1) solargraph treetop (= 1.6.12) diff --git a/arch/csr/mtval.yaml b/arch/csr/mtval.yaml index 217119e65..d2222d5c5 100644 --- a/arch/csr/mtval.yaml +++ b/arch/csr/mtval.yaml @@ -22,7 +22,7 @@ mtval: ! [1] Instruction access fault ! The <% if ext?(:C) %> portion of the <% end %> virtual PC causing the access fault <%- unless ext?(:C) -%>(same as the value written to `mepc`)<%- end -%>. ! [2] Illegal Instruction ! The encoding of the illegal instruction. ! [3] Breakpoint - ! <%- if REPORT_EBREAK_PC_IN_TVAL -%> + ! <%- if REPORT_VA_IN_MTVAL_ON_BREAKPOINT -%> When caused by an EBREAK instruction, the virtual PC of the breakpoint instruction. <%- else -%> When caused by an EBREAK instruction, zero. diff --git a/arch/csr/stval.yaml b/arch/csr/stval.yaml index 6f297e6d2..52be3f540 100644 --- a/arch/csr/stval.yaml +++ b/arch/csr/stval.yaml @@ -22,7 +22,7 @@ stval: ! [1] Instruction access fault ! The <% if ext?(:C) %> portion of the <% end %> virtual PC causing the access fault <%- unless ext?(:C) -%>(same as the value written to `mepc`)<%- end -%>. ! [2] Illegal Instruction ! The encoding of the illegal instruction. ! [3] Breakpoint - ! <%- if REPORT_EBREAK_PC_IN_TVAL -%> + ! <%- if REPORT_VA_IN_STVAL_ON_BREAKPOINT -%> When caused by an EBREAK instruction, the virtual PC of the breakpoint instruction. <%- else -%> When caused by an EBREAK instruction, zero. diff --git a/arch/csr/vstval.yaml b/arch/csr/vstval.yaml new file mode 100644 index 000000000..a02d7ea61 --- /dev/null +++ b/arch/csr/vstval.yaml @@ -0,0 +1,96 @@ +# yaml-language-server: $schema=../../schemas/csr_schema.json + +vstval: + long_name: Virtual supervisor Trap Value + address: 0x243 + virtual_address: 0x143 + description: Holds trap-specific information + priv_mode: S + length: VSXLEN + definedBy: H + fields: + VALUE: + location_rv32: 31-0 + location_rv64: 63-0 + description: | + Written with trap-specific information when a trap is taken into VS-mode. + + The values are: + + !=== + ! Exception type ! Value + + ! [0] Instruction address misaligned ! The misaligned virtual PC (same as the value written to `mepc`). + ! [1] Instruction access fault ! The <% if ext?(:C) %> portion of the <% end %> virtual PC causing the access fault <%- unless ext?(:C) -%>(same as the value written to `mepc`)<%- end -%>. + ! [2] Illegal Instruction ! The encoding of the illegal instruction. + ! [3] Breakpoint + ! <%- if REPORT_VA_IN_STVAL_ON_BREAKPOINT -%> + When caused by an EBREAK instruction, the virtual PC of the breakpoint instruction. + <%- else -%> + When caused by an EBREAK instruction, zero. + <%- end -%> + + When caused by a data address (_i.e._, watchpoint) breakpoint, the faulting virtual address. + When caused by an instruction address breakpoint, the faulting virtual PC. + ! [4] Load address misaligned ! The misaligned virtual load address. + ! [5] Load access fault + ! The part of virtual load address causing in the access fault. + + When the load is misaligned, the reported value is the smallest address on the page causing a fault + (_e.g._, if an 8-byte load is equally split across a page and the fault occurs on the second page, + address + 4 is reported). + + (Even though the access fault arises on a physical address, the virtual address is reported) + ! [6] Store/AMO address misaligned ! The misaligned virtual store/AMO address. + ! [7] Store/AMO access fault + ! The virtual store/AMO address causing the access fault. + + When the store/AMO is misaligned, the reported value is the smallest address on the page causing a fault + (_e.g._, if an 8-byte store is equally split across a page and the fault occurs on the second page, + address + 4 is reported). + + (Even though the access fault arises on a physical address, the virtual address is reported) + ! [8] Environment call from U-mode <% if ext?(:H) %>or VU-mode<% end %> ! Zero + ! [9] Environment call from (H)S-mode ! Zero + <%- if ext?(:H) -%> + ! [10] Environment call from VS-mode ! Zero + <%- end -%> + ! [12] Instruction page fault + ! The <% if ext?(:C) %> portion of the <% end %> virtual PC causing the page fault + <% unless ext?(:C) %>(same as the value written to `mepc`)<% end %>. + ! [13] Load page fault + ! The part of the virtual load address causing in the page fault. + + When the load is misaligned, the reported value is the smallest address on the page causing a fault + (_e.g._, if an 8-byte load is equally split across a page and the fault occurs on the second page, address + 4 is reported). + ! [15] Store/AMO page fault + ! The virtual store/AMO address causing in the page fault. + + When the store/AMO is misaligned, the reported value is the smallest address on the page causing a fault + (_e.g._, if an 8-byte store is equally split across a page and the fault occurs on the second page, address + 4 is reported). + <%- if ext?(:H) -%> + ! [20] Instruction guest-page fault + ! The <% if ext?(:C) %> portion of the <% end %> virtual PC causing the fault <% unless ext?(:C) %>(same as the value written to `mepc`)<% end %>. + + The guest physical address is reported in `mtval2`. + ! [21] Load guest-page fault + ! The part of the virtual address causing the fault. + + When the load is misaligned, the reported value is the smallest address on the page causing a fault + (_e.g._, if an 8-byte load is equally split across a page and the fault occurs on the second page, address + 4 is reported). + + The guest physical address is reported in `mtval2`. + ! [22] Virutal instruction + ! The encoding of the faulting virtual instruction. + ! [23] Store/AMO guest-page fault + ! The part of the virtual address causing the fault. + + When the store/AMO is misaligned, the reported value is the smallest address on the page causing a fault + (_e.g._, if an 8-byte store is equally split across a page and the fault occurs on the second page, address + 4 is reported). + + The guest physical address is reported in `htval`. + <%- end -%> + !=== + + type: RW-H + reset_value: 0 diff --git a/arch/ext/A.yaml b/arch/ext/A.yaml index c889fb64f..8aeab5392 100644 --- a/arch/ext/A.yaml +++ b/arch/ext/A.yaml @@ -4,6 +4,7 @@ A: type: unprivileged versions: - version: 2.1 + state: ratified ratification_date: 2019-12 implies: - [Zaamo, 1.0] diff --git a/arch/ext/B.yaml b/arch/ext/B.yaml index fa9b981c6..98225589a 100644 --- a/arch/ext/B.yaml +++ b/arch/ext/B.yaml @@ -4,6 +4,7 @@ B: type: unprivileged versions: - version: 1.0 + state: ratified ratification_date: 2024-04 url: https://drive.google.com/file/d/1SgLoasaBjs5WboQMaU3wpHkjUwV71UZn/view implies: diff --git a/arch/ext/C.yaml b/arch/ext/C.yaml index 05ba14b75..7468e3950 100644 --- a/arch/ext/C.yaml +++ b/arch/ext/C.yaml @@ -4,6 +4,7 @@ C: type: unprivileged versions: - version: 2.2 + state: ratified ratification_date: 2019-12 description: | The `C` extension reduces static and dynamic code size by diff --git a/arch/ext/D.yaml b/arch/ext/D.yaml index b2b1d0289..626e4e0e8 100644 --- a/arch/ext/D.yaml +++ b/arch/ext/D.yaml @@ -4,6 +4,7 @@ D: type: unprivileged versions: - version: 2.2 + state: ratified ratification_date: 2019-12 changes: Define NaN-boxing scheme, changed definition of FMAX and FMIN implies: [F, 2.2] diff --git a/arch/ext/F.yaml b/arch/ext/F.yaml index d9805d841..16c224648 100644 --- a/arch/ext/F.yaml +++ b/arch/ext/F.yaml @@ -4,6 +4,7 @@ F: type: unprivileged versions: - version: 2.2 + state: ratified ratification_date: 2019-12 changes: Define NaN-boxing scheme, changed definition of FMAX and FMIN description: | diff --git a/arch/ext/H.yaml b/arch/ext/H.yaml index 6daf63d9e..83daea8b3 100644 --- a/arch/ext/H.yaml +++ b/arch/ext/H.yaml @@ -4,6 +4,7 @@ H: type: privileged versions: - version: 1.0 + state: ratified ratification_date: 2019-12 requires: [S, '>= 1.12'] interrupt_codes: diff --git a/arch/ext/I.yaml b/arch/ext/I.yaml index a3ca6d4cb..a1197bdb2 100644 --- a/arch/ext/I.yaml +++ b/arch/ext/I.yaml @@ -4,6 +4,7 @@ I: type: unprivileged versions: - version: 2.1 + state: ratified ratification_date: 2019-06 changes: atified RVWMO memory model and exclusion of FENCE.I, counters, and CSR instructions that were in previous base ISA description: | diff --git a/arch/ext/M.yaml b/arch/ext/M.yaml index 48f13d8fb..46881e086 100644 --- a/arch/ext/M.yaml +++ b/arch/ext/M.yaml @@ -4,6 +4,7 @@ M: type: unprivileged versions: - version: 2.0 + state: ratified ratification_date: 2019-12 description: | This chapter describes the standard integer multiplication and division diff --git a/arch/ext/S.yaml b/arch/ext/S.yaml index 67bfb1aae..2c5a5bc37 100644 --- a/arch/ext/S.yaml +++ b/arch/ext/S.yaml @@ -4,8 +4,9 @@ S: type: privileged versions: - version: 1.12 + state: ratified ratification_date: 2019-12 - requires: [U, 1.12] + requires: [U, "= 1.12"] description: | This chapter describes the RISC-V supervisor-level architecture, which contains a common core that is used with various supervisor-level diff --git a/arch/ext/Smaia.yaml b/arch/ext/Smaia.yaml index e52de05df..090868454 100644 --- a/arch/ext/Smaia.yaml +++ b/arch/ext/Smaia.yaml @@ -5,5 +5,6 @@ Smaia: type: privileged versions: - version: 1.0 + state: ratified ratification_date: 2023-06 url: https://github.com/riscv/riscv-aia/releases/download/1.0/riscv-interrupts-1.0.pdf diff --git a/arch/ext/Smcdeleg.yaml b/arch/ext/Smcdeleg.yaml index e35012472..d6c4fe7e8 100644 --- a/arch/ext/Smcdeleg.yaml +++ b/arch/ext/Smcdeleg.yaml @@ -5,5 +5,6 @@ Smcdeleg: type: privileged versions: - version: 0 + state: ratified ratification_date: null url: https://docs.google.com/document/d/1s-GeH5XpHBLzbQZucA8DPA7vvF7Xvf_nrPbrU2YLBcE/edit#heading=h.yyrgtolcaczx diff --git a/arch/ext/Smcntrpmf.yaml b/arch/ext/Smcntrpmf.yaml index d8b718c54..6719a6812 100644 --- a/arch/ext/Smcntrpmf.yaml +++ b/arch/ext/Smcntrpmf.yaml @@ -5,5 +5,6 @@ Smcntrpmf: type: privileged versions: - version: 1.0 + state: ratified ratification_date: 2023-08 url: https://github.com/riscv/riscv-smcntrpmf/releases/download/v1.0_rc4-frozen/riscv-smcntrpmf-v1.0_rc4.pdf diff --git a/arch/ext/Ssaia.yaml b/arch/ext/Ssaia.yaml index ae4f3a155..49a5218d2 100644 --- a/arch/ext/Ssaia.yaml +++ b/arch/ext/Ssaia.yaml @@ -5,6 +5,7 @@ Ssaia: type: privileged versions: - version: 1.0 + state: ratified ratification_date: 2023-06 url: https://github.com/riscv/riscv-aia/releases/download/1.0/riscv-interrupts-1.0.pdf requires: [S, ">= 1.12"] diff --git a/arch/ext/Ssccfg.yaml b/arch/ext/Ssccfg.yaml index 70b47dc5d..04261f5c2 100644 --- a/arch/ext/Ssccfg.yaml +++ b/arch/ext/Ssccfg.yaml @@ -5,5 +5,6 @@ Ssccfg: type: privileged versions: - version: 0 + state: ratified ratification_date: null url: https://docs.google.com/document/d/1s-GeH5XpHBLzbQZucA8DPA7vvF7Xvf_nrPbrU2YLBcE/edit#heading=h.yyrgtolcaczx diff --git a/arch/ext/Sscofpmf.yaml b/arch/ext/Sscofpmf.yaml index 5755c3973..cc67f3b0b 100644 --- a/arch/ext/Sscofpmf.yaml +++ b/arch/ext/Sscofpmf.yaml @@ -5,5 +5,6 @@ Sscofpmf: type: privileged versions: - version: 1.0 + state: ratified ratification_date: 2023-08 url: https://drive.google.com/file/d/1KcjgbLM5L1ZKY8934aJl8aQwGlMz6Cbo/view?usp=drive_link diff --git a/arch/ext/Sstc.yaml b/arch/ext/Sstc.yaml index a25987372..8b11436b7 100644 --- a/arch/ext/Sstc.yaml +++ b/arch/ext/Sstc.yaml @@ -5,5 +5,6 @@ Sstc: type: privileged versions: - version: 0.9 + state: ratified ratification_date: null url: https://drive.google.com/file/d/1m84Re2yK8m_vbW7TspvevCDR82MOBaSX/view?usp=drive_link diff --git a/arch/ext/Sv32.yaml b/arch/ext/Sv32.yaml index cb5dfc853..251d3779b 100644 --- a/arch/ext/Sv32.yaml +++ b/arch/ext/Sv32.yaml @@ -5,5 +5,6 @@ Sv32: type: privileged versions: - version: 1.12 + state: ratified ratification_date: unknown url: https://github.com/riscv/riscv-isa-manual/releases/download/Priv-v1.12/riscv-privileged-20211203.pdf diff --git a/arch/ext/Sv39.yaml b/arch/ext/Sv39.yaml index 416eb04fe..f3ef68b2a 100644 --- a/arch/ext/Sv39.yaml +++ b/arch/ext/Sv39.yaml @@ -5,5 +5,6 @@ Sv39: type: privileged versions: - version: 1.12 + state: ratified ratification_date: unknown url: https://github.com/riscv/riscv-isa-manual/releases/download/Priv-v1.12/riscv-privileged-20211203.pdf diff --git a/arch/ext/Sv48.yaml b/arch/ext/Sv48.yaml index cd5ef2b11..b522e5af7 100644 --- a/arch/ext/Sv48.yaml +++ b/arch/ext/Sv48.yaml @@ -5,6 +5,7 @@ Sv48: type: privileged versions: - version: 1.12 + state: ratified ratification_date: unknown url: https://github.com/riscv/riscv-isa-manual/releases/download/Priv-v1.12/riscv-privileged-20211203.pdf requires: [Sv39, ">= 1.12"] diff --git a/arch/ext/Sv57.yaml b/arch/ext/Sv57.yaml index e55ca2f26..e25626ea6 100644 --- a/arch/ext/Sv57.yaml +++ b/arch/ext/Sv57.yaml @@ -5,6 +5,7 @@ Sv57: type: privileged versions: - version: 1.12 + state: ratified ratification_date: unknown url: https://github.com/riscv/riscv-isa-manual/releases/download/Priv-v1.12/riscv-privileged-20211203.pdf requires: [Sv48, ">= 1.12"] diff --git a/arch/ext/U.yaml b/arch/ext/U.yaml index 343164626..ce24796cc 100644 --- a/arch/ext/U.yaml +++ b/arch/ext/U.yaml @@ -5,4 +5,5 @@ U: type: privileged versions: - version: 1.12 + state: ratified ratification_date: 2019-12 diff --git a/arch/ext/Zaamo.yaml b/arch/ext/Zaamo.yaml index 0a18d25c7..37e23565e 100644 --- a/arch/ext/Zaamo.yaml +++ b/arch/ext/Zaamo.yaml @@ -4,6 +4,7 @@ Zaamo: type: unprivileged versions: - version: 1.0 + state: ratified ratification_date: 2024-04 description: | The atomic memory operation (AMO) instructions perform read-modify-write diff --git a/arch/ext/Zalrsc.yaml b/arch/ext/Zalrsc.yaml index b7006a68d..4a0f9bd28 100644 --- a/arch/ext/Zalrsc.yaml +++ b/arch/ext/Zalrsc.yaml @@ -4,6 +4,7 @@ Zalrsc: type: unprivileged versions: - version: 1.0 + state: ratified ratification_date: 2024-04 description: | diff --git a/arch/ext/Zba.yaml b/arch/ext/Zba.yaml index 785c14490..89bd4ab76 100644 --- a/arch/ext/Zba.yaml +++ b/arch/ext/Zba.yaml @@ -18,4 +18,5 @@ Zba: type: unprivileged versions: - version: 1.0 + state: ratified ratification_date: 2021-06 diff --git a/arch/ext/Zbb.yaml b/arch/ext/Zbb.yaml index 8ff5e9d5b..a115d783d 100644 --- a/arch/ext/Zbb.yaml +++ b/arch/ext/Zbb.yaml @@ -6,4 +6,5 @@ Zbb: type: unprivileged versions: - version: 1.0 + state: ratified ratification_date: 2021-06 diff --git a/arch/ext/Zbc.yaml b/arch/ext/Zbc.yaml index 63ad1efc4..c812ab1a7 100644 --- a/arch/ext/Zbc.yaml +++ b/arch/ext/Zbc.yaml @@ -6,4 +6,5 @@ Zbc: type: unprivileged versions: - version: 1.0 + state: ratified ratification_date: 2021-06 diff --git a/arch/ext/Zicbom.yaml b/arch/ext/Zicbom.yaml index 90177d1e8..d59644fe7 100644 --- a/arch/ext/Zicbom.yaml +++ b/arch/ext/Zicbom.yaml @@ -5,4 +5,5 @@ Zicbom: type: unprivileged versions: - version: 1.0.1-b34ea8a + state: ratified ratification_date: 2022-05 diff --git a/arch/ext/Zicboz.yaml b/arch/ext/Zicboz.yaml index 3df7c1669..4db1cda01 100644 --- a/arch/ext/Zicboz.yaml +++ b/arch/ext/Zicboz.yaml @@ -5,4 +5,5 @@ Zicboz: type: unprivileged versions: - version: 1.0.1-b34ea8a + state: ratified ratification_date: 2022-05 diff --git a/arch/ext/Zicntr.yaml b/arch/ext/Zicntr.yaml index 26db173aa..6ba295262 100644 --- a/arch/ext/Zicntr.yaml +++ b/arch/ext/Zicntr.yaml @@ -5,5 +5,6 @@ Zicntr: type: unprivileged versions: - version: 2.0 + state: ratified ratification_date: 2019-12 requires: [Zicsr, ">= 2.0"] diff --git a/arch/ext/Zicsr.yaml b/arch/ext/Zicsr.yaml index 3ba2417fd..2d8495334 100644 --- a/arch/ext/Zicsr.yaml +++ b/arch/ext/Zicsr.yaml @@ -5,4 +5,5 @@ Zicsr: type: unprivileged versions: - version: 2.0 + state: ratified ratification_date: null diff --git a/arch/ext/Zihpm.yaml b/arch/ext/Zihpm.yaml index d5de323c6..d70eef526 100644 --- a/arch/ext/Zihpm.yaml +++ b/arch/ext/Zihpm.yaml @@ -5,4 +5,5 @@ Zihpm: type: unprivileged versions: - version: 2.0 + state: ratified ratification_date: unknown diff --git a/arch/ext/Zmmul.yaml b/arch/ext/Zmmul.yaml index 675429576..24e07b6fc 100644 --- a/arch/ext/Zmmul.yaml +++ b/arch/ext/Zmmul.yaml @@ -18,4 +18,5 @@ Zmmul: type: unprivileged versions: - version: 1.0 + state: ratified ratification_date: 2022-06 diff --git a/arch/inst/B/add.uw.yaml b/arch/inst/B/add.uw.yaml index acce1df0d..a02245e6b 100644 --- a/arch/inst/B/add.uw.yaml +++ b/arch/inst/B/add.uw.yaml @@ -8,12 +8,26 @@ add.uw: zero-extended least-significant word of rs1. definedBy: [B, Zba] assembly: xd, xs1, xs2 + encoding: + match: 0000100----------000-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always + pseudoinstructions: + when: rs2 == 0 + to: zext.w xd, xs1 operation(): | - raise (ExceptionCode::IllegalInstruction) if (CSR[misa].B == 1'b0); + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } X[rd] = X[rs2] + X[rs1][31:0]; diff --git a/arch/inst/B/andn.yaml b/arch/inst/B/andn.yaml index 8af42503c..badb3e1c2 100644 --- a/arch/inst/B/andn.yaml +++ b/arch/inst/B/andn.yaml @@ -7,10 +7,21 @@ andn: bitwise inversion of `rs2`. definedBy: [B, Zbb] assembly: xd, xs1, xs2 + encoding: + match: 0100000----------111-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + raise (ExceptionCode::IllegalInstruction, $encoding) if (CSR[misa].B == 1'b0); + X[rd] = X[rs2] & ~X[rs1]; diff --git a/arch/inst/B/bclr.yaml b/arch/inst/B/bclr.yaml index f49dd426b..a6c0cdf6a 100644 --- a/arch/inst/B/bclr.yaml +++ b/arch/inst/B/bclr.yaml @@ -7,11 +7,22 @@ bclr: The index is read from the lower log2(XLEN) bits of rs2. definedBy: [B, Zbs] assembly: xd, xs1, xs2 + encoding: + match: 0100100----------001-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + raise (ExceptionCode::IllegalInstruction, $encoding) if (CSR[misa].B == 1'b0); + XReg index = X[rs2] & (xlen() - 1); X[rd] = X[rs1] & ~(1 << index); diff --git a/arch/inst/B/bclri.yaml b/arch/inst/B/bclri.yaml index 22d996ddd..f2b93aced 100644 --- a/arch/inst/B/bclri.yaml +++ b/arch/inst/B/bclri.yaml @@ -8,11 +8,34 @@ bclri: to shamt[5]=1 are reserved. definedBy: [B, Zbs] assembly: xd, xs1, shamt + encoding: + RV32: + match: 0100100----------001-----0010011 + variables: + - name: shamt + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 + RV64: + match: 010010-----------001-----0010011 + variables: + - name: shamt + location: 25-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg index = shamt & (xlen() - 1); X[rd] = X[rs1] & ~(1 << index); diff --git a/arch/inst/B/bext.yaml b/arch/inst/B/bext.yaml index b48d90ce7..a8a6c8501 100644 --- a/arch/inst/B/bext.yaml +++ b/arch/inst/B/bext.yaml @@ -7,11 +7,24 @@ bext: The index is read from the lower log2(XLEN) bits of rs2. definedBy: [B, Zbs] assembly: xd, xs1, xs2 + encoding: + match: 0100100----------101-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg index = X[rs2] & (xlen() - 1); X[rd] = (X[rs1] >> index) & 1; diff --git a/arch/inst/B/bexti.yaml b/arch/inst/B/bexti.yaml index 287835b77..bbf455710 100644 --- a/arch/inst/B/bexti.yaml +++ b/arch/inst/B/bexti.yaml @@ -8,11 +8,34 @@ bexti: corresponding to shamt[5]=1 are reserved. definedBy: [B, Zbs] assembly: xd, xs1, shamt + encoding: + RV32: + match: 0100100----------101-----0010011 + variables: + - name: shamt + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 + RV64: + match: 010010-----------101-----0010011 + variables: + - name: shamt + location: 25-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg index = shamt & (xlen() - 1); X[rd] = (X[rs1] >> index) & 1; diff --git a/arch/inst/B/binv.yaml b/arch/inst/B/binv.yaml index 7fcd1353a..a4d019dd4 100644 --- a/arch/inst/B/binv.yaml +++ b/arch/inst/B/binv.yaml @@ -7,11 +7,24 @@ binv: The index is read from the lower log2(XLEN) bits of rs2. definedBy: [B, Zbs] assembly: xd, xs1, xs2 + encoding: + match: 0110100----------001-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg index = X[rs2] & (xlen() - 1); X[rd] = X[rs1] ^ (1 << index); diff --git a/arch/inst/B/binvi.yaml b/arch/inst/B/binvi.yaml index abb9fe7e6..c230a39bb 100644 --- a/arch/inst/B/binvi.yaml +++ b/arch/inst/B/binvi.yaml @@ -8,11 +8,34 @@ binvi: For RV32, the encodings corresponding to shamt[5]=1 are reserved. definedBy: [B, Zbs] assembly: xd, xs1, shamt + encoding: + RV32: + match: 0110100----------001-----0010011 + variables: + - name: shamt + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 + RV64: + match: 011010-----------001-----0010011 + variables: + - name: shamt + location: 25-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg index = shamt & (xlen() - 1); X[rd] = X[rs1] ^ (1 << index); diff --git a/arch/inst/B/bset.yaml b/arch/inst/B/bset.yaml index 7aec522a7..7ed6d5858 100644 --- a/arch/inst/B/bset.yaml +++ b/arch/inst/B/bset.yaml @@ -7,11 +7,24 @@ bset: The index is read from the lower log2(XLEN) bits of rs2. definedBy: [B, Zbs] assembly: xd, xs1, xs2 + encoding: + match: 0010100----------001-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg index = X[rs2] & (xlen() - 1); X[rd] = X[rs1] | (1 << index); diff --git a/arch/inst/B/bseti.yaml b/arch/inst/B/bseti.yaml index 480e7b93f..66c7a1558 100644 --- a/arch/inst/B/bseti.yaml +++ b/arch/inst/B/bseti.yaml @@ -8,11 +8,34 @@ bseti: For RV32, the encodings corresponding to shamt[5]=1 are reserved. definedBy: [B, Zbs] assembly: xd, xs1, shamt + encoding: + RV32: + match: 0010100----------001-----0010011 + variables: + - name: shamt + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 + RV64: + match: 001010-----------001-----0010011 + variables: + - name: shamt + location: 25-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg index = shamt & (xlen() - 1); X[rd] = X[rs1] | (1 << index); diff --git a/arch/inst/B/clmul.yaml b/arch/inst/B/clmul.yaml index 522bf7939..85568eca8 100644 --- a/arch/inst/B/clmul.yaml +++ b/arch/inst/B/clmul.yaml @@ -6,12 +6,25 @@ clmul: `clmul` produces the lower half of the 2*XLEN carry-less product definedBy: [B, Zbc] assembly: xd, xs1, xs2 + encoding: + match: 0000101----------001-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg rs1_val = X[rs1]; XReg rs2_val = X[rs2]; XReg output = 0; diff --git a/arch/inst/B/clmulh.yaml b/arch/inst/B/clmulh.yaml index 0b2b0362c..d0175bf74 100644 --- a/arch/inst/B/clmulh.yaml +++ b/arch/inst/B/clmulh.yaml @@ -6,12 +6,25 @@ clmulh: `clmulh` produces the upper half of the 2*XLEN carry-less product definedBy: [B, Zbc] assembly: xd, xs1, xs2 + encoding: + match: 0000101----------011-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg rs1_val = X[rs1]; XReg rs2_val = X[rs2]; XReg output = 0; diff --git a/arch/inst/B/clmulr.yaml b/arch/inst/B/clmulr.yaml index 92358d659..9d5b7574e 100644 --- a/arch/inst/B/clmulr.yaml +++ b/arch/inst/B/clmulr.yaml @@ -11,7 +11,20 @@ clmulr: u: always vs: always vu: always + encoding: + match: 0000101----------010-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg rs1_val = X[rs1]; XReg rs2_val = X[rs2]; XReg output = 0; diff --git a/arch/inst/B/clz.yaml b/arch/inst/B/clz.yaml index efe19836c..f9c937289 100644 --- a/arch/inst/B/clz.yaml +++ b/arch/inst/B/clz.yaml @@ -9,10 +9,21 @@ clz: bit of the input is a 1, the output is 0. definedBy: [B, Zbb] assembly: xd, xs1 + encoding: + match: 011000000000-----001-----0010011 + variables: + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = (xlen() - 1) - $signed(highest_set_bit(X[rs1])); diff --git a/arch/inst/B/clzw.yaml b/arch/inst/B/clzw.yaml index c7144bddd..37ebcb612 100644 --- a/arch/inst/B/clzw.yaml +++ b/arch/inst/B/clzw.yaml @@ -9,10 +9,21 @@ clzw: base: 64 definedBy: [B, Zbb] assembly: xd, xs1 + encoding: + match: 011000000000-----001-----0011011 + variables: + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = 31 - $signed(highest_set_bit(X[rs1][31:0])); diff --git a/arch/inst/B/cpop.yaml b/arch/inst/B/cpop.yaml index 3ae7fbf8c..d186ee31d 100644 --- a/arch/inst/B/cpop.yaml +++ b/arch/inst/B/cpop.yaml @@ -18,12 +18,23 @@ cpop: ---- definedBy: [B, Zbb] assembly: xd, xs1 + encoding: + match: 011000000010-----001-----0010011 + variables: + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg bitcount = 0; XReg rs1_val = X[rs1]; diff --git a/arch/inst/B/cpopw.yaml b/arch/inst/B/cpopw.yaml index fd104a027..c938b5722 100644 --- a/arch/inst/B/cpopw.yaml +++ b/arch/inst/B/cpopw.yaml @@ -19,12 +19,23 @@ cpopw: definedBy: [B, Zbb] base: 64 assembly: xd, xs1 + encoding: + match: 011000000010-----001-----0011011 + variables: + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg bitcount = 0; XReg rs1_val = X[rs1]; diff --git a/arch/inst/B/ctz.yaml b/arch/inst/B/ctz.yaml index 36e2f500b..2af94bfc3 100644 --- a/arch/inst/B/ctz.yaml +++ b/arch/inst/B/ctz.yaml @@ -10,10 +10,21 @@ ctz: of the input is a 1, the output is 0. definedBy: [B, Zbb] assembly: xd, xs1 + encoding: + match: 011000000001-----001-----0010011 + variables: + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = (xlen() - 1) - $signed(lowest_set_bit(X[rs1])); diff --git a/arch/inst/B/ctzw.yaml b/arch/inst/B/ctzw.yaml index f7ea3fa9a..614a25768 100644 --- a/arch/inst/B/ctzw.yaml +++ b/arch/inst/B/ctzw.yaml @@ -11,10 +11,21 @@ ctzw: definedBy: [B, Zbb] base: 64 assembly: xd, xs1 + encoding: + match: 011000000001-----001-----0011011 + variables: + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = (xlen() - 1) - $signed(lowest_set_bit(X[rs1][31:0])); diff --git a/arch/inst/B/max.yaml b/arch/inst/B/max.yaml index 7a8e2b916..338e3baf1 100644 --- a/arch/inst/B/max.yaml +++ b/arch/inst/B/max.yaml @@ -14,10 +14,23 @@ max: together. definedBy: [B, Zbb] assembly: xd, xs1, xs2 + encoding: + match: 0000101----------110-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = ($signed(X[rs1]) > $signed(X[rs2])) ? X[rs1] : X[rs2]; diff --git a/arch/inst/B/maxu.yaml b/arch/inst/B/maxu.yaml index 9cc72638d..c43123762 100644 --- a/arch/inst/B/maxu.yaml +++ b/arch/inst/B/maxu.yaml @@ -6,10 +6,23 @@ maxu: This instruction returns the larger of two unsigned integers. definedBy: [B, Zbb] assembly: xd, xs1, xs2 + encoding: + match: 0000101----------111-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = (X[rs1] > X[rs2]) ? X[rs1] : X[rs2]; diff --git a/arch/inst/B/min.yaml b/arch/inst/B/min.yaml index a499535ad..94a01c747 100644 --- a/arch/inst/B/min.yaml +++ b/arch/inst/B/min.yaml @@ -6,10 +6,23 @@ min: This instruction returns the smaller of two signed integers. definedBy: [B, Zbb] assembly: xd, xs1, xs2 + encoding: + match: 0000101----------100-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = ($signed(X[rs1]) < $signed(X[rs2])) ? X[rs1] : X[rs2]; diff --git a/arch/inst/B/minu.yaml b/arch/inst/B/minu.yaml index 235b6bec0..2466a7606 100644 --- a/arch/inst/B/minu.yaml +++ b/arch/inst/B/minu.yaml @@ -6,10 +6,23 @@ minu: This instruction returns the smaller of two unsigned integers. definedBy: [B, Zbb] assembly: xd, xs1, xs2 + encoding: + match: 0000101----------101-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = (X[rs1] < X[rs2]) ? X[rs1] : X[rs2]; diff --git a/arch/inst/B/orc.b.yaml b/arch/inst/B/orc.b.yaml index 5c3ae727f..5ee8c9413 100644 --- a/arch/inst/B/orc.b.yaml +++ b/arch/inst/B/orc.b.yaml @@ -8,12 +8,23 @@ orc.b: of rs is set, or to all ones if any bit within the respective byte of rs is set. definedBy: [B, Zbb] assembly: xd, xs1, xs2 + encoding: + match: 001010000111-----101-----0010011 + variables: + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg input = X[rs1]; XReg output = 0; diff --git a/arch/inst/B/orn.yaml b/arch/inst/B/orn.yaml index 9cd1e701e..6b0c3f134 100644 --- a/arch/inst/B/orn.yaml +++ b/arch/inst/B/orn.yaml @@ -6,10 +6,23 @@ orn: This instruction performs the bitwise logical OR operation between rs1 and the bitwise inversion of rs2. definedBy: [B, Zbb, Zbkb] assembly: xd, xs1, xs2 + encoding: + match: 0100000----------110-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = X[rs1] | ~X[rs2]; diff --git a/arch/inst/B/rev8.yaml b/arch/inst/B/rev8.yaml index ee7498a08..6148a9d34 100644 --- a/arch/inst/B/rev8.yaml +++ b/arch/inst/B/rev8.yaml @@ -14,20 +14,38 @@ rev8: is XLEN-32 and XLEN-16, respectively. definedBy: [B, Zbb, Zbkb] assembly: xd, xs1 - # TODO: this instruction has different encodings in RV32 / RV64 + encoding: + RV32: + match: 011010011000-----101-----0010011 + variables: + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 + RV64: + match: 011010111000-----101-----0010011 + variables: + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg input = X[rs1]; XReg output = 0; XReg j = xlen() - 1; for (U32 i=0; i<(xlen()-8); i = i+8) { - output[i:(i+7)] = input[(j-7):j]; + output[(i+7):i] = input[j:(j-7)]; j = j - 8; } diff --git a/arch/inst/B/rol.yaml b/arch/inst/B/rol.yaml index b87b732f3..38406e432 100644 --- a/arch/inst/B/rol.yaml +++ b/arch/inst/B/rol.yaml @@ -6,12 +6,25 @@ rol: This instruction performs a rotate left of rs1 by the amount in least-significant `log2(XLEN)` bits of rs2. definedBy: [B, Zbb, Zbkb] assembly: xd, xs1, xs2 + encoding: + match: 0110000----------001-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg shamt = (xlen() == 32) ? X[rs2][4:0] : X[rs2][5:0]; X[rd] = (X[rs1] << shamt) | (X[rs1] >> (xlen() - shamt)); diff --git a/arch/inst/B/rolw.yaml b/arch/inst/B/rolw.yaml index d0d637f65..9e6d892df 100644 --- a/arch/inst/B/rolw.yaml +++ b/arch/inst/B/rolw.yaml @@ -8,12 +8,25 @@ rolw: definedBy: [B, Zbb, Zbkb] assembly: xd, xs1, xs2 base: 64 + encoding: + match: 0110000----------001-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg rs1_word = X[rs1][31:0]; XReg shamt = X[rs2][4:0]; diff --git a/arch/inst/B/ror.yaml b/arch/inst/B/ror.yaml index a97730560..f45acdea8 100644 --- a/arch/inst/B/ror.yaml +++ b/arch/inst/B/ror.yaml @@ -6,12 +6,25 @@ ror: This instruction performs a rotate right of rs1 by the amount in least-significant `log2(XLEN)` bits of rs2. definedBy: [B, Zbb, Zbkb] assembly: xd, xs1, xs2 + encoding: + match: 0110000----------101-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg shamt = (xlen() == 32) ? X[rs2][4:0] : X[rs2][5:0]; X[rd] = (X[rs1] >> shamt) | (X[rs1] << (xlen() - shamt)); diff --git a/arch/inst/B/rori.yaml b/arch/inst/B/rori.yaml index b14f257a4..bf7ce3d42 100644 --- a/arch/inst/B/rori.yaml +++ b/arch/inst/B/rori.yaml @@ -7,12 +7,35 @@ rori: For RV32, the encodings corresponding to shamt[5]=1 are reserved. definedBy: [B, Zbb, Zbkb] assembly: xd, xs1, shamt + encoding: + RV32: + match: 0110000----------101-----0110011 + variables: + - name: shamt + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 + RV64: + match: 011000-----------101-----0110011 + variables: + - name: shamt + location: 25-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg shamt = (xlen() == 32) ? shamt[4:0] : shamt[5:0]; X[rd] = (X[rs1] >> shamt) | (X[rs1] << (xlen() - shamt)); diff --git a/arch/inst/B/roriw.yaml b/arch/inst/B/roriw.yaml index 240462433..3ec88044f 100644 --- a/arch/inst/B/roriw.yaml +++ b/arch/inst/B/roriw.yaml @@ -9,12 +9,25 @@ roriw: definedBy: [B, Zbb, Zbkb] assembly: xd, xs1, shamt base: 64 + encoding: + match: 0110000----------101-----0011011 + variables: + - name: shamt + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg rs1_word = X[rs1][31:0]; XReg unextended_result = (X[rs1] >> shamt) | (X[rs1] << (32 - shamt)); diff --git a/arch/inst/B/rorw.yaml b/arch/inst/B/rorw.yaml index 0d77044f1..b711fc043 100644 --- a/arch/inst/B/rorw.yaml +++ b/arch/inst/B/rorw.yaml @@ -9,12 +9,25 @@ rorw: definedBy: [B, Zbb, Zbkb] assembly: xd, xs1, xs2 base: 64 + encoding: + match: 0110000----------101-----0111011 + variables: + - name: shamt + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg rs1_word = X[rs1][31:0]; XReg shamt = X[rs1][4:0]; diff --git a/arch/inst/B/sext.b.yaml b/arch/inst/B/sext.b.yaml index e165ab145..0b3a4d2a6 100644 --- a/arch/inst/B/sext.b.yaml +++ b/arch/inst/B/sext.b.yaml @@ -7,12 +7,23 @@ sext.b: most-significant bit in the byte (i.e., bit 7) to all of the more-significant bits. definedBy: [B, Zbb] assembly: xd, xs1 + encoding: + match: 011000000100-----001-----0010011 + variables: + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + if (xlen() == 32) { X[rd] = {{24{X[rs1][7]}}, X[rs1][7:0]}; } else if (xlen() == 64) { diff --git a/arch/inst/B/sext.h.yaml b/arch/inst/B/sext.h.yaml index 0dfc99d01..b97b009a8 100644 --- a/arch/inst/B/sext.h.yaml +++ b/arch/inst/B/sext.h.yaml @@ -7,12 +7,23 @@ sext.h: most-significant bit in the halfword (i.e., bit 15) to all of the more-significant bits. definedBy: [B, Zbb] assembly: xd, xs1 + encoding: + match: 011000000101-----001-----0010011 + variables: + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + if (xlen() == 32) { X[rd] = {{16{X[rs1][15]}}, X[rs1][15:0]}; } else if (xlen() == 64) { diff --git a/arch/inst/B/sh1add.uw.yaml b/arch/inst/B/sh1add.uw.yaml index a55a3daf8..252f96e3f 100644 --- a/arch/inst/B/sh1add.uw.yaml +++ b/arch/inst/B/sh1add.uw.yaml @@ -8,6 +8,15 @@ sh1add.uw: and shifting it left by 1 place. definedBy: [B, Zba] base: 64 + encoding: + match: 0010000----------010-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 assembly: xd, xs1, xs2 access: s: always @@ -15,4 +24,8 @@ sh1add.uw: vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = X[rs2] + (X[rs1][31:0] << 1); diff --git a/arch/inst/B/sh1add.yaml b/arch/inst/B/sh1add.yaml index 7dfce976e..6caa659b4 100644 --- a/arch/inst/B/sh1add.yaml +++ b/arch/inst/B/sh1add.yaml @@ -6,10 +6,23 @@ sh1add: This instruction shifts `rs1` to the left by 1 bit and adds it to `rs2`. definedBy: [B, Zba] assembly: xd, xs1, xs2 + encoding: + match: 0010000----------010-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = X[rs2] + (X[rs1] << 1); diff --git a/arch/inst/B/sh2add.uw.yaml b/arch/inst/B/sh2add.uw.yaml index 76c0e0f59..734516f32 100644 --- a/arch/inst/B/sh2add.uw.yaml +++ b/arch/inst/B/sh2add.uw.yaml @@ -9,10 +9,23 @@ sh2add.uw: definedBy: [B, Zba] base: 64 assembly: xd, xs1, xs2 + encoding: + match: 0010000----------100-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = X[rs2] + (X[rs1][31:0] << 2); diff --git a/arch/inst/B/sh2add.yaml b/arch/inst/B/sh2add.yaml index 094ace1d1..0fd311000 100644 --- a/arch/inst/B/sh2add.yaml +++ b/arch/inst/B/sh2add.yaml @@ -6,10 +6,23 @@ sh2add: This instruction shifts `rs1` to the left by 2 places and adds it to `rs2`. definedBy: [B, Zba] assembly: xd, xs1, xs2 + encoding: + match: 0010000----------100-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = X[rs2] + (X[rs1] << 2); diff --git a/arch/inst/B/sh3add.uw.yaml b/arch/inst/B/sh3add.uw.yaml index a84d59780..f490f3c78 100644 --- a/arch/inst/B/sh3add.uw.yaml +++ b/arch/inst/B/sh3add.uw.yaml @@ -9,10 +9,23 @@ sh3add.uw: definedBy: [B, Zba] base: 64 assembly: xd, xs1, xs2 + encoding: + match: 0010000----------110-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = X[rs2] + (X[rs1][31:0] << 3); diff --git a/arch/inst/B/sh3add.yaml b/arch/inst/B/sh3add.yaml index 921b74e48..4272241f3 100644 --- a/arch/inst/B/sh3add.yaml +++ b/arch/inst/B/sh3add.yaml @@ -6,10 +6,23 @@ sh3add: This instruction shifts `rs1` to the left by 3 places and adds it to `rs2`. definedBy: [B, Zba] assembly: xd, xs1, xs2 + encoding: + match: 0010000----------110-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = X[rs2] + (X[rs1] << 3); diff --git a/arch/inst/B/slli.uw.yaml b/arch/inst/B/slli.uw.yaml index 50fce0791..e048579aa 100644 --- a/arch/inst/B/slli.uw.yaml +++ b/arch/inst/B/slli.uw.yaml @@ -10,6 +10,15 @@ slli.uw: This instruction is the same as `slli` with `zext.w` performed on rs1 before shifting. definedBy: [B, Zba] base: 64 + encoding: + match: 0000010----------001-----0011011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 assembly: xd, xs1, shamt access: s: always @@ -17,4 +26,8 @@ slli.uw: vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = X[rs1][31:0] << shamt; diff --git a/arch/inst/B/xnor.yaml b/arch/inst/B/xnor.yaml index 729f0e23c..ac9db14a4 100644 --- a/arch/inst/B/xnor.yaml +++ b/arch/inst/B/xnor.yaml @@ -6,10 +6,23 @@ xnor: This instruction performs the bit-wise exclusive-NOR operation on rs1 and rs2. definedBy: [B, Zbb, Zbkb] assembly: xd, xs1, xs2 + encoding: + match: 0100000----------100-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = ~(X[rs1] ^ X[rs2]); diff --git a/arch/inst/B/zext.h.yaml b/arch/inst/B/zext.h.yaml index 2b2c7a8df..044e3d118 100644 --- a/arch/inst/B/zext.h.yaml +++ b/arch/inst/B/zext.h.yaml @@ -14,15 +14,15 @@ zext.h: definedBy: [B, Zbb] encoding: RV32: - mask: 000010000000-----100-----0110011 - fields: + match: 000010000000-----100-----0110011 + variables: - name: rs1 location: 19-15 - name: rd location: 11-7 RV64: - mask: 000010000000-----100-----0111011 - fields: + match: 000010000000-----100-----0111011 + variables: - name: rs1 location: 19-15 - name: rd @@ -35,4 +35,8 @@ zext.h: vs: always vu: always operation(): | + if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + X[rd] = X[rs1][15:0]; diff --git a/arch/inst/F/fmv.w.x.yaml b/arch/inst/F/fmv.w.x.yaml index 9f8ce8902..d25dddec6 100644 --- a/arch/inst/F/fmv.w.x.yaml +++ b/arch/inst/F/fmv.w.x.yaml @@ -9,6 +9,13 @@ fmv.w.x: the payloads of non-canonical NaNs are preserved. definedBy: F assembly: fd, xs1 + encoding: + match: 111100000000-----000-----1010011 + variables: + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/add.yaml b/arch/inst/I/add.yaml index a7384c3d9..fc6bf2429 100644 --- a/arch/inst/I/add.yaml +++ b/arch/inst/I/add.yaml @@ -1,12 +1,21 @@ # yaml-language-server: $schema=../../../schemas/inst_schema.json add: - long_name: Add + long_name: Integer add description: | Add the value in rs1 to rs2, and store the result in rd. Any overflow is thrown away. definedBy: I assembly: xd, xs1, xs2 + encoding: + match: 0000000----------000-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/addi.yaml b/arch/inst/I/addi.yaml index 29a46d01f..b6c3d7bc9 100644 --- a/arch/inst/I/addi.yaml +++ b/arch/inst/I/addi.yaml @@ -5,6 +5,15 @@ addi: description: Add an immediate to the value in rs1, and store the result in rd definedBy: I assembly: xd, xs1, imm + encoding: + match: -----------------000-----0010011 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/addiw.yaml b/arch/inst/I/addiw.yaml index d3c73ffc4..b3b58be43 100644 --- a/arch/inst/I/addiw.yaml +++ b/arch/inst/I/addiw.yaml @@ -6,6 +6,15 @@ addiw: definedBy: I base: 64 assembly: xd, xs1, imm + encoding: + match: -----------------000-----0001011 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/addw.yaml b/arch/inst/I/addw.yaml index 07a9e4606..c3d2c5e3c 100644 --- a/arch/inst/I/addw.yaml +++ b/arch/inst/I/addw.yaml @@ -8,6 +8,15 @@ addw: definedBy: I base: 64 assembly: xd, xs1, xs2 + encoding: + match: 0000000----------000-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/and.yaml b/arch/inst/I/and.yaml index 3dcccdce5..7f29c55c8 100644 --- a/arch/inst/I/and.yaml +++ b/arch/inst/I/and.yaml @@ -5,6 +5,15 @@ and: description: And rs1 with rs2, and store the result in rd definedBy: I assembly: xd, xs1, xs2 + encoding: + match: 0000000----------111-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/andi.yaml b/arch/inst/I/andi.yaml index 5dea6fa4b..fa90164d8 100644 --- a/arch/inst/I/andi.yaml +++ b/arch/inst/I/andi.yaml @@ -5,6 +5,15 @@ andi: description: And an immediate to the value in rs1, and store the result in rd definedBy: I assembly: xd, xs1, imm + encoding: + match: -----------------111-----0010011 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/auipc.yaml b/arch/inst/I/auipc.yaml index 8bed804b2..99e32304a 100644 --- a/arch/inst/I/auipc.yaml +++ b/arch/inst/I/auipc.yaml @@ -5,6 +5,14 @@ auipc: description: Add an immediate to the current PC. definedBy: I assembly: xd, imm + encoding: + match: --------------------------001011 + variables: + - name: imm + location: 31-12 + left_shift: 12 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/beq.yaml b/arch/inst/I/beq.yaml index a3ff95cad..a8afb46c9 100644 --- a/arch/inst/I/beq.yaml +++ b/arch/inst/I/beq.yaml @@ -9,6 +9,16 @@ beq: Raise a `MisalignedAddress` exception if PC + imm is misaligned. definedBy: I assembly: xs1, xs2, imm + encoding: + match: -----------------000-----1100011 + variables: + - name: imm + location: 31|7|30-25|11-8 + left_shift: 1 + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 access: s: always u: always diff --git a/arch/inst/I/bge.yaml b/arch/inst/I/bge.yaml index 250ae9670..537a47c11 100644 --- a/arch/inst/I/bge.yaml +++ b/arch/inst/I/bge.yaml @@ -9,6 +9,16 @@ bge: Raise a `MisalignedAddress` exception if PC + imm is misaligned. definedBy: I assembly: xs1, xs2, imm + encoding: + match: -----------------101-----1100011 + variables: + - name: imm + location: 31|7|30-25|11-8 + left_shift: 1 + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 access: s: always u: always diff --git a/arch/inst/I/bgeu.yaml b/arch/inst/I/bgeu.yaml index 2ca485678..639486d51 100644 --- a/arch/inst/I/bgeu.yaml +++ b/arch/inst/I/bgeu.yaml @@ -9,6 +9,16 @@ bgeu: Raise a `MisalignedAddress` exception if PC + imm is misaligned. definedBy: I assembly: xs1, xs2, imm + encoding: + match: -----------------111-----1100011 + variables: + - name: imm + location: 31|7|30-25|11-8 + left_shift: 1 + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 access: s: always u: always diff --git a/arch/inst/I/blt.yaml b/arch/inst/I/blt.yaml index 0ea068385..11c156f4c 100644 --- a/arch/inst/I/blt.yaml +++ b/arch/inst/I/blt.yaml @@ -9,6 +9,16 @@ blt: Raise a `MisalignedAddress` exception if PC + imm is misaligned. definedBy: I assembly: xs1, xs2, imm + encoding: + match: -----------------100-----1100011 + variables: + - name: imm + location: 31|7|30-25|11-8 + left_shift: 1 + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 access: s: always u: always diff --git a/arch/inst/I/bltu.yaml b/arch/inst/I/bltu.yaml index 3b08882c7..d62d94e4b 100644 --- a/arch/inst/I/bltu.yaml +++ b/arch/inst/I/bltu.yaml @@ -9,6 +9,16 @@ bltu: Raise a `MisalignedAddress` exception if PC + imm is misaligned. definedBy: I assembly: xs1, xs2, imm + encoding: + match: -----------------110-----1100011 + variables: + - name: imm + location: 31|7|30-25|11-8 + left_shift: 1 + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 access: s: always u: always diff --git a/arch/inst/I/bne.yaml b/arch/inst/I/bne.yaml index aa590b895..bd3242711 100644 --- a/arch/inst/I/bne.yaml +++ b/arch/inst/I/bne.yaml @@ -9,6 +9,16 @@ bne: Raise a `MisalignedAddress` exception if PC + imm is misaligned. definedBy: I assembly: xs1, xs2, imm + encoding: + match: -----------------001-----1100011 + variables: + - name: imm + location: 31|7|30-25|11-8 + left_shift: 1 + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 access: s: always u: always diff --git a/arch/inst/I/ebreak.yaml b/arch/inst/I/ebreak.yaml index 7374b3b44..87b83f97a 100644 --- a/arch/inst/I/ebreak.yaml +++ b/arch/inst/I/ebreak.yaml @@ -17,10 +17,12 @@ ebreak: and should not increment the `minstret` CSR. definedBy: I assembly: '' + encoding: + match: '00000000000100000000000001110011' access: s: always u: always vs: always vu: always operation(): | - raise (ExceptionCode::Breakpoint); + raise (ExceptionCode::Breakpoint, $pc); diff --git a/arch/inst/I/ecall.yaml b/arch/inst/I/ecall.yaml index 35516e174..0fc49bcdd 100644 --- a/arch/inst/I/ecall.yaml +++ b/arch/inst/I/ecall.yaml @@ -20,6 +20,8 @@ ecall: and should not increment the `minstret` CSR. definedBy: I assembly: '' + encoding: + match: '00000000000000000000000001110011' access: s: always u: always @@ -27,9 +29,9 @@ ecall: vu: always operation(): | if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::Mcall); + raise(ExceptionCode::Mcall, 0); } else if (mode() == PrivilegeMode::S) { - raise (ExceptionCode::Scall); + raise (ExceptionCode::Scall, 0); } else if (mode() == PrivilegeMode::U) { - raise (ExceptionCode::Ucall); + raise (ExceptionCode::Ucall, 0); } diff --git a/arch/inst/I/fence.yaml b/arch/inst/I/fence.yaml index 320868349..542b13e27 100644 --- a/arch/inst/I/fence.yaml +++ b/arch/inst/I/fence.yaml @@ -120,6 +120,19 @@ fence: definedBy: I assembly: "TODO" + encoding: + match: -----------------000-----0001111 + variables: + - name: fm + location: 31-28 + - name: pred + location: 27-24 + - name: succ + location: 23-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/jal.yaml b/arch/inst/I/jal.yaml index 47c041f42..2b3564870 100644 --- a/arch/inst/I/jal.yaml +++ b/arch/inst/I/jal.yaml @@ -8,8 +8,8 @@ jal: definedBy: I assembly: xd, imm encoding: - mask: -------------------------1101111 - fields: + match: -------------------------1101111 + variables: - name: imm location: 31|19-12|20|30-21 left_shift: 1 diff --git a/arch/inst/I/jalr.yaml b/arch/inst/I/jalr.yaml index 3611d427d..e6320746a 100644 --- a/arch/inst/I/jalr.yaml +++ b/arch/inst/I/jalr.yaml @@ -7,6 +7,15 @@ jalr: to a signed offset, and store the return address in rd. definedBy: I assembly: xd, imm(rs1) + encoding: + match: -----------------000-----1100111 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/lb.yaml b/arch/inst/I/lb.yaml index 0c5c8b5f9..d3801e604 100644 --- a/arch/inst/I/lb.yaml +++ b/arch/inst/I/lb.yaml @@ -8,6 +8,15 @@ lb: Sign extend the result. definedBy: I assembly: xd, imm(rs1) + encoding: + match: -----------------000-----0000111 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/lbu.yaml b/arch/inst/I/lbu.yaml index 70b00dcce..cf5dc0a55 100644 --- a/arch/inst/I/lbu.yaml +++ b/arch/inst/I/lbu.yaml @@ -8,6 +8,15 @@ lbu: Zero extend the result. definedBy: I assembly: xd, imm(rs1) + encoding: + match: -----------------100-----0000111 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/ld.yaml b/arch/inst/I/ld.yaml index d17ee9660..dfdec74f1 100644 --- a/arch/inst/I/ld.yaml +++ b/arch/inst/I/ld.yaml @@ -8,6 +8,15 @@ ld: definedBy: I base: 64 assembly: xd, imm(rs1) + encoding: + match: -----------------011-----0000111 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/lh.yaml b/arch/inst/I/lh.yaml index b4aa8b276..a6db7b6c8 100644 --- a/arch/inst/I/lh.yaml +++ b/arch/inst/I/lh.yaml @@ -8,6 +8,15 @@ lh: Sign extend the result. definedBy: I assembly: xd, imm(rs1) + encoding: + match: -----------------001-----0000111 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/lhu.yaml b/arch/inst/I/lhu.yaml index e75335902..1ffcb4ce7 100644 --- a/arch/inst/I/lhu.yaml +++ b/arch/inst/I/lhu.yaml @@ -8,6 +8,15 @@ lhu: Zero extend the result. definedBy: I assembly: xd, imm(rs1) + encoding: + match: -----------------101-----0000111 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/lui.yaml b/arch/inst/I/lui.yaml index 5c6cd5534..4ff132852 100644 --- a/arch/inst/I/lui.yaml +++ b/arch/inst/I/lui.yaml @@ -5,6 +5,14 @@ lui: description: Load the zero-extended imm into rd. definedBy: I assembly: xd, imm + encoding: + match: -------------------------0000111 + variables: + - name: imm + location: 31-12 + left_shift: 12 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/lw.yaml b/arch/inst/I/lw.yaml index cc4e87edc..e53527bbe 100644 --- a/arch/inst/I/lw.yaml +++ b/arch/inst/I/lw.yaml @@ -8,6 +8,15 @@ lw: Sign extend the result. definedBy: I assembly: xd, imm(rs1) + encoding: + match: -----------------010-----0000111 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/lwu.yaml b/arch/inst/I/lwu.yaml index 66fc37425..7447a8c2d 100644 --- a/arch/inst/I/lwu.yaml +++ b/arch/inst/I/lwu.yaml @@ -9,6 +9,15 @@ lwu: definedBy: I base: 64 assembly: xd, imm(rs1) + encoding: + match: -----------------110-----0000111 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/mret.yaml b/arch/inst/I/mret.yaml index ff6a2d700..c35223060 100644 --- a/arch/inst/I/mret.yaml +++ b/arch/inst/I/mret.yaml @@ -9,6 +9,8 @@ mret: u: never vs: never vu: never + encoding: + match: '00110000001000000000000001110011' operation(): | if (implemented?(ExtensionName::S) && CSR[mstatus].MPP != 2'b11) { CSR[mstatus].MPRV = 0; diff --git a/arch/inst/I/or.yaml b/arch/inst/I/or.yaml index ada1c0064..454e5f5c5 100644 --- a/arch/inst/I/or.yaml +++ b/arch/inst/I/or.yaml @@ -5,6 +5,15 @@ or: description: Or rs1 with rs2, and store the result in rd definedBy: I assembly: xd, xs1, xs2 + encoding: + match: 0000000----------110-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/ori.yaml b/arch/inst/I/ori.yaml index 7ebe288cb..eeb03c54d 100644 --- a/arch/inst/I/ori.yaml +++ b/arch/inst/I/ori.yaml @@ -5,6 +5,15 @@ ori: description: Or an immediate to the value in rs1, and store the result in rd definedBy: I assembly: xd, xs1, imm + encoding: + match: -----------------110-----0010011 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/sb.yaml b/arch/inst/I/sb.yaml index 109429e6d..cc52aadc6 100644 --- a/arch/inst/I/sb.yaml +++ b/arch/inst/I/sb.yaml @@ -7,6 +7,15 @@ sb: address formed by adding `rs1` to a signed offset. definedBy: I assembly: xs2, imm(xs1) + encoding: + match: -----------------000-----0100011 + variables: + - name: imm + location: 31-25|11-7 + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 access: s: always u: always diff --git a/arch/inst/I/sd.yaml b/arch/inst/I/sd.yaml index 375dcd018..ef04eb4eb 100644 --- a/arch/inst/I/sd.yaml +++ b/arch/inst/I/sd.yaml @@ -9,8 +9,8 @@ sd: base: 64 assembly: xs2, imm(xs1) encoding: - mask: -----------------011-----0100011 - fields: + match: -----------------011-----0100011 + variables: - name: imm location: 31-25|11-7 sign_extend: true diff --git a/arch/inst/I/sh.yaml b/arch/inst/I/sh.yaml index bbee22f6b..799b89ea3 100644 --- a/arch/inst/I/sh.yaml +++ b/arch/inst/I/sh.yaml @@ -7,6 +7,15 @@ sh: address formed by adding `rs1` to a signed offset. definedBy: I assembly: xs2, imm(xs1) + encoding: + match: -----------------001-----0100011 + variables: + - name: imm + location: 31-25|11-7 + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 access: s: always u: always diff --git a/arch/inst/I/sll.yaml b/arch/inst/I/sll.yaml index 9611ae256..ea94c511a 100644 --- a/arch/inst/I/sll.yaml +++ b/arch/inst/I/sll.yaml @@ -6,13 +6,22 @@ sll: Shift the value in `rs1` left by the value in the lower 6 bits of `rs2`, and store the result in `rd`. definedBy: I assembly: xd, xs1, xs2 + encoding: + match: -----------------001-----0010011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | - if (XLEN == 64) { + if (xlen() == 64) { X[rd] = X[rs1] << X[rs2][5:0]; } else { X[rd] = X[rs1] << X[rs2][4:0]; diff --git a/arch/inst/I/slli.yaml b/arch/inst/I/slli.yaml index 2fa0c21f6..d1d32b606 100644 --- a/arch/inst/I/slli.yaml +++ b/arch/inst/I/slli.yaml @@ -5,6 +5,25 @@ slli: description: Shift the value in rs1 left by shamt, and store the result in rd definedBy: I assembly: xd, xs1, shamt + encoding: + RV32: + match: 0000000----------001-----0010011 + variables: + - name: shamt + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 + RV64: + match: 000000-----------001-----0010011 + variables: + - name: shamt + location: 25-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/slliw.yaml b/arch/inst/I/slliw.yaml index d9c118f2e..ebb67c5bd 100644 --- a/arch/inst/I/slliw.yaml +++ b/arch/inst/I/slliw.yaml @@ -6,6 +6,15 @@ slliw: definedBy: I base: 64 assembly: xd, xs1, shamt + encoding: + match: 0000000----------001-----0011011 + variables: + - name: shamt + location: 25-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/sllw.yaml b/arch/inst/I/sllw.yaml index c52ea7062..29da5ee5f 100644 --- a/arch/inst/I/sllw.yaml +++ b/arch/inst/I/sllw.yaml @@ -7,6 +7,15 @@ sllw: definedBy: I base: 64 assembly: xd, xs1, xs2 + encoding: + match: 0000000----------001-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/slt.yaml b/arch/inst/I/slt.yaml index 75a49d56a..e8498a3c8 100644 --- a/arch/inst/I/slt.yaml +++ b/arch/inst/I/slt.yaml @@ -7,6 +7,15 @@ slt: both sources are treated as signed numbers, else 0 is written to `rd`. definedBy: I assembly: xd, xs1, rs2 + encoding: + match: 0000000----------010-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/slti.yaml b/arch/inst/I/slti.yaml index c71af1c11..dff628dbb 100644 --- a/arch/inst/I/slti.yaml +++ b/arch/inst/I/slti.yaml @@ -7,6 +7,15 @@ slti: when both are treated as signed numbers, else 0 is written to `rd`. definedBy: I assembly: xd, xs1, imm + encoding: + match: -----------------010-----0010011 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/sltiu.yaml b/arch/inst/I/sltiu.yaml index c60dd7886..0d91a8940 100644 --- a/arch/inst/I/sltiu.yaml +++ b/arch/inst/I/sltiu.yaml @@ -11,6 +11,15 @@ sltiu: (assembler pseudoinstruction `SEQZ rd, rs`). definedBy: I assembly: xd, xs1, imm + encoding: + match: -----------------011-----0010011 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/sltu.yaml b/arch/inst/I/sltu.yaml index ffebd12f8..9e421ac8d 100644 --- a/arch/inst/I/sltu.yaml +++ b/arch/inst/I/sltu.yaml @@ -7,6 +7,15 @@ sltu: both sources are treated as unsigned numbers, else 0 is written to `rd`. definedBy: I assembly: xd, xs1, xs2 + encoding: + match: 0000000----------011-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/sra.yaml b/arch/inst/I/sra.yaml index c0358e0db..6f1f1a8f3 100644 --- a/arch/inst/I/sra.yaml +++ b/arch/inst/I/sra.yaml @@ -6,13 +6,22 @@ sra: Arithmetic shift the value in `rs1` right by the value in the lower 5 bits of `rs2`, and store the result in `rd`. definedBy: I assembly: xd, xs1, xs2 + encoding: + match: 0100000----------101-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | - if (XLEN == 64) { + if (xlen() == 64) { X[rd] = X[rs1] >>> X[rs2][5:0]; } else { X[rd] = X[rs1] >>> X[rs2][4:0]; diff --git a/arch/inst/I/srai.yaml b/arch/inst/I/srai.yaml index f285cd264..312e96ade 100644 --- a/arch/inst/I/srai.yaml +++ b/arch/inst/I/srai.yaml @@ -7,6 +7,25 @@ srai: value in rs1 right by shamt, and store the result in rd. definedBy: I assembly: xd, xs1, shamt + encoding: + RV32: + match: 0100000----------101-----0010011 + variables: + - name: shamt + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 + RV64: + match: 010000-----------101-----0010011 + variables: + - name: shamt + location: 25-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/sraiw.yaml b/arch/inst/I/sraiw.yaml index c7efdd0ad..0bf6cdffc 100644 --- a/arch/inst/I/sraiw.yaml +++ b/arch/inst/I/sraiw.yaml @@ -8,6 +8,15 @@ sraiw: definedBy: I base: 64 assembly: xd, xs1, shamt + encoding: + match: 0100000----------101-----0011011 + variables: + - name: shamt + location: 25-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/sraw.yaml b/arch/inst/I/sraw.yaml index f0d165ff7..b4e0b5887 100644 --- a/arch/inst/I/sraw.yaml +++ b/arch/inst/I/sraw.yaml @@ -7,6 +7,15 @@ sraw: definedBy: I base: 64 assembly: xd, xs1, xs2 + encoding: + match: 0100000----------101-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/srl.yaml b/arch/inst/I/srl.yaml index 7ef0e5709..460a3442b 100644 --- a/arch/inst/I/srl.yaml +++ b/arch/inst/I/srl.yaml @@ -6,6 +6,15 @@ srl: Logical shift the value in `rs1` right by the value in the lower bits of `rs2`, and store the result in `rd`. definedBy: I assembly: xd, xs1, xs2 + encoding: + match: 0000000----------101-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/srli.yaml b/arch/inst/I/srli.yaml index a3910cd5b..4aa8c1ec7 100644 --- a/arch/inst/I/srli.yaml +++ b/arch/inst/I/srli.yaml @@ -4,6 +4,25 @@ srli: description: Shift the value in rs1 right by shamt, and store the result in rd definedBy: I assembly: xd, xs1, shamt + encoding: + RV32: + match: 0000000----------101-----0010011 + variables: + - name: shamt + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 + RV64: + match: 000000-----------101-----0010011 + variables: + - name: shamt + location: 25-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/srliw.yaml b/arch/inst/I/srliw.yaml index 2fb386991..0eaff1773 100644 --- a/arch/inst/I/srliw.yaml +++ b/arch/inst/I/srliw.yaml @@ -6,6 +6,15 @@ srliw: definedBy: I base: 64 assembly: xd, xs1, shamt + encoding: + match: 0000000----------101-----0011011 + variables: + - name: shamt + location: 25-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/srlw.yaml b/arch/inst/I/srlw.yaml index 0615c9b8d..7e47cbac9 100644 --- a/arch/inst/I/srlw.yaml +++ b/arch/inst/I/srlw.yaml @@ -7,6 +7,15 @@ srlw: definedBy: I base: 64 assembly: xd, xs1, xs2 + encoding: + match: 0000000----------101-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/sub.yaml b/arch/inst/I/sub.yaml index 310dbbe97..620aab65b 100644 --- a/arch/inst/I/sub.yaml +++ b/arch/inst/I/sub.yaml @@ -5,6 +5,15 @@ sub: description: Subtract the value in rs2 from rs1, and store the result in rd definedBy: I assembly: xd, xs1, xs2 + encoding: + match: 0100000----------000-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/subw.yaml b/arch/inst/I/subw.yaml index e0e045523..b212c65b5 100644 --- a/arch/inst/I/subw.yaml +++ b/arch/inst/I/subw.yaml @@ -6,6 +6,15 @@ subw: definedBy: I base: 64 assembly: xd, xs1, xs2 + encoding: + match: 0100000----------000-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/sw.yaml b/arch/inst/I/sw.yaml index c337475da..aa81c9c9f 100644 --- a/arch/inst/I/sw.yaml +++ b/arch/inst/I/sw.yaml @@ -7,6 +7,15 @@ sw: address formed by adding `rs1` to a signed offset. definedBy: I assembly: xs2, imm(xs1) + encoding: + match: -----------------010-----0100011 + variables: + - name: imm + location: 31-25|11-7 + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 access: s: always u: always diff --git a/arch/inst/I/wfi.yaml b/arch/inst/I/wfi.yaml index 409eaa794..1fe8f469b 100644 --- a/arch/inst/I/wfi.yaml +++ b/arch/inst/I/wfi.yaml @@ -44,6 +44,8 @@ wfi: above). definedBy: I assembly: "" + encoding: + match: '00010000010100000000000001110011' access: s: sometimes u: sometimes @@ -85,21 +87,21 @@ wfi: operation(): | # first, perform all the access checks if (mode() == PrivilegeMode::U) { - raise (ExceptionCode::IllegalInstruction); + raise (ExceptionCode::IllegalInstruction, $encoding); } if ((CSR[misa].S == 1) && (CSR[mstatus].TW == 1'b1)) { if (mode() != PrivilegeMode::M) { - raise (ExceptionCode::IllegalInstruction); + raise (ExceptionCode::IllegalInstruction, $encoding); } } if (CSR[misa].H == 1) { if (CSR[hstatus].VTW == 1'b0) { if (mode() == PrivilegeMode::VU) { - raise (ExceptionCode::VirtualInstruction); + raise (ExceptionCode::VirtualInstruction, $encoding); } } else if (CSR[hstatus].VTW == 1'b1) { if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise (ExceptionCode::VirtualInstruction); + raise (ExceptionCode::VirtualInstruction, $encoding); } } } diff --git a/arch/inst/I/xor.yaml b/arch/inst/I/xor.yaml index 090e229dd..215c3defc 100644 --- a/arch/inst/I/xor.yaml +++ b/arch/inst/I/xor.yaml @@ -5,6 +5,15 @@ xor: description: Exclusive or rs1 with rs2, and store the result in rd definedBy: I assembly: xd, xs1, xs2 + encoding: + match: 0000000----------100-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/I/xori.yaml b/arch/inst/I/xori.yaml index d6b032ea5..d879c2db8 100644 --- a/arch/inst/I/xori.yaml +++ b/arch/inst/I/xori.yaml @@ -5,6 +5,15 @@ xori: description: Exclusive or an immediate to the value in rs1, and store the result in rd definedBy: I assembly: xd, xs1, imm + encoding: + match: -----------------100-----0010011 + variables: + - name: imm + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/M/div.yaml b/arch/inst/M/div.yaml index ba23c12f4..dc5883415 100644 --- a/arch/inst/M/div.yaml +++ b/arch/inst/M/div.yaml @@ -11,12 +11,25 @@ div: will put the most negative number into rd; definedBy: M assembly: xd, xs1, xs2 + encoding: + match: 0000001----------100-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::M) && (CSR[misa].M == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg src1 = X[rs1]; XReg src2 = X[rs2]; diff --git a/arch/inst/M/divu.yaml b/arch/inst/M/divu.yaml index fa5f729f4..83a671bac 100644 --- a/arch/inst/M/divu.yaml +++ b/arch/inst/M/divu.yaml @@ -10,12 +10,25 @@ divu: If the value in rs2 is zero, rd gets the largest unsigned value. definedBy: M assembly: xd, xs1, xs2 + encoding: + match: 0000001----------101-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::M) && (CSR[misa].M == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg src1 = X[rs1]; XReg src2 = X[rs2]; diff --git a/arch/inst/M/divuw.yaml b/arch/inst/M/divuw.yaml index 4ae0d86c1..9108ca79b 100644 --- a/arch/inst/M/divuw.yaml +++ b/arch/inst/M/divuw.yaml @@ -10,12 +10,25 @@ divuw: If the value in rs2 is zero, rd is written with all 1s. definedBy: M assembly: xd, xs1, xs2 + encoding: + match: 0000001----------101-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::M) && (CSR[misa].M == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + Bits<32> src1 = X[rs1][31:0]; Bits<32> src2 = X[rs2][31:0]; diff --git a/arch/inst/M/divw.yaml b/arch/inst/M/divw.yaml index 6a4b04979..998c61cf7 100644 --- a/arch/inst/M/divw.yaml +++ b/arch/inst/M/divw.yaml @@ -14,12 +14,25 @@ divw: will put the most negative number into rd; definedBy: M assembly: xd, xs1, xs2 + encoding: + match: 0000001----------100-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::M) && (CSR[misa].M == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + Bits<32> src1 = X[rs1][31:0]; Bits<32> src2 = X[rs2][31:0]; diff --git a/arch/inst/M/mul.yaml b/arch/inst/M/mul.yaml index 41388bc34..688428de0 100644 --- a/arch/inst/M/mul.yaml +++ b/arch/inst/M/mul.yaml @@ -17,12 +17,25 @@ mul: definedBy: [M, Zmmul] assembly: xd, xs1, xs2 + encoding: + match: 0000001----------000-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::M) && (CSR[misa].M == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg src1 = X[rs1]; XReg src2 = X[rs2]; diff --git a/arch/inst/M/mulh.yaml b/arch/inst/M/mulh.yaml index 28bbab77b..d291a8461 100644 --- a/arch/inst/M/mulh.yaml +++ b/arch/inst/M/mulh.yaml @@ -16,18 +16,31 @@ mulh: Microarchitectures may look for that sequence and fuse the operations. definedBy: [M, Zmmul] assembly: xd, xs1, xs2 + encoding: + match: 0000001----------001-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::M) && (CSR[misa].M == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + # enlarge and sign extend the sources Bits<1> rs1_sign_bit = X[rs1][XLEN-1]; - Bits src1 = {{XLEN{rs1_sign_bit}}, X[rs1]}; + Bits src1 = {{XLEN{rs1_sign_bit}}, X[rs1]}; Bits<1> rs2_sign_bit = X[rs2][XLEN-1]; - Bits src2 = {{XLEN{rs2_sign_bit}}, X[rs2]}; + Bits src2 = {{XLEN{rs2_sign_bit}}, X[rs2]}; # grab the high half of the result, and put it in rd - X[rd] = (src1 * src2)[(XLEN*2)-1:XLEN]; \ No newline at end of file + X[rd] = (src1 * src2)[(XLEN*8'd2)-1:XLEN]; \ No newline at end of file diff --git a/arch/inst/M/mulhsu.yaml b/arch/inst/M/mulhsu.yaml index 8acb7cf1e..3836e7b95 100644 --- a/arch/inst/M/mulhsu.yaml +++ b/arch/inst/M/mulhsu.yaml @@ -16,15 +16,28 @@ mulhsu: Microarchitectures may look for that sequence and fuse the operations. definedBy: [M, Zmmul] assembly: xd, xs1, xs2 + encoding: + match: 0000001----------010-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::M) && (CSR[misa].M == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + # enlarge and extend the sources Bits<1> rs1_sign_bit = X[rs1][XLEN-1]; - Bits src1 = {{XLEN{rs1_sign_bit}}, X[rs1]}; - Bits src2 = {{XLEN{1'b0}}, X[rs2]}; + Bits src1 = {{XLEN{rs1_sign_bit}}, X[rs1]}; + Bits src2 = {{XLEN{1'b0}}, X[rs2]}; - X[rd] = (src1 * src2)[(XLEN*2)-1:XLEN]; \ No newline at end of file + X[rd] = (src1 * src2)[(XLEN*8'd2)-1:XLEN]; \ No newline at end of file diff --git a/arch/inst/M/mulhu.yaml b/arch/inst/M/mulhu.yaml index 06b26c3b1..2a1449bc9 100644 --- a/arch/inst/M/mulhu.yaml +++ b/arch/inst/M/mulhu.yaml @@ -16,14 +16,27 @@ mulhu: Microarchitectures may look for that sequence and fuse the operations. definedBy: [M, Zmmul] assembly: xd, xs1, xs2 + encoding: + match: 0000001----------011-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::M) && (CSR[misa].M == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + # enlarge and zero-extend the sources - Bits src1 = {{XLEN{1'b0}}, X[rs1]}; - Bits src2 = {{XLEN{1'b0}}, X[rs2]}; + Bits src1 = {{XLEN{1'b0}}, X[rs1]}; + Bits src2 = {{XLEN{1'b0}}, X[rs2]}; - X[rd] = (src1 * src2)[(XLEN*2)-1:XLEN]; \ No newline at end of file + X[rd] = (src1 * src2)[(XLEN*8'd2)-1:XLEN]; \ No newline at end of file diff --git a/arch/inst/M/mulw.yaml b/arch/inst/M/mulw.yaml index 050c88b37..dbb6985be 100644 --- a/arch/inst/M/mulw.yaml +++ b/arch/inst/M/mulw.yaml @@ -15,12 +15,25 @@ mulw: an alternative is to shift both arguments left by 32 bits, then use MULH[[S]U]. definedBy: [M, Zmmul] assembly: xd, xs1, xs2 + encoding: + match: 0000001----------000-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::M) && (CSR[misa].M == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + Bits<32> src1 = X[rs1][31:0]; Bits<32> src2 = X[rs2][31:0]; diff --git a/arch/inst/M/rem.yaml b/arch/inst/M/rem.yaml index acfc2c27c..676af77fb 100644 --- a/arch/inst/M/rem.yaml +++ b/arch/inst/M/rem.yaml @@ -10,12 +10,25 @@ rem: If the result of the division overflows, write zero into rd; definedBy: M assembly: xd, xs1, xs2 + encoding: + match: 0000001----------110-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::M) && (CSR[misa].M == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg src1 = X[rs1]; XReg src2 = X[rs2]; diff --git a/arch/inst/M/remu.yaml b/arch/inst/M/remu.yaml index 54405fecd..63fda287a 100644 --- a/arch/inst/M/remu.yaml +++ b/arch/inst/M/remu.yaml @@ -6,12 +6,25 @@ remu: Calculate the remainder of unsigned division of rs1 by rs2, and store the result in rd. definedBy: M assembly: xd, xs1, xs2 + encoding: + match: 0000001----------111-----0110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::M) && (CSR[misa].M == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + XReg src1 = X[rs1]; XReg src2 = X[rs2]; diff --git a/arch/inst/M/remuw.yaml b/arch/inst/M/remuw.yaml index 3aa58db0b..686f6ead1 100644 --- a/arch/inst/M/remuw.yaml +++ b/arch/inst/M/remuw.yaml @@ -9,12 +9,25 @@ remuw: If the value in rs2 is zero, rd gets the sign-extended value in rs1. definedBy: M assembly: xd, xs1, xs2 + encoding: + match: 0000001----------111-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::M) && (CSR[misa].M == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + Bits<32> src1 = X[rs1][31:0]; Bits<32> src2 = X[rs2][31:0]; diff --git a/arch/inst/M/remw.yaml b/arch/inst/M/remw.yaml index bc80a4545..1d384e6bb 100644 --- a/arch/inst/M/remw.yaml +++ b/arch/inst/M/remw.yaml @@ -11,12 +11,25 @@ remw: If the result of the division overflows, write zero into rd; definedBy: M assembly: xd, xs1, xs2 + encoding: + match: 0000001----------110-----0111011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always vs: always vu: always operation(): | + if (implemented?(ExtensionName::M) && (CSR[misa].M == 1'b0)) { + raise (ExceptionCode::IllegalInstruction, $encoding); + } + Bits<32> src1 = X[rs1][31:0]; Bits<32> src2 = X[rs2][31:0]; diff --git a/arch/inst/S/sfence.vma.yaml b/arch/inst/S/sfence.vma.yaml index 467d7e242..e7c3c959c 100644 --- a/arch/inst/S/sfence.vma.yaml +++ b/arch/inst/S/sfence.vma.yaml @@ -206,6 +206,13 @@ sfence.vma: attempts to execute an SFENCE.VMA instruction might raise an illegal-instruction exception. assembly: xs1, xs2 + encoding: + match: 0001001----------000000001110011 + variables: + - name: rs2 + location: 24-20 + - name: rs1 + location: 19-15 access: s: always u: always diff --git a/arch/inst/S/sret.yaml b/arch/inst/S/sret.yaml index 5e405a55b..412a49550 100644 --- a/arch/inst/S/sret.yaml +++ b/arch/inst/S/sret.yaml @@ -44,6 +44,8 @@ sret: definedBy: S assembly: "" + encoding: + match: '00010000001000000000000001110011' access: s: sometimes u: never @@ -67,32 +69,32 @@ sret: if (implemented?(ExtensionName::H)) { if (CSR[mstatus].TSR == 1'b0 && CSR[hstatus].VTSR == 1'b0) { if (mode() == PrivilegeMode::U) { - raise (ExceptionCode::IllegalInstruction); + raise (ExceptionCode::IllegalInstruction, $encoding); } else if (mode() == PrivilegeMode::VU) { - raise (ExceptionCode::VirtualInstruction); + raise (ExceptionCode::VirtualInstruction, $encoding); } } else if (CSR[mstatus].TSR == 1'b0 && CSR[hstatus].VTSR == 1'b1) { if (mode() == PrivilegeMode::U) { - raise (ExceptionCode::IllegalInstruction); + raise (ExceptionCode::IllegalInstruction, $encoding); } else if (mode() == PrivilegeMode::VU || mode() == PrivilegeMode::VS) { - raise (ExceptionCode::VirtualInstruction); + raise (ExceptionCode::VirtualInstruction, $encoding); } } else if (CSR[mstatus].TSR == 1'b1 && CSR[hstatus].VTSR == 1'b0) { if (mode() == PrivilegeMode::U || mode() == PrivilegeMode::S) { - raise (ExceptionCode::IllegalInstruction); + raise (ExceptionCode::IllegalInstruction, $encoding); } else if (mode() == PrivilegeMode::VU) { - raise (ExceptionCode::VirtualInstruction); + raise (ExceptionCode::VirtualInstruction, $encoding); } } else if (CSR[mstatus].TSR == 1'b1 && CSR[hstatus].VTSR == 1'b1) { if (mode() == PrivilegeMode::U || mode() == PrivilegeMode::S) { - raise (ExceptionCode::IllegalInstruction); + raise (ExceptionCode::IllegalInstruction, $encoding); } else if (mode() == PrivilegeMode::VU || mode() == PrivilegeMode::VS) { - raise (ExceptionCode::VirtualInstruction); + raise (ExceptionCode::VirtualInstruction, $encoding); } } } else { if (mode() != PrivilegeMode::U) { - raise (ExceptionCode::IllegalInstruction); + raise (ExceptionCode::IllegalInstruction, $encoding); } } @@ -114,7 +116,7 @@ sret: PC = $bits(CSR[sepc]); } else { if (CSR[mstatus].TSR == 1'b1) { - raise (ExceptionCode::IllegalInstruction); + raise (ExceptionCode::IllegalInstruction, $encoding); } CSR[vsstatus].SPP = 0; CSR[vsstatus].SIE = CSR[vsstatus].SPIE; diff --git a/arch/inst/Zicbom/cbo.clean.yaml b/arch/inst/Zicbom/cbo.clean.yaml index 06bf91071..1e60bf9bf 100644 --- a/arch/inst/Zicbom/cbo.clean.yaml +++ b/arch/inst/Zicbom/cbo.clean.yaml @@ -35,6 +35,11 @@ cbo.clean: definedBy: Zicbom assembly: "TODO" + encoding: + match: 000000000001-----010000000001111 + variables: + - name: rs1 + location: 19-15 access: m: always s: sometimes diff --git a/arch/inst/Zicbom/cbo.flush.yaml b/arch/inst/Zicbom/cbo.flush.yaml index 33c8ade6b..397bc921f 100644 --- a/arch/inst/Zicbom/cbo.flush.yaml +++ b/arch/inst/Zicbom/cbo.flush.yaml @@ -28,6 +28,11 @@ cbo.flush: CBO operations never raise a misaligned address fault. definedBy: Zicbom assembly: "TODO" + encoding: + match: 000000000010-----010000000001111 + variables: + - name: rs1 + location: 19-15 access: m: always s: sometimes diff --git a/arch/inst/Zicbom/cbo.inval.yaml b/arch/inst/Zicbom/cbo.inval.yaml index cd895a22d..73bebfbc0 100644 --- a/arch/inst/Zicbom/cbo.inval.yaml +++ b/arch/inst/Zicbom/cbo.inval.yaml @@ -67,6 +67,11 @@ cbo.inval: CBO operations never raise a misaligned address fault. definedBy: Zicbom assembly: "TODO" + encoding: + match: 000000000000-----010000000001111 + variables: + - name: rs1 + location: 19-15 access: m: always s: sometimes diff --git a/arch/inst/Zicboz/cbo.zero.yaml b/arch/inst/Zicboz/cbo.zero.yaml index b01552725..423e077d6 100644 --- a/arch/inst/Zicboz/cbo.zero.yaml +++ b/arch/inst/Zicboz/cbo.zero.yaml @@ -30,6 +30,11 @@ cbo.zero: CBO operations never raise a misaligned address fault. definedBy: Zicboz assembly: "TODO" + encoding: + match: 000000000100-----010000000001111 + variables: + - name: rs1 + location: 19-15 access: m: always s: sometimes diff --git a/arch/inst/Zicsr/csrrs.yaml b/arch/inst/Zicsr/csrrs.yaml index 16bc5a02c..2af31cf8d 100644 --- a/arch/inst/Zicsr/csrrs.yaml +++ b/arch/inst/Zicsr/csrrs.yaml @@ -13,6 +13,15 @@ csrrs: Other bits in the CSR are not explicitly written. definedBy: Zicsr assembly: xd, xs1, csr + encoding: + match: -----------------000-----0010011 + variables: + - name: csr + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/Zicsr/csrrw.yaml b/arch/inst/Zicsr/csrrw.yaml index 71320dd28..30e2efb29 100644 --- a/arch/inst/Zicsr/csrrw.yaml +++ b/arch/inst/Zicsr/csrrw.yaml @@ -12,6 +12,15 @@ csrrw: cause any of the side effects that might occur on a CSR read. definedBy: Zicsr assembly: xd, xs1, csr + encoding: + match: -----------------001-----1110011 + variables: + - name: csr + location: 31-20 + - name: rs1 + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always diff --git a/arch/inst/Zicsr/csrrwi.yaml b/arch/inst/Zicsr/csrrwi.yaml index 1fe8de5dc..f0b87c423 100644 --- a/arch/inst/Zicsr/csrrwi.yaml +++ b/arch/inst/Zicsr/csrrwi.yaml @@ -12,6 +12,15 @@ csrrwi: cause any of the side effects that might occur on a CSR read. definedBy: Zicsr assembly: xd, zimm, csr + encoding: + match: -----------------101-----1110011 + variables: + - name: csr + location: 31-20 + - name: imm + location: 19-15 + - name: rd + location: 11-7 access: s: always u: always @@ -24,4 +33,4 @@ csrrwi: # writes the zero-extended immediate to the CSR, # performing any WARL transformations first - CSR[csr].sw_write({{XLEN-5{1'b0}}, zimm}); + CSR[csr].sw_write({{XLEN-5{1'b0}}, imm}); diff --git a/arch/isa/globals.isa b/arch/isa/globals.isa index bc3196391..b144b756b 100644 --- a/arch/isa/globals.isa +++ b/arch/isa/globals.isa @@ -105,7 +105,9 @@ enum ExceptionCode { LoadPageFault 13 // reserved 14 StoreAmoPageFault 15 - // reserved 16-19 + // reserved 16-17 + SoftwareCheck 18 + HardwareError 19 InstructionGuestPageFault 20 LoadGuestPageFault 21 VirtualInstruction 22 @@ -258,8 +260,203 @@ function exception_handling_mode { } } +function mtval_readonly? { + returns Boolean + description { + Returns whether or not CSR[mtval] is read-only based on implementation options + } + body { + return !( + REPORT_VA_IN_MTVAL_ON_BREAKPOINT || + REPORT_VA_IN_MTVAL_ON_LOAD_MISALIGNED || + REPORT_VA_IN_MTVAL_ON_STORE_AMO_MISALIGNED || + REPORT_VA_IN_MTVAL_ON_INSTRUCTION_MISALIGNED || + REPORT_VA_IN_MTVAL_ON_LOAD_ACCESS_FAULT || + REPORT_VA_IN_MTVAL_ON_STORE_AMO_ACCESS_FAULT || + REPORT_VA_IN_MTVAL_ON_INSTRUCTION_ACCESS_FAULT || + REPORT_VA_IN_MTVAL_ON_LOAD_PAGE_FAULT || + REPORT_VA_IN_MTVAL_ON_STORE_AMO_PAGE_FAULT || + REPORT_VA_IN_MTVAL_ON_INSTRUCTION_PAGE_FAULT || + REPORT_ENCODING_IN_MTVAL_ON_ILLEGAL_INSTRUCTION || + REPORT_CAUSE_IN_MTVAL_ON_SOFTWARE_CHECK || + implemented?(ExtensionName::Sdext) + ); + } +} + +function stval_readonly? { + returns Boolean + description { + Returns whether or not CSR[stval] is read-only based on implementation options + } + body { + if (implemented?(ExtensionName::S)) { + return !( + REPORT_VA_IN_STVAL_ON_BREAKPOINT || + REPORT_VA_IN_STVAL_ON_LOAD_MISALIGNED || + REPORT_VA_IN_STVAL_ON_STORE_AMO_MISALIGNED || + REPORT_VA_IN_STVAL_ON_INSTRUCTION_MISALIGNED || + REPORT_VA_IN_STVAL_ON_LOAD_ACCESS_FAULT || + REPORT_VA_IN_STVAL_ON_STORE_AMO_ACCESS_FAULT || + REPORT_VA_IN_STVAL_ON_INSTRUCTION_ACCESS_FAULT || + REPORT_VA_IN_STVAL_ON_LOAD_PAGE_FAULT || + REPORT_VA_IN_STVAL_ON_STORE_AMO_PAGE_FAULT || + REPORT_VA_IN_STVAL_ON_INSTRUCTION_PAGE_FAULT || + REPORT_ENCODING_IN_STVAL_ON_ILLEGAL_INSTRUCTION || + REPORT_CAUSE_IN_STVAL_ON_SOFTWARE_CHECK || + implemented?(ExtensionName::Sdext) + ); + } else { + return true; + } + } +} + +function vstval_readonly? { + returns Boolean + description { + Returns whether or not CSR[vstval] is read-only based on implementation options + } + body { + if (implemented?(ExtensionName::H)) { + return !( + REPORT_VA_IN_VSTVAL_ON_BREAKPOINT || + REPORT_VA_IN_VSTVAL_ON_LOAD_MISALIGNED || + REPORT_VA_IN_VSTVAL_ON_STORE_AMO_MISALIGNED || + REPORT_VA_IN_VSTVAL_ON_INSTRUCTION_MISALIGNED || + REPORT_VA_IN_VSTVAL_ON_LOAD_ACCESS_FAULT || + REPORT_VA_IN_VSTVAL_ON_STORE_AMO_ACCESS_FAULT || + REPORT_VA_IN_VSTVAL_ON_INSTRUCTION_ACCESS_FAULT || + REPORT_VA_IN_VSTVAL_ON_LOAD_PAGE_FAULT || + REPORT_VA_IN_VSTVAL_ON_STORE_AMO_PAGE_FAULT || + REPORT_VA_IN_VSTVAL_ON_INSTRUCTION_PAGE_FAULT || + REPORT_ENCODING_IN_VSTVAL_ON_ILLEGAL_INSTRUCTION || + REPORT_CAUSE_IN_VSTVAL_ON_SOFTWARE_CHECK || + implemented?(ExtensionName::Sdext) + ); + } else { + return true; + } + } +} + +function mtval_for { + returns XReg + arguments ExceptionCode exception_code, XReg tval + description { + Given an exception code and a *legal* non-zero value for mtval, + returns the value to be written in mtval considering implementation options + } + body { + if (exception_code == ExceptionCode::Breakpoint) { + return REPORT_VA_IN_MTVAL_ON_BREAKPOINT ? tval : 0; + } else if (exception_code == ExceptionCode::LoadAddressMisaligned) { + return REPORT_VA_IN_MTVAL_ON_LOAD_MISALIGNED ? tval : 0; + } else if (exception_code == ExceptionCode::StoreAmoAddressMisaligned) { + return REPORT_VA_IN_MTVAL_ON_STORE_AMO_MISALIGNED ? tval : 0; + } else if (exception_code == ExceptionCode::InstructionAddressMisaligned) { + return REPORT_VA_IN_MTVAL_ON_INSTRUCTION_MISALIGNED ? tval : 0; + } else if (exception_code == ExceptionCode::LoadAccessFault) { + return REPORT_VA_IN_MTVAL_ON_LOAD_ACCESS_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::StoreAmoAccessFault) { + return REPORT_VA_IN_MTVAL_ON_STORE_AMO_ACCESS_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::InstructionAccessFault) { + return REPORT_VA_IN_MTVAL_ON_INSTRUCTION_ACCESS_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::LoadPageFault) { + return REPORT_VA_IN_MTVAL_ON_LOAD_PAGE_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::StoreAmoPageFault) { + return REPORT_VA_IN_MTVAL_ON_STORE_AMO_PAGE_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::InstructionPageFault) { + return REPORT_VA_IN_MTVAL_ON_INSTRUCTION_PAGE_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::IllegalInstruction) { + return REPORT_ENCODING_IN_MTVAL_ON_ILLEGAL_INSTRUCTION ? tval : 0; + } else if (exception_code == ExceptionCode::SoftwareCheck) { + return REPORT_CAUSE_IN_MTVAL_ON_SOFTWARE_CHECK ? tval : 0; + } else { + return 0; + } + } +} + +function stval_for { + returns XReg + arguments ExceptionCode exception_code, XReg tval + description { + Given an exception code and a *legal* non-zero value for stval, + returns the value to be written in stval considering implementation options + } + body { + if (exception_code == ExceptionCode::Breakpoint) { + return REPORT_VA_IN_STVAL_ON_BREAKPOINT ? tval : 0; + } else if (exception_code == ExceptionCode::LoadAddressMisaligned) { + return REPORT_VA_IN_STVAL_ON_LOAD_MISALIGNED ? tval : 0; + } else if (exception_code == ExceptionCode::StoreAmoAddressMisaligned) { + return REPORT_VA_IN_STVAL_ON_STORE_AMO_MISALIGNED ? tval : 0; + } else if (exception_code == ExceptionCode::InstructionAddressMisaligned) { + return REPORT_VA_IN_STVAL_ON_INSTRUCTION_MISALIGNED ? tval : 0; + } else if (exception_code == ExceptionCode::LoadAccessFault) { + return REPORT_VA_IN_STVAL_ON_LOAD_ACCESS_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::StoreAmoAccessFault) { + return REPORT_VA_IN_STVAL_ON_STORE_AMO_ACCESS_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::InstructionAccessFault) { + return REPORT_VA_IN_STVAL_ON_INSTRUCTION_ACCESS_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::LoadPageFault) { + return REPORT_VA_IN_STVAL_ON_LOAD_PAGE_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::StoreAmoPageFault) { + return REPORT_VA_IN_STVAL_ON_STORE_AMO_PAGE_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::InstructionPageFault) { + return REPORT_VA_IN_STVAL_ON_INSTRUCTION_PAGE_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::IllegalInstruction) { + return REPORT_ENCODING_IN_STVAL_ON_ILLEGAL_INSTRUCTION ? tval : 0; + } else if (exception_code == ExceptionCode::SoftwareCheck) { + return REPORT_CAUSE_IN_STVAL_ON_SOFTWARE_CHECK ? tval : 0; + } else { + return 0; + } + } +} + + +function vstval_for { + returns XReg + arguments ExceptionCode exception_code, XReg tval + description { + Given an exception code and a *legal* non-zero value for vstval, + returns the value to be written in vstval considering implementation options + } + body { + if (exception_code == ExceptionCode::Breakpoint) { + return REPORT_VA_IN_VSTVAL_ON_BREAKPOINT ? tval : 0; + } else if (exception_code == ExceptionCode::LoadAddressMisaligned) { + return REPORT_VA_IN_VSTVAL_ON_LOAD_MISALIGNED ? tval : 0; + } else if (exception_code == ExceptionCode::StoreAmoAddressMisaligned) { + return REPORT_VA_IN_VSTVAL_ON_STORE_AMO_MISALIGNED ? tval : 0; + } else if (exception_code == ExceptionCode::InstructionAddressMisaligned) { + return REPORT_VA_IN_VSTVAL_ON_INSTRUCTION_MISALIGNED ? tval : 0; + } else if (exception_code == ExceptionCode::LoadAccessFault) { + return REPORT_VA_IN_VSTVAL_ON_LOAD_ACCESS_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::StoreAmoAccessFault) { + return REPORT_VA_IN_VSTVAL_ON_STORE_AMO_ACCESS_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::InstructionAccessFault) { + return REPORT_VA_IN_VSTVAL_ON_INSTRUCTION_ACCESS_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::LoadPageFault) { + return REPORT_VA_IN_VSTVAL_ON_LOAD_PAGE_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::StoreAmoPageFault) { + return REPORT_VA_IN_VSTVAL_ON_STORE_AMO_PAGE_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::InstructionPageFault) { + return REPORT_VA_IN_VSTVAL_ON_INSTRUCTION_PAGE_FAULT ? tval : 0; + } else if (exception_code == ExceptionCode::IllegalInstruction) { + return REPORT_ENCODING_IN_VSTVAL_ON_ILLEGAL_INSTRUCTION ? tval : 0; + } else if (exception_code == ExceptionCode::SoftwareCheck) { + return REPORT_CAUSE_IN_VSTVAL_ON_SOFTWARE_CHECK ? tval : 0; + } else { + return 0; + } + } +} + function raise { - arguments ExceptionCode exception_code + arguments ExceptionCode exception_code, XReg tval description { Raise synchronous exception number `exception_code`. } @@ -268,16 +465,24 @@ function raise { if (handling_mode == PrivilegeMode::M) { CSR[mepc] = PC; + if (!mtval_readonly?()) { + CSR[mtval] = mtval_for(exception_code, tval); + } PC = {CSR[mtvec].BASE, 2'b00}; CSR[mcause] = exception_code.value; - // note that mtval is set elsewhere } else if (implemented?(ExtensionName::S) && (handling_mode == PrivilegeMode::HS)) { CSR[sepc] = PC; + if (!stval_readonly?()) { + CSR[stval] = stval_for(exception_code, tval); + } PC = {CSR[stvec].BASE, 2'b00}; CSR[scause] = exception_code.value; // note that stval is set elsewhere } else if (implemented?(ExtensionName::H) && (handling_mode == PrivilegeMode::VS)) { CSR[vsepc] = PC; + if (!vstval_readonly?()) { + CSR[vstval] = vstval_for(exception_code, tval); + } PC = {CSR[vstvec].BASE, 2'b00}; CSR[vscause] = exception_code.value; } @@ -300,9 +505,9 @@ function jump { if (implemented?(ExtensionName::C) && # C is implemented (CSR[misa].C == 0x1) && # and C is enabled dynamically ((target_addr & 0x1) != 0)) { # and the target PC is odd - raise(ExceptionCode::InstructionAddressMisaligned); + raise(ExceptionCode::InstructionAddressMisaligned, target_addr); } else if ((target_addr & 0x3) != 0) { - raise(ExceptionCode::InstructionAddressMisaligned); + raise(ExceptionCode::InstructionAddressMisaligned, target_addr); } PC = target_addr; @@ -882,7 +1087,7 @@ function pmp_check { function access_check { template U32 access_size returns Boolean, ExceptionCode - arguments Bits paddr, MemoryOperation type + arguments Bits paddr, XReg vaddr, MemoryOperation type description { Returns True if the current privilege mode cannot access the physical address paddr. } @@ -890,11 +1095,11 @@ function access_check { # check if this is a valid physical address if (paddr > ((1 << PHYS_ADDR_WIDTH) - access_size)) { if (type == MemoryOperation::Write) { - raise (ExceptionCode::StoreAmoAccessFault); + raise (ExceptionCode::StoreAmoAccessFault, vaddr); } else if (type == MemoryOperation::Read) { - raise (ExceptionCode::LoadAccessFault); + raise (ExceptionCode::LoadAccessFault, vaddr); } else if (type == MemoryOperation::Fetch) { - raise (ExceptionCode::InstructionAccessFault); + raise (ExceptionCode::InstructionAccessFault, vaddr); } } @@ -902,11 +1107,11 @@ function access_check { # can return either AccessFault or AddressMisalignedException if (!pmp_check(paddr[PHYS_ADDR_WIDTH-1:0], type)) { if (type == MemoryOperation::Write) { - raise (ExceptionCode::StoreAmoAccessFault); + raise (ExceptionCode::StoreAmoAccessFault, vaddr); } else if (type == MemoryOperation::Read) { - raise (ExceptionCode::LoadAccessFault); + raise (ExceptionCode::LoadAccessFault, vaddr); } else if (type == MemoryOperation::Fetch) { - raise (ExceptionCode::InstructionAccessFault); + raise (ExceptionCode::InstructionAccessFault, vaddr); } } return false, -; @@ -1119,14 +1324,14 @@ function translate_sv39 { # non-canonical virtual address raises a page fault # note that if pointer masking is enabled, # vaddr has already been transformed before reaching here - raise (ecode); + raise (ecode, vaddr); } for (U32 i = 2; i >= 0; i--) { XReg pte_addr = (ppn << 12) + ((vaddr >> (12 + 9*i)) & 0x1ff); # perform access check on the physical address of pte before it's used - access_check<64>(pte_addr, op); + access_check<64>(pte_addr, vaddr, op); Sv39PageTableEntry pte = read_physical_memory<64>(pte_addr); if (pte.V == 0 # invalid entry @@ -1135,7 +1340,7 @@ function translate_sv39 { # || (!implemented?(ExtensionName::Svnapot) && pte.N != 0) # || (!implemented?(ExtensionName::Svpbmt) && pte.PBMT != 0)) { # found invalid PTE - raise (ecode); + raise (ecode, vaddr); } else if (pte.R == 1 || pte.X == 1) { # found a leaf PTE @@ -1143,27 +1348,27 @@ function translate_sv39 { if ((CSR[mstatus].MXR == 0 && pte.R == 0) || (CSR[mstatus].MXR == 1 && pte.X == 0 && pte.R == 0)) { # no read permission - raise (ExceptionCode::LoadPageFault); + raise (ExceptionCode::LoadPageFault, vaddr); } if ((mode() == PrivilegeMode::U && pte.U == 0) || (mode() == PrivilegeMode::M && CSR[mstatus].MPRV == 1 && CSR[mstatus].MPP == $bits(PrivilegeMode::HS) && pte.U == 1 && CSR[mstatus].SUM == 0) || (mode() == PrivilegeMode::S && pte.U == 1 && CSR[mstatus].SUM == 0)) { # supervisor cannot read U unless mstatus.SUM = 1 - raise (ExceptionCode::LoadPageFault); + raise (ExceptionCode::LoadPageFault, vaddr); } } else if ((op == MemoryOperation::Write) && (pte.W == 0)) { # no write permission - raise (ExceptionCode::StoreAmoPageFault); + raise (ExceptionCode::StoreAmoPageFault, vaddr); } else if ((op == MemoryOperation::Fetch) && (pte.X == 0)) { # no execute permission - raise (ExceptionCode::InstructionPageFault); + raise (ExceptionCode::InstructionPageFault, vaddr); } if (pte.U == 0) { # supervisor page if (mode() == PrivilegeMode::U) { # user access to supervisor page is never allowed - raise (ecode); + raise (ecode, vaddr); } } else { # user page @@ -1172,26 +1377,26 @@ function translate_sv39 { if (op == MemoryOperation::Read) { if (CSR[mstatus].SUM == 0) { # supervisor can only read user pages when mstatus.SUM == 1 - raise (ExceptionCode::LoadPageFault); + raise (ExceptionCode::LoadPageFault, vaddr); } } else { # supervisor can never write or execute a user page - raise (ecode); + raise (ecode, vaddr); } } } # ensure remaining PPN bits are zero, otherwise there is a misaligned super page - raise (ecode) if (i >= 1 && pte.PPN0 != 0); - raise (ecode) if (i == 2 && pte.PPN1 != 0); + raise (ecode, vaddr) if (i >= 1 && pte.PPN0 != 0); + raise (ecode, vaddr) if (i == 2 && pte.PPN1 != 0); if (false) { // implemented?(ExtensionName::Svadu)) { # svadu requires page tables to be located in memory with hardware page-table write access # and RsrvEventual PMA if (!check_pma(pte_addr, PmaAttribute::RsrvEventual)) { - raise (ExceptionCode::LoadAccessFault); + raise (ExceptionCode::LoadAccessFault, vaddr); } - access_check<64>(pte_addr, MemoryOperation::Write); + access_check<64>(pte_addr, vaddr, MemoryOperation::Write); # if (implemented?(ExtensionName::H) && CSR[henvcfg].ADUE == 0b1) { # update the A bit # this should be atomic with the translation @@ -1205,7 +1410,7 @@ function translate_sv39 { if (//implemented?(ExtensionName::Svade) && pte.A == 0) { # trap on access with A == 0 - raise (ecode); + raise (ecode, vaddr); } # translation succeeded @@ -1215,12 +1420,12 @@ function translate_sv39 { if (i == 0) { # a pointer can't exist on the last level - raise (ecode); + raise (ecode, vaddr); } if (pte.D == 1 || pte.A == 1 || pte.U == 1) { # D, A, and U are reserved in non-leaf PTEs - raise (ecode); + raise (ecode, vaddr); } ppn = pte.PPN << 12; @@ -1293,12 +1498,12 @@ function translate { # bare == no translation if (vaddr > ((1 << PHYS_ADDR_WIDTH) - 1)) { if (op == MemoryOperation::Read) { - raise (ExceptionCode::LoadAccessFault); + raise (ExceptionCode::LoadAccessFault, vaddr); } else if (op == MemoryOperation::Write) { - raise (ExceptionCode::StoreAmoAccessFault); + raise (ExceptionCode::StoreAmoAccessFault, vaddr); } else { assert(op == MemoryOperation::Fetch); - raise (ExceptionCode::InstructionAccessFault); + raise (ExceptionCode::InstructionAccessFault, vaddr); } } return vaddr; @@ -1335,7 +1540,7 @@ function read_memory_aligned { : virtual_address; # may raise an exception - access_check(physical_address, MemoryOperation::Read); + access_check(physical_address, virtual_address, MemoryOperation::Read); return read_physical_memory(physical_address); } @@ -1354,7 +1559,7 @@ function read_memory { if (aligned) { return read_memory_aligned(virtual_address); } else if (!aligned && !MISALIGNED_LDST) { - raise (ExceptionCode::LoadAddressMisaligned); + raise (ExceptionCode::LoadAddressMisaligned, virtual_address); } else { # misaligned, must break into multiple reads Bits result = 0; @@ -1366,6 +1571,10 @@ function read_memory { } } +//function load_reserved { +// +//} + @@ -1383,7 +1592,7 @@ function write_memory_aligned { : virtual_address; # may raise an exception - access_check(physical_address, MemoryOperation::Write); + access_check(physical_address, virtual_address, MemoryOperation::Write); write_physical_memory(physical_address, value); } @@ -1401,7 +1610,7 @@ function write_memory { if (aligned) { write_memory_aligned(virtual_address, value); } else if (!aligned && !MISALIGNED_LDST) { - raise (ExceptionCode::StoreAmoAddressMisaligned); + raise (ExceptionCode::StoreAmoAddressMisaligned, virtual_address); } else { # misaligned, must break into multiple writes for (U32 i = 0; i <= len; i++) { @@ -1411,34 +1620,3 @@ function write_memory { } } -// function Mem { -// template U32 len -// returns XReg -// arguments XReg eaddr -// description { -// Read memory. -// } -// body { -// XReg vaddr, paddr; -// Boolean has_fault; -// ExceptionCode ecode; -// -// # by default, vaddr = eaddr -// vaddr = mask_eaddr(eaddr); -// -// (paddr, ecode) = translate_load(vaddr); -// raise (ExceptionCode::LoadPageFault) if (ecode == ExceptionCode::LoadPageFault); -// raise (ExceptionCode::LoadGuestPageFault) if (ecode == ExceptionCode::LoadGuestPageFault); -// raise (ExceptionCode::LoadAccessFault) if (ecode == ExceptionCode::LoadAccessFault); -// -// (has_fault, ecode) = access_check(paddr, MemoryOperation::Read); -// -// # Load Address Misaligned is a lower-priority exception than Page Fault -// # it is higher-priority than access fault if Zihpme (High-Priority Misaligned Exception) is implemented -// raise (ExceptionCode::LoadAddressMisaligned) if implemented?(ExtensionName::Zihpme) && has_fault && (ecode == ExceptionCode::LoadAddressMisaligned); -// raise (ExceptionCode::LoadAccessFault) if has_fault && (ecode == ExceptionCode::LoadAccessFault); -// raise (ExceptionCode::LoadAddressMisaligned) if !implemented?(ExtensionName::Zihpme) && has_fault && (ecode == ExceptionCode::LoadAddressMisaligned); -// -// return read_physical_memory(paddr); -// } -// } diff --git a/arch/prose/idl.adoc b/arch/prose/idl.adoc index 7811f9d62..7c1ffe08d 100644 --- a/arch/prose/idl.adoc +++ b/arch/prose/idl.adoc @@ -219,7 +219,8 @@ Literals may contain any number of underscores after the initial digit for clari -8'sd13 # -13 decimal, signed, 8-bit wide -16'shd # -13 decimal, signed, 16-bit wide -12'so15 # -13 decimal, signed, 12-bit wide --4'sb1101 # -13 decimal, signed, 4-bit wide +4'sb1101 # -3 decimal, signed, 4-bit wide +-4'sb1101 # 3 decimal, signed, 4-bit wide 32'h80000000 # 0x8000000, unsigned, 32-bit wide 32'h8000_0000 # same as above (underscores ignored) @@ -228,11 +229,12 @@ Literals may contain any number of underscores after the initial digit for clari '13 # 13 decimal, unsigned XLEN-bit wide 's13 # 13 decimal, signed XLEN-bit wide +# 'h100000000 # compilation error when XLEN == 32; does not fit in XLEN bits -4'd13 # 3 decimal: the literal is 13, unsigned, in 4-bits. when negated, the sign bit is lost # -8'sd200 # compilation error: -200 does not fit in 8 bits # 0'15 # compilation error: cannot have integer with 0 length -# 4'xff # compilation error: value does not fit in 4 bits +# 4'hff # compilation error: value does not fit in 4 bits ---- .C style literals diff --git a/cfgs/config_validation.rb b/cfgs/config_validation.rb index 0936d2a5b..2af4f1061 100644 --- a/cfgs/config_validation.rb +++ b/cfgs/config_validation.rb @@ -21,6 +21,36 @@ # is SXLEN is fixed to 32, then UXLEN cannot be > 32 assert [nil, 32].include?(UXLEN) if ext?(:S) && ext?(:U) && SXLEN == 32 +max_va_width = + if ext?(:Sv57) + 57 + elsif ext?(:Sv48) + 48 + elsif ext?(:Sv39) + 39 + elsif ext?(:Sv32) + 32 + else + PHYS_ADDR_WIDTH + end +mtval_holds_va = + REPORT_VA_IN_MTVAL_ON_BREAKPOINT || + REPORT_VA_IN_MTVAL_ON_LOAD_MISALIGNED || + REPORT_VA_IN_MTVAL_ON_STORE_AMO_MISALIGNED || + REPORT_VA_IN_MTVAL_ON_INSTRUCTION_MISALIGNED || + REPORT_VA_IN_MTVAL_ON_LOAD_ACCESS_FAULT || + REPORT_VA_IN_MTVAL_ON_STORE_AMO_ACCESS_FAULT || + REPORT_VA_IN_MTVAL_ON_INSTRUCTION_ACCESS_FAULT || + REPORT_VA_IN_MTVAL_ON_LOAD_PAGE_FAULT || + REPORT_VA_IN_MTVAL_ON_STORE_AMO_PAGE_FAULT || + REPORT_VA_IN_MTVAL_ON_INSTRUCTION_PAGE_FAULT || + ext?(:Sdext) + +assert(MTVAL_WIDTH >= max_va_width) if mtval_holds_va + +# 32 stands for ILEN below. Update this if/when instructions become longer than 32 +assert(MTVAL_WIDTH >= [XLEN, 32].min) if REPORT_ENCODING_IN_MTVAL_ON_ILLEGAL_INSTRUCTION + # check for conditionally required params require_param :MUTABLE_MISA_A if ext?(:A) require_param :MUTABLE_MISA_B if ext?(:B) diff --git a/cfgs/generic_rv64/arch_overlay/ext/Xcustom.yaml b/cfgs/generic_rv64/arch_overlay/ext/Xcustom.yaml index 2f6885833..bbc9db3e0 100644 --- a/cfgs/generic_rv64/arch_overlay/ext/Xcustom.yaml +++ b/cfgs/generic_rv64/arch_overlay/ext/Xcustom.yaml @@ -4,5 +4,6 @@ Xcustom: versions: - version: 0.1 ratification_date: null + state: development description: | A new custom extension! diff --git a/cfgs/generic_rv64/params.yaml b/cfgs/generic_rv64/params.yaml index 7e898f37e..5f9ef8b58 100644 --- a/cfgs/generic_rv64/params.yaml +++ b/cfgs/generic_rv64/params.yaml @@ -77,7 +77,47 @@ params: # when false, *tval is written with 0 on an EBREAK instruction # # regardless, *tval is always written with a virtual PC when an external breakpoint is generated - REPORT_EBREAK_PC_IN_TVAL: false + REPORT_VA_IN_MTVAL_ON_BREAKPOINT: true + + REPORT_VA_IN_MTVAL_ON_LOAD_MISALIGNED: true + REPORT_VA_IN_MTVAL_ON_STORE_AMO_MISALIGNED: true + REPORT_VA_IN_MTVAL_ON_INSTRUCTION_MISALIGNED: true + REPORT_VA_IN_MTVAL_ON_LOAD_ACCESS_FAULT: true + REPORT_VA_IN_MTVAL_ON_STORE_AMO_ACCESS_FAULT: true + REPORT_VA_IN_MTVAL_ON_INSTRUCTION_ACCESS_FAULT: true + REPORT_VA_IN_MTVAL_ON_LOAD_PAGE_FAULT: true + REPORT_VA_IN_MTVAL_ON_STORE_AMO_PAGE_FAULT: true + REPORT_VA_IN_MTVAL_ON_INSTRUCTION_PAGE_FAULT: true + REPORT_ENCODING_IN_MTVAL_ON_ILLEGAL_INSTRUCTION: true + REPORT_CAUSE_IN_MTVAL_ON_SOFTWARE_CHECK: true + MTVAL_WIDTH: 64 # must check that this can hold any valid VA if any REPORT_VA* or Sdext, and, if REPORT_ENCODING*, at least [MXLEN, ILEN].min bits + + REPORT_VA_IN_STVAL_ON_BREAKPOINT: true + REPORT_VA_IN_STVAL_ON_STORE_AMO_MISALIGNED: true + REPORT_VA_IN_STVAL_ON_INSTRUCTION_MISALIGNED: true + REPORT_VA_IN_STVAL_ON_LOAD_ACCESS_FAULT: true + REPORT_VA_IN_STVAL_ON_STORE_AMO_ACCESS_FAULT: true + REPORT_VA_IN_STVAL_ON_INSTRUCTION_ACCESS_FAULT: true + REPORT_VA_IN_STVAL_ON_LOAD_PAGE_FAULT: true + REPORT_VA_IN_STVAL_ON_STORE_AMO_PAGE_FAULT: true + REPORT_VA_IN_STVAL_ON_INSTRUCTION_PAGE_FAULT: true + REPORT_ENCODING_IN_STVAL_ON_ILLEGAL_INSTRUCTION: true + REPORT_CAUSE_IN_STVAL_ON_SOFTWARE_CHECK: true + STVAL_WIDTH: 64 # must check that this can hold any valid VA, and, if REPORT_ENCODING*, at least [SXLEN, ILEN].min bits + + REPORT_VA_IN_VSTVAL_ON_BREAKPOINT: true + REPORT_VA_IN_VSTVAL_ON_STORE_AMO_MISALIGNED: true + REPORT_VA_IN_VSTVAL_ON_INSTRUCTION_MISALIGNED: true + REPORT_VA_IN_VSTVAL_ON_LOAD_ACCESS_FAULT: true + REPORT_VA_IN_VSTVAL_ON_STORE_AMO_ACCESS_FAULT: true + REPORT_VA_IN_VSTVAL_ON_INSTRUCTION_ACCESS_FAULT: true + REPORT_VA_IN_VSTVAL_ON_LOAD_PAGE_FAULT: true + REPORT_VA_IN_VSTVAL_ON_STORE_AMO_PAGE_FAULT: true + REPORT_VA_IN_VSTVAL_ON_INSTRUCTION_PAGE_FAULT: true + REPORT_ENCODING_IN_VSTVAL_ON_ILLEGAL_INSTRUCTION: true + REPORT_CAUSE_IN_VSTVAL_ON_SOFTWARE_CHECK: true + # VSTVAL_WIDTH not needed; "vstval is a WARL register that must be able to hold the same set of values that stval can hold" + # address of the unified discovery configuration data structure # this address is reported in the mconfigptr CSR diff --git a/docs/ruby/ArchDef.html b/docs/ruby/ArchDef.html index 83c19aead..9f4a97d5c 100644 --- a/docs/ruby/ArchDef.html +++ b/docs/ruby/ArchDef.html @@ -143,6 +143,35 @@

Instance Attribute Summary collaps

The configuration parameters.

+ + + +
  • + + + #global_ast ⇒ Idl::AstNode + + + + + + + + + readonly + + + + + + + + + +
    +

    Abstract syntax tree of global scope.

    +
    +
  • @@ -754,34 +783,34 @@

     
     
    -1220
    -1221
    -1222
    -1223
    -1224
    -1225
    -1226
    -1227
    -1228
    -1229
    -1230
    -1231
    -1232
    -1233
    -1234
    -1235
    -1236
    -1237
    -1238
    -1239
    -1240
    -1241
    -1242
    -1243
    -1244
    +1345 +1346 +1347 +1348 +1349 +1350 +1351 +1352 +1353 +1354 +1355 +1356 +1357 +1358 +1359 +1360 +1361 +1362 +1363 +1364 +1365 +1366 +1367 +1368 +1369 -
    # File 'lib/arch_def.rb', line 1220
    +      
    # File 'lib/arch_def.rb', line 1345
     
     def initialize(config_name)
       @name = config_name.to_s
    @@ -803,7 +832,7 @@ 

    @idl_compiler = Idl::Compiler.new(self) # load the globals into the symbol table - @idl_compiler.compile_file( + @global_ast = @idl_compiler.compile_file( $root / "arch" / "isa" / "globals.isa", @sym_table ) @@ -864,12 +893,12 @@

     
     
    -1211
    -1212
    -1213
    +1333 +1334 +1335

    -
    # File 'lib/arch_def.rb', line 1211
    +      
    # File 'lib/arch_def.rb', line 1333
     
     def config_params
       @config_params
    @@ -880,6 +909,67 @@ 

    + +
    +

    + + #global_astIdl::AstNode (readonly) + + + + + +

    +
    + +

    Returns Abstract syntax tree of global scope.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Idl::AstNode) + + + + — +
      +

      Abstract syntax tree of global scope

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +1339
    +1340
    +1341
    +
    +
    # File 'lib/arch_def.rb', line 1339
    +
    +def global_ast
    +  @global_ast
    +end
    +
    +
    + +

    @@ -925,12 +1015,12 @@

     
     
    -1214
    -1215
    -1216
    +1336 +1337 +1338

    -
    # File 'lib/arch_def.rb', line 1214
    +      
    # File 'lib/arch_def.rb', line 1336
     
     def idl_compiler
       @idl_compiler
    @@ -986,12 +1076,12 @@ 

     
     
    -1205
    -1206
    -1207
    +1327 +1328 +1329

    -
    # File 'lib/arch_def.rb', line 1205
    +      
    # File 'lib/arch_def.rb', line 1327
     
     def name
       @name
    @@ -1047,12 +1137,12 @@ 

     
     
    -1208
    -1209
    -1210
    +1330 +1331 +1332

    -
    # File 'lib/arch_def.rb', line 1208
    +      
    # File 'lib/arch_def.rb', line 1330
     
     def sym_table
       @sym_table
    @@ -1113,12 +1203,12 @@ 

     
     
    -1343
    -1344
    -1345
    +1468 +1469 +1470

    -
    # File 'lib/arch_def.rb', line 1343
    +      
    # File 'lib/arch_def.rb', line 1468
     
     def all_known_csr_names
       @arch_def["csrs"].map { |csr| csr[0] }
    @@ -1192,12 +1282,12 @@ 

     
     
    -1377
    -1378
    -1379
    +1502 +1503 +1504

    -
    # File 'lib/arch_def.rb', line 1377
    +      
    # File 'lib/arch_def.rb', line 1502
     
     def csr(csr_name)
       csr_hash[csr_name]
    @@ -1251,18 +1341,18 @@ 

     
     
    -1359
    -1360
    -1361
    -1362
    -1363
    -1364
    -1365
    -1366
    -1367
    +1484 +1485 +1486 +1487 +1488 +1489 +1490 +1491 +1492

    -
    # File 'lib/arch_def.rb', line 1359
    +      
    # File 'lib/arch_def.rb', line 1484
     
     def csr_hash
       return @csr_hash unless @csr_hash.nil?
    @@ -1322,16 +1412,16 @@ 

     
     
    -1333
    -1334
    -1335
    -1336
    -1337
    -1338
    -1339
    +1458 +1459 +1460 +1461 +1462 +1463 +1464

    -
    # File 'lib/arch_def.rb', line 1333
    +      
    # File 'lib/arch_def.rb', line 1458
     
     def csrs
       return @csrs unless @csrs.nil?
    @@ -1389,12 +1479,12 @@ 

     
     
    -1319
    -1320
    -1321
    +1444 +1445 +1446

    -
    # File 'lib/arch_def.rb', line 1319
    +      
    # File 'lib/arch_def.rb', line 1444
     
     def data
       @arch_def
    @@ -1596,19 +1686,19 @@ 

     
     
    -1307
    -1308
    -1309
    -1310
    -1311
    -1312
    -1313
    -1314
    -1315
    -1316
    +1432 +1433 +1434 +1435 +1436 +1437 +1438 +1439 +1440 +1441

    -
    # File 'lib/arch_def.rb', line 1307
    +      
    # File 'lib/arch_def.rb', line 1432
     
     def ext?(ext_name, *ext_version_requirements)
       implemented_extensions.any? do |e|
    @@ -1701,12 +1791,12 @@ 

     
     
    -1289
    -1290
    -1291
    +1414 +1415 +1416

    -
    # File 'lib/arch_def.rb', line 1289
    +      
    # File 'lib/arch_def.rb', line 1414
     
     def extension(name)
       extension_hash[name.to_s]
    @@ -1731,18 +1821,18 @@ 

     
     
    -1276
    -1277
    -1278
    -1279
    -1280
    -1281
    -1282
    -1283
    -1284
    +1401 +1402 +1403 +1404 +1405 +1406 +1407 +1408 +1409

    -
    # File 'lib/arch_def.rb', line 1276
    +      
    # File 'lib/arch_def.rb', line 1401
     
     def extension_hash
       return @extension_hash unless @extension_hash.nil?
    @@ -1802,18 +1892,18 @@ 

     
     
    -1265
    -1266
    -1267
    -1268
    -1269
    -1270
    -1271
    -1272
    -1273
    +1390 +1391 +1392 +1393 +1394 +1395 +1396 +1397 +1398

    -
    # File 'lib/arch_def.rb', line 1265
    +      
    # File 'lib/arch_def.rb', line 1390
     
     def extensions
       return @extensions unless @extensions.nil?
    @@ -1893,27 +1983,27 @@ 
    -
    # File 'lib/arch_def.rb', line 1429
    +      
    # File 'lib/arch_def.rb', line 1552
     
     def find_replace_links(adoc)
       adoc.gsub(/`([\w.]+)`/) do |match|
    @@ -1921,13 +2011,13 @@ 

     
     
    -1371
    -1372
    -1373
    +1496 +1497 +1498

    -
    # File 'lib/arch_def.rb', line 1371
    +      
    # File 'lib/arch_def.rb', line 1496
     
     def implemented_csr(csr_name)
       implemented_csr_hash[csr_name]
    @@ -2061,18 +2151,18 @@ 

     
     
    -1348
    -1349
    -1350
    -1351
    -1352
    -1353
    -1354
    -1355
    -1356
    +1473 +1474 +1475 +1476 +1477 +1478 +1479 +1480 +1481

    -
    # File 'lib/arch_def.rb', line 1348
    +      
    # File 'lib/arch_def.rb', line 1473
     
     def implemented_csr_hash
       return @implemented_csr_hash unless @implemented_csr_hash.nil?
    @@ -2132,16 +2222,16 @@ 

     
     
    -1324
    -1325
    -1326
    -1327
    -1328
    -1329
    -1330
    +1449 +1450 +1451 +1452 +1453 +1454 +1455

    -
    # File 'lib/arch_def.rb', line 1324
    +      
    # File 'lib/arch_def.rb', line 1449
     
     def implemented_csrs
       return @implemented_csrs unless @implemented_csrs.nil?
    @@ -2199,27 +2289,27 @@ 

     
     
    -1253
    -1254
    -1255
    -1256
    -1257
    -1258
    -1259
    -1260
    -1261
    -1262
    +1378 +1379 +1380 +1381 +1382 +1383 +1384 +1385 +1386 +1387

    -
    # File 'lib/arch_def.rb', line 1253
    +      
    # File 'lib/arch_def.rb', line 1378
     
     def implemented_extensions
       return @implemented_extensions unless @implemented_extensions.nil?
     
       @implemented_extensions = []
       @arch_def["implemented_extensions"].each do |e|
    -    @implemented_extensions << ExtensionVersion.new(e["name"], e["version"], self)
    -  end
    +    @implemented_extensions << ExtensionVersion.new(e["name"], e["version"])
    +2    end
     
       @implemented_extensions
     end
    @@ -2272,20 +2362,20 @@

     
     
    -1406
    -1407
    -1408
    -1409
    -1410
    -1411
    -1412
    -1413
    -1414
    -1415
    -1416
    +1529 +1530 +1531 +1532 +1533 +1534 +1535 +1536 +1537 +1538 +1539

    -
    # File 'lib/arch_def.rb', line 1406
    +      
    # File 'lib/arch_def.rb', line 1529
     
     def implemented_instructions
       return @implemented_instructions unless @implemented_instructions.nil?
    @@ -2367,12 +2457,12 @@ 

     
     
    -1420
    -1421
    -1422
    +1543 +1544 +1545

    -
    # File 'lib/arch_def.rb', line 1420
    +      
    # File 'lib/arch_def.rb', line 1543
     
     def inst(inst_name)
       instruction_hash[inst_name.to_s]
    @@ -2426,18 +2516,18 @@ 

     
     
    -1395
    -1396
    -1397
    -1398
    -1399
    -1400
    -1401
    -1402
    -1403
    +1518 +1519 +1520 +1521 +1522 +1523 +1524 +1525 +1526

    -
    # File 'lib/arch_def.rb', line 1395
    +      
    # File 'lib/arch_def.rb', line 1518
     
     def instruction_hash
       return @instruction_hash unless @instruction_hash.nil?
    @@ -2497,28 +2587,24 @@ 

     
     
    -1382
    -1383
    -1384
    -1385
    -1386
    -1387
    -1388
    -1389
    -1390
    -1391
    -1392
    +1507 +1508 +1509 +1510 +1511 +1512 +1513 +1514 +1515

    -
    # File 'lib/arch_def.rb', line 1382
    +      
    # File 'lib/arch_def.rb', line 1507
     
     def instructions
       return @instructions unless @instructions.nil?
     
    -  opcode_data = YAML.load_file("#{$root}/ext/riscv-opcodes/instr_dict.yaml")
    -
       @instructions = @arch_def["instructions"].map do |_inst_name, inst_data|
    -    Instruction.new(inst_data, opcode_data, @sym_table, self)
    +    Instruction.new(inst_data)
       end
     
       @instructions
    @@ -2572,12 +2658,12 @@ 

     
     
    -1248
    -1249
    -1250
    +1373 +1374 +1375

    -
    # File 'lib/arch_def.rb', line 1248
    +      
    # File 'lib/arch_def.rb', line 1373
     
     def multi_xlen?
       ["SXLEN", "UXLEN", "VSXLEN", "VUXLEN"].any? { |key| @config_params[key] == 3264 }
    @@ -2592,7 +2678,7 @@ 

    diff --git a/docs/ruby/ArchDefObject.html b/docs/ruby/ArchDefObject.html index c3bc59380..a62c30f75 100644 --- a/docs/ruby/ArchDefObject.html +++ b/docs/ruby/ArchDefObject.html @@ -326,14 +326,14 @@

     
     
    +38
    +39
    +40
     41
    -42
    -43
    -44
    -45
    +42

    -
    # File 'lib/arch_def.rb', line 41
    +      
    # File 'lib/arch_def.rb', line 38
     
     def initialize(data)
       raise "Bad data" unless data.is_a?(Hash)
    @@ -379,6 +379,9 @@ 

     
     
    +56
    +57
    +58
     59
     60
     61
    @@ -386,13 +389,10 @@ 

    63 64 65 -66 -67 -68 -69

    +66

    -
    # File 'lib/arch_def.rb', line 59
    +      
    # File 'lib/arch_def.rb', line 56
     
     def method_missing(method_name, *args, &block)
       if @data.key?(method_name.to_s)
    @@ -432,12 +432,12 @@ 

     
     
    -47
    -48
    -49
    +44 +45 +46

    -
    # File 'lib/arch_def.rb', line 47
    +      
    # File 'lib/arch_def.rb', line 44
     
     def inspect
       self.class.name
    @@ -491,10 +491,10 @@ 

     
     
    -56
    +53

    -
    # File 'lib/arch_def.rb', line 56
    +      
    # File 'lib/arch_def.rb', line 53
     
     def keys = @data.keys
    @@ -539,12 +539,12 @@

     
     
    -71
    -72
    -73
    +68 +69 +70

    -
    # File 'lib/arch_def.rb', line 71
    +      
    # File 'lib/arch_def.rb', line 68
     
     def respond_to_missing?(method_name, include_private = false)
       @data.key?(method_name.to_s) || super
    @@ -559,7 +559,7 @@ 

    diff --git a/docs/ruby/ArchGen.html b/docs/ruby/ArchGen.html index fcb5b5639..6461895b0 100644 --- a/docs/ruby/ArchGen.html +++ b/docs/ruby/ArchGen.html @@ -506,7 +506,6 @@

     
     
    -36
     37
     38
     39
    @@ -527,10 +526,11 @@ 

    54 55 56 -57

    +57 +58

    -
    # File 'lib/arch_gen.rb', line 36
    +      
    # File 'lib/arch_gen.rb', line 37
     
     def initialize(config_name)
       @validator = Validator.instance
    @@ -592,12 +592,12 @@ 

     
     
    -25
     26
    -27
    +27 +28

    -
    # File 'lib/arch_gen.rb', line 25
    +      
    # File 'lib/arch_gen.rb', line 26
     
     def gen_dir
       @gen_dir
    @@ -635,12 +635,12 @@ 

     
     
    -22
     23
    -24
    +24 +25

    -
    # File 'lib/arch_gen.rb', line 22
    +      
    # File 'lib/arch_gen.rb', line 23
     
     def name
       @name
    @@ -701,17 +701,17 @@ 

     
     
    -586
     587
     588
     589
     590
     591
     592
    -593
    +593 +594

    -
    # File 'lib/arch_gen.rb', line 586
    +      
    # File 'lib/arch_gen.rb', line 587
     
     def all_known_exts
       (
    @@ -741,7 +741,6 @@ 

     
     
    -110
     111
     112
     113
    @@ -758,10 +757,11 @@ 

    124 125 126 -127

    +127 +128

    -
    # File 'lib/arch_gen.rb', line 110
    +      
    # File 'lib/arch_gen.rb', line 111
     
     def check_extension_dependencies
       @implemented_extensions.each do |ext|
    @@ -830,7 +830,6 @@ 

     
     
    -667
     668
     669
     670
    @@ -846,10 +845,11 @@ 

    680 681 682 -683

    +683 +684

    -
    # File 'lib/arch_gen.rb', line 667
    +      
    # File 'lib/arch_gen.rb', line 668
     
     def exception_codes
       return @exception_codes unless @exception_codes.nil?
    @@ -901,7 +901,6 @@ 

     
     
    -95
     96
     97
     98
    @@ -914,10 +913,11 @@ 

    105 106 107 -108

    +108 +109

    -
    # File 'lib/arch_gen.rb', line 95
    +      
    # File 'lib/arch_gen.rb', line 96
     
     def generate
       # extensions need to be parsed first since we pull, e.g., exception codes from them
    @@ -982,13 +982,13 @@ 

     
     
    -157
     158
     159
    -160
    +160 +161

    -
    # File 'lib/arch_gen.rb', line 157
    +      
    # File 'lib/arch_gen.rb', line 158
     
     def implemented_csrs
       generate unless @generate_done
    @@ -1043,13 +1043,13 @@ 

     
     
    -169
     170
     171
    -172
    +172 +173

    -
    # File 'lib/arch_gen.rb', line 169
    +      
    # File 'lib/arch_gen.rb', line 170
     
     def implemented_extensions
       generate unless @generate_done
    @@ -1104,13 +1104,13 @@ 

     
     
    -163
     164
     165
    -166
    +166 +167

    -
    # File 'lib/arch_gen.rb', line 163
    +      
    # File 'lib/arch_gen.rb', line 164
     
     def implemented_instructions
       generate unless @generate_done
    @@ -1165,7 +1165,6 @@ 

     
     
    -688
     689
     690
     691
    @@ -1181,10 +1180,11 @@ 

    701 702 703 -704

    +704 +705

    -
    # File 'lib/arch_gen.rb', line 688
    +      
    # File 'lib/arch_gen.rb', line 689
     
     def interrupt_codes
       return @interrupt_codes unless @interrupt_codes.nil?
    @@ -1289,7 +1289,6 @@ 

     
     
    -60
     61
     62
     63
    @@ -1318,10 +1317,11 @@ 

    86 87 88 -89

    +89 +90

    -
    # File 'lib/arch_gen.rb', line 60
    +      
    # File 'lib/arch_gen.rb', line 61
     
     def validate_config
       fork do
    @@ -1363,7 +1363,7 @@ 

    diff --git a/docs/ruby/Csr.html b/docs/ruby/Csr.html index 1b0af927b..00f65a326 100644 --- a/docs/ruby/Csr.html +++ b/docs/ruby/Csr.html @@ -639,15 +639,15 @@

     
     
    -351
    -352
    -353
    -354
    -355
    -356
    +359 +360 +361 +362 +363 +364

    -
    # File 'lib/arch_def.rb', line 351
    +      
    # File 'lib/arch_def.rb', line 359
     
     def initialize(csr_data, sym_table, arch_def)
       super(csr_data)
    @@ -721,12 +721,12 @@ 

     
     
    -343
    -344
    -345
    +351 +352 +353

    -
    # File 'lib/arch_def.rb', line 343
    +      
    # File 'lib/arch_def.rb', line 351
     
     def arch_def
       @arch_def
    @@ -782,12 +782,12 @@ 

     
     
    -346
    -347
    -348
    +354 +355 +356

    -
    # File 'lib/arch_def.rb', line 346
    +      
    # File 'lib/arch_def.rb', line 354
     
     def sym_table
       @sym_table
    @@ -848,12 +848,12 @@ 

     
     
    -460
    -461
    -462
    +467 +468 +469

    -
    # File 'lib/arch_def.rb', line 460
    +      
    # File 'lib/arch_def.rb', line 467
     
     def description_html
       Asciidoctor.convert description
    @@ -907,24 +907,24 @@ 

     
     
    -360
    -361
    -362
    -363
    -364
    -365
    -366
    -367
     368
     369
     370
     371
     372
     373
    -374
    +374 +375 +376 +377 +378 +379 +380 +381 +382

    -
    # File 'lib/arch_def.rb', line 360
    +      
    # File 'lib/arch_def.rb', line 368
     
     def dynamic_length?
       return false if @data["length"].is_a?(Integer)
    @@ -972,12 +972,12 @@ 

     
     
    -547
    -548
    -549
    +554 +555 +556

    -
    # File 'lib/arch_def.rb', line 547
    +      
    # File 'lib/arch_def.rb', line 554
     
     def field(field_name)
       field_hash[field_name.to_s]
    @@ -1031,12 +1031,12 @@ 

     
     
    -542
    -543
    -544
    +549 +550 +551

    -
    # File 'lib/arch_def.rb', line 542
    +      
    # File 'lib/arch_def.rb', line 549
     
     def field?(field_name)
       field_hash.key?(field_name.to_s)
    @@ -1090,19 +1090,19 @@ 

     
     
    -530
    -531
    -532
    -533
    -534
    -535
    -536
     537
     538
    -539
    +539 +540 +541 +542 +543 +544 +545 +546

    -
    # File 'lib/arch_def.rb', line 530
    +      
    # File 'lib/arch_def.rb', line 537
     
     def field_hash
       @field_hash unless @field_hash.nil?
    @@ -1163,18 +1163,18 @@ 

     
     
    -465
    -466
    -467
    -468
    -469
    -470
    -471
     472
    -473
    +473 +474 +475 +476 +477 +478 +479 +480

    -
    # File 'lib/arch_def.rb', line 465
    +      
    # File 'lib/arch_def.rb', line 472
     
     def fields
       return @fields unless @fields.nil?
    @@ -1234,12 +1234,12 @@ 

     
     
    -552
    -553
    -554
    +559 +560 +561

    -
    # File 'lib/arch_def.rb', line 552
    +      
    # File 'lib/arch_def.rb', line 559
     
     def has_custom_sw_read?
       @data.key?("sw_read") && !sw_read.empty?
    @@ -1293,13 +1293,6 @@ 

     
     
    -501
    -502
    -503
    -504
    -505
    -506
    -507
     508
     509
     510
    @@ -1319,10 +1312,17 @@ 

    524 525 526 -527

    +527 +528 +529 +530 +531 +532 +533 +534

    -
    # File 'lib/arch_def.rb', line 501
    +      
    # File 'lib/arch_def.rb', line 508
     
     def implemented_fields
       return @implemented_fields unless @implemented_fields.nil?
    @@ -1400,13 +1400,6 @@ 

     
     
    -477
    -478
    -479
    -480
    -481
    -482
    -483
     484
     485
     486
    @@ -1420,10 +1413,17 @@ 

    494 495 496 -497

    +497 +498 +499 +500 +501 +502 +503 +504

    -
    # File 'lib/arch_def.rb', line 477
    +      
    # File 'lib/arch_def.rb', line 484
     
     def implemented_fields_for(effective_xlen)
       @implemented_fields_for ||= {}
    @@ -1517,14 +1517,6 @@ 

     
     
    -378
    -379
    -380
    -381
    -382
    -383
    -384
    -385
     386
     387
     388
    @@ -1548,10 +1540,17 @@ 

    406 407 408 -409

    +409 +410 +411 +412 +413 +414 +415 +416

    -
    # File 'lib/arch_def.rb', line 378
    +      
    # File 'lib/arch_def.rb', line 386
     
     def length(effective_xlen = nil)
       case @data["length"]
    @@ -1563,7 +1562,6 @@ 

    effective_xlen else - puts arch_def.implemented_csrs.map { |c| c.name } raise "CSR #{name} is not implemented" if arch_def.implemented_csrs.none? { |c| c.name == name } raise "CSR #{name} is not implemented" if arch_def.config_params["SXLEN"].nil? @@ -1634,19 +1632,19 @@

     
     
    -412
    -413
    -414
    -415
    -416
    -417
    -418
     419
     420
    -421
    +421 +422 +423 +424 +425 +426 +427 +428

    -
    # File 'lib/arch_def.rb', line 412
    +      
    # File 'lib/arch_def.rb', line 419
     
     def length_cond32
       case @data["length"]
    @@ -1707,19 +1705,19 @@ 

     
     
    -424
    -425
    -426
    -427
    -428
    -429
    -430
     431
     432
    -433
    +433 +434 +435 +436 +437 +438 +439 +440

    -
    # File 'lib/arch_def.rb', line 424
    +      
    # File 'lib/arch_def.rb', line 431
     
     def length_cond64
       case @data["length"]
    @@ -1780,13 +1778,6 @@ 

     
     
    -436
    -437
    -438
    -439
    -440
    -441
    -442
     443
     444
     445
    @@ -1799,10 +1790,17 @@ 

    452 453 454 -455

    +455 +456 +457 +458 +459 +460 +461 +462

    -
    # File 'lib/arch_def.rb', line 436
    +      
    # File 'lib/arch_def.rb', line 443
     
     def length_pretty
       if dynamic_length?
    @@ -1911,13 +1909,6 @@ 

     
     
    -573
    -574
    -575
    -576
    -577
    -578
    -579
     580
     581
     582
    @@ -1933,10 +1924,17 @@ 

    592 593 594 -595

    +595 +596 +597 +598 +599 +600 +601 +602

    -
    # File 'lib/arch_def.rb', line 573
    +      
    # File 'lib/arch_def.rb', line 580
     
     def wavedrom_desc(effective_xlen)
       desc = {
    @@ -1971,7 +1969,7 @@ 

    diff --git a/docs/ruby/CsrField.html b/docs/ruby/CsrField.html index c5c6ec881..176f5bfdb 100644 --- a/docs/ruby/CsrField.html +++ b/docs/ruby/CsrField.html @@ -648,13 +648,13 @@

     
     
    -89
    -90
    -91
    -92
    +86 +87 +88 +89

    -
    # File 'lib/arch_def.rb', line 89
    +      
    # File 'lib/arch_def.rb', line 86
     
     def initialize(parent_csr, field_data)
       super(field_data)
    @@ -730,12 +730,12 @@ 

     
     
    -79
    -80
    -81
    +76 +77 +78

    -
    # File 'lib/arch_def.rb', line 79
    +      
    # File 'lib/arch_def.rb', line 76
     
     def parent
       @parent
    @@ -796,7 +796,6 @@ 

     
     
    -156
     157
     158
     159
    @@ -820,10 +819,11 @@ 

    177 178 179 -180

    +180 +181

    -
    # File 'lib/arch_def.rb', line 156
    +      
    # File 'lib/arch_def.rb', line 157
     
     def alias
       return @alias unless @alias.nil?
    @@ -899,12 +899,12 @@ 

     
     
    -95
    -96
    -97
    +92 +93 +94

    -
    # File 'lib/arch_def.rb', line 95
    +      
    # File 'lib/arch_def.rb', line 92
     
     def arch_def
       @parent.arch_def
    @@ -958,10 +958,10 @@ 

     
     
    -266
    +274

    -
    # File 'lib/arch_def.rb', line 266
    +      
    # File 'lib/arch_def.rb', line 274
     
     def base32_only? = @data.key?("base") && @data["base"] == 32
    @@ -1013,10 +1013,10 @@

     
     
    -263
    +271

    -
    # File 'lib/arch_def.rb', line 263
    +      
    # File 'lib/arch_def.rb', line 271
     
     def base64_only? = @data.key?("base") && @data["base"] == 64
    @@ -1068,10 +1068,10 @@

     
     
    -269
    +277

    -
    # File 'lib/arch_def.rb', line 269
    +      
    # File 'lib/arch_def.rb', line 277
     
     def defined_in_all_bases? = @data["base"].nil?
    @@ -1123,14 +1123,14 @@

     
     
    -192
     193
     194
     195
    -196
    +196 +197

    -
    # File 'lib/arch_def.rb', line 192
    +      
    # File 'lib/arch_def.rb', line 193
     
     def dynamic_location?
       return false if @data.key?("location")
    @@ -1186,12 +1186,12 @@ 

     
     
    -183
     184
    -185
    +185 +186

    -
    # File 'lib/arch_def.rb', line 183
    +      
    # File 'lib/arch_def.rb', line 184
     
     def has_custom_write?
       @data.key?("write(csr_value)") && !@data["write(csr_value)"].empty?
    @@ -1267,14 +1267,6 @@ 

     
     
    -232
    -233
    -234
    -235
    -236
    -237
    -238
    -239
     240
     241
     242
    @@ -1295,10 +1287,18 @@ 

    257 258 259 -260

    +260 +261 +262 +263 +264 +265 +266 +267 +268

    -
    # File 'lib/arch_def.rb', line 232
    +      
    # File 'lib/arch_def.rb', line 240
     
     def location(effective_xlen = nil)
       key =
    @@ -1378,14 +1378,6 @@ 

     
     
    -278
    -279
    -280
    -281
    -282
    -283
    -284
    -285
     286
     287
     288
    @@ -1402,10 +1394,18 @@ 

    299 300 301 -302

    +302 +303 +304 +305 +306 +307 +308 +309 +310

    -
    # File 'lib/arch_def.rb', line 278
    +      
    # File 'lib/arch_def.rb', line 286
     
     def location_pretty
       derangeify = proc { |loc|
    @@ -1493,7 +1493,6 @@ 

     
     
    -218
     219
     220
     221
    @@ -1503,21 +1502,36 @@ 

    225 226 227 -228

    +228 +229 +230 +231 +232 +233 +234 +235 +236

    -
    # File 'lib/arch_def.rb', line 218
    +      
    # File 'lib/arch_def.rb', line 219
     
     def reset_value
       return @reset_value unless @reset_value.nil?
     
    -  @reset_value =
    -    if @data.key?("reset_value")
    -      @data["reset_value"]
    -    else
    -      puts "evaluating #{name}"
    -      reset_value_func.return_value(arch_def.sym_table)
    -    end
    +  symtab = arch_def.sym_table
    +
    +  symtab.push # for consistency with template functions
    +
    +  begin
    +    @reset_value =
    +      if @data.key?("reset_value")
    +        @data["reset_value"]
    +      else
    +        reset_value_func.return_value(arch_def.sym_table)
    +      end
    +  ensure
    +    symtab.pop
    +  end
     end
    @@ -1586,7 +1600,6 @@

     
     
    -200
     201
     202
     203
    @@ -1600,10 +1613,11 @@ 

    211 212 213 -214

    +214 +215

    -
    # File 'lib/arch_def.rb', line 200
    +      
    # File 'lib/arch_def.rb', line 201
     
     def reset_value_func
       raise "Not an IDL value" unless @data.key?("reset_value()")
    @@ -1685,6 +1699,9 @@ 

     
     
    +104
    +105
    +106
     107
     108
     109
    @@ -1731,10 +1748,11 @@ 

    150 151 152 -153

    +153 +154

    -
    # File 'lib/arch_def.rb', line 107
    +      
    # File 'lib/arch_def.rb', line 104
     
     def type
       return @type unless @type.nil?
    @@ -1759,6 +1777,8 @@ 

    parent: "#{csr.name}.#{name}" ) + sym_table.push # for consistency with template functions + begin case ast.return_value(sym_table) when 0 @@ -1780,6 +1800,8 @@

    warn "In parsing #{csr.name}.#{name}::type()" warn " Return of type() function cannot be evaluated at compile time" raise e + ensure + sym_table.pop end end end

    @@ -1832,12 +1854,12 @@

     
     
    -335
    -336
    -337
    +343 +344 +345

    -
    # File 'lib/arch_def.rb', line 335
    +      
    # File 'lib/arch_def.rb', line 343
     
     def type_desc
       TYPE_DESC_MAP[type]
    @@ -1911,12 +1933,12 @@ 

     
     
    -273
    -274
    -275
    +281 +282 +283

    -
    # File 'lib/arch_def.rb', line 273
    +      
    # File 'lib/arch_def.rb', line 281
     
     def width(effective_xlen)
       location(effective_xlen).size
    @@ -1931,7 +1953,7 @@ 

    diff --git a/docs/ruby/CsrField/Alias.html b/docs/ruby/CsrField/Alias.html index 8b20f586a..eba577280 100644 --- a/docs/ruby/CsrField/Alias.html +++ b/docs/ruby/CsrField/Alias.html @@ -218,10 +218,10 @@

     
     
    -85
    +82

    -
    # File 'lib/arch_def.rb', line 85
    +      
    # File 'lib/arch_def.rb', line 82
     
     Alias = Struct.new(:field, :range)
    @@ -275,10 +275,10 @@

     
     
    -85
    +82

    -
    # File 'lib/arch_def.rb', line 85
    +      
    # File 'lib/arch_def.rb', line 82
     
     Alias = Struct.new(:field, :range)
    @@ -292,7 +292,7 @@

    diff --git a/docs/ruby/DecodeField.html b/docs/ruby/DecodeField.html index d930aae02..4e16bd0bc 100644 --- a/docs/ruby/DecodeField.html +++ b/docs/ruby/DecodeField.html @@ -445,13 +445,6 @@

     
     
    -229
    -230
    -231
    -232
    -233
    -234
    -235
     236
     237
     238
    @@ -497,10 +490,17 @@ 

    278 279 280 -281

    +281 +282 +283 +284 +285 +286 +287 +288

    -
    # File 'lib/opcodes.rb', line 229
    +      
    # File 'lib/opcodes.rb', line 236
     
     def initialize(inst, name, decode_ring_key, field_data)
       raise "No field '#{name}', needed by #{inst.name}, in Opcodes module" unless Opcodes::DECODER_RING.key?(decode_ring_key)
    @@ -598,12 +598,12 @@ 

     
     
    -227
    -228
    -229
    +234 +235 +236

    -
    # File 'lib/opcodes.rb', line 227
    +      
    # File 'lib/opcodes.rb', line 234
     
     def decode_variable
       @decode_variable
    @@ -641,12 +641,12 @@ 

     
     
    -220
    -221
    -222
    +227 +228 +229

    -
    # File 'lib/opcodes.rb', line 220
    +      
    # File 'lib/opcodes.rb', line 227
     
     def name
       @name
    @@ -696,12 +696,12 @@ 

     
     
    -302
    -303
    -304
    +309 +310 +311

    -
    # File 'lib/opcodes.rb', line 302
    +      
    # File 'lib/opcodes.rb', line 309
     
     def bits
       @field_data[:bits].is_a?(Range) ? [@field_data[:bits]] : @field_data[:bits]
    @@ -748,12 +748,12 @@ 

     
     
    -283
    -284
    -285
    +290 +291 +292

    -
    # File 'lib/opcodes.rb', line 283
    +      
    # File 'lib/opcodes.rb', line 290
     
     def eql?(other)
       @name.eql?(other.name)
    @@ -789,13 +789,6 @@ 

     
     
    -326
    -327
    -328
    -329
    -330
    -331
    -332
     333
     334
     335
    @@ -816,10 +809,17 @@ 

    350 351 352 -353

    +353 +354 +355 +356 +357 +358 +359 +360

    -
    # File 'lib/opcodes.rb', line 326
    +      
    # File 'lib/opcodes.rb', line 333
     
     def extract
       ops = []
    @@ -869,12 +869,12 @@ 

     
     
    -306
    -307
    -308
    +313 +314 +315

    -
    # File 'lib/opcodes.rb', line 306
    +      
    # File 'lib/opcodes.rb', line 313
     
     def grouped_encoding_fields
       @encoding_fields
    @@ -899,12 +899,12 @@ 

     
     
    -287
    -288
    -289
    +294 +295 +296

    -
    # File 'lib/opcodes.rb', line 287
    +      
    # File 'lib/opcodes.rb', line 294
     
     def hash
       @name.hash
    @@ -953,12 +953,12 @@ 

     
     
    -321
    -322
    -323
    +328 +329 +330

    -
    # File 'lib/opcodes.rb', line 321
    +      
    # File 'lib/opcodes.rb', line 328
     
     def sext?
       @field_data[:sext] == true
    @@ -994,12 +994,12 @@ 

     
     
    -311
    -312
    -313
    +318 +319 +320

    -
    # File 'lib/opcodes.rb', line 311
    +      
    # File 'lib/opcodes.rb', line 318
     
     def size
       size_in_encoding + (@field_data.key?(:lshift) ? @field_data[:lshift] : 0)
    @@ -1035,12 +1035,12 @@ 

     
     
    -316
    -317
    -318
    +323 +324 +325

    -
    # File 'lib/opcodes.rb', line 316
    +      
    # File 'lib/opcodes.rb', line 323
     
     def size_in_encoding
       bits.reduce(0) { |sum, f| sum + (f.is_a?(Integer) ? 1 : f.size) }
    @@ -1089,12 +1089,12 @@ 

     
     
    -292
    -293
    -294
    +299 +300 +301

    -
    # File 'lib/opcodes.rb', line 292
    +      
    # File 'lib/opcodes.rb', line 299
     
     def split?
       encoding_fields.size > 1
    @@ -1109,7 +1109,7 @@ 

    diff --git a/docs/ruby/DecodeVariable.html b/docs/ruby/DecodeVariable.html index f31437036..1a27e1dcd 100644 --- a/docs/ruby/DecodeVariable.html +++ b/docs/ruby/DecodeVariable.html @@ -290,7 +290,7 @@

  • - #extract_location(location_string) ⇒ Object + #extract_location(location) ⇒ Object @@ -531,23 +531,23 @@

     
     
    -136
    -137
    -138
    -139
    -140
    -141
    -142
     143
     144
     145
     146
     147
     148
    -149
    +149 +150 +151 +152 +153 +154 +155 +156

  • -
    # File 'lib/opcodes.rb', line 136
    +      
    # File 'lib/opcodes.rb', line 143
     
     def initialize(inst, field_data)
       @inst = inst
    @@ -746,14 +746,14 @@ 

     
     
    -170
    -171
    -172
    -173
    -174
    +177 +178 +179 +180 +181

    -
    # File 'lib/opcodes.rb', line 170
    +      
    # File 'lib/opcodes.rb', line 177
     
     def bits
       @encoding_fields.map do |ef|
    @@ -802,12 +802,12 @@ 

     
     
    -151
    -152
    -153
    +158 +159 +160

    -
    # File 'lib/opcodes.rb', line 151
    +      
    # File 'lib/opcodes.rb', line 158
     
     def eql?(other)
       @name.eql?(other.name)
    @@ -843,13 +843,6 @@ 

     
     
    -192
    -193
    -194
    -195
    -196
    -197
    -198
     199
     200
     201
    @@ -866,10 +859,17 @@ 

    212 213 214 -215

    +215 +216 +217 +218 +219 +220 +221 +222

    -
    # File 'lib/opcodes.rb', line 192
    +      
    # File 'lib/opcodes.rb', line 199
     
     def extract
       ops = []
    @@ -903,7 +903,7 @@ 

    - #extract_location(location_string) ⇒ Object + #extract_location(location) ⇒ Object @@ -932,14 +932,28 @@

    72 73 74 -75

    +75 +76 +77 +78 +79 +80 +81 +82
    # File 'lib/opcodes.rb', line 58
     
    -def extract_location(location_string)
    -  parts = location_string.split("|")
    +def extract_location(location)
       @encoding_fields = []
    +
    +  if location.is_a?(Integer)
    +    @encoding_fields << EncodingField.new("", location..location)
    +    return
    +  end
    +
    +  location_string = location
    +  parts = location_string.split("|")
       parts.each do |part|
         if part =~ /^([0-9]+)$/
           bit = ::Regexp.last_match(1)
    @@ -986,13 +1000,6 @@ 

     
     
    -112
    -113
    -114
    -115
    -116
    -117
    -118
     119
     120
     121
    @@ -1008,10 +1015,17 @@ 

    131 132 133 -134

    +134 +135 +136 +137 +138 +139 +140 +141

    -
    # File 'lib/opcodes.rb', line 112
    +      
    # File 'lib/opcodes.rb', line 119
     
     def grouped_encoding_fields
       sorted_encoding_fields = @encoding_fields.sort { |a, b| b.range.last <=> a.range.last }
    @@ -1056,12 +1070,12 @@ 

     
     
    -155
    -156
    -157
    +162 +163 +164

    -
    # File 'lib/opcodes.rb', line 155
    +      
    # File 'lib/opcodes.rb', line 162
     
     def hash
       @name.hash
    @@ -1086,22 +1100,22 @@ 

     
     
    -77
    -78
    -79
    -80
    -81
    -82
    -83
     84
     85
     86
     87
     88
    -89
    +89 +90 +91 +92 +93 +94 +95 +96

    -
    # File 'lib/opcodes.rb', line 77
    +      
    # File 'lib/opcodes.rb', line 84
     
     def inst_pos_to_var_pos
       s = size
    @@ -1160,12 +1174,12 @@ 

     
     
    -187
    -188
    -189
    +194 +195 +196

    -
    # File 'lib/opcodes.rb', line 187
    +      
    # File 'lib/opcodes.rb', line 194
     
     def sext?
       @sext
    @@ -1201,12 +1215,12 @@ 

     
     
    -177
    -178
    -179
    +184 +185 +186

    -
    # File 'lib/opcodes.rb', line 177
    +      
    # File 'lib/opcodes.rb', line 184
     
     def size
       size_in_encoding + @left_shift
    @@ -1242,12 +1256,12 @@ 

     
     
    -182
    -183
    -184
    +189 +190 +191

    -
    # File 'lib/opcodes.rb', line 182
    +      
    # File 'lib/opcodes.rb', line 189
     
     def size_in_encoding
       bits.reduce(0) { |sum, f| sum + (f.is_a?(Integer) ? 1 : f.size) }
    @@ -1296,12 +1310,12 @@ 

     
     
    -160
    -161
    -162
    +167 +168 +169

    -
    # File 'lib/opcodes.rb', line 160
    +      
    # File 'lib/opcodes.rb', line 167
     
     def split?
       @encoding_fields.size > 1
    @@ -1316,7 +1330,7 @@ 

    diff --git a/docs/ruby/EncodingField.html b/docs/ruby/EncodingField.html index 507ee5f61..70a77bc0a 100644 --- a/docs/ruby/EncodingField.html +++ b/docs/ruby/EncodingField.html @@ -680,7 +680,7 @@

    diff --git a/docs/ruby/Extension.html b/docs/ruby/Extension.html index 82e6274a5..036e5078c 100644 --- a/docs/ruby/Extension.html +++ b/docs/ruby/Extension.html @@ -164,7 +164,7 @@

  • - #implies ⇒ Array<String> + #implies(version_requirement = ">= 0") ⇒ Array<ExtensionVersion> @@ -179,7 +179,7 @@

    -

    Array of extensions implied by this one.

    +

    Array of extensions implied by any version of this extension meeting version_requirement.

  • @@ -208,6 +208,30 @@

    A new instance of Extension.

    + + + +
  • + + + #instructions ⇒ Object + + + + + + + + + + + + + +
    +

    returns the list of instructions implemented by this extension.

    +
    +
  • @@ -282,13 +306,13 @@

     
     
    -1123
    -1124
    -1125
    -1126
    +1192 +1193 +1194 +1195

    -
    # File 'lib/arch_def.rb', line 1123
    +      
    # File 'lib/arch_def.rb', line 1192
     
     def initialize(ext_data, arch_def)
       super(ext_data)
    @@ -360,12 +384,12 @@ 

     
     
    -1119
    -1120
    -1121
    +1188 +1189 +1190

    -
    # File 'lib/arch_def.rb', line 1119
    +      
    # File 'lib/arch_def.rb', line 1188
     
     def arch_def
       @arch_def
    @@ -385,7 +409,7 @@ 

    Instance Method Details

    - #impliesArray<String> + #implies(version_requirement = ">= 0") ⇒ Array<ExtensionVersion> @@ -394,26 +418,48 @@

    -

    Returns Array of extensions implied by this one.

    +

    Returns Array of extensions implied by any version of this extension meeting version_requirement.

    +

    Parameters:

    +
      +
    • + + version_requirement + + + (String) + + + (defaults to: ">= 0") + + + — +
      +

      Version requirement

      +
      + +
    • + +
    +

    Returns:

    • - (Array<String>) + (Array<ExtensionVersion>)
      -

      Array of extensions implied by this one

      +

      Array of extensions implied by any version of this extension meeting version_requirement

    • @@ -426,29 +472,86 @@

       
       
      -1129
      -1130
      -1131
      -1132
      -1133
      -1134
      -1135
      -1136
      -1137
      -1138
      +1199 +1200 +1201 +1202 +1203 +1204 +1205 +1206 +1207 +1208 +1209 +1210 +1211 +1212 +1213 +1214 +1215 +1216

    -
    # File 'lib/arch_def.rb', line 1129
    -
    -def implies
    -  case @data["implies"]
    -  when nil
    -    []
    -  when Array
    -    @data["implies"]
    -  else
    -    [@data["implies"]]
    +      
    # File 'lib/arch_def.rb', line 1199
    +
    +def implies(version_requirement = ">= 0")
    +  implications = []
    +  @data["versions"].each do |v|
    +    next unless Gem::Requirement.new(version_requirement).satisfied_by?(Gem::Version.new(v["version"]))
    +
    +    case v["implies"]
    +    when nil
    +      next
    +    when Array
    +      if v["implies"][0].is_a?(Array)
    +        implications += v["implies"].map { |e| ExtensionVersion.new(e[0], e[1])}
    +      else
    +        implications << ExtensionVersion.new(v["implies"][0], v["implies"][1])
    +      end
    +    end
       end
    +  implications
    +end
    + + + + + +
    +

    + + #instructionsObject + + + + + +

    +
    + +

    returns the list of instructions implemented by this extension

    + + +
    +
    +
    + + +
    + + + @@ -460,7 +563,7 @@

    diff --git a/docs/ruby/ExtensionVersion.html b/docs/ruby/ExtensionVersion.html index 0702b9900..67fc0b0aa 100644 --- a/docs/ruby/ExtensionVersion.html +++ b/docs/ruby/ExtensionVersion.html @@ -117,64 +117,6 @@

    Overview

    Instance Attribute Summary collapse

    @@ -455,129 +393,7 @@

    Instance Attribute Details

    -

    - - #arch_defArchDef (readonly) - - - - - -

    -
    - -

    Returns Owning ArchDef.

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (ArchDef) - - - - — -
      -

      Owning ArchDef

      -
      - -
    • - -
    - -
    +
    +
    +
    +1219
    +1220
    +1221
    +
    +
    # File 'lib/arch_def.rb', line 1219
    +
    +def instructions
    +  arch_def.instructions.select { |i| i.definedBy == name || (i.definedBy.is_a?(Array) && i.definedBy.include?(name)) }
     end
    -
    # File 'lib/arch_def.rb', line 1158
    +      
    # File 'lib/arch_def.rb', line 1236
     
    -def initialize(name, version, arch_def)
    +def initialize(name, version)
       @name = name.to_s
       @version = Gem::Version.new(version)
    -  @arch_def = arch_def
    -  @extension = @arch_def.extension(@name)
     end
    - - - - -
    -
    -
    -
    -1150
    -1151
    -1152
    -
    -
    # File 'lib/arch_def.rb', line 1150
    -
    -def arch_def
    -  @arch_def
    -end
    -
    -
    - - - -
    -

    - - #extensionExtension (readonly) - - - - - -

    -
    - -

    Returns The full definition of the extension (all versions).

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Extension) - - - - — -
      -

      The full definition of the extension (all versions)

      -
      - -
    • - -
    - -
    - - - - -
    -
    -
    -
    -1153
    -1154
    -1155
    -
    -
    # File 'lib/arch_def.rb', line 1153
    -
    -def extension
    -  @extension
    -end
    -
    -
    - - - -
    -

    +

    #nameString (readonly) @@ -620,12 +436,12 @@

     
     
    -1144
    -1145
    -1146
    +1227 +1228 +1229

    -
    # File 'lib/arch_def.rb', line 1144
    +      
    # File 'lib/arch_def.rb', line 1227
     
     def name
       @name
    @@ -681,12 +497,12 @@ 

     
     
    -1147
    -1148
    -1149
    +1230 +1231 +1232

    -
    # File 'lib/arch_def.rb', line 1147
    +      
    # File 'lib/arch_def.rb', line 1230
     
     def version
       @version
    @@ -742,18 +558,18 @@ 

     
     
    -1191
    -1192
    -1193
    -1194
    -1195
    -1196
    -1197
    -1198
    -1199
    +1267 +1268 +1269 +1270 +1271 +1272 +1273 +1274 +1275

    -
    # File 'lib/arch_def.rb', line 1191
    +      
    # File 'lib/arch_def.rb', line 1267
     
     def <=>(other)
       raise ArgumentError, "ExtensionVersions are only comparable to other extension versions" unless other.is_a?(ExtensionVersion)
    @@ -784,19 +600,19 @@ 

     
     
    -1171
    -1172
    -1173
    -1174
    -1175
    -1176
    -1177
    -1178
    -1179
    -1180
    +1247 +1248 +1249 +1250 +1251 +1252 +1253 +1254 +1255 +1256

    -
    # File 'lib/arch_def.rb', line 1171
    +      
    # File 'lib/arch_def.rb', line 1247
     
     def ==(other)
       case other
    @@ -900,12 +716,12 @@ 

     
     
    -1186
    -1187
    -1188
    +1262 +1263 +1264

    -
    # File 'lib/arch_def.rb', line 1186
    +      
    # File 'lib/arch_def.rb', line 1262
     
     def satisfies?(ext_name, *ext_version_requirements)
       @name == ext_name && Gem::Requirement.new(ext_version_requirements).satisfied_by?(@version)
    @@ -920,7 +736,7 @@ 

    diff --git a/docs/ruby/Idl.html b/docs/ruby/Idl.html index db8406614..d55482634 100644 --- a/docs/ruby/Idl.html +++ b/docs/ruby/Idl.html @@ -79,7 +79,7 @@
    Defined in:
    lib/idl.rb,
    - lib/idl/ast.rb,
    lib/idl/type.rb,
    lib/idl/symbol_table.rb,
    lib/idl/passes/gen_adoc.rb,
    lib/idl/passes/find_return_values.rb
    + lib/idl/ast.rb,
    lib/idl/type.rb,
    lib/idl/passes/prune.rb,
    lib/idl/symbol_table.rb,
    lib/idl/passes/gen_adoc.rb,
    lib/idl/passes/find_return_values.rb
    @@ -89,11 +89,11 @@

    Defined Under Namespace

    - Modules: AstNodeFuncs, Executable, FunctionStatementAst, IntAst, Returns, Rvalue, VarReadExpressionAst + Modules: AstNodeFuncs, Declaration, Executable, IntLiteralSyntaxNode, Returns, Rvalue - Classes: ArrayLiteralAst, AryAccess, AryElementAccessAst, AryElementAssignmentAst, AryRangeAccessAst, AryRangeAssignmentAst, AssignmentAst, AstNode, BinaryExpressionAst, BinaryExpressionRightAst, BitfieldAccessExpressionAst, BitfieldDefinitionAst, BitfieldType, BitsCastAst, BitsTypeAst, BuiltinEnumDefinitionAst, BuiltinTypeNameAst, Compiler, ConcatenationExpressionAst, ConditionalReturnStatementAst, ConditionalStatementAst, CsrFieldReadExpressionAst, CsrReadExpressionAst, CsrSoftwareReadAst, CsrSoftwareWriteAst, CsrType, CsrWriteAst, DontCareLvalueAst, DontCareReturnAst, EnumDefinitionAst, EnumRefAst, EnumerationType, ExecutionCommentAst, FieldAssignmentAst, FieldNameAst, ForLoopAst, FunctionBodyAst, FunctionCallExpressionAst, FunctionDefAst, FunctionType, GlobalAst, GlobalWithInitializationAst, IdAst, IfAst, InstructionOperationAst, IsaAst, MultiVariableAssignmentAst, MultiVariableDeclarationAst, ParenExpressionAst, PostDecrementExpressionAst, PostIncrementExpressionAst, ReplicationExpressionAst, ReturnStatementAst, SignCastAst, StatementAst, SymbolTable, TemplateFunctionType, TernaryOperatorExpressionAst, Type, UnaryOperatorExpressionAst, UserTypeNameAst, Var, VariableAssignmentAst, VariableDeclarationAst, VariableDeclarationWithInitializationAst, XregType + Classes: ArrayLiteralAst, AryAccessSyntaxNode, AryElementAccessAst, AryElementAssignmentAst, AryElementAssignmentSyntaxNode, AryRangeAccessAst, AryRangeAssignmentAst, AssignmentAst, AstNode, BinaryExpressionAst, BinaryExpressionRightSyntaxNode, BitfieldAccessExpressionAst, BitfieldDefinitionAst, BitfieldType, BitsCastAst, BuiltinEnumDefinitionAst, BuiltinTypeNameAst, BuiltinTypeNameSyntaxNode, BuiltinVariableAst, BuiltinVariableSyntaxNode, Compiler, ConcatenationExpressionAst, ConditionalReturnStatementAst, ConditionalStatementAst, ConditionalStatementSyntaxNode, CsrFieldReadExpressionAst, CsrReadExpressionAst, CsrSoftwareReadAst, CsrSoftwareWriteAst, CsrType, CsrWriteAst, DontCareLvalueAst, DontCareReturnAst, DontCareReturnSyntaxNode, ElseIfAst, EnumDefinitionAst, EnumRefAst, EnumRefSyntaxNode, EnumerationType, ExecutionCommentAst, FieldAssignmentAst, FieldNameAst, ForLoopAst, ForLoopSyntaxNode, FunctionBodyAst, FunctionBodySyntaxNode, FunctionCallExpressionAst, FunctionCallExpressionSyntaxNode, FunctionDefAst, FunctionType, GlobalAst, GlobalWithInitializationAst, IdAst, IdSyntaxNode, IfAst, IfBodyAst, IfSyntaxNode, InstructionOperationAst, InstructionOperationSyntaxNode, IntLiteralAst, IsaAst, MultiVariableAssignmentAst, MultiVariableDeclarationAst, NoopAst, ParenExpressionAst, ParenExpressionSyntaxNode, PostDecrementExpressionAst, PostIncrementExpressionAst, ReplicationExpressionAst, ReplicationExpressionSyntaxNode, ReturnStatementAst, SignCastAst, SignCastSyntaxNode, StatementAst, StatementSyntaxNode, SymbolTable, TernaryOperatorExpressionAst, TernaryOperatorExpressionSyntaxNode, Type, UnaryOperatorExpressionAst, UserTypeNameAst, Var, VariableAssignmentAst, VariableAssignmentSyntaxNode, VariableDeclarationAst, VariableDeclarationWithInitializationAst, VariableDeclarationWithInitializationSyntaxNode, XregType

    @@ -109,7 +109,7 @@

    Defined Under Namespace

    diff --git a/docs/ruby/Idl/ArrayLiteralAst.html b/docs/ruby/Idl/ArrayLiteralAst.html index bc63ea2d8..ac8d205b0 100644 --- a/docs/ruby/Idl/ArrayLiteralAst.html +++ b/docs/ruby/Idl/ArrayLiteralAst.html @@ -232,6 +232,35 @@

    + + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
    +
  • @@ -267,12 +296,12 @@

     
     
    -1728
    -1729
    -1730
    +1948 +1949 +1950

    -
    # File 'lib/idl/ast.rb', line 1728
    +      
    # File 'lib/idl/ast.rb', line 1948
     
     def element_nodes
       [first] + rest.elements.map(&:expression)
    @@ -297,10 +326,10 @@ 

     
     
    -1751
    +1971

    -
    # File 'lib/idl/ast.rb', line 1751
    +      
    # File 'lib/idl/ast.rb', line 1971
     
     def to_idl = "[#{element_nodes.map(&:to_idl).join(',')}]"
    @@ -323,12 +352,12 @@

     
     
    -1743
    -1744
    -1745
    +1963 +1964 +1965

    -
    # File 'lib/idl/ast.rb', line 1743
    +      
    # File 'lib/idl/ast.rb', line 1963
     
     def type(symtab)
       Type.new(:array, width: element_nodes.size, sub_type: element_nodes[0].type(symtab))
    @@ -418,18 +447,18 @@ 

     
     
    -1733
    -1734
    -1735
    -1736
    -1737
    -1738
    -1739
    -1740
    -1741
    +1953 +1954 +1955 +1956 +1957 +1958 +1959 +1960 +1961

    -
    # File 'lib/idl/ast.rb', line 1733
    +      
    # File 'lib/idl/ast.rb', line 1953
     
     def type_check(symtab)
       element_nodes.each do |node|
    @@ -460,12 +489,12 @@ 

     
     
    -1747
    -1748
    -1749
    +1967 +1968 +1969

    -
    # File 'lib/idl/ast.rb', line 1747
    +      
    # File 'lib/idl/ast.rb', line 1967
     
     def value(symtab)
       element_nodes.map { |e| e.value(symtab) }
    @@ -473,6 +502,102 @@ 

    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -480,7 +605,7 @@

    diff --git a/docs/ruby/Idl/AryAccess.html b/docs/ruby/Idl/AryAccessSyntaxNode.html similarity index 89% rename from docs/ruby/Idl/AryAccess.html rename to docs/ruby/Idl/AryAccessSyntaxNode.html index 5c5200d85..e6d19d4f7 100644 --- a/docs/ruby/Idl/AryAccess.html +++ b/docs/ruby/Idl/AryAccessSyntaxNode.html @@ -4,7 +4,7 @@ - Class: Idl::AryAccess + Class: Idl::AryAccessSyntaxNode — Documentation by YARD 0.9.36 @@ -15,7 +15,7 @@ <link rel="stylesheet" href="../css/common.css" type="text/css" /> <script type="text/javascript"> - pathId = "Idl::AryAccess"; + pathId = "Idl::AryAccessSyntaxNode"; relpath = '../'; </script> @@ -39,7 +39,7 @@ <a href="../_index.html">Index (A)</a> » <span class='title'><span class='object_link'><a href="../Idl.html" title="Idl (module)">Idl</a></span></span> » - <span class="title">AryAccess</span> + <span class="title">AryAccessSyntaxNode</span> </div> @@ -59,7 +59,7 @@ <div class="clear"></div> </div> - <div id="content"><h1>Class: Idl::AryAccess + <div id="content"><h1>Class: Idl::AryAccessSyntaxNode @@ -76,7 +76,7 @@ <li class="next"><span class='object_link'><a href="../Treetop/Runtime/SyntaxNode.html" title="Treetop::Runtime::SyntaxNode (class)">Treetop::Runtime::SyntaxNode</a></span></li> - <li class="next">Idl::AryAccess</li> + <li class="next">Idl::AryAccessSyntaxNode</li> </ul> <a href="#" class="inheritanceTree">show all</a> @@ -135,7 +135,7 @@ <h2> <li class="public "> <span class="summary_signature"> - <a href="#make_left-instance_method" title="#make_left (instance method)">#<strong>make_left</strong> ⇒ AstNode </a> + <a href="#to_ast-instance_method" title="#to_ast (instance method)">#<strong>to_ast</strong> ⇒ AstNode </a> @@ -192,9 +192,9 @@ <h2>Instance Method Details</h2> <div class="method_details first"> - <h3 class="signature first" id="make_left-instance_method"> + <h3 class="signature first" id="to_ast-instance_method"> - #<strong>make_left</strong> ⇒ <tt><span class='object_link'><a href="AstNode.html" title="Idl::AstNode (class)">AstNode</a></span></tt> + #<strong>to_ast</strong> ⇒ <tt><span class='object_link'><a href="AstNode.html" title="Idl::AstNode (class)">AstNode</a></span></tt> @@ -235,35 +235,35 @@ <h3 class="signature first" id="make_left-instance_method"> <pre class="lines"> -751 -752 -753 -754 -755 -756 -757 -758 -759 -760 -761 -762 -763 -764 -765 -766</pre> +792 +793 +794 +795 +796 +797 +798 +799 +800 +801 +802 +803 +804 +805 +806 +807</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 751</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 792</span> -<span class='kw'>def</span> <span class='id identifier rubyid_make_left'>make_left</span> - <span class='id identifier rubyid_var'>var</span> <span class='op'>=</span> <span class='id identifier rubyid_a'>a</span><span class='period'>.</span><span class='id identifier rubyid_make_left'>make_left</span> +<span class='kw'>def</span> <span class='id identifier rubyid_to_ast'>to_ast</span> + <span class='id identifier rubyid_var'>var</span> <span class='op'>=</span> <span class='id identifier rubyid_a'>a</span><span class='period'>.</span><span class='id identifier rubyid_to_ast'>to_ast</span> <span class='id identifier rubyid_interval_start'>interval_start</span> <span class='op'>=</span> <span class='id identifier rubyid_interval'>interval</span><span class='period'>.</span><span class='id identifier rubyid_begin'>begin</span> <span class='id identifier rubyid_brackets'>brackets</span><span class='period'>.</span><span class='id identifier rubyid_elements'>elements</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_bracket'>bracket</span><span class='op'>|</span> <span class='id identifier rubyid_var'>var</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_bracket'>bracket</span><span class='period'>.</span><span class='id identifier rubyid_msb'>msb</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> - <span class='const'><span class='object_link'><a href="AryElementAccessAst.html" title="Idl::AryElementAccessAst (class)">AryElementAccessAst</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="AryElementAccessAst.html#initialize-instance_method" title="Idl::AryElementAccessAst#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_interval_start'>interval_start</span><span class='op'>...</span><span class='id identifier rubyid_bracket'>bracket</span><span class='period'>.</span><span class='id identifier rubyid_interval'>interval</span><span class='period'>.</span><span class='id identifier rubyid_end'>end</span><span class='comma'>,</span> <span class='id identifier rubyid_var'>var</span><span class='comma'>,</span> <span class='id identifier rubyid_bracket'>bracket</span><span class='period'>.</span><span class='id identifier rubyid_lsb'>lsb</span><span class='period'>.</span><span class='id identifier rubyid_make_left'>make_left</span><span class='rparen'>)</span> + <span class='const'><span class='object_link'><a href="AryElementAccessAst.html" title="Idl::AryElementAccessAst (class)">AryElementAccessAst</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="AryElementAccessAst.html#initialize-instance_method" title="Idl::AryElementAccessAst#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_interval_start'>interval_start</span><span class='op'>...</span><span class='id identifier rubyid_bracket'>bracket</span><span class='period'>.</span><span class='id identifier rubyid_interval'>interval</span><span class='period'>.</span><span class='id identifier rubyid_end'>end</span><span class='comma'>,</span> <span class='id identifier rubyid_var'>var</span><span class='comma'>,</span> <span class='id identifier rubyid_bracket'>bracket</span><span class='period'>.</span><span class='id identifier rubyid_lsb'>lsb</span><span class='period'>.</span><span class='id identifier rubyid_to_ast'>to_ast</span><span class='rparen'>)</span> <span class='kw'>else</span> <span class='const'><span class='object_link'><a href="AryRangeAccessAst.html" title="Idl::AryRangeAccessAst (class)">AryRangeAccessAst</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="AryRangeAccessAst.html#initialize-instance_method" title="Idl::AryRangeAccessAst#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_interval_start'>interval_start</span><span class='op'>...</span><span class='id identifier rubyid_bracket'>bracket</span><span class='period'>.</span><span class='id identifier rubyid_interval'>interval</span><span class='period'>.</span><span class='id identifier rubyid_end'>end</span><span class='comma'>,</span> <span class='id identifier rubyid_var'>var</span><span class='comma'>,</span> - <span class='id identifier rubyid_bracket'>bracket</span><span class='period'>.</span><span class='id identifier rubyid_msb'>msb</span><span class='period'>.</span><span class='id identifier rubyid_expression'>expression</span><span class='period'>.</span><span class='id identifier rubyid_make_left'>make_left</span><span class='comma'>,</span> <span class='id identifier rubyid_bracket'>bracket</span><span class='period'>.</span><span class='id identifier rubyid_lsb'>lsb</span><span class='period'>.</span><span class='id identifier rubyid_make_left'>make_left</span><span class='rparen'>)</span> + <span class='id identifier rubyid_bracket'>bracket</span><span class='period'>.</span><span class='id identifier rubyid_msb'>msb</span><span class='period'>.</span><span class='id identifier rubyid_expression'>expression</span><span class='period'>.</span><span class='id identifier rubyid_to_ast'>to_ast</span><span class='comma'>,</span> <span class='id identifier rubyid_bracket'>bracket</span><span class='period'>.</span><span class='id identifier rubyid_lsb'>lsb</span><span class='period'>.</span><span class='id identifier rubyid_to_ast'>to_ast</span><span class='rparen'>)</span> <span class='kw'>end</span> <span class='id identifier rubyid_interval_start'>interval_start</span> <span class='op'>=</span> <span class='id identifier rubyid_bracket'>bracket</span><span class='period'>.</span><span class='id identifier rubyid_interval'>interval</span><span class='period'>.</span><span class='id identifier rubyid_end'>end</span> <span class='kw'>end</span> @@ -320,16 +320,16 @@ <h3 class="signature " id="to_idl-instance_method"> <pre class="lines"> -769 -770 -771 -772 -773 -774 -775</pre> +810 +811 +812 +813 +814 +815 +816</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 769</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 810</span> <span class='kw'>def</span> <span class='id identifier rubyid_to_idl'>to_idl</span> <span class='kw'>if</span> <span class='id identifier rubyid_bracket'>bracket</span><span class='period'>.</span><span class='id identifier rubyid_msb'>msb</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> @@ -348,7 +348,7 @@ <h3 class="signature " id="to_idl-instance_method"> </div> <div id="footer"> - Generated on Fri Jul 12 07:33:10 2024 by + Generated on Thu Jul 18 13:55:45 2024 by <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.36 (ruby-3.2.3). </div> diff --git a/docs/ruby/Idl/AryElementAccessAst.html b/docs/ruby/Idl/AryElementAccessAst.html index fd5172051..d0d13617a 100644 --- a/docs/ruby/Idl/AryElementAccessAst.html +++ b/docs/ruby/Idl/AryElementAccessAst.html @@ -103,7 +103,9 @@ <dl> <dt>Defined in:</dt> - <dd>lib/idl/ast.rb</dd> + <dd>lib/idl/ast.rb<span class="defines">,<br /> + lib/idl/passes/prune.rb,<br /> lib/idl/passes/gen_adoc.rb</span> +</dd> </dl> </div> @@ -189,6 +191,28 @@ <h2> <li class="public "> <span class="summary_signature"> + <a href="#gen_adoc-instance_method" title="#gen_adoc (instance method)">#<strong>gen_adoc</strong>(indent = 0, indent_spaces: 2) ⇒ Object </a> + + + + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'></div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(input, interval, var, index) ⇒ AryElementAccessAst </a> @@ -209,6 +233,52 @@ <h2> <p>A new instance of AryElementAccessAst.</p> </div></span> +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#prune-instance_method" title="#prune (instance method)">#<strong>prune</strong>(symtab) ⇒ Object </a> + + + + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'></div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#to_idl-instance_method" title="#to_idl (instance method)">#<strong>to_idl</strong> ⇒ String </a> + + + + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Return valid IDL representation of the node (and its subtree).</p> +</div></span> + </li> @@ -277,6 +347,35 @@ <h2> <span class="summary_desc"><div class='inline'></div></span> +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#values-instance_method" title="#values (instance method)">#<strong>values</strong>(symtab) ⇒ Array<Integer>, ... </a> + + + + </span> + + <span class="note title not_defined_here"> + included + from <span class='object_link'><a href="Rvalue.html#values-instance_method" title="Idl::Rvalue#values (method)">Rvalue</a></span> + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.</p> +</div></span> + </li> @@ -320,14 +419,14 @@ <h3 class="signature first" id="initialize-instance_method"> <pre class="lines"> -783 -784 -785 -786 -787</pre> +824 +825 +826 +827 +828</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 783</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 824</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_interval'>interval</span><span class='comma'>,</span> <span class='id identifier rubyid_var'>var</span><span class='comma'>,</span> <span class='id identifier rubyid_index'>index</span><span class='rparen'>)</span> <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_interval'>interval</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='id identifier rubyid_var'>var</span><span class='comma'>,</span> <span class='id identifier rubyid_index'>index</span><span class='rbracket'>]</span><span class='rparen'>)</span> @@ -372,12 +471,12 @@ <h3 class="signature first" id="index-instance_method"> <pre class="lines"> -781 -782 -783</pre> +822 +823 +824</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 781</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 822</span> <span class='kw'>def</span> <span class='id identifier rubyid_index'>index</span> <span class='ivar'>@index</span> @@ -415,12 +514,12 @@ <h3 class="signature " id="var-instance_method"> <pre class="lines"> -781 -782 -783</pre> +822 +823 +824</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 781</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 822</span> <span class='kw'>def</span> <span class='id identifier rubyid_var'>var</span> <span class='ivar'>@var</span> @@ -438,7 +537,122 @@ <h2>Instance Method Details</h2> <div class="method_details first"> - <h3 class="signature first" id="type-instance_method"> + <h3 class="signature first" id="gen_adoc-instance_method"> + + #<strong>gen_adoc</strong>(indent = 0, indent_spaces: 2) ⇒ <tt>Object</tt> + + + + + +</h3><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +122 +123 +124</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/passes/gen_adoc.rb', line 122</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_gen_adoc'>gen_adoc</span><span class='lparen'>(</span><span class='id identifier rubyid_indent'>indent</span> <span class='op'>=</span> <span class='int'>0</span><span class='comma'>,</span> <span class='label'>indent_spaces:</span> <span class='int'>2</span><span class='rparen'>)</span> + <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_gen_adoc'>gen_adoc</span><span class='lparen'>(</span><span class='id identifier rubyid_indent'>indent</span><span class='comma'>,</span> <span class='label'>indent_spaces:</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_index'>index</span><span class='period'>.</span><span class='id identifier rubyid_gen_adoc'>gen_adoc</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='label'>indent_spaces:</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>]</span><span class='tstring_end'>"</span></span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <h3 class="signature " id="prune-instance_method"> + + #<strong>prune</strong>(symtab) ⇒ <tt>Object</tt> + + + + + +</h3><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +106 +107 +108</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/passes/prune.rb', line 106</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_prune'>prune</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> + <span class='const'><span class='object_link'><a href="" title="Idl::AryElementAccessAst (class)">AryElementAccessAst</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="Idl::AryElementAccessAst#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_interval'>interval</span><span class='comma'>,</span> <span class='ivar'>@var</span><span class='period'>.</span><span class='id identifier rubyid_prune'>prune</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='ivar'>@index</span><span class='period'>.</span><span class='id identifier rubyid_prune'>prune</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='rparen'>)</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <h3 class="signature " id="to_idl-instance_method"> + + #<strong>to_idl</strong> ⇒ <tt>String</tt> + + + + + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Return valid IDL representation of the node (and its subtree)</p> + + + </div> +</div> +<div class="tags"> + +<p class="tag_title">Returns:</p> +<ul class="return"> + + <li> + + + <span class='type'>(<tt>String</tt>)</span> + + + + — + <div class='inline'> +<p>IDL code for the node</p> +</div> + + </li> + +</ul> + +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +891</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 891</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_to_idl'>to_idl</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='ivar'>@var</span><span class='period'>.</span><span class='id identifier rubyid_to_idl'>to_idl</span><span class='embexpr_end'>}</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='ivar'>@index</span><span class='period'>.</span><span class='id identifier rubyid_to_idl'>to_idl</span><span class='embexpr_end'>}</span><span class='tstring_content'>]</span><span class='tstring_end'>"</span></span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <h3 class="signature " id="type-instance_method"> #<strong>type</strong>(symtab) ⇒ <tt>Object</tt> @@ -452,18 +666,18 @@ <h3 class="signature first" id="type-instance_method"> <pre class="lines"> -821 -822 -823 -824 -825 -826 -827 -828 -829</pre> +862 +863 +864 +865 +866 +867 +868 +869 +870</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 821</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 862</span> <span class='kw'>def</span> <span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='ivar'>@var</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_kind'>kind</span> <span class='op'>==</span> <span class='symbol'>:array</span> @@ -559,39 +773,39 @@ <h3 class="signature " id="type_check-instance_method"> <pre class="lines"> -790 -791 -792 -793 -794 -795 -796 -797 -798 -799 -800 -801 -802 -803 -804 -805 -806 -807 -808 -809 -810 -811 -812 -813 -814 -815 -816 -817 -818 -819</pre> +831 +832 +833 +834 +835 +836 +837 +838 +839 +840 +841 +842 +843 +844 +845 +846 +847 +848 +849 +850 +851 +852 +853 +854 +855 +856 +857 +858 +859 +860</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 790</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 831</span> <span class='kw'>def</span> <span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='ivar'>@var</span><span class='period'>.</span><span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> @@ -643,26 +857,26 @@ <h3 class="signature " id="value-instance_method"> <pre class="lines"> -831 -832 -833 -834 -835 -836 -837 -838 -839 -840 -841 -842 -843 -844 -845 -846 -847</pre> +872 +873 +874 +875 +876 +877 +878 +879 +880 +881 +882 +883 +884 +885 +886 +887 +888</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 831</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 872</span> <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='ivar'>@var</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_integral?'>integral?</span> @@ -684,6 +898,102 @@ <h3 class="signature " id="value-instance_method"> </td> </tr> </table> +</div> + + <div class="method_details "> + <h3 class="signature " id="values-instance_method"> + + #<strong>values</strong>(symtab) ⇒ <tt>Array<Integer></tt>, ... + + + + + + <span class="not_defined_here"> + Originally defined in module + <span class='object_link'><a href="Rvalue.html#values-instance_method" title="Idl::Rvalue#values (method)">Rvalue</a></span> + </span> + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined</p> + +<p>For most AstNodes, this will just be a single-entry array</p> + + + </div> +</div> +<div class="tags"> + <p class="tag_title">Parameters:</p> +<ul class="param"> + + <li> + + <span class='name'>symtab</span> + + + <span class='type'>(<tt><span class='object_link'><a href="SymbolTable.html" title="Idl::SymbolTable (class)">SymbolTable</a></span></tt>)</span> + + + + — + <div class='inline'> +<p>The context for the evaulation</p> +</div> + + </li> + +</ul> + +<p class="tag_title">Returns:</p> +<ul class="return"> + + <li> + + + <span class='type'>(<tt>Array<Integer></tt>)</span> + + + + — + <div class='inline'> +<p>The complete list of compile-time-known values, when they are integral</p> +</div> + + </li> + + <li> + + + <span class='type'>(<tt>Array<Boolean></tt>)</span> + + + + — + <div class='inline'> +<p>The complete list of compile-time-known values, when they are booleans</p> +</div> + + </li> + + <li> + + + <span class='type'>(<tt><span class='object_link'><a href="AstNode/ValueError.html" title="Idl::AstNode::ValueError (class)">AstNode::ValueError</a></span></tt>)</span> + + + + — + <div class='inline'> +<p>if the list of values is not knowable at compile time</p> +</div> + + </li> + +</ul> + +</div> </div> </div> @@ -691,7 +1001,7 @@ <h3 class="signature " id="value-instance_method"> </div> <div id="footer"> - Generated on Fri Jul 12 07:33:10 2024 by + Generated on Thu Jul 18 13:55:45 2024 by <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.36 (ruby-3.2.3). </div> diff --git a/docs/ruby/Idl/AryElementAssignmentAst.html b/docs/ruby/Idl/AryElementAssignmentAst.html index d450c16c1..25f3f39c8 100644 --- a/docs/ruby/Idl/AryElementAssignmentAst.html +++ b/docs/ruby/Idl/AryElementAssignmentAst.html @@ -69,7 +69,7 @@ <dl> <dt>Inherits:</dt> <dd> - <span class="inheritName"><span class='object_link'><a href="AssignmentAst.html" title="Idl::AssignmentAst (class)">AssignmentAst</a></span></span> + <span class="inheritName"><span class='object_link'><a href="AstNode.html" title="Idl::AstNode (class)">AstNode</a></span></span> <ul class="fullTree"> <li>Object</li> @@ -78,8 +78,6 @@ <li class="next"><span class='object_link'><a href="AstNode.html" title="Idl::AstNode (class)">AstNode</a></span></li> - <li class="next"><span class='object_link'><a href="AssignmentAst.html" title="Idl::AssignmentAst (class)">AssignmentAst</a></span></li> - <li class="next">Idl::AryElementAssignmentAst</li> </ul> @@ -100,7 +98,9 @@ <dl> <dt>Defined in:</dt> - <dd>lib/idl/ast.rb</dd> + <dd>lib/idl/ast.rb<span class="defines">,<br /> + lib/idl/passes/gen_adoc.rb</span> +</dd> </dl> </div> @@ -125,6 +125,98 @@ <h2>Overview</h2><div class="docstring"> + <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2> + <ul class="summary"> + + <li class="public "> + <span class="summary_signature"> + + <a href="#idx-instance_method" title="#idx (instance method)">#<strong>idx</strong> ⇒ Object </a> + + + + </span> + + + + + <span class="note title readonly">readonly</span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Returns the value of attribute idx.</p> +</div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#lhs-instance_method" title="#lhs (instance method)">#<strong>lhs</strong> ⇒ Object </a> + + + + </span> + + + + + <span class="note title readonly">readonly</span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Returns the value of attribute lhs.</p> +</div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#rhs-instance_method" title="#rhs (instance method)">#<strong>rhs</strong> ⇒ Object </a> + + + + </span> + + + + + <span class="note title readonly">readonly</span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Returns the value of attribute rhs.</p> +</div></span> + +</li> + + + </ul> + @@ -161,7 +253,7 @@ <h2> <li class="public "> <span class="summary_signature"> - <a href="#lhs-instance_method" title="#lhs (instance method)">#<strong>lhs</strong> ⇒ Object </a> + <a href="#gen_adoc-instance_method" title="#gen_adoc (instance method)">#<strong>gen_adoc</strong>(indent = 0, indent_spaces: 2) ⇒ Object </a> @@ -183,13 +275,15 @@ <h2> <li class="public "> <span class="summary_signature"> - <a href="#rhs-instance_method" title="#rhs (instance method)">#<strong>rhs</strong> ⇒ Object </a> + <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(input, interval, lhs, idx, rhs) ⇒ AryElementAssignmentAst </a> </span> + <span class="note title constructor">constructor</span> + @@ -197,7 +291,9 @@ <h2> - <span class="summary_desc"><div class='inline'></div></span> + <span class="summary_desc"><div class='inline'> +<p>A new instance of AryElementAssignmentAst.</p> +</div></span> </li> @@ -259,120 +355,269 @@ <h2> + <div id="constructor_details" class="method_details_list"> + <h2>Constructor Details</h2> + <div class="method_details first"> + <h3 class="signature first" id="initialize-instance_method"> + #<strong>initialize</strong>(input, interval, lhs, idx, rhs) ⇒ <tt><span class='object_link'><a href="" title="Idl::AryElementAssignmentAst (class)">AryElementAssignmentAst</a></span></tt> + + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Returns a new instance of AryElementAssignmentAst.</p> - <div id="instance_method_details" class="method_details_list"> - <h2>Instance Method Details</h2> + </div> +</div> +<div class="tags"> + + +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +1030 +1031 +1032 +1033 +1034 +1035</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1030</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_interval'>interval</span><span class='comma'>,</span> <span class='id identifier rubyid_lhs'>lhs</span><span class='comma'>,</span> <span class='id identifier rubyid_idx'>idx</span><span class='comma'>,</span> <span class='id identifier rubyid_rhs'>rhs</span><span class='rparen'>)</span> + <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_interval'>interval</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='id identifier rubyid_lhs'>lhs</span><span class='comma'>,</span> <span class='id identifier rubyid_idx'>idx</span><span class='comma'>,</span> <span class='id identifier rubyid_rhs'>rhs</span><span class='rbracket'>]</span><span class='rparen'>)</span> + <span class='ivar'>@lhs</span> <span class='op'>=</span> <span class='id identifier rubyid_lhs'>lhs</span> + <span class='ivar'>@idx</span> <span class='op'>=</span> <span class='id identifier rubyid_idx'>idx</span> + <span class='ivar'>@rhs</span> <span class='op'>=</span> <span class='id identifier rubyid_rhs'>rhs</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + +</div> + + <div id="instance_attr_details" class="attr_details"> + <h2>Instance Attribute Details</h2> + + <span id=""></span> <div class="method_details first"> - <h3 class="signature first" id="execute-instance_method"> + <h3 class="signature first" id="idx-instance_method"> - #<strong>execute</strong>(symtab) ⇒ <tt>Object</tt> + #<strong>idx</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span> -</h3><table class="source_code"> +</h3><div class="docstring"> + <div class="discussion"> + +<p>Returns the value of attribute idx.</p> + + + </div> +</div> +<div class="tags"> + + +</div><table class="source_code"> <tr> <td> <pre class="lines"> -1002 -1003 -1004 -1005 -1006 -1007 -1008 -1009 -1010 -1011 -1012 -1013 -1014</pre> +1028 +1029 +1030</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1002</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1028</span> -<span class='kw'>def</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> - <span class='kw'>case</span> <span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_kind'>kind</span> - <span class='kw'>when</span> <span class='symbol'>:array</span> - <span class='id identifier rubyid_value_error'>value_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>TODO: array element assignement execution</span><span class='tstring_end'>"</span></span> - <span class='kw'>when</span> <span class='symbol'>:bits</span> - <span class='id identifier rubyid_v'>v</span> <span class='op'>=</span> <span class='id identifier rubyid_rhs'>rhs</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> - <span class='id identifier rubyid_var'>var</span> <span class='op'>=</span> <span class='id identifier rubyid_symtab'>symtab</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_text_value'>text_value</span><span class='rparen'>)</span> - <span class='id identifier rubyid_mask'>mask</span> <span class='op'>=</span> <span class='int'>1</span> <span class='op'><<</span> <span class='id identifier rubyid_idx'>idx</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> - <span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span> <span class='op'>&</span> <span class='op'>~</span><span class='int'>0</span><span class='rparen'>)</span> <span class='op'>|</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span> <span class='op'>&</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='op'><<</span> <span class='id identifier rubyid_idx'>idx</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='rparen'>)</span> - <span class='kw'>else</span> - <span class='id identifier rubyid_internal_error'>internal_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>unexpected type for array element assignment</span><span class='tstring_end'>"</span></span> - <span class='kw'>end</span> +<span class='kw'>def</span> <span class='id identifier rubyid_idx'>idx</span> + <span class='ivar'>@idx</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> + + <span id=""></span> <div class="method_details "> <h3 class="signature " id="lhs-instance_method"> - #<strong>lhs</strong> ⇒ <tt>Object</tt> + #<strong>lhs</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span> -</h3><table class="source_code"> +</h3><div class="docstring"> + <div class="discussion"> + +<p>Returns the value of attribute lhs.</p> + + + </div> +</div> +<div class="tags"> + + +</div><table class="source_code"> <tr> <td> <pre class="lines"> -994 -995 -996</pre> +1028 +1029 +1030</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 994</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1028</span> <span class='kw'>def</span> <span class='id identifier rubyid_lhs'>lhs</span> - <span class='id identifier rubyid_internal_error'>internal_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>What's this used for?</span><span class='tstring_end'>"</span></span> + <span class='ivar'>@lhs</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> + + <span id=""></span> <div class="method_details "> <h3 class="signature " id="rhs-instance_method"> - #<strong>rhs</strong> ⇒ <tt>Object</tt> + #<strong>rhs</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span> -</h3><table class="source_code"> +</h3><div class="docstring"> + <div class="discussion"> + +<p>Returns the value of attribute rhs.</p> + + + </div> +</div> +<div class="tags"> + + +</div><table class="source_code"> <tr> <td> <pre class="lines"> -998 -999 -1000</pre> +1028 +1029 +1030</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 998</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1028</span> <span class='kw'>def</span> <span class='id identifier rubyid_rhs'>rhs</span> - <span class='id identifier rubyid_rval'>rval</span> + <span class='ivar'>@rhs</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + </div> + + + <div id="instance_method_details" class="method_details_list"> + <h2>Instance Method Details</h2> + + + <div class="method_details first"> + <h3 class="signature first" id="execute-instance_method"> + + #<strong>execute</strong>(symtab) ⇒ <tt>Object</tt> + + + + + +</h3><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +1072 +1073 +1074 +1075 +1076 +1077 +1078 +1079 +1080 +1081 +1082 +1083</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1072</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> + <span class='kw'>case</span> <span class='ivar'>@lhs</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_kind'>kind</span> + <span class='kw'>when</span> <span class='symbol'>:array</span> + <span class='ivar'>@lhs</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='ivar'>@idx</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='ivar'>@rhs</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> + <span class='kw'>when</span> <span class='symbol'>:bits</span> + <span class='id identifier rubyid_v'>v</span> <span class='op'>=</span> <span class='ivar'>@rhs</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> + <span class='id identifier rubyid_var'>var</span> <span class='op'>=</span> <span class='id identifier rubyid_symtab'>symtab</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='ivar'>@lhs</span><span class='period'>.</span><span class='id identifier rubyid_text_value'>text_value</span><span class='rparen'>)</span> + <span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='ivar'>@lhs</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span> <span class='op'>&</span> <span class='op'>~</span><span class='int'>0</span><span class='rparen'>)</span> <span class='op'>|</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span> <span class='op'>&</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='op'><<</span> <span class='ivar'>@idx</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='rparen'>)</span> + <span class='kw'>else</span> + <span class='id identifier rubyid_internal_error'>internal_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>unexpected type for array element assignment</span><span class='tstring_end'>"</span></span> + <span class='kw'>end</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <h3 class="signature " id="gen_adoc-instance_method"> + + #<strong>gen_adoc</strong>(indent = 0, indent_spaces: 2) ⇒ <tt>Object</tt> + + + + + +</h3><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +140 +141 +142</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/passes/gen_adoc.rb', line 140</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_gen_adoc'>gen_adoc</span><span class='lparen'>(</span><span class='id identifier rubyid_indent'>indent</span> <span class='op'>=</span> <span class='int'>0</span><span class='comma'>,</span> <span class='label'>indent_spaces:</span> <span class='int'>2</span><span class='rparen'>)</span> + <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_lhs'>lhs</span><span class='period'>.</span><span class='id identifier rubyid_gen_adoc'>gen_adoc</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='label'>indent_spaces:</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='ivar'>@idx</span><span class='period'>.</span><span class='id identifier rubyid_gen_adoc'>gen_adoc</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='label'>indent_spaces:</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>] = </span><span class='embexpr_beg'>#{</span><span class='ivar'>@rhs</span><span class='period'>.</span><span class='id identifier rubyid_gen_adoc'>gen_adoc</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='label'>indent_spaces:</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>end</span></pre> </td> </tr> @@ -423,12 +668,12 @@ <h3 class="signature " id="to_idl-instance_method"> <pre class="lines"> -1017</pre> +1086</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1017</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1086</span> -<span class='kw'>def</span> <span class='id identifier rubyid_to_idl'>to_idl</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_to_idl'>to_idl</span><span class='embexpr_end'>}</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_idx'>idx</span><span class='period'>.</span><span class='id identifier rubyid_to_idl'>to_idl</span><span class='embexpr_end'>}</span><span class='tstring_content'>] = </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_rval'>rval</span><span class='period'>.</span><span class='id identifier rubyid_to_idl'>to_idl</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span></pre> +<span class='kw'>def</span> <span class='id identifier rubyid_to_idl'>to_idl</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='ivar'>@lhs</span><span class='period'>.</span><span class='id identifier rubyid_to_idl'>to_idl</span><span class='embexpr_end'>}</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='ivar'>@idx</span><span class='period'>.</span><span class='id identifier rubyid_to_idl'>to_idl</span><span class='embexpr_end'>}</span><span class='tstring_content'>] = </span><span class='embexpr_beg'>#{</span><span class='ivar'>@rhs</span><span class='period'>.</span><span class='id identifier rubyid_to_idl'>to_idl</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span></pre> </td> </tr> </table> @@ -514,66 +759,70 @@ <h3 class="signature " id="type_check-instance_method"> <pre class="lines"> -962 -963 -964 -965 -966 -967 -968 -969 -970 -971 -972 -973 -974 -975 -976 -977 -978 -979 -980 -981 -982 -983 -984 -985 -986 -987 -988 -989 -990 -991 -992</pre> +1038 +1039 +1040 +1041 +1042 +1043 +1044 +1045 +1046 +1047 +1048 +1049 +1050 +1051 +1052 +1053 +1054 +1055 +1056 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 962</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1038</span> <span class='kw'>def</span> <span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> - <span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> - <span class='id identifier rubyid_type_error'>type_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_text_value'>text_value</span><span class='embexpr_end'>}</span><span class='tstring_content'> must be an array or an integral type</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='lbracket'>[</span><span class='symbol'>:array</span><span class='comma'>,</span> <span class='symbol'>:bits</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_kind'>kind</span><span class='rparen'>)</span> - <span class='id identifier rubyid_type_errpr'>type_errpr</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Assigning to a constant</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_const?'>const?</span> + <span class='ivar'>@lhs</span><span class='period'>.</span><span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> + <span class='kw'>unless</span> <span class='lbracket'>[</span><span class='symbol'>:array</span><span class='comma'>,</span> <span class='symbol'>:bits</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@lhs</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_kind'>kind</span><span class='rparen'>)</span> + <span class='id identifier rubyid_type_error'>type_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='ivar'>@lhs</span><span class='period'>.</span><span class='id identifier rubyid_text_value'>text_value</span><span class='embexpr_end'>}</span><span class='tstring_content'> must be an array or an integral type</span><span class='tstring_end'>"</span></span> + <span class='kw'>end</span> + <span class='id identifier rubyid_type_errpr'>type_errpr</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Assigning to a constant</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='ivar'>@lhs</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_const?'>const?</span> - <span class='id identifier rubyid_idx'>idx</span><span class='period'>.</span><span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> + <span class='ivar'>@idx</span><span class='period'>.</span><span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> - <span class='id identifier rubyid_type_error'>type_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Index must be integral</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_idx'>idx</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_integral?'>integral?</span> + <span class='id identifier rubyid_type_error'>type_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Index must be integral</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='ivar'>@idx</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_integral?'>integral?</span> <span class='kw'>begin</span> - <span class='id identifier rubyid_idx_value'>idx_value</span> <span class='op'>=</span> <span class='id identifier rubyid_idx'>idx</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> - <span class='id identifier rubyid_type_error'>type_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array index out of range</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_idx_value'>idx_value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='op'>>=</span> <span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_width'>width</span> + <span class='id identifier rubyid_idx_value'>idx_value</span> <span class='op'>=</span> <span class='ivar'>@idx</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> + <span class='id identifier rubyid_type_error'>type_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array index (</span><span class='embexpr_beg'>#{</span><span class='ivar'>@idx</span><span class='period'>.</span><span class='id identifier rubyid_text_value'>text_value</span><span class='embexpr_end'>}</span><span class='tstring_content'> = </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_idx_value'>idx_value</span><span class='embexpr_end'>}</span><span class='tstring_content'>) out of range (< </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_width'>width</span><span class='embexpr_end'>}</span><span class='tstring_content'>)</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_idx_value'>idx_value</span> <span class='op'>>=</span> <span class='ivar'>@lhs</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_width'>width</span> <span class='kw'>rescue</span> <span class='const'><span class='object_link'><a href="AstNode/ValueError.html" title="Idl::AstNode::ValueError (class)">ValueError</a></span></span> <span class='comment'># OK, doesn't need to be known </span> <span class='kw'>end</span> - <span class='id identifier rubyid_rval'>rval</span><span class='period'>.</span><span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> + <span class='ivar'>@rhs</span><span class='period'>.</span><span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> - <span class='kw'>case</span> <span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_kind'>kind</span> + <span class='kw'>case</span> <span class='ivar'>@lhs</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_kind'>kind</span> <span class='kw'>when</span> <span class='symbol'>:array</span> - <span class='kw'>unless</span> <span class='id identifier rubyid_rval'>rval</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_convertable_to?'>convertable_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_sub_type'>sub_type</span><span class='rparen'>)</span> + <span class='kw'>unless</span> <span class='ivar'>@rhs</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_convertable_to?'>convertable_to?</span><span class='lparen'>(</span><span class='ivar'>@lhs</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_sub_type'>sub_type</span><span class='rparen'>)</span> <span class='id identifier rubyid_type_error'>type_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Incompatible type in array assignment</span><span class='tstring_end'>"</span></span> <span class='kw'>end</span> <span class='kw'>when</span> <span class='symbol'>:bits</span> - <span class='kw'>unless</span> <span class='id identifier rubyid_rval'>rval</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_convertable_to?'>convertable_to?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="Type.html" title="Idl::Type (class)">Type</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Type.html#initialize-instance_method" title="Idl::Type#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='symbol'>:bits</span><span class='comma'>,</span> <span class='label'>width:</span> <span class='int'>1</span><span class='rparen'>)</span><span class='rparen'>)</span> + <span class='kw'>unless</span> <span class='ivar'>@rhs</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_convertable_to?'>convertable_to?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="Type.html" title="Idl::Type (class)">Type</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Type.html#initialize-instance_method" title="Idl::Type#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='symbol'>:bits</span><span class='comma'>,</span> <span class='label'>width:</span> <span class='int'>1</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='id identifier rubyid_type_error'>type_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Incompatible type in integer slice assignement</span><span class='tstring_end'>"</span></span> <span class='kw'>end</span> <span class='kw'>else</span> @@ -590,7 +839,7 @@ <h3 class="signature " id="type_check-instance_method"> </div> <div id="footer"> - Generated on Fri Jul 12 07:33:10 2024 by + Generated on Thu Jul 18 13:55:45 2024 by <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.36 (ruby-3.2.3). </div> diff --git a/docs/ruby/Idl/AryElementAssignmentSyntaxNode.html b/docs/ruby/Idl/AryElementAssignmentSyntaxNode.html new file mode 100644 index 000000000..90e3b0fbe --- /dev/null +++ b/docs/ruby/Idl/AryElementAssignmentSyntaxNode.html @@ -0,0 +1,194 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> +<title> + Class: Idl::AryElementAssignmentSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::AryElementAssignmentSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +1018
    +1019
    +1020
    +
    +
    # File 'lib/idl/ast.rb', line 1018
    +
    +def to_ast
    +  AryElementAssignmentAst.new(input, interval, var.to_ast, idx.to_ast, rval.to_ast)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/AryRangeAccessAst.html b/docs/ruby/Idl/AryRangeAccessAst.html index dc489927f..f3fe3beda 100644 --- a/docs/ruby/Idl/AryRangeAccessAst.html +++ b/docs/ruby/Idl/AryRangeAccessAst.html @@ -104,7 +104,7 @@
    Defined in:
    lib/idl/ast.rb,
    - lib/idl/passes/gen_adoc.rb
    + lib/idl/passes/prune.rb,
    lib/idl/passes/gen_adoc.rb
    @@ -268,7 +268,7 @@

  • - #type(symtab) ⇒ Object + #prune(symtab) ⇒ Object @@ -290,7 +290,7 @@

  • - #type_check(symtab) ⇒ Object + #to_idl ⇒ String @@ -304,7 +304,57 @@

    -
    +
    +

    Return valid IDL representation of the node (and its subtree).

    +
    + +

  • + + +
  • + + + #type(symtab) ⇒ Type + + + + + + + + + + + + + +
    +

    Given a specific symbol table, return the type of this node.

    +
    + +
  • + + +
  • + + + #type_check(symtab) ⇒ void + + + + + + + + + + + + + +
    +

    type check this node and all children.

    +
  • @@ -326,7 +376,38 @@

    -
    +
    +

    Return the compile-time-known value of the node.

    +
    + +

  • + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
  • @@ -371,15 +452,15 @@

     
     
    -855
    -856
    -857
    -858
    -859
    -860
    +899 +900 +901 +902 +903 +904

    -
    # File 'lib/idl/ast.rb', line 855
    +      
    # File 'lib/idl/ast.rb', line 899
     
     def initialize(input, interval, var, msb, lsb)
       super(input, interval, [var, msb, lsb])
    @@ -425,12 +506,12 @@ 

     
     
    -853
    -854
    -855
    +897 +898 +899

    -
    # File 'lib/idl/ast.rb', line 853
    +      
    # File 'lib/idl/ast.rb', line 897
     
     def lsb
       @lsb
    @@ -468,12 +549,12 @@ 

     
     
    -853
    -854
    -855
    +897 +898 +899

    -
    # File 'lib/idl/ast.rb', line 853
    +      
    # File 'lib/idl/ast.rb', line 897
     
     def msb
       @msb
    @@ -511,12 +592,12 @@ 

     
     
    -853
    -854
    -855
    +897 +898 +899

    -
    # File 'lib/idl/ast.rb', line 853
    +      
    # File 'lib/idl/ast.rb', line 897
     
     def var
       @var
    @@ -548,35 +629,15 @@ 

     
     
    -31
    -32
    -33
    -34
    -35
    -36
    -37
    -38
    -39
    -40
    -41
    -42
    -43
    +67 +68 +69

    -
    # File 'lib/idl/passes/gen_adoc.rb', line 31
    +      
    # File 'lib/idl/passes/gen_adoc.rb', line 67
     
     def gen_adoc(indent = 0, indent_spaces: 2)
    -  adoc = ''
    -  unless var.is_a?(AryRangeAccessAst) || var.is_a?(AryElementAccessAst)
    -    adoc << input[interval.begin...var.interval.begin]
    -    adoc << var.gen_adoc(indent + indent_spaces, indent_spaces: indent_spaces)
    -  end
    -  adoc << input[var.interval.end...msb.interval.begin]
    -  adoc << msb.gen_adoc(indent + indent_spaces, indent_spaces: indent_spaces)
    -  adoc << input[msb.interval.end...lsb.interval.begin]
    -  adoc << lsb.gen_adoc(indent + indent_spaces, indent_spaces: indent_spaces)
    -  adoc << input[lsb.interval.end...interval.end]
    -  adoc
    +  "#{var.gen_adoc(indent, indent_spaces:)}[#{msb.gen_adoc(0, indent_spaces:)}:#{lsb.gen_adoc(0, indent_spaces:)}]"
     end
    @@ -584,9 +645,9 @@

    -

    +

    - #type(symtab) ⇒ Object + #prune(symtab) ⇒ Object @@ -598,20 +659,174 @@

     
     
    -887
    -888
    -889
    -890
    -891
    -892
    -893
    -894
    -895
    -896
    -897
    +111 +112 +113

    -
    # File 'lib/idl/ast.rb', line 887
    +      
    # File 'lib/idl/passes/prune.rb', line 111
    +
    +def prune(symtab)
    +  AryRangeAccessAst.new(input, interval, @var.prune(symtab), @msb.prune(symtab), @lsb.prune(symtab))
    +end
    + + + + + +
    +

    + + #to_idlString + + + + + +

    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +952
    +
    +
    # File 'lib/idl/ast.rb', line 952
    +
    +def to_idl = "#{@var.to_idl}[#{@msb.to_idl}:#{@lsb.to_idl}]"
    +
    +
    + +
    +

    + + #type(symtab) ⇒ Type + + + + + +

    +
    + +

    Given a specific symbol table, return the type of this node.

    + +

    Should not be called until #type_check is called with the same arguments

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      Symbol table for lookup

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Type) + + + + — +
      +

      The type of the node

      +
      + +
    • + +
    +

    Raises:

    +
      + +
    • + + + (AstNode::InternalError) + + + + — +
      +

      if the type is dependent on symtab, and type_check was not called first

      +
      + +
    • + +
    + +
    + + +
    +
    +
    +
    +933
    +934
    +935
    +936
    +937
    +938
    +939
    +940
    +941
    +942
    +943
    +
    +
    # File 'lib/idl/ast.rb', line 933
     
     def type(symtab)
       begin
    @@ -632,45 +847,110 @@ 

    - #type_check(symtab) ⇒ Object + #type_check(symtab) ⇒ void -

    +
    +
    +

    This method returns an undefined value.

    +

    type check this node and all children

    + +

    Calls to #type and/or #value may depend on type_check being called first with the same symtab. If not, those functions may raise an AstNode::InternalError

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      Symbol table for lookup

      +
      + +
    • + +
    + +

    Raises:

    + + +
    @@ -520,36 +520,36 @@

     
     
    -1026
    -1027
    -1028
    -1029
    -1030
    -1031
    -1032
    -1033
    -1034
    -1035
    -1036
    -1037
    -1038
    -1039
    -1040
    -1041
    -1042
    -1043
    -1044
    -1045
    -1046
    -1047
    -1048
    -1049
    -1050
    -1051
    -1052
    +1095 +1096 +1097 +1098 +1099 +1100 +1101 +1102 +1103 +1104 +1105 +1106 +1107 +1108 +1109 +1110 +1111 +1112 +1113 +1114 +1115 +1116 +1117 +1118 +1119 +1120 +1121

    @@ -843,12 +843,12 @@

     
     
    -306
    +291

     
     
    -862
    -863
    -864
    -865
    -866
    -867
    -868
    -869
    -870
    -871
    -872
    -873
    -874
    -875
    -876
    -877
    -878
    -879
    -880
    -881
    -882
    -883
    -884
    -885
    +907 +908 +909 +910 +911 +912 +913 +914 +915 +916 +917 +918 +919 +920 +921 +922 +923 +924 +925 +926 +927 +928 +929 +930
    -
    # File 'lib/idl/ast.rb', line 862
    +      
    # File 'lib/idl/ast.rb', line 907
     
     def type_check(symtab)
       @var.type_check(symtab)
    @@ -710,19 +990,30 @@ 

    -

    +
    +
    + +

    Return the compile-time-known value of the node

    + + +
    +
    +
    + + +
     
     
    -899
    -900
    -901
    -902
    +946 +947 +948 +949
    -
    # File 'lib/idl/ast.rb', line 899
    +      
    # File 'lib/idl/ast.rb', line 946
     
     def value(symtab)
       mask = (1 << (@msb.value(symtab) - @lsb.value(symtab) + 1)) - 1
    @@ -731,6 +1022,102 @@ 

    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -738,7 +1125,7 @@

    diff --git a/docs/ruby/Idl/AryRangeAssignmentAst.html b/docs/ruby/Idl/AryRangeAssignmentAst.html index 7316e85f1..9965454b8 100644 --- a/docs/ruby/Idl/AryRangeAssignmentAst.html +++ b/docs/ruby/Idl/AryRangeAssignmentAst.html @@ -284,25 +284,25 @@

     
     
    -1062
    -1063
    -1064
    -1065
    -1066
    -1067
    -1068
    -1069
    -1070
    -1071
    -1072
    -1073
    -1074
    -1075
    -1076
    -1077
    +1131 +1132 +1133 +1134 +1135 +1136 +1137 +1138 +1139 +1140 +1141 +1142 +1143 +1144 +1145 +1146

    -
    # File 'lib/idl/ast.rb', line 1062
    +      
    # File 'lib/idl/ast.rb', line 1131
     
     def execute(symtab)
       var_val = var.value(symtab)
    @@ -310,7 +310,7 @@ 

    msb_val = msb.value(symtab) lsb_val = lsb.value(symtab) - type_error "MSB is <= LSB" if msb_val <= lsb_val + type_error "MSB (#{msb_val}) is <= LSB (#{lsb_val})" if msb_val <= lsb_val rval_val = rval.value(symtab) @@ -340,12 +340,12 @@

     
     
    -1054
    -1055
    -1056
    +1123 +1124 +1125

    -
    # File 'lib/idl/ast.rb', line 1054
    +      
    # File 'lib/idl/ast.rb', line 1123
     
     def lhs
       internal_error "What's this used for?"
    @@ -370,12 +370,12 @@ 

     
     
    -1058
    -1059
    -1060
    +1127 +1128 +1129

    -
    # File 'lib/idl/ast.rb', line 1058
    +      
    # File 'lib/idl/ast.rb', line 1127
     
     def rhs
       rval
    @@ -429,10 +429,10 @@ 

     
     
    -1080
    +1149

    -
    # File 'lib/idl/ast.rb', line 1080
    +      
    # File 'lib/idl/ast.rb', line 1149
     
     def to_idl = "#{var.to_idl}[#{msb.to_idl}:#{lsb.to_idl}] = #{rval.to_idl}"
    -
    # File 'lib/idl/ast.rb', line 1026
    +      
    # File 'lib/idl/ast.rb', line 1095
     
     def type_check(symtab)
       var.type_check(symtab)
    @@ -588,7 +588,7 @@ 

    diff --git a/docs/ruby/Idl/AssignmentAst.html b/docs/ruby/Idl/AssignmentAst.html index 58d98a294..26b8c0c33 100644 --- a/docs/ruby/Idl/AssignmentAst.html +++ b/docs/ruby/Idl/AssignmentAst.html @@ -125,7 +125,7 @@

    Overview

    @@ -328,12 +328,12 @@

     
     
    -911
    -912
    -913
    +962 +963 +964

    -
    # File 'lib/idl/ast.rb', line 911
    +      
    # File 'lib/idl/ast.rb', line 962
     
     def lhs
       internal_error "#{self.class} must implement lhs"
    @@ -369,12 +369,12 @@ 

     
     
    -916
    -917
    -918
    +967 +968 +969

    -
    # File 'lib/idl/ast.rb', line 916
    +      
    # File 'lib/idl/ast.rb', line 967
     
     def rhs
       internal_error "#{calss} must implement rhs"
    @@ -389,7 +389,7 @@ 

    diff --git a/docs/ruby/Idl/AstNode.html b/docs/ruby/Idl/AstNode.html index d6d8ef388..06a0dbfe1 100644 --- a/docs/ruby/Idl/AstNode.html +++ b/docs/ruby/Idl/AstNode.html @@ -102,7 +102,7 @@
    Defined in:
    lib/idl/ast.rb,
    - lib/idl/ast.rb
    + lib/idl/ast.rb,
    lib/idl/passes/prune.rb,
    lib/idl/passes/gen_adoc.rb
    @@ -111,7 +111,7 @@

    Overview

    -

    reopen AstNode, and add functions

    +

    set up a default

    @@ -121,7 +121,7 @@

    Overview

    Direct Known Subclasses

    -

    ArrayLiteralAst, AryElementAccessAst, AryRangeAccessAst, AssignmentAst, BinaryExpressionAst, BinaryExpressionRightAst, BitfieldAccessExpressionAst, BitfieldDefinitionAst, BitsCastAst, BitsTypeAst, BuiltinTypeNameAst, ConcatenationExpressionAst, CsrFieldReadExpressionAst, CsrReadExpressionAst, CsrSoftwareReadAst, CsrSoftwareWriteAst, CsrWriteAst, DontCareLvalueAst, DontCareReturnAst, EnumDefinitionAst, EnumRefAst, ExecutionCommentAst, FieldNameAst, ForLoopAst, FunctionBodyAst, FunctionCallExpressionAst, FunctionDefAst, GlobalAst, GlobalWithInitializationAst, IdAst, IfAst, InstructionOperationAst, IsaAst, ParenExpressionAst, PostDecrementExpressionAst, PostIncrementExpressionAst, ReplicationExpressionAst, ReturnStatementAst, SignCastAst, StatementAst, TernaryOperatorExpressionAst, UnaryOperatorExpressionAst, UserTypeNameAst, VariableDeclarationAst

    +

    ArrayLiteralAst, AryElementAccessAst, AryElementAssignmentAst, AryRangeAccessAst, AssignmentAst, BinaryExpressionAst, BitfieldAccessExpressionAst, BitfieldDefinitionAst, BitsCastAst, BuiltinTypeNameAst, BuiltinVariableAst, ConcatenationExpressionAst, ConditionalStatementAst, CsrFieldReadExpressionAst, CsrReadExpressionAst, CsrSoftwareReadAst, CsrSoftwareWriteAst, CsrWriteAst, DontCareLvalueAst, DontCareReturnAst, ElseIfAst, EnumDefinitionAst, EnumRefAst, ExecutionCommentAst, FieldNameAst, ForLoopAst, FunctionBodyAst, FunctionCallExpressionAst, FunctionDefAst, GlobalAst, GlobalWithInitializationAst, IdAst, IfAst, IfBodyAst, InstructionOperationAst, IntLiteralAst, IsaAst, MultiVariableDeclarationAst, NoopAst, ParenExpressionAst, PostDecrementExpressionAst, PostIncrementExpressionAst, ReplicationExpressionAst, ReturnStatementAst, SignCastAst, StatementAst, StatementSyntaxNode, TernaryOperatorExpressionAst, UnaryOperatorExpressionAst, UserTypeNameAst, VariableAssignmentAst, VariableDeclarationAst, VariableDeclarationWithInitializationAst

    Defined Under Namespace

    @@ -174,6 +174,28 @@

    List of children, or an empty array for a terminal.

    + + + +
  • + + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + + + + + + + + + +
    +
  • @@ -261,6 +283,28 @@

    pretty print the AST rooted at this node.

    + + + +
  • + + + #prune(_symtab) ⇒ Object + + + + + + + + + + + + + +
    +
  • @@ -466,6 +510,50 @@

    + + +
    +

    + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +11
    +12
    +13
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 4
    +
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  adoc = []
    +  puts self.class.name if elements.nil?
    +  elements.each do |e|
    +    next unless e.is_a?(Idl::AstNode)
    +
    +    adoc << e.gen_adoc(indent, indent_spaces:)
    +  end
    +  adoc.map{ |a| "#{' '*indent}#{a}" }.join('')
    +end
    +
    @@ -664,6 +752,36 @@
    + + +
    +

    + + #prune(_symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +43
    +44
    +45
    +
    +
    # File 'lib/idl/passes/prune.rb', line 43
    +
    +def prune(_symtab)
    +  clone
    +end
    +
    @@ -1020,7 +1138,7 @@

    diff --git a/docs/ruby/Idl/AstNode/InternalError.html b/docs/ruby/Idl/AstNode/InternalError.html index 0b6ae4fd8..89f663f35 100644 --- a/docs/ruby/Idl/AstNode/InternalError.html +++ b/docs/ruby/Idl/AstNode/InternalError.html @@ -249,19 +249,19 @@

     
     
    -161
    -162
    -163
    -164
    -165
    -166
    -167
    -168
    -169
    -170
    +146 +147 +148 +149 +150 +151 +152 +153 +154 +155

    -
    # File 'lib/idl/ast.rb', line 161
    +      
    # File 'lib/idl/ast.rb', line 146
     
     def initialize(what)
       super(what)
    @@ -331,12 +331,12 @@ 

     
     
    -159
    -160
    -161
    +144 +145 +146

    -
    # File 'lib/idl/ast.rb', line 159
    +      
    # File 'lib/idl/ast.rb', line 144
     
     def bt
       @bt
    @@ -392,12 +392,12 @@ 

     
     
    -152
    -153
    -154
    +137 +138 +139

    -
    # File 'lib/idl/ast.rb', line 152
    +      
    # File 'lib/idl/ast.rb', line 137
     
     def what
       @what
    @@ -413,7 +413,7 @@ 

    diff --git a/docs/ruby/Idl/AstNode/TypeError.html b/docs/ruby/Idl/AstNode/TypeError.html index a89fbe45b..c15d5a35f 100644 --- a/docs/ruby/Idl/AstNode/TypeError.html +++ b/docs/ruby/Idl/AstNode/TypeError.html @@ -269,19 +269,19 @@

     
     
    -137
    -138
    -139
    -140
    -141
    -142
    -143
    -144
    -145
    -146
    +122 +123 +124 +125 +126 +127 +128 +129 +130 +131

    -
    # File 'lib/idl/ast.rb', line 137
    +      
    # File 'lib/idl/ast.rb', line 122
     
     def initialize(what)
       super(what)
    @@ -351,12 +351,12 @@ 

     
     
    -134
    -135
    -136
    +119 +120 +121

    -
    # File 'lib/idl/ast.rb', line 134
    +      
    # File 'lib/idl/ast.rb', line 119
     
     def bt
       @bt
    @@ -412,12 +412,12 @@ 

     
     
    -127
    -128
    -129
    +112 +113 +114

    -
    # File 'lib/idl/ast.rb', line 127
    +      
    # File 'lib/idl/ast.rb', line 112
     
     def what
       @what
    @@ -433,7 +433,7 @@ 

    diff --git a/docs/ruby/Idl/AstNode/ValueError.html b/docs/ruby/Idl/AstNode/ValueError.html index 213fd94f9..2285cb6bc 100644 --- a/docs/ruby/Idl/AstNode/ValueError.html +++ b/docs/ruby/Idl/AstNode/ValueError.html @@ -249,14 +249,14 @@

     
     
    -178
    -179
    -180
    -181
    -182
    +163 +164 +165 +166 +167

    -
    # File 'lib/idl/ast.rb', line 178
    +      
    # File 'lib/idl/ast.rb', line 163
     
     def initialize(what, lineno, file)
       super(what)
    @@ -301,12 +301,12 @@ 

     
     
    -176
    -177
    -178
    +161 +162 +163

    -
    # File 'lib/idl/ast.rb', line 176
    +      
    # File 'lib/idl/ast.rb', line 161
     
     def file
       @file
    @@ -344,12 +344,12 @@ 

     
     
    -176
    -177
    -178
    +161 +162 +163

    -
    # File 'lib/idl/ast.rb', line 176
    +      
    # File 'lib/idl/ast.rb', line 161
     
     def lineno
       @lineno
    @@ -365,7 +365,7 @@ 

    diff --git a/docs/ruby/Idl/AstNodeFuncs.html b/docs/ruby/Idl/AstNodeFuncs.html index 77390ed5a..69ad5ec5e 100644 --- a/docs/ruby/Idl/AstNodeFuncs.html +++ b/docs/ruby/Idl/AstNodeFuncs.html @@ -76,7 +76,7 @@
    Included in:
    -
    AstNode, FunctionStatementAst, IntAst
    +
    AstNode, IntLiteralAst
    @@ -383,17 +383,17 @@

     
     
    -241
    -242
    -243
    -244
    -245
    -246
    -247
    -248
    +226 +227 +228 +229 +230 +231 +232 +233

    -
    # File 'lib/idl/ast.rb', line 241
    +      
    # File 'lib/idl/ast.rb', line 226
     
     def children
       if terminal?
    @@ -472,18 +472,18 @@ 

     
     
    -206
    -207
    -208
    -209
    -210
    -211
    -212
    -213
    -214
    +191 +192 +193 +194 +195 +196 +197 +198 +199

    -
    # File 'lib/idl/ast.rb', line 206
    +      
    # File 'lib/idl/ast.rb', line 191
     
     def internal_error(reason)
       msg = <<~WHAT
    @@ -543,24 +543,24 @@ 

     
     
    -265
    -266
    -267
    -268
    -269
    -270
    -271
    -272
    -273
    -274
    -275
    -276
    -277
    -278
    -279
    +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264

    -
    # File 'lib/idl/ast.rb', line 265
    +      
    # File 'lib/idl/ast.rb', line 250
     
     def nodes
       return @nodes unless @nodes.nil?
    @@ -666,15 +666,15 @@ 
    -
    # File 'lib/idl/ast.rb', line 286
    +      
    # File 'lib/idl/ast.rb', line 271
     
     def print_ast(indent = 0, indent_size: 2, io: $stdout)
       io.puts "#{' ' * indent}#{self.class.name}:"
    @@ -748,10 +748,10 @@ 

     
     
    -315
    +300

    -
    # File 'lib/idl/ast.rb', line 315
    +      
    # File 'lib/idl/ast.rb', line 300
     
     def to_idl = raise NotImplementedError, "#{self.class.name} must implement to_idl"
    -
    # File 'lib/idl/ast.rb', line 306
    +      
    # File 'lib/idl/ast.rb', line 291
     
    -def type_check(symtab) = raise NotImplementedError, "Subclass of AstNode must implement type_check"
    +def type_check(symtab) = raise NotImplementedError, "#{self.class.name} must implement type_check"
    @@ -918,18 +918,18 @@

     
     
    -192
    -193
    -194
    -195
    -196
    -197
    -198
    -199
    -200
    +177 +178 +179 +180 +181 +182 +183 +184 +185

    -
    # File 'lib/idl/ast.rb', line 192
    +      
    # File 'lib/idl/ast.rb', line 177
     
     def type_error(reason)
       msg = <<~WHAT
    @@ -1011,12 +1011,12 @@ 

     
     
    -236
    -237
    -238
    +221 +222 +223

    -
    # File 'lib/idl/ast.rb', line 236
    +      
    # File 'lib/idl/ast.rb', line 221
     
     def unindent(s)
       s.gsub(/^#{s.scan(/^[ \t]+(?=\S)/).min}/, "")
    @@ -1090,18 +1090,18 @@ 

     
     
    -220
    -221
    -222
    -223
    -224
    -225
    -226
    -227
    -228
    +205 +206 +207 +208 +209 +210 +211 +212 +213

    -
    # File 'lib/idl/ast.rb', line 220
    +      
    # File 'lib/idl/ast.rb', line 205
     
     def value_error(reason)
       msg = <<~WHAT
    @@ -1122,7 +1122,7 @@ 

    diff --git a/docs/ruby/Idl/BinaryExpressionAst.html b/docs/ruby/Idl/BinaryExpressionAst.html index 5355c1036..44a9b480a 100644 --- a/docs/ruby/Idl/BinaryExpressionAst.html +++ b/docs/ruby/Idl/BinaryExpressionAst.html @@ -103,7 +103,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/prune.rb,
    lib/idl/passes/gen_adoc.rb
    +
    @@ -249,6 +251,28 @@

  • + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + #initialize(input, interval, lhs, op, rhs) ⇒ BinaryExpressionAst @@ -293,6 +317,30 @@

    This expression, but with an inverted condition.

    +

  • + + +
  • + + + #prune(symtab) ⇒ AstNode + + + + + + + + + + + + + +
    +

    A new abstract syntax tree with all dead/unreachable code removed.

    +
    +
  • @@ -389,6 +437,35 @@

    Return the compile-time-known value of the node.

    + + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
    +
  • @@ -432,21 +509,21 @@

     
     
    -1540
    -1541
    -1542
    -1543
    -1544
    -1545
    -1546
    +1668 +1669 +1670 +1671 +1672 +1673 +1674

    -
    # File 'lib/idl/ast.rb', line 1540
    +      
    # File 'lib/idl/ast.rb', line 1668
     
     def initialize(input, interval, lhs, op, rhs)
    -  super(input, interval, [lhs, op, rhs])
    +  super(input, interval, [lhs, rhs])
       @lhs = lhs
    -  @op = op.text_value
    +  @op = op.to_s
       type_error "Bad op '#{@op}'" unless OPS.include?(@op)
       @rhs = rhs
     end
    @@ -488,12 +565,12 @@

     
     
    -1694
    -1695
    -1696
    +1901 +1902 +1903

    -
    # File 'lib/idl/ast.rb', line 1694
    +      
    # File 'lib/idl/ast.rb', line 1901
     
     def lhs
       @lhs
    @@ -531,12 +608,12 @@ 

     
     
    -1700
    -1701
    -1702
    +1907 +1908 +1909

    -
    # File 'lib/idl/ast.rb', line 1700
    +      
    # File 'lib/idl/ast.rb', line 1907
     
     def op
       @op
    @@ -574,12 +651,12 @@ 

     
     
    -1697
    -1698
    -1699
    +1904 +1905 +1906

    -
    # File 'lib/idl/ast.rb', line 1697
    +      
    # File 'lib/idl/ast.rb', line 1904
     
     def rhs
       @rhs
    @@ -597,7 +674,37 @@ 

    Instance Method Details

    -

    +

    + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +128
    +129
    +130
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 128
    +
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  "#{lhs.gen_adoc(0, indent_spaces:)} #{op} #{rhs.gen_adoc(0, indent_spaces:)}"
    +end
    +
    +
    + +
    +

    #invert(symtab) ⇒ BinaryExpressionAst @@ -640,35 +747,35 @@

     
     
    -1549
    -1550
    -1551
    -1552
    -1553
    -1554
    -1555
    -1556
    -1557
    -1558
    -1559
    -1560
    -1561
    -1562
    -1563
    -1564
    -1565
    -1566
    -1567
    -1568
    -1569
    -1570
    -1571
    -1572
    -1573
    -1574
    +1677 +1678 +1679 +1680 +1681 +1682 +1683 +1684 +1685 +1686 +1687 +1688 +1689 +1690 +1691 +1692 +1693 +1694 +1695 +1696 +1697 +1698 +1699 +1700 +1701 +1702

    -
    # File 'lib/idl/ast.rb', line 1549
    +      
    # File 'lib/idl/ast.rb', line 1677
     
     def invert(symtab)
       type_error "Not a boolean operator" unless type(symtab).kind == :boolean
    @@ -699,6 +806,129 @@ 

    +
    + +
    +

    + + #prune(symtab) ⇒ AstNode + + + + + +

    +
    + +

    Returns A new abstract syntax tree with all dead/unreachable code removed.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (Idl::SymbolTable) + + + + — +
      +

      Context of the compilation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (AstNode) + + + + — +
      +

      A new abstract syntax tree with all dead/unreachable code removed

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +124
    +125
    +126
    +127
    +128
    +129
    +130
    +131
    +132
    +133
    +134
    +135
    +136
    +137
    +138
    +139
    +140
    +141
    +
    +
    # File 'lib/idl/passes/prune.rb', line 117
    +
    +def prune(symtab)
    +  if op == "&&"
    +    begin
    +      if @lhs.value(symtab) == false
    +        @rhs.prune(symtab)
    +      else
    +        BinaryExpressionAst.new(input, interval, @lhs.prune(symtab), @op, @rhs.prune(symtab))
    +      end
    +    rescue ValueError
    +      BinaryExpressionAst.new(input, interval, @lhs.prune(symtab), @op, @rhs.prune(symtab))
    +    end
    +  elsif op == "||"
    +    begin
    +      if @lhs.value(symtab) == true
    +        @rhs.prune(symtab)
    +      else
    +        BinaryExpressionAst.new(input, interval, @lhs.prune(symtab), @op, @rhs.prune(symtab))
    +      end
    +    rescue ValueError
    +      BinaryExpressionAst.new(input, interval, @lhs.prune(symtab), @op, @rhs.prune(symtab))
    +    end
    +  else
    +    BinaryExpressionAst.new(input, interval, @lhs.prune(symtab), @op, @rhs.prune(symtab))
    +  end
    +end
    +
    @@ -745,15 +975,15 @@

     
     
    -1577
    -1578
    -1579
    +1705 +1706 +1707

    -
    # File 'lib/idl/ast.rb', line 1577
    +      
    # File 'lib/idl/ast.rb', line 1705
     
     def to_idl
    -  "#{lhs.to_idl} #{op} #{rhs.to_idl}"
    +  "(#{lhs.to_idl} #{op} #{rhs.to_idl})"
     end
    @@ -844,29 +1074,29 @@

     
     
    -1582
    -1583
    -1584
    -1585
    -1586
    -1587
    -1588
    -1589
    -1590
    -1591
    -1592
    -1593
    -1594
    -1595
    -1596
    -1597
    -1598
    -1599
    -1600
    -1601
    +1710 +1711 +1712 +1713 +1714 +1715 +1716 +1717 +1718 +1719 +1720 +1721 +1722 +1723 +1724 +1725 +1726 +1727 +1728 +1729

    -
    # File 'lib/idl/ast.rb', line 1582
    +      
    # File 'lib/idl/ast.rb', line 1710
     
     def type(symtab)
       qualifiers = []
    @@ -973,67 +1203,67 @@ 

     
     
    -1604
    -1605
    -1606
    -1607
    -1608
    -1609
    -1610
    -1611
    -1612
    -1613
    -1614
    -1615
    -1616
    -1617
    -1618
    -1619
    -1620
    -1621
    -1622
    -1623
    -1624
    -1625
    -1626
    -1627
    -1628
    -1629
    -1630
    -1631
    -1632
    -1633
    -1634
    -1635
    -1636
    -1637
    -1638
    -1639
    -1640
    -1641
    -1642
    -1643
    -1644
    -1645
    -1646
    -1647
    -1648
    -1649
    -1650
    -1651
    -1652
    -1653
    -1654
    -1655
    -1656
    -1657
    -1658
    -1659
    -1660
    -1661
    +1732 +1733 +1734 +1735 +1736 +1737 +1738 +1739 +1740 +1741 +1742 +1743 +1744 +1745 +1746 +1747 +1748 +1749 +1750 +1751 +1752 +1753 +1754 +1755 +1756 +1757 +1758 +1759 +1760 +1761 +1762 +1763 +1764 +1765 +1766 +1767 +1768 +1769 +1770 +1771 +1772 +1773 +1774 +1775 +1776 +1777 +1778 +1779 +1780 +1781 +1782 +1783 +1784 +1785 +1786 +1787 +1788 +1789

    -
    # File 'lib/idl/ast.rb', line 1604
    +      
    # File 'lib/idl/ast.rb', line 1732
     
     def type_check(symtab)
       internal_error "No type_check function #{@lhs.inspect}" unless @lhs.respond_to?(:type_check)
    @@ -1124,37 +1354,116 @@ 

     
     
    -1664
    -1665
    -1666
    -1667
    -1668
    -1669
    -1670
    -1671
    -1672
    -1673
    -1674
    -1675
    -1676
    -1677
    -1678
    -1679
    -1680
    -1681
    -1682
    -1683
    -1684
    -1685
    -1686
    -1687
    -1688
    -1689
    -1690
    -1691
    +1792 +1793 +1794 +1795 +1796 +1797 +1798 +1799 +1800 +1801 +1802 +1803 +1804 +1805 +1806 +1807 +1808 +1809 +1810 +1811 +1812 +1813 +1814 +1815 +1816 +1817 +1818 +1819 +1820 +1821 +1822 +1823 +1824 +1825 +1826 +1827 +1828 +1829 +1830 +1831 +1832 +1833 +1834 +1835 +1836 +1837 +1838 +1839 +1840 +1841 +1842 +1843 +1844 +1845 +1846 +1847 +1848 +1849 +1850 +1851 +1852 +1853 +1854 +1855 +1856 +1857 +1858 +1859 +1860 +1861 +1862 +1863 +1864 +1865 +1866 +1867 +1868 +1869 +1870 +1871 +1872 +1873 +1874 +1875 +1876 +1877 +1878 +1879 +1880 +1881 +1882 +1883 +1884 +1885 +1886 +1887 +1888 +1889 +1890 +1891 +1892 +1893 +1894 +1895 +1896 +1897 +1898

    -
    # File 'lib/idl/ast.rb', line 1664
    +      
    # File 'lib/idl/ast.rb', line 1792
     
     def value(symtab)
       if op == ">>>"
    @@ -1180,13 +1489,188 @@ 

    else eval "lhs_value #{op} rhs.value(symtab)", binding, __FILE__, __LINE__ end + elsif op == "==" + begin + @lhs.value(symtab) == @rhs.value(symtab) + rescue ValueError + # even if we don't know the exact value of @lhs and @rhs, we can still + # know that == is false if the possible values of each do not overlap + if @lhs.values(symtab).intersection(@rhs.value(symtab)).empty? + false + else + value_error "There is overlap in the lhs/rhs return values" + end + end + elsif op == "!=" + begin + @lhs.value(symtab) != @rhs.value(symtab) + rescue ValueError + # even if we don't know the exact value of @lhs and @rhs, we can still + # know that != is true if the possible values of each do not overlap + if @lhs.values(symtab).intersection(@rhs.value(symtab)).empty? + true + else + value_error "There is overlap in the lhs/rhs return values" + end + end + elsif op == "<=" + begin + @lhs.value(symtab) <= @rhs.value(symtab) + rescue ValueError + # even if we don't know the exact value of @lhs and @rhs, we can still + # know that != is true if the possible values of lhs are all <= the possible values of rhs + rhs_values = @rhs.values(symtab) + if @lhs.values(symtab).all? { |lhs_value| rhs_values.all? { |rhs_value| lhs_value <= rhs_value} } + true + else + value_error "Some value of lhs is not <= some value of rhs" + end + end + elsif op == ">=" + begin + @lhs.value(symtab) >= @rhs.value(symtab) + rescue ValueError + # even if we don't know the exact value of @lhs and @rhs, we can still + # know that != is true if the possible values of lhs are all >= the possible values of rhs + rhs_values = @rhs.values(symtab) + if @lhs.values(symtab).all? { |lhs_value| rhs_values.all? { |rhs_value| lhs_value >= rhs_value} } + true + else + value_error "Some value of lhs is not >= some value of rhs" + end + end + elsif op == "<" + begin + @lhs.value(symtab) < @rhs.value(symtab) + rescue ValueError + # even if we don't know the exact value of @lhs and @rhs, we can still + # know that != is true if the possible values of lhs are all < the possible values of rhs + rhs_values = @rhs.values(symtab) + if @lhs.values(symtab).all? { |lhs_value| rhs_values.all? { |rhs_value| lhs_value < rhs_value} } + true + else + value_error "Some value of lhs is not < some value of rhs" + end + end + elsif op == ">" + begin + @lhs.value(symtab) > @rhs.value(symtab) + rescue ValueError + # even if we don't know the exact value of @lhs and @rhs, we can still + # know that != is true if the possible values of lhs are all > the possible values of rhs + rhs_values = @rhs.values(symtab) + if @lhs.values(symtab).all? { |lhs_value| rhs_values.all? { |rhs_value| lhs_value > rhs_value} } + true + else + value_error "Some value of lhs is not > some value of rhs" + end + end else - eval "lhs.value(symtab) #{op} rhs.value(symtab)", binding, __FILE__, __LINE__ + v = eval "lhs.value(symtab) #{op} rhs.value(symtab)", binding, __FILE__, __LINE__ + v_trunc = v & ((1 << type(symtab).width) - 1) + warn "WARNING: The value of '#{text_value}' is truncated from #{v} to #{v_trunc} because the result is only #{type(symtab).width} bits" if v != v_trunc + v_trunc end end

    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -1194,7 +1678,7 @@

    diff --git a/docs/ruby/Idl/BinaryExpressionRightAst.html b/docs/ruby/Idl/BinaryExpressionRightSyntaxNode.html similarity index 62% rename from docs/ruby/Idl/BinaryExpressionRightAst.html rename to docs/ruby/Idl/BinaryExpressionRightSyntaxNode.html index 70d50c4d9..ae8f79dff 100644 --- a/docs/ruby/Idl/BinaryExpressionRightAst.html +++ b/docs/ruby/Idl/BinaryExpressionRightSyntaxNode.html @@ -4,7 +4,7 @@ - Class: Idl::BinaryExpressionRightAst + Class: Idl::BinaryExpressionRightSyntaxNode — Documentation by YARD 0.9.36 @@ -15,7 +15,7 @@ <link rel="stylesheet" href="../css/common.css" type="text/css" /> <script type="text/javascript"> - pathId = "Idl::BinaryExpressionRightAst"; + pathId = "Idl::BinaryExpressionRightSyntaxNode"; relpath = '../'; </script> @@ -39,7 +39,7 @@ <a href="../_index.html">Index (B)</a> » <span class='title'><span class='object_link'><a href="../Idl.html" title="Idl (module)">Idl</a></span></span> » - <span class="title">BinaryExpressionRightAst</span> + <span class="title">BinaryExpressionRightSyntaxNode</span> </div> @@ -59,7 +59,7 @@ <div class="clear"></div> </div> - <div id="content"><h1>Class: Idl::BinaryExpressionRightAst + <div id="content"><h1>Class: Idl::BinaryExpressionRightSyntaxNode @@ -69,16 +69,14 @@ <dl> <dt>Inherits:</dt> <dd> - <span class="inheritName"><span class='object_link'><a href="AstNode.html" title="Idl::AstNode (class)">AstNode</a></span></span> + <span class="inheritName"><span class='object_link'><a href="../Treetop/Runtime/SyntaxNode.html" title="Treetop::Runtime::SyntaxNode (class)">Treetop::Runtime::SyntaxNode</a></span></span> <ul class="fullTree"> <li>Object</li> <li class="next"><span class='object_link'><a href="../Treetop/Runtime/SyntaxNode.html" title="Treetop::Runtime::SyntaxNode (class)">Treetop::Runtime::SyntaxNode</a></span></li> - <li class="next"><span class='object_link'><a href="AstNode.html" title="Idl::AstNode (class)">AstNode</a></span></li> - - <li class="next">Idl::BinaryExpressionRightAst</li> + <li class="next">Idl::BinaryExpressionRightSyntaxNode</li> </ul> <a href="#" class="inheritanceTree">show all</a> @@ -121,7 +119,7 @@ <h2> <li class="public "> <span class="summary_signature"> - <a href="#make_left-instance_method" title="#make_left (instance method)">#<strong>make_left</strong> ⇒ Object </a> + <a href="#to_ast-instance_method" title="#to_ast (instance method)">#<strong>to_ast</strong> ⇒ Object </a> @@ -135,7 +133,9 @@ <h2> - <span class="summary_desc"><div class='inline'></div></span> + <span class="summary_desc"><div class='inline'> +<p>fix up left recursion i.e., xlen() - 1 - i => (xlen() - 1) - i.</p> +</div></span> </li> @@ -143,7 +143,7 @@ <h2> <li class="public "> <span class="summary_signature"> - <a href="#type_check-instance_method" title="#type_check (instance method)">#<strong>type_check</strong>(_symtab, _archdef) ⇒ Object </a> + <a href="#type_check-instance_method" title="#type_check (instance method)">#<strong>type_check</strong>(_symtab) ⇒ Object </a> @@ -168,67 +168,72 @@ <h2> - - - - <div id="instance_method_details" class="method_details_list"> <h2>Instance Method Details</h2> <div class="method_details first"> - <h3 class="signature first" id="make_left-instance_method"> + <h3 class="signature first" id="to_ast-instance_method"> - #<strong>make_left</strong> ⇒ <tt>Object</tt> + #<strong>to_ast</strong> ⇒ <tt>Object</tt> -</h3><table class="source_code"> +</h3><div class="docstring"> + <div class="discussion"> + +<p>fix up left recursion i.e., xlen() - 1 - i => (xlen() - 1) - i</p> + + + </div> +</div> +<div class="tags"> + + +</div><table class="source_code"> <tr> <td> <pre class="lines"> -1428 -1429 -1430 -1431 -1432 -1433 -1434 -1435 -1436 -1437 -1438 -1439 -1440 -1441 -1442 -1443 -1444</pre> +1542 +1543 +1544 +1545 +1546 +1547 +1548 +1549 +1550 +1551 +1552 +1553 +1554 +1555 +1556 +1557</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1428</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1542</span> -<span class='kw'>def</span> <span class='id identifier rubyid_make_left'>make_left</span> +<span class='kw'>def</span> <span class='id identifier rubyid_to_ast'>to_ast</span> <span class='id identifier rubyid_first'>first</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="BinaryExpressionAst.html" title="Idl::BinaryExpressionAst (class)">BinaryExpressionAst</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="BinaryExpressionAst.html#initialize-instance_method" title="Idl::BinaryExpressionAst#initialize (method)">new</a></span></span><span class='lparen'>(</span> <span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='lparen'>(</span><span class='id identifier rubyid_interval'>interval</span><span class='period'>.</span><span class='id identifier rubyid_begin'>begin</span><span class='op'>...</span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_elements'>elements</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_interval'>interval</span><span class='period'>.</span><span class='id identifier rubyid_end'>end</span><span class='rparen'>)</span><span class='comma'>,</span> - <span class='id identifier rubyid_l'>l</span><span class='period'>.</span><span class='id identifier rubyid_make_left'>make_left</span><span class='comma'>,</span> <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_elements'>elements</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_op'>op</span><span class='comma'>,</span> <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_elements'>elements</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_make_left'>make_left</span> + <span class='id identifier rubyid_l'>l</span><span class='period'>.</span><span class='id identifier rubyid_to_ast'>to_ast</span><span class='comma'>,</span> <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_elements'>elements</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_op'>op</span><span class='period'>.</span><span class='id identifier rubyid_text_value'>text_value</span><span class='comma'>,</span> <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_elements'>elements</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_to_ast'>to_ast</span> <span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_elements'>elements</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>1</span> <span class='id identifier rubyid_first'>first</span> <span class='kw'>else</span> - <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_elements'>elements</span><span class='lbracket'>[</span><span class='int'>1</span><span class='comma'>,</span> <span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_inject'>inject</span><span class='lparen'>(</span><span class='id identifier rubyid_first'>first</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_lhs'>lhs</span><span class='comma'>,</span> <span class='id identifier rubyid_r'>r</span><span class='op'>|</span> - <span class='const'><span class='object_link'><a href="BinaryExpressionAst.html" title="Idl::BinaryExpressionAst (class)">BinaryExpressionAst</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="BinaryExpressionAst.html#initialize-instance_method" title="Idl::BinaryExpressionAst#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='lparen'>(</span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_interval'>interval</span><span class='period'>.</span><span class='id identifier rubyid_begin'>begin</span><span class='op'>...</span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_interval'>interval</span><span class='period'>.</span><span class='id identifier rubyid_end'>end</span><span class='rparen'>)</span><span class='comma'>,</span> - <span class='id identifier rubyid_lhs'>lhs</span><span class='comma'>,</span> <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_op'>op</span><span class='comma'>,</span> <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_make_left'>make_left</span><span class='rparen'>)</span> + <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_elements'>elements</span><span class='lbracket'>[</span><span class='int'>1</span><span class='op'>..</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_inject'>inject</span><span class='lparen'>(</span><span class='id identifier rubyid_first'>first</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_lhs'>lhs</span><span class='comma'>,</span> <span class='id identifier rubyid_el'>el</span><span class='op'>|</span> + <span class='const'><span class='object_link'><a href="BinaryExpressionAst.html" title="Idl::BinaryExpressionAst (class)">BinaryExpressionAst</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="BinaryExpressionAst.html#initialize-instance_method" title="Idl::BinaryExpressionAst#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='lparen'>(</span><span class='id identifier rubyid_lhs'>lhs</span><span class='period'>.</span><span class='id identifier rubyid_interval'>interval</span><span class='period'>.</span><span class='id identifier rubyid_begin'>begin</span><span class='op'>...</span><span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_interval'>interval</span><span class='period'>.</span><span class='id identifier rubyid_end'>end</span><span class='rparen'>)</span><span class='comma'>,</span> + <span class='id identifier rubyid_lhs'>lhs</span><span class='comma'>,</span> <span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_op'>op</span><span class='period'>.</span><span class='id identifier rubyid_text_value'>text_value</span><span class='comma'>,</span> <span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_to_ast'>to_ast</span><span class='rparen'>)</span> <span class='kw'>end</span> <span class='kw'>end</span> - <span class='id identifier rubyid_first'>first</span> <span class='kw'>end</span></pre> </td> </tr> @@ -238,7 +243,7 @@ <h3 class="signature first" id="make_left-instance_method"> <div class="method_details "> <h3 class="signature " id="type_check-instance_method"> - #<strong>type_check</strong>(_symtab, _archdef) ⇒ <tt>Object</tt> + #<strong>type_check</strong>(_symtab) ⇒ <tt>Object</tt> @@ -250,15 +255,15 @@ <h3 class="signature " id="type_check-instance_method"> <pre class="lines"> -1446 -1447 -1448</pre> +1559 +1560 +1561</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1446</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1559</span> -<span class='kw'>def</span> <span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid__symtab'>_symtab</span><span class='comma'>,</span> <span class='id identifier rubyid__archdef'>_archdef</span><span class='rparen'>)</span> - <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>you must have forgotten the make_left pass</span><span class='tstring_end'>"</span></span> +<span class='kw'>def</span> <span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid__symtab'>_symtab</span><span class='rparen'>)</span> + <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>you must have forgotten the to_ast pass</span><span class='tstring_end'>"</span></span> <span class='kw'>end</span></pre> </td> </tr> @@ -270,7 +275,7 @@ <h3 class="signature " id="type_check-instance_method"> </div> <div id="footer"> - Generated on Fri Jul 12 07:33:11 2024 by + Generated on Thu Jul 18 13:55:45 2024 by <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.36 (ruby-3.2.3). </div> diff --git a/docs/ruby/Idl/BitfieldAccessExpressionAst.html b/docs/ruby/Idl/BitfieldAccessExpressionAst.html index ec31a8332..dbeff4d7f 100644 --- a/docs/ruby/Idl/BitfieldAccessExpressionAst.html +++ b/docs/ruby/Idl/BitfieldAccessExpressionAst.html @@ -253,6 +253,35 @@ <h2> <p>Return the compile-time-known value of the node.</p> </div></span> +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#values-instance_method" title="#values (instance method)">#<strong>values</strong>(symtab) ⇒ Array<Integer>, ... </a> + + + + </span> + + <span class="note title not_defined_here"> + included + from <span class='object_link'><a href="Rvalue.html#values-instance_method" title="Idl::Rvalue#values (method)">Rvalue</a></span> + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.</p> +</div></span> + </li> @@ -288,12 +317,12 @@ <h3 class="signature first" id="kind-instance_method"> <pre class="lines"> -1906 -1907 -1908</pre> +2178 +2179 +2180</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1906</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2178</span> <span class='kw'>def</span> <span class='id identifier rubyid_kind'>kind</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='id identifier rubyid_rval'>rval</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_kind'>kind</span> @@ -347,10 +376,10 @@ <h3 class="signature " id="to_idl-instance_method"> <pre class="lines"> -1966</pre> +2238</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1966</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2238</span> <span class='kw'>def</span> <span class='id identifier rubyid_to_idl'>to_idl</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_rval'>rval</span><span class='period'>.</span><span class='id identifier rubyid_to_idl'>to_idl</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field_name'>field_name</span><span class='period'>.</span><span class='id identifier rubyid_to_idl'>to_idl</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span></pre> </td> @@ -442,20 +471,20 @@ <h3 class="signature " id="type-instance_method"> <pre class="lines"> -1911 -1912 -1913 -1914 -1915 -1916 -1917 -1918 -1919 -1920 -1921</pre> +2183 +2184 +2185 +2186 +2187 +2188 +2189 +2190 +2191 +2192 +2193</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1911</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2183</span> <span class='kw'>def</span> <span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='id identifier rubyid_rval_type'>rval_type</span> <span class='op'>=</span> <span class='id identifier rubyid_rval'>rval</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> @@ -488,38 +517,38 @@ <h3 class="signature " id="type_check-instance_method"> <pre class="lines"> -1923 -1924 -1925 -1926 -1927 -1928 -1929 -1930 -1931 -1932 -1933 -1934 -1935 -1936 -1937 -1938 -1939 -1940 -1941 -1942 -1943 -1944 -1945 -1946 -1947 -1948 -1949 -1950 -1951</pre> +2195 +2196 +2197 +2198 +2199 +2200 +2201 +2202 +2203 +2204 +2205 +2206 +2207 +2208 +2209 +2210 +2211 +2212 +2213 +2214 +2215 +2216 +2217 +2218 +2219 +2220 +2221 +2222 +2223</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1923</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2195</span> <span class='kw'>def</span> <span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='id identifier rubyid_rval'>rval</span><span class='period'>.</span><span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> @@ -581,19 +610,19 @@ <h3 class="signature " id="value-instance_method"> <pre class="lines"> -1954 -1955 -1956 -1957 -1958 -1959 -1960 -1961 -1962 -1963</pre> +2226 +2227 +2228 +2229 +2230 +2231 +2232 +2233 +2234 +2235</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1954</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2226</span> <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_kind'>kind</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='symbol'>:bitfield</span> @@ -608,6 +637,102 @@ <h3 class="signature " id="value-instance_method"> </td> </tr> </table> +</div> + + <div class="method_details "> + <h3 class="signature " id="values-instance_method"> + + #<strong>values</strong>(symtab) ⇒ <tt>Array<Integer></tt>, ... + + + + + + <span class="not_defined_here"> + Originally defined in module + <span class='object_link'><a href="Rvalue.html#values-instance_method" title="Idl::Rvalue#values (method)">Rvalue</a></span> + </span> + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined</p> + +<p>For most AstNodes, this will just be a single-entry array</p> + + + </div> +</div> +<div class="tags"> + <p class="tag_title">Parameters:</p> +<ul class="param"> + + <li> + + <span class='name'>symtab</span> + + + <span class='type'>(<tt><span class='object_link'><a href="SymbolTable.html" title="Idl::SymbolTable (class)">SymbolTable</a></span></tt>)</span> + + + + — + <div class='inline'> +<p>The context for the evaulation</p> +</div> + + </li> + +</ul> + +<p class="tag_title">Returns:</p> +<ul class="return"> + + <li> + + + <span class='type'>(<tt>Array<Integer></tt>)</span> + + + + — + <div class='inline'> +<p>The complete list of compile-time-known values, when they are integral</p> +</div> + + </li> + + <li> + + + <span class='type'>(<tt>Array<Boolean></tt>)</span> + + + + — + <div class='inline'> +<p>The complete list of compile-time-known values, when they are booleans</p> +</div> + + </li> + + <li> + + + <span class='type'>(<tt><span class='object_link'><a href="AstNode/ValueError.html" title="Idl::AstNode::ValueError (class)">AstNode::ValueError</a></span></tt>)</span> + + + + — + <div class='inline'> +<p>if the list of values is not knowable at compile time</p> +</div> + + </li> + +</ul> + +</div> </div> </div> @@ -615,7 +740,7 @@ <h3 class="signature " id="value-instance_method"> </div> <div id="footer"> - Generated on Fri Jul 12 07:33:11 2024 by + Generated on Thu Jul 18 13:55:46 2024 by <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.36 (ruby-3.2.3). </div> diff --git a/docs/ruby/Idl/BitfieldDefinitionAst.html b/docs/ruby/Idl/BitfieldDefinitionAst.html index b38456cc1..e81f348ff 100644 --- a/docs/ruby/Idl/BitfieldDefinitionAst.html +++ b/docs/ruby/Idl/BitfieldDefinitionAst.html @@ -153,6 +153,30 @@ <h2> <li class="public "> <span class="summary_signature"> + <a href="#add_symbol-instance_method" title="#add_symbol (instance method)">#<strong>add_symbol</strong>(symtab) ⇒ Object </a> + + + + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Add symbol(s) at the outermost scope of the symbol table.</p> +</div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + <a href="#element_names-instance_method" title="#element_names (instance method)">#<strong>element_names</strong> ⇒ Array<String> </a> @@ -334,7 +358,70 @@ <h2>Instance Method Details</h2> <div class="method_details first"> - <h3 class="signature first" id="element_names-instance_method"> + <h3 class="signature first" id="add_symbol-instance_method"> + + #<strong>add_symbol</strong>(symtab) ⇒ <tt>Object</tt> + + + + + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Add symbol(s) at the outermost scope of the symbol table</p> + + + </div> +</div> +<div class="tags"> + <p class="tag_title">Parameters:</p> +<ul class="param"> + + <li> + + <span class='name'>symtab</span> + + + <span class='type'>(<tt><span class='object_link'><a href="SymbolTable.html" title="Idl::SymbolTable (class)">SymbolTable</a></span></tt>)</span> + + + + — + <div class='inline'> +<p>Symbol table at the scope that the symbol(s) will be inserted</p> +</div> + + </li> + +</ul> + + +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +737 +738 +739 +740</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 737</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_add_symbol'>add_symbol</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> + <span class='id identifier rubyid_t'>t</span> <span class='op'>=</span> <span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> + <span class='id identifier rubyid_symtab'>symtab</span><span class='period'>.</span><span class='id identifier rubyid_add!'>add!</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_t'>t</span><span class='rparen'>)</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <h3 class="signature " id="element_names-instance_method"> #<strong>element_names</strong> ⇒ <tt>Array<String></tt> @@ -377,14 +464,14 @@ <h3 class="signature first" id="element_names-instance_method"> <pre class="lines"> -662 -663 -664 -665 -666</pre> +698 +699 +700 +701 +702</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 662</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 698</span> <span class='kw'>def</span> <span class='id identifier rubyid_element_names'>element_names</span> <span class='kw'>return</span> <span class='ivar'>@element_names</span> <span class='kw'>unless</span> <span class='ivar'>@element_names</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> @@ -440,22 +527,22 @@ <h3 class="signature " id="element_ranges-instance_method"> <pre class="lines"> -670 -671 -672 -673 -674 -675 -676 -677 -678 -679 -680 -681 -682</pre> +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 670</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 706</span> <span class='kw'>def</span> <span class='id identifier rubyid_element_ranges'>element_ranges</span> <span class='kw'>return</span> <span class='ivar'>@element_ranges</span> <span class='kw'>unless</span> <span class='ivar'>@element_ranges</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> @@ -519,10 +606,10 @@ <h3 class="signature " id="name-instance_method"> <pre class="lines"> -705</pre> +746</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 705</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 746</span> <span class='kw'>def</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_user_type_name'>user_type_name</span><span class='period'>.</span><span class='id identifier rubyid_text_value'>text_value</span></pre> </td> @@ -574,17 +661,17 @@ <h3 class="signature " id="to_idl-instance_method"> <pre class="lines"> -711 -712 -713 -714 -715 -716 -717 -718</pre> +752 +753 +754 +755 +756 +757 +758 +759</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 711</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 752</span> <span class='kw'>def</span> <span class='id identifier rubyid_to_idl'>to_idl</span> <span class='id identifier rubyid_idl'>idl</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bitfield (</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_bf_size'>bf_size</span><span class='embexpr_end'>}</span><span class='tstring_content'>) </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'> { </span><span class='tstring_end'>"</span></span> @@ -663,10 +750,10 @@ <h3 class="signature " id="type-instance_method"> <pre class="lines"> -702</pre> +743</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 702</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 743</span> <span class='kw'>def</span> <span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="BitfieldType.html" title="Idl::BitfieldType (class)">BitfieldType</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="BitfieldType.html#initialize-instance_method" title="Idl::BitfieldType#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_int'>int</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_element_names'>element_names</span><span class='comma'>,</span> <span class='id identifier rubyid_element_ranges'>element_ranges</span><span class='rparen'>)</span></pre> </td> @@ -754,24 +841,23 @@ <h3 class="signature " id="type_check-instance_method"> <pre class="lines"> -685 -686 -687 -688 -689 -690 -691 -692 -693 -694 -695 -696 -697 -698 -699</pre> +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 685</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 721</span> <span class='kw'>def</span> <span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='id identifier rubyid_int'>int</span><span class='period'>.</span><span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> @@ -785,8 +871,7 @@ <h3 class="signature " id="type_check-instance_method"> <span class='id identifier rubyid_type_error'>type_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Field position (</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_b'>b</span><span class='embexpr_end'>}</span><span class='tstring_content'>) is larger than the bitfield width (</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_bf_size'>bf_size</span><span class='embexpr_end'>}</span><span class='tstring_content'>)</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_b'>b</span> <span class='op'>>=</span> <span class='id identifier rubyid_bf_size'>bf_size</span> <span class='kw'>end</span> - <span class='id identifier rubyid_t'>t</span> <span class='op'>=</span> <span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> - <span class='id identifier rubyid_symtab'>symtab</span><span class='period'>.</span><span class='id identifier rubyid_add!'>add!</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_t'>t</span><span class='rparen'>)</span> + <span class='id identifier rubyid_add_symbol'>add_symbol</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='kw'>end</span></pre> </td> </tr> @@ -889,10 +974,10 @@ <h3 class="signature " id="value-instance_method"> <pre class="lines"> -708</pre> +749</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 708</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 749</span> <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid__symtab'>_symtab</span><span class='comma'>,</span> <span class='id identifier rubyid__archdef'>_archdef</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="AstNode.html" title="Idl::AstNode (class)">AstNode</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="AstNode/InternalError.html" title="Idl::AstNode::InternalError (class)">InternalError</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Bitfield defintions have no value</span><span class='tstring_end'>"</span></span></pre> </td> @@ -905,7 +990,7 @@ <h3 class="signature " id="value-instance_method"> </div> <div id="footer"> - Generated on Fri Jul 12 07:33:10 2024 by + Generated on Thu Jul 18 13:55:45 2024 by <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.36 (ruby-3.2.3). </div> diff --git a/docs/ruby/Idl/BitfieldType.html b/docs/ruby/Idl/BitfieldType.html index 178d22567..527824565 100644 --- a/docs/ruby/Idl/BitfieldType.html +++ b/docs/ruby/Idl/BitfieldType.html @@ -242,17 +242,17 @@ <h3 class="signature first" id="initialize-instance_method"> <pre class="lines"> -376 -377 -378 -379 -380 -381 -382 -383</pre> +387 +388 +389 +390 +391 +392 +393 +394</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/type.rb', line 376</span> + <pre class="code"><span class="info file"># File 'lib/idl/type.rb', line 387</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_type_name'>type_name</span><span class='comma'>,</span> <span class='id identifier rubyid_width'>width</span><span class='comma'>,</span> <span class='id identifier rubyid_field_names'>field_names</span><span class='comma'>,</span> <span class='id identifier rubyid_field_ranges'>field_ranges</span><span class='rparen'>)</span> <span class='kw'>super</span><span class='lparen'>(</span><span class='symbol'>:bitfield</span><span class='comma'>,</span> <span class='label'>name:</span> <span class='id identifier rubyid_type_name'>type_name</span><span class='comma'>,</span> <span class='label'>width:</span> <span class='id identifier rubyid_width'>width</span><span class='rparen'>)</span> @@ -289,17 +289,17 @@ <h3 class="signature first" id="clone-instance_method"> <pre class="lines"> -396 -397 -398 -399 -400 -401 -402 -403</pre> +407 +408 +409 +410 +411 +412 +413 +414</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/type.rb', line 396</span> + <pre class="code"><span class="info file"># File 'lib/idl/type.rb', line 407</span> <span class='kw'>def</span> <span class='id identifier rubyid_clone'>clone</span> <span class='const'><span class='object_link'><a href="" title="Idl::BitfieldType (class)">BitfieldType</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="Idl::BitfieldType#initialize (method)">new</a></span></span><span class='lparen'>(</span> @@ -329,12 +329,12 @@ <h3 class="signature " id="field_names-instance_method"> <pre class="lines"> -392 -393 -394</pre> +403 +404 +405</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/type.rb', line 392</span> + <pre class="code"><span class="info file"># File 'lib/idl/type.rb', line 403</span> <span class='kw'>def</span> <span class='id identifier rubyid_field_names'>field_names</span> <span class='ivar'>@field_names</span> @@ -359,15 +359,15 @@ <h3 class="signature " id="range-instance_method"> <pre class="lines"> -385 -386 -387 -388 -389 -390</pre> +396 +397 +398 +399 +400 +401</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/type.rb', line 385</span> + <pre class="code"><span class="info file"># File 'lib/idl/type.rb', line 396</span> <span class='kw'>def</span> <span class='id identifier rubyid_range'>range</span><span class='lparen'>(</span><span class='id identifier rubyid_field_name'>field_name</span><span class='rparen'>)</span> <span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='ivar'>@field_names</span><span class='period'>.</span><span class='id identifier rubyid_index'>index</span><span class='lparen'>(</span><span class='id identifier rubyid_field_name'>field_name</span><span class='rparen'>)</span> @@ -385,7 +385,7 @@ <h3 class="signature " id="range-instance_method"> </div> <div id="footer"> - Generated on Fri Jul 12 07:33:12 2024 by + Generated on Thu Jul 18 13:55:48 2024 by <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.36 (ruby-3.2.3). </div> diff --git a/docs/ruby/Idl/BitsCastAst.html b/docs/ruby/Idl/BitsCastAst.html index 86f9b0e1b..a15d09806 100644 --- a/docs/ruby/Idl/BitsCastAst.html +++ b/docs/ruby/Idl/BitsCastAst.html @@ -232,6 +232,35 @@ <h2> <p>Return the compile-time-known value of the node.</p> </div></span> +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#values-instance_method" title="#values (instance method)">#<strong>values</strong>(symtab) ⇒ Array<Integer>, ... </a> + + + + </span> + + <span class="note title not_defined_here"> + included + from <span class='object_link'><a href="Rvalue.html#values-instance_method" title="Idl::Rvalue#values (method)">Rvalue</a></span> + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.</p> +</div></span> + </li> @@ -296,10 +325,10 @@ <h3 class="signature first" id="to_idl-instance_method"> <pre class="lines"> -1528</pre> +1656</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1528</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1656</span> <span class='kw'>def</span> <span class='id identifier rubyid_to_idl'>to_idl</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>$signed(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_expression'>expression</span><span class='period'>.</span><span class='id identifier rubyid_to_idl'>to_idl</span><span class='embexpr_end'>}</span><span class='tstring_content'>)</span><span class='tstring_end'>"</span></span></pre> </td> @@ -391,22 +420,22 @@ <h3 class="signature " id="type-instance_method"> <pre class="lines"> -1498 -1499 -1500 -1501 -1502 -1503 -1504 -1505 -1506 -1507 -1508 -1509 -1510</pre> +1624 +1625 +1626 +1627 +1628 +1629 +1630 +1631 +1632 +1633 +1634 +1635 +1636</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1498</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1624</span> <span class='kw'>def</span> <span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='id identifier rubyid_etype'>etype</span> <span class='op'>=</span> <span class='id identifier rubyid_expression'>expression</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> @@ -506,16 +535,16 @@ <h3 class="signature " id="type_check-instance_method"> <pre class="lines"> -1489 -1490 -1491 -1492 -1493 -1494 -1495</pre> +1615 +1616 +1617 +1618 +1619 +1620 +1621</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1489</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1615</span> <span class='kw'>def</span> <span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='id identifier rubyid_expression'>expression</span><span class='period'>.</span><span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> @@ -555,22 +584,24 @@ <h3 class="signature " id="value-instance_method"> <pre class="lines"> -1513 -1514 -1515 -1516 -1517 -1518 -1519 -1520 -1521 -1522 -1523 -1524 -1525</pre> +1639 +1640 +1641 +1642 +1643 +1644 +1645 +1646 +1647 +1648 +1649 +1650 +1651 +1652 +1653</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1513</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1639</span> <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='id identifier rubyid_etype'>etype</span> <span class='op'>=</span> <span class='id identifier rubyid_expression'>expression</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> @@ -582,12 +613,110 @@ <h3 class="signature " id="value-instance_method"> <span class='id identifier rubyid_element_name'>element_name</span> <span class='op'>=</span> <span class='id identifier rubyid_expression'>expression</span><span class='period'>.</span><span class='id identifier rubyid_text_value'>text_value</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>:</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> <span class='id identifier rubyid_etype'>etype</span><span class='period'>.</span><span class='id identifier rubyid_enum_class'>enum_class</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_element_name'>element_name</span><span class='rparen'>)</span> <span class='kw'>when</span> <span class='symbol'>:csr</span> - <span class='id identifier rubyid_internal_error'>internal_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>TODO</span><span class='tstring_end'>"</span></span> + <span class='id identifier rubyid_expression'>expression</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> + <span class='kw'>else</span> + <span class='id identifier rubyid_internal_error'>internal_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>TODO: Bits cast for </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_etype'>etype</span><span class='period'>.</span><span class='id identifier rubyid_kind'>kind</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>end</span> <span class='kw'>end</span></pre> </td> </tr> </table> +</div> + + <div class="method_details "> + <h3 class="signature " id="values-instance_method"> + + #<strong>values</strong>(symtab) ⇒ <tt>Array<Integer></tt>, ... + + + + + + <span class="not_defined_here"> + Originally defined in module + <span class='object_link'><a href="Rvalue.html#values-instance_method" title="Idl::Rvalue#values (method)">Rvalue</a></span> + </span> + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined</p> + +<p>For most AstNodes, this will just be a single-entry array</p> + + + </div> +</div> +<div class="tags"> + <p class="tag_title">Parameters:</p> +<ul class="param"> + + <li> + + <span class='name'>symtab</span> + + + <span class='type'>(<tt><span class='object_link'><a href="SymbolTable.html" title="Idl::SymbolTable (class)">SymbolTable</a></span></tt>)</span> + + + + — + <div class='inline'> +<p>The context for the evaulation</p> +</div> + + </li> + +</ul> + +<p class="tag_title">Returns:</p> +<ul class="return"> + + <li> + + + <span class='type'>(<tt>Array<Integer></tt>)</span> + + + + — + <div class='inline'> +<p>The complete list of compile-time-known values, when they are integral</p> +</div> + + </li> + + <li> + + + <span class='type'>(<tt>Array<Boolean></tt>)</span> + + + + — + <div class='inline'> +<p>The complete list of compile-time-known values, when they are booleans</p> +</div> + + </li> + + <li> + + + <span class='type'>(<tt><span class='object_link'><a href="AstNode/ValueError.html" title="Idl::AstNode::ValueError (class)">AstNode::ValueError</a></span></tt>)</span> + + + + — + <div class='inline'> +<p>if the list of values is not knowable at compile time</p> +</div> + + </li> + +</ul> + +</div> </div> </div> @@ -595,7 +724,7 @@ <h3 class="signature " id="value-instance_method"> </div> <div id="footer"> - Generated on Fri Jul 12 07:33:11 2024 by + Generated on Thu Jul 18 13:55:45 2024 by <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.36 (ruby-3.2.3). </div> diff --git a/docs/ruby/Idl/BuiltinEnumDefinitionAst.html b/docs/ruby/Idl/BuiltinEnumDefinitionAst.html index 6794d1662..a83176dde 100644 --- a/docs/ruby/Idl/BuiltinEnumDefinitionAst.html +++ b/docs/ruby/Idl/BuiltinEnumDefinitionAst.html @@ -264,10 +264,10 @@ <h3 class="signature first" id="to_idl-instance_method"> <pre class="lines"> -636</pre> +672</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 636</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 672</span> <span class='kw'>def</span> <span class='id identifier rubyid_to_idl'>to_idl</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>builtin enum </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_user_type_name'>user_type_name</span><span class='period'>.</span><span class='id identifier rubyid_text_value'>text_value</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span></pre> </td> @@ -290,10 +290,10 @@ <h3 class="signature " id="type-instance_method"> <pre class="lines"> -633</pre> +669</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 633</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 669</span> <span class='kw'>def</span> <span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='id identifier rubyid_symtab'>symtab</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='id identifier rubyid_user_type_name'>user_type_name</span><span class='period'>.</span><span class='id identifier rubyid_text_value'>text_value</span><span class='rparen'>)</span></pre> </td> @@ -316,14 +316,14 @@ <h3 class="signature " id="type_check-instance_method"> <pre class="lines"> -626 -627 -628 -629 -630</pre> +662 +663 +664 +665 +666</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 626</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 662</span> <span class='kw'>def</span> <span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid__symtab'>_symtab</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_user_type_name'>user_type_name</span><span class='period'>.</span><span class='id identifier rubyid_text_value'>text_value</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ExtensionName</span><span class='tstring_end'>"</span></span> @@ -340,7 +340,7 @@ <h3 class="signature " id="type_check-instance_method"> </div> <div id="footer"> - Generated on Fri Jul 12 07:33:10 2024 by + Generated on Thu Jul 18 13:55:45 2024 by <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.36 (ruby-3.2.3). </div> diff --git a/docs/ruby/Idl/BuiltinTypeNameAst.html b/docs/ruby/Idl/BuiltinTypeNameAst.html index 110f09ba6..9830c7fb6 100644 --- a/docs/ruby/Idl/BuiltinTypeNameAst.html +++ b/docs/ruby/Idl/BuiltinTypeNameAst.html @@ -98,7 +98,9 @@ <dl> <dt>Defined in:</dt> - <dd>lib/idl/ast.rb</dd> + <dd>lib/idl/ast.rb<span class="defines">,<br /> + lib/idl/passes/gen_adoc.rb</span> +</dd> </dl> </div> @@ -121,6 +123,78 @@ <h2> <li class="public "> <span class="summary_signature"> + <a href="#gen_adoc-instance_method" title="#gen_adoc (instance method)">#<strong>gen_adoc</strong>(indent = 0, indent_spaces: 2) ⇒ Object </a> + + + + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'></div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(input, interval, type_name, bits_expression) ⇒ BuiltinTypeNameAst </a> + + + + </span> + + + <span class="note title constructor">constructor</span> + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>A new instance of BuiltinTypeNameAst.</p> +</div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#to_idl-instance_method" title="#to_idl (instance method)">#<strong>to_idl</strong> ⇒ String </a> + + + + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Return valid IDL representation of the node (and its subtree).</p> +</div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + <a href="#type-instance_method" title="#type (instance method)">#<strong>type</strong>(symtab) ⇒ Type </a> @@ -175,14 +249,176 @@ <h2> + <div id="constructor_details" class="method_details_list"> + <h2>Constructor Details</h2> + + <div class="method_details first"> + <h3 class="signature first" id="initialize-instance_method"> + + #<strong>initialize</strong>(input, interval, type_name, bits_expression) ⇒ <tt><span class='object_link'><a href="" title="Idl::BuiltinTypeNameAst (class)">BuiltinTypeNameAst</a></span></tt> + + + + + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Returns a new instance of BuiltinTypeNameAst.</p> + + + </div> +</div> +<div class="tags"> +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +2820 +2821 +2822 +2823 +2824 +2825 +2826 +2827 +2828</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2820</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_interval'>interval</span><span class='comma'>,</span> <span class='id identifier rubyid_type_name'>type_name</span><span class='comma'>,</span> <span class='id identifier rubyid_bits_expression'>bits_expression</span><span class='rparen'>)</span> + <span class='kw'>if</span> <span class='id identifier rubyid_bits_expression'>bits_expression</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> + <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_interval'>interval</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span> + <span class='kw'>else</span> + <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_interval'>interval</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='id identifier rubyid_bits_expression'>bits_expression</span><span class='rbracket'>]</span><span class='rparen'>)</span> + <span class='kw'>end</span> + <span class='ivar'>@type_name</span> <span class='op'>=</span> <span class='id identifier rubyid_type_name'>type_name</span> + <span class='ivar'>@bits_expression</span> <span class='op'>=</span> <span class='id identifier rubyid_bits_expression'>bits_expression</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + +</div> + + <div id="instance_method_details" class="method_details_list"> <h2>Instance Method Details</h2> <div class="method_details first"> - <h3 class="signature first" id="type-instance_method"> + <h3 class="signature first" id="gen_adoc-instance_method"> + + #<strong>gen_adoc</strong>(indent = 0, indent_spaces: 2) ⇒ <tt>Object</tt> + + + + + +</h3><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +85 +86 +87 +88 +89 +90 +91</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/passes/gen_adoc.rb', line 85</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_gen_adoc'>gen_adoc</span><span class='lparen'>(</span><span class='id identifier rubyid_indent'>indent</span> <span class='op'>=</span> <span class='int'>0</span><span class='comma'>,</span> <span class='label'>indent_spaces:</span> <span class='int'>2</span><span class='rparen'>)</span> + <span class='kw'>if</span> <span class='ivar'>@type_name</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Bits</span><span class='tstring_end'>"</span></span> + <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Bits<</span><span class='embexpr_beg'>#{</span><span class='ivar'>@bits_expression</span><span class='period'>.</span><span class='id identifier rubyid_gen_adoc'>gen_adoc</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='label'>indent_spaces:</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>></span><span class='tstring_end'>"</span></span> + <span class='kw'>else</span> + <span class='id identifier rubyid_to_idl'>to_idl</span> + <span class='kw'>end</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <h3 class="signature " id="to_idl-instance_method"> + + #<strong>to_idl</strong> ⇒ <tt>String</tt> + + + + + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Return valid IDL representation of the node (and its subtree)</p> + + + </div> +</div> +<div class="tags"> + +<p class="tag_title">Returns:</p> +<ul class="return"> + + <li> + + + <span class='type'>(<tt>String</tt>)</span> + + + + — + <div class='inline'> +<p>IDL code for the node</p> +</div> + + </li> + +</ul> + +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +2861 +2862 +2863 +2864 +2865 +2866 +2867</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2861</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_to_idl'>to_idl</span> + <span class='kw'>if</span> <span class='ivar'>@type_name</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Bits</span><span class='tstring_end'>"</span></span> + <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Bits<</span><span class='embexpr_beg'>#{</span><span class='ivar'>@bits_expression</span><span class='period'>.</span><span class='id identifier rubyid_to_idl'>to_idl</span><span class='embexpr_end'>}</span><span class='tstring_content'>></span><span class='tstring_end'>"</span></span> + <span class='kw'>else</span> + <span class='ivar'>@type_name</span> + <span class='kw'>end</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <h3 class="signature " id="type-instance_method"> #<strong>type</strong>(symtab) ⇒ <tt><span class='object_link'><a href="Type.html" title="Idl::Type (class)">Type</a></span></tt> @@ -265,28 +501,30 @@ <h3 class="signature first" id="type-instance_method"> <pre class="lines"> -2443 -2444 -2445 -2446 -2447 -2448 -2449 -2450 -2451 -2452 -2453 -2454 -2455 -2456 -2457</pre> +2842 +2843 +2844 +2845 +2846 +2847 +2848 +2849 +2850 +2851 +2852 +2853 +2854 +2855 +2856 +2857 +2858</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2443</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2842</span> <span class='kw'>def</span> <span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='id identifier rubyid_archdef'>archdef</span> <span class='op'>=</span> <span class='id identifier rubyid_symtab'>symtab</span><span class='period'>.</span><span class='id identifier rubyid_archdef'>archdef</span> - <span class='kw'>case</span> <span class='id identifier rubyid_text_value'>text_value</span> + <span class='kw'>case</span> <span class='ivar'>@type_name</span> <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>XReg</span><span class='tstring_end'>"</span></span> <span class='const'><span class='object_link'><a href="Type.html" title="Idl::Type (class)">Type</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Type.html#initialize-instance_method" title="Idl::Type#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='symbol'>:bits</span><span class='comma'>,</span> <span class='label'>width:</span> <span class='id identifier rubyid_archdef'>archdef</span><span class='period'>.</span><span class='id identifier rubyid_config_params'>config_params</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>XLEN</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Boolean</span><span class='tstring_end'>"</span></span> @@ -295,6 +533,8 @@ <h3 class="signature first" id="type-instance_method"> <span class='const'><span class='object_link'><a href="Type.html" title="Idl::Type (class)">Type</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Type.html#initialize-instance_method" title="Idl::Type#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='symbol'>:bits</span><span class='comma'>,</span> <span class='label'>width:</span> <span class='int'>32</span><span class='rparen'>)</span> <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>U64</span><span class='tstring_end'>"</span></span> <span class='const'><span class='object_link'><a href="Type.html" title="Idl::Type (class)">Type</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Type.html#initialize-instance_method" title="Idl::Type#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='symbol'>:bits</span><span class='comma'>,</span> <span class='label'>width:</span> <span class='int'>64</span><span class='rparen'>)</span> + <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Bits</span><span class='tstring_end'>"</span></span> + <span class='const'><span class='object_link'><a href="Type.html" title="Idl::Type (class)">Type</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Type.html#initialize-instance_method" title="Idl::Type#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='symbol'>:bits</span><span class='comma'>,</span> <span class='label'>width:</span> <span class='ivar'>@bits_expression</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>else</span> <span class='id identifier rubyid_internal_error'>internal_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>TODO: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_text_value'>text_value</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>end</span> @@ -384,15 +624,27 @@ <h3 class="signature " id="type_check-instance_method"> <pre class="lines"> -2438 -2439 -2440</pre> +2831 +2832 +2833 +2834 +2835 +2836 +2837 +2838 +2839</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2438</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2831</span> <span class='kw'>def</span> <span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> - <span class='id identifier rubyid_type_error'>type_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Unimplemented builtin type </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_text_value'>text_value</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>XReg</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Boolean</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>U32</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>U64</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_text_value'>text_value</span><span class='rparen'>)</span> + <span class='kw'>if</span> <span class='ivar'>@type_name</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Bits</span><span class='tstring_end'>"</span></span> + <span class='ivar'>@bits_expression</span><span class='period'>.</span><span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> + <span class='id identifier rubyid_type_error'>type_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Bits width (</span><span class='embexpr_beg'>#{</span><span class='ivar'>@bits_expression</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>) must be positive</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='ivar'>@bits_expression</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_positive?'>positive?</span> + <span class='kw'>end</span> + <span class='kw'>unless</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Bits</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>XReg</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Boolean</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>U32</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>U64</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@type_name</span><span class='rparen'>)</span> + <span class='id identifier rubyid_type_error'>type_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Unimplemented builtin type </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_text_value'>text_value</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> + <span class='kw'>end</span> <span class='kw'>end</span></pre> </td> </tr> @@ -404,7 +656,7 @@ <h3 class="signature " id="type_check-instance_method"> </div> <div id="footer"> - Generated on Fri Jul 12 07:33:11 2024 by + Generated on Thu Jul 18 13:55:46 2024 by <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.36 (ruby-3.2.3). </div> diff --git a/docs/ruby/Idl/BuiltinTypeNameSyntaxNode.html b/docs/ruby/Idl/BuiltinTypeNameSyntaxNode.html new file mode 100644 index 000000000..83678f553 --- /dev/null +++ b/docs/ruby/Idl/BuiltinTypeNameSyntaxNode.html @@ -0,0 +1,202 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> +<title> + Class: Idl::BuiltinTypeNameSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::BuiltinTypeNameSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +2809
    +2810
    +2811
    +2812
    +2813
    +2814
    +2815
    +
    +
    # File 'lib/idl/ast.rb', line 2809
    +
    +def to_ast
    +  if !respond_to?(:i)
    +    BuiltinTypeNameAst.new(input, interval, elements[0].text_value, nil)
    +  else
    +    BuiltinTypeNameAst.new(input, interval, elements[0].text_value, i.to_ast)
    +  end
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/BuiltinVariableAst.html b/docs/ruby/Idl/BuiltinVariableAst.html new file mode 100644 index 000000000..3f3ae8b69 --- /dev/null +++ b/docs/ruby/Idl/BuiltinVariableAst.html @@ -0,0 +1,527 @@ + + + + + + + Class: Idl::BuiltinVariableAst + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::BuiltinVariableAst + + + +

    +
    + +
    +
    Inherits:
    +
    + AstNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb,
    + lib/idl/passes/gen_adoc.rb
    +
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #name ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute name.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(input, interval, name) ⇒ BuiltinVariableAst + + + + + +

    +
    + +

    Returns a new instance of BuiltinVariableAst.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +2114
    +2115
    +2116
    +2117
    +
    +
    # File 'lib/idl/ast.rb', line 2114
    +
    +def initialize(input, interval, name)
    +  super(input, interval, [])
    +  @name = name
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #nameObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute name.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +2112
    +2113
    +2114
    +
    +
    # File 'lib/idl/ast.rb', line 2112
    +
    +def name
    +  @name
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +106
    +107
    +108
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 106
    +
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  name
    +end
    +
    +
    + +
    +

    + + #type(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +2123
    +2124
    +2125
    +2126
    +2127
    +2128
    +2129
    +2130
    +2131
    +2132
    +
    +
    # File 'lib/idl/ast.rb', line 2123
    +
    +def type(symtab)
    +  case @name
    +  when "$encoding"
    +    sz = symtab.get("__instruction_encoding_size")
    +    internal_error "Forgot to set __instruction_encoding_size" if sz.nil?
    +    Type.new(:bits, width: sz.value, qualifiers: [:const])
    +  when "$pc"
    +    Type.new(:bits, width: symtab.archdef.config_params["XLEN"])
    +  end
    +end
    +
    +
    + +
    +

    + + #type_check(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +2119
    +2120
    +2121
    +
    +
    # File 'lib/idl/ast.rb', line 2119
    +
    +def type_check(symtab)
    +  type_error "Not a builtin variable" unless ["$pc", "$encoding"].include?(@name)
    +end
    +
    +
    + +
    +

    + + #value(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +2134
    +2135
    +2136
    +
    +
    # File 'lib/idl/ast.rb', line 2134
    +
    +def value(symtab)
    +  value_error "Cannot know the value of pc or encoding"
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/BuiltinVariableSyntaxNode.html b/docs/ruby/Idl/BuiltinVariableSyntaxNode.html new file mode 100644 index 000000000..f7e7aa169 --- /dev/null +++ b/docs/ruby/Idl/BuiltinVariableSyntaxNode.html @@ -0,0 +1,194 @@ + + + + + + + Class: Idl::BuiltinVariableSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::BuiltinVariableSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +2106
    +2107
    +2108
    +
    +
    # File 'lib/idl/ast.rb', line 2106
    +
    +def to_ast
    +  BuiltinVariableAst.new(input, interval, text_value)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/Compiler.html b/docs/ruby/Idl/Compiler.html index db936c242..13a459f72 100644 --- a/docs/ruby/Idl/Compiler.html +++ b/docs/ruby/Idl/Compiler.html @@ -128,6 +128,28 @@

  • + #compile_expression(expression, symtab, pass_error: false) ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + #compile_file(path, symtab) ⇒ Object @@ -174,7 +196,7 @@

  • - #compile_inst_operation(operation, symtab: SymbolTable.new, name: nil, parent: nil, input_file: nil, input_line: 0) ⇒ Ast + #compile_inst_operation(inst, input_file: nil, input_line: 0) ⇒ Ast @@ -218,6 +240,30 @@

    A new instance of Compiler.

    +

  • + + +
  • + + + #type_check(ast, symtab, what) ⇒ Object + + + + + + + + + + + + + +
    +

    Type check an abstract syntax tree.

    +
    +
  • @@ -298,7 +344,93 @@

    Instance Method Details

    -

    +

    + + #compile_expression(expression, symtab, pass_error: false) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +
    +
    # File 'lib/idl.rb', line 189
    +
    +def compile_expression(expression, symtab, pass_error: false)
    +  m = @parser.parse(expression, root: :expression)
    +  if m.nil?
    +    raise SyntaxError, <<~MSG
    +      While parsing #{expression}:#{@parser.failure_line}:#{@parser.failure_column}
    +
    +      #{@parser.failure_reason}
    +    MSG
    +  end
    +
    +  ast = m.to_ast
    +  begin
    +    ast.type_check(symtab)
    +  rescue AstNode::TypeError => e
    +    raise e if pass_error
    +
    +    warn "Compiling #{expression}"
    +    warn e.what
    +    warn e.backtrace
    +    exit 1
    +  rescue AstNode::InternalError => e
    +    raise e if pass_error
    +
    +    warn "Compiling #{expression}"
    +    warn e.what
    +    warn e.backtrace
    +    exit 1
    +  end
    +
    +  ast
    +end
    +
    +
    + +
    +

    #compile_file(path, symtab) ⇒ Object @@ -358,17 +490,17 @@

    raise "unexpected type #{m.class.name}" unless m.is_a?(IsaAst) - m.make_left + ast = m.to_ast - m.set_input_file(path.to_s) + ast.set_input_file(path.to_s) begin - m.type_check(symtab) + ast.type_check(symtab) rescue AstNode::TypeError, AstNode::InternalError => e warn e.what warn e.bt exit 1 end - m + ast end

  • @@ -632,8 +764,8 @@

    cloned_symtab.pop end - ast = @parser.parse(body, root: :function_body) - if ast.nil? + m = @parser.parse(body, root: :function_body) + if m.nil? raise SyntaxError, <<~MSG While parsing #{parent}::#{name} #{@parser.failure_line}:#{@parser.failure_column} @@ -642,15 +774,15 @@

    end # fix up left recursion - ast.make_left + ast = m.to_ast # type check cloned_symtab.push cloned_symtab.add("__expected_return_type", return_type) unless return_type.nil? begin - ast.func_stmt_list.elements.each do |e| - e.choice.type_check(cloned_symtab) + ast.statements.each do |s| + s.type_check(cloned_symtab) end rescue AstNode::TypeError => e raise e if no_rescue @@ -687,7 +819,7 @@

    - #compile_inst_operation(operation, symtab: SymbolTable.new, name: nil, parent: nil, input_file: nil, input_line: 0) ⇒ Ast + #compile_inst_operation(inst, input_file: nil, input_line: 0) ⇒ Ast @@ -707,16 +839,16 @@

  • - operation + inst - (String) + (Instruction)
    -

    Instruction operation source code

    +

    Instruction object

  • @@ -729,8 +861,6 @@

    (SymbolTable) - (defaults to: SymbolTable.new) - —
    @@ -741,10 +871,10 @@

  • - name + input_file - (String) + (Pathname) (defaults to: nil) @@ -752,80 +882,185 @@

    -

    Function name, used for error messages

    +

    Path to the input file this source comes from

  • - parent + input_line - (String) + (Integer) - (defaults to: nil) + (defaults to: 0)
    -

    Parent class of the function, used for error messages

    +

    Starting line in the input file that this source comes from

  • + + +

    Returns:

    +
      +
    • - input_file + (Ast) - (Pathname) - (defaults to: nil) + — +
      +

      The root of the abstract syntax tree

      +
      + +
    • + +
    + +

    + + + + +
    +
    +
    +
    +146
    +147
    +148
    +149
    +150
    +151
    +152
    +153
    +154
    +155
    +156
    +157
    +158
    +159
    +160
    +161
    +162
    +163
    +
    +
    # File 'lib/idl.rb', line 146
    +
    +def compile_inst_operation(inst, input_file: nil, input_line: 0)
    +  operation = inst["operation()"]
    +  @parser.set_input_file(input_file, input_line)
    +
    +  m = @parser.parse(operation, root: :instruction_operation)
    +  if m.nil?
    +    raise SyntaxError, <<~MSG
    +      While parsing #{input_file}:#{@parser.failure_line}:#{@parser.failure_column}
    +
    +      #{@parser.failure_reason}
    +    MSG
    +  end
    +
    +  # fix up left recursion
    +  ast = m.to_ast
    +  ast.set_input_file("Inst #{inst.name} (#{input_file})", input_line)
    +  ast
    +end
    +
    +

    + +
    +

    + + #type_check(ast, symtab, what) ⇒ Object + + + + + +

    +
    + +

    Type check an abstract syntax tree

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + ast + + + (AstNode) + —
      -

      Path to the input file this source comes from

      +

      An abstract syntax tree

    • - input_line + symtab - (Integer) + (SymbolTable) - (defaults to: 0) + + — +
      +

      The compilation context

      +
      + +
    • + +
    • + + what + + + (String) + —
      -

      Starting line in the input file that this source comes from

      +

      A description of what you are type checking (for error messages)

    -

    Returns:

    -
      +

      Raises:

      +
      • - (Ast) + - — +
        -

        The root of the abstract syntax tree

        +

        AstNode::TypeError if a type error is found

      • @@ -838,29 +1073,6 @@

         
         
        -148
        -149
        -150
        -151
        -152
        -153
        -154
        -155
        -156
        -157
        -158
        -159
        -160
        -161
        -162
        -163
        -164
        -165
        -166
        -167
        -168
        -169
        -170
         171
         172
         173
        @@ -877,54 +1089,25 @@ 

        184 185 186 -187 -188 -189 -190

        +187

    -
    # File 'lib/idl.rb', line 148
    -
    -def compile_inst_operation(operation, symtab: SymbolTable.new, name: nil, parent: nil, input_file: nil, input_line: 0)
    -  @parser.set_input_file(input_file, input_line)
    -
    -  ast = @parser.parse(operation, root: :instruction_operation)
    -  if ast.nil?
    -    raise SyntaxError, <<~MSG
    -      While parsing #{input_file}:#{@parser.failure_line}:#{@parser.failure_column}
    -
    -      #{@parser.failure_reason}
    -    MSG
    -  end
    -
    -  # fix up left recursion
    -  ast.make_left
    +      
    # File 'lib/idl.rb', line 171
     
    +def type_check(ast, symtab, what)
       # type check
    -  symtab.push
    -
    -  begin
    +  begin
         ast.type_check(symtab)
       rescue AstNode::TypeError => e
    -    if name && parent
    -      warn "In function #{name} of #{parent}:"
    -    elsif name && parent.nil?
    -      warn "In function #{name}:"
    -    end
    +    warn "While type checking #{what}:"
         warn e.what
    -    warn e.backtrace
         exit 1
       rescue AstNode::InternalError => e
    -    if name && parent
    -      warn "In function #{name} of #{parent}:"
    -    elsif name && parent.nil?
    -      warn "In function #{name}:"
    -    end
    +    warn "While type checking #{what}:"
         warn e.what
         warn e.backtrace
         exit 1
       end
    -  symtab.pop
     
       ast
     end
    @@ -938,7 +1121,7 @@

    diff --git a/docs/ruby/Idl/ConcatenationExpressionAst.html b/docs/ruby/Idl/ConcatenationExpressionAst.html index f59d576bd..982d0715d 100644 --- a/docs/ruby/Idl/ConcatenationExpressionAst.html +++ b/docs/ruby/Idl/ConcatenationExpressionAst.html @@ -232,6 +232,35 @@

    Return the compile-time-known value of the node.

    + + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
    +
  • @@ -296,10 +325,10 @@

     
     
    -1799
    +2020

    -
    # File 'lib/idl/ast.rb', line 1799
    +      
    # File 'lib/idl/ast.rb', line 2020
     
     def to_idl = "{#{first.to_idl},#{rest.elements.map { |e| e.expression.to_idl }.join(',')}}"
    @@ -391,18 +420,18 @@

     
     
    -1777
    -1778
    -1779
    -1780
    -1781
    -1782
    -1783
    -1784
    -1785
    +1997 +1998 +1999 +2000 +2001 +2002 +2003 +2004 +2005

    -
    # File 'lib/idl/ast.rb', line 1777
    +      
    # File 'lib/idl/ast.rb', line 1997
     
     def type(symtab)
       total_width = first.type(symtab).width
    @@ -498,22 +527,22 @@ 

     
     
    -1762
    -1763
    -1764
    -1765
    -1766
    -1767
    -1768
    -1769
    -1770
    -1771
    -1772
    -1773
    -1774
    +1982 +1983 +1984 +1985 +1986 +1987 +1988 +1989 +1990 +1991 +1992 +1993 +1994

    -
    # File 'lib/idl/ast.rb', line 1762
    +      
    # File 'lib/idl/ast.rb', line 1982
     
     def type_check(symtab)
       first.type_check(symtab)
    @@ -559,31 +588,129 @@ 

     
     
    -1788
    -1789
    -1790
    -1791
    -1792
    -1793
    -1794
    -1795
    -1796
    +2008 +2009 +2010 +2011 +2012 +2013 +2014 +2015 +2016 +2017

    -
    # File 'lib/idl/ast.rb', line 1788
    +      
    # File 'lib/idl/ast.rb', line 2008
     
     def value(symtab)
    -  result = first.value(symtab)
    -  total_width = first.type(symtab).width
    -  rest.elements.each do |e|
    +  result = 0
    +  total_width = 0
    +  rest.elements.reverse_each do |e|
         result |= (e.expression.value(symtab) << total_width)
         total_width += e.expression.type(symtab).width
       end
    +  result |= first.value(symtab) << total_width
       result
     end
    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -591,7 +718,7 @@

    diff --git a/docs/ruby/Idl/ConditionalReturnStatementAst.html b/docs/ruby/Idl/ConditionalReturnStatementAst.html index 3352254af..4d6ada231 100644 --- a/docs/ruby/Idl/ConditionalReturnStatementAst.html +++ b/docs/ruby/Idl/ConditionalReturnStatementAst.html @@ -164,6 +164,28 @@

    +
    + + + + +
  • + + + #return_values(symtab) ⇒ Object + + + + + + + + + + + + +
  • @@ -203,12 +225,12 @@

     
     
    -2395
    -2396
    -2397
    +2775 +2776 +2777

    -
    # File 'lib/idl/ast.rb', line 2395
    +      
    # File 'lib/idl/ast.rb', line 2775
     
     def condition
       expression
    @@ -233,20 +255,20 @@ 

     
     
    -2399
    -2400
    -2401
    -2402
    -2403
    -2404
    -2405
    -2406
    -2407
    -2408
    -2409
    +2780 +2781 +2782 +2783 +2784 +2785 +2786 +2787 +2788 +2789 +2790

    -
    # File 'lib/idl/ast.rb', line 2399
    +      
    # File 'lib/idl/ast.rb', line 2780
     
     def return_value(symtab)
       cond = condition.value(symtab)
    @@ -262,6 +284,48 @@ 

    + + +
    +

    + + #return_values(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +2793
    +2794
    +2795
    +2796
    +2797
    +2798
    +2799
    +2800
    +2801
    +
    +
    # File 'lib/idl/ast.rb', line 2793
    +
    +def return_values(symtab)
    +  cond = condition.value(symtab)
    +
    +  cond ? return_value_nodes.map { |n| n.values(symtab) }.flatten.uniq : []
    +
    +rescue ValueError
    +  # condition isn't known, so the return value is always possible
    +  return_value_nodes.map { |n| n.values(symtab) }.flatten
    +end
    +
    @@ -269,7 +333,7 @@

    diff --git a/docs/ruby/Idl/ConditionalStatementAst.html b/docs/ruby/Idl/ConditionalStatementAst.html index c84feb74b..042a402d2 100644 --- a/docs/ruby/Idl/ConditionalStatementAst.html +++ b/docs/ruby/Idl/ConditionalStatementAst.html @@ -69,7 +69,7 @@
    Inherits:
    - StatementAst + AstNode @@ -100,7 +98,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/prune.rb,
    lib/idl/passes/gen_adoc.rb
    +
    @@ -125,6 +125,69 @@

    Overview

    +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #action ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute action.

      +
      + +
    • + + +
    • + + + #condition ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute condition.

      +
      + +
    • + + +
    + @@ -139,7 +202,7 @@

  • - #action ⇒ Object + #execute(symtab) ⇒ void @@ -153,7 +216,9 @@

    -
    +
    +

    “execute” the statement by updating the variables in the symbol table.

    +

  • @@ -161,7 +226,7 @@

  • - #condition ⇒ Object + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object @@ -183,7 +248,33 @@

  • - #execute(symtab) ⇒ Object + #initialize(action, condition) ⇒ ConditionalStatementAst + + + + + + + constructor + + + + + + + + +
    +

    A new instance of ConditionalStatementAst.

    +
    + +
  • + + +
  • + + + #prune(symtab) ⇒ Object @@ -199,6 +290,30 @@

    +

  • + + +
  • + + + #to_idl ⇒ String + + + + + + + + + + + + + +
    +

    Return valid IDL representation of the node (and its subtree).

    +
    +
  • @@ -235,108 +350,370 @@

    +
    +

    Constructor Details

    +
    +

    + #initialize(action, condition) ⇒ ConditionalStatementAst + + +

    +
    + +

    Returns a new instance of ConditionalStatementAst.

    -
    -

    Instance Method Details

    +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +2558
    +2559
    +2560
    +2561
    +2562
    +
    +
    # File 'lib/idl/ast.rb', line 2558
    +
    +def initialize(action, condition)
    +  super(action.input, action.interval.first..action.interval.end, [action, condition])
    +  @action = action
    +  @condition = condition
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + +

    - #actionObject + #actionObject (readonly) -

    +
    +
    + +

    Returns the value of attribute action.

    + + +
    +
    +
    + + +
     
     
    -2224
    +2556 +2557 +2558
    -
    # File 'lib/idl/ast.rb', line 2224
    +      
    # File 'lib/idl/ast.rb', line 2556
     
    -def action = a
    +def action + @action +end
    + +

    - #conditionObject + #conditionObject (readonly) -

    +
    +
    + +

    Returns the value of attribute condition.

    + + +
    +
    +
    + + +
     
     
    -2226
    -2227
    -2228
    +2556 +2557 +2558
    -
    # File 'lib/idl/ast.rb', line 2226
    +      
    # File 'lib/idl/ast.rb', line 2556
     
     def condition
    -  expression
    +  @condition
     end
    -
    -

    +

    + + +
    +

    Instance Method Details

    + + +
    +

    - #execute(symtab) ⇒ Object + #execute(symtab) ⇒ void -

    +
    +
    +

    This method returns an undefined value.

    +

    “execute” the statement by updating the variables in the symbol table

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The symbol table for the context

      +
      + +
    • + +
    + +

    Raises:

    +
      + +
    • + + + + + + + +
      +

      ValueError if some part of the statement cannot be executed at compile time

      +
      + +
    • + +
    + +
     
     
    -2230
    -2231
    -2232
    -2233
    -2234
    -2235
    -2236
    +2572 +2573 +2574 +2575 +2576 +2577 +2578
    -
    # File 'lib/idl/ast.rb', line 2230
    +      
    # File 'lib/idl/ast.rb', line 2572
     
     def execute(symtab)
    -  cond = condition.value(symtab)
    +  cond = @condition.value(symtab)
     
       if (cond)
    -    action.execute(symtab)
    +    @action.execute(symtab)
       end
     end
    +
    + +
    +

    + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +172
    +173
    +174
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 172
    +
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  "#{action.gen_adoc(indent, indent_spaces:)} if (#{condition.gen_adoc(0, indent_spaces:)});"
    +end
    +
    +
    + +
    +

    + + #prune(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +
    +
    # File 'lib/idl/passes/prune.rb', line 203
    +
    +def prune(symtab)
    +  if condition.value(symtab)
    +    StatementAst.new(action.prune(symtab))
    +  else
    +    NoopAst.new()
    +  end
    +rescue ValueError
    +  # condition not known
    +  ConditionalStatementAst.new(action.prune(symtab), condition.prune(symtab))
    +end
    +
    +
    + +
    +

    + + #to_idlString + + + + + +

    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +2581
    +2582
    +2583
    +
    +
    # File 'lib/idl/ast.rb', line 2581
    +
    +def to_idl
    +  "#{@action.to_idl} if (#{@condition.to_idl});"
    +end
    +
    @@ -419,19 +796,19 @@

     
     
    -2218
    -2219
    -2220
    -2221
    -2222
    +2565 +2566 +2567 +2568 +2569

  • -
    # File 'lib/idl/ast.rb', line 2218
    +      
    # File 'lib/idl/ast.rb', line 2565
     
     def type_check(symtab)
    -  action.type_check(symtab)
    -  condition.type_check(symtab)
    -  type_error "condition is not boolean" unless condition.type(symtab).convertable_to?(:boolean)
    +  @action.type_check(symtab)
    +  @condition.type_check(symtab)
    +  type_error "condition is not boolean" unless @condition.type(symtab).convertable_to?(:boolean)
     end
    @@ -443,7 +820,7 @@

    diff --git a/docs/ruby/Idl/ConditionalStatementSyntaxNode.html b/docs/ruby/Idl/ConditionalStatementSyntaxNode.html new file mode 100644 index 000000000..ebbb6cfd4 --- /dev/null +++ b/docs/ruby/Idl/ConditionalStatementSyntaxNode.html @@ -0,0 +1,194 @@ + + + + + + + Class: Idl::ConditionalStatementSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::ConditionalStatementSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +2546
    +2547
    +2548
    +
    +
    # File 'lib/idl/ast.rb', line 2546
    +
    +def to_ast
    +  ConditionalStatementAst.new(a.to_ast, expression.to_ast)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/CsrFieldReadExpressionAst.html b/docs/ruby/Idl/CsrFieldReadExpressionAst.html index bb0d6b9d1..600fee921 100644 --- a/docs/ruby/Idl/CsrFieldReadExpressionAst.html +++ b/docs/ruby/Idl/CsrFieldReadExpressionAst.html @@ -103,7 +103,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/gen_adoc.rb
    +
    @@ -206,6 +208,28 @@

    +
    + + + + +
  • + + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + + + + + + + + +
  • @@ -304,6 +328,35 @@

    Return the compile-time-known value of the node.

    + + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
    +
  • @@ -339,23 +392,23 @@

     
     
    -3290
    -3291
    -3292
    -3293
    -3294
    -3295
    -3296
    -3297
    -3298
    +4110 +4111 +4112 +4113 +4114 +4115 +4116 +4117 +4118

    -
    # File 'lib/idl/ast.rb', line 3290
    +      
    # File 'lib/idl/ast.rb', line 4110
     
     def csr_def(symtab)
       archdef = symtab.archdef
     
    -  if idx.is_a?(IntAst)
    +  if idx.is_a?(IntLiteralAst)
         archdef.implemented_csrs.find { |c| c.address == idx.value(symtab) }
       else
         archdef.implemented_csrs.find { |c| c.name == idx.text_value }
    @@ -381,12 +434,12 @@ 

     
     
    -3300
    -3301
    -3302
    +4120 +4121 +4122

    -
    # File 'lib/idl/ast.rb', line 3300
    +      
    # File 'lib/idl/ast.rb', line 4120
     
     def csr_name(symtab)
       csr_def(symtab).name
    @@ -411,12 +464,12 @@ 

     
     
    -3304
    -3305
    -3306
    +4124 +4125 +4126

    -
    # File 'lib/idl/ast.rb', line 3304
    +      
    # File 'lib/idl/ast.rb', line 4124
     
     def field_def(symtab)
       csr_def(symtab).implemented_fields.find { |f| f.name == csr_field_name.text_value }
    @@ -441,12 +494,12 @@ 

     
     
    -3308
    -3309
    -3310
    +4128 +4129 +4130

    -
    # File 'lib/idl/ast.rb', line 3308
    +      
    # File 'lib/idl/ast.rb', line 4128
     
     def field_name(symtab)
       field_def(symtab).name
    @@ -454,6 +507,46 @@ 

    + + +
    +

    + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +200
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 193
    +
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  csr_text = "CSR[#{idx.text_value}].#{csr_field_name.text_value}"
    +  if idx.text_value =~ /[0-9]+/
    +    csr_text
    +  else
    +    "%%LINK%csr_field;#{idx.text_value}.#{csr_field_name.text_value};#{csr_text}%%"
    +  end
    +end
    +
    @@ -500,19 +593,19 @@

     
     
    -3313
    -3314
    -3315
    -3316
    -3317
    -3318
    -3319
    +4133 +4134 +4135 +4136 +4137 +4138 +4139

    -
    # File 'lib/idl/ast.rb', line 3313
    +      
    # File 'lib/idl/ast.rb', line 4133
     
     def to_idl
    -  if idx.is_a?(IntAst)
    +  if idx.is_a?(IntLiteralAst)
         "CSR[#{idx.to_idl}].#{csr_field_name.text_value}"
       else
         "CSR[#{idx.text_value}].#{csr_field_name.text_value}"
    @@ -607,21 +700,21 @@ 

     
     
    -3322
    -3323
    -3324
    -3325
    -3326
    -3327
    -3328
    -3329
    -3330
    -3331
    -3332
    -3333
    +4142 +4143 +4144 +4145 +4146 +4147 +4148 +4149 +4150 +4151 +4152 +4153

    -
    # File 'lib/idl/ast.rb', line 3322
    +      
    # File 'lib/idl/ast.rb', line 4142
     
     def type(symtab)
       fd = field_def(symtab)
    @@ -720,30 +813,22 @@ 

     
     
    -3275
    -3276
    -3277
    -3278
    -3279
    -3280
    -3281
    -3282
    -3283
    -3284
    -3285
    -3286
    -3287
    -3288
    +4099 +4100 +4101 +4102 +4103 +4104 +4105 +4106 +4107 +4108

    -
    # File 'lib/idl/ast.rb', line 3275
    +      
    # File 'lib/idl/ast.rb', line 4099
     
     def type_check(symtab)
    -  archdef = symtab.archdef
    -
    -
    -
    -  if idx.is_a?(IntAst)
    +  if idx.is_a?(IntLiteralAst)
         type_error "No CSR at address #{idx.text_value}" if csr_def(symtab).nil?
       else
         # idx is a csr name
    @@ -783,13 +868,13 @@ 

     
     
    -3336
    -3337
    -3338
    -3339
    +4156 +4157 +4158 +4159

    -
    # File 'lib/idl/ast.rb', line 3336
    +      
    # File 'lib/idl/ast.rb', line 4156
     
     def value(symtab)
       value_error "'#{csr_name(symtab)}.#{field_name(symtab)}' is not RO" unless field_def(symtab).type == "RO"
    @@ -798,6 +883,102 @@ 

    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -805,7 +986,7 @@

    diff --git a/docs/ruby/Idl/CsrReadExpressionAst.html b/docs/ruby/Idl/CsrReadExpressionAst.html index 5f2b14597..c7f1be196 100644 --- a/docs/ruby/Idl/CsrReadExpressionAst.html +++ b/docs/ruby/Idl/CsrReadExpressionAst.html @@ -103,7 +103,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/gen_adoc.rb
    +
    @@ -186,6 +188,52 @@

    + + + +
  • + + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + #to_idl ⇒ String + + + + + + + + + + + + + +
    +

    Return valid IDL representation of the node (and its subtree).

    +
    +
  • @@ -254,7 +302,38 @@

    -
    +
    +

    Return the compile-time-known value of the node.

    +
    + + + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
  • @@ -291,29 +370,29 @@

     
     
    -3382
    -3383
    -3384
    -3385
    -3386
    -3387
    -3388
    -3389
    -3390
    -3391
    -3392
    -3393
    -3394
    -3395
    -3396
    -3397
    -3398
    -3399
    -3400
    -3401
    +4202 +4203 +4204 +4205 +4206 +4207 +4208 +4209 +4210 +4211 +4212 +4213 +4214 +4215 +4216 +4217 +4218 +4219 +4220 +4221

    -
    # File 'lib/idl/ast.rb', line 3382
    +      
    # File 'lib/idl/ast.rb', line 4202
     
     def csr_def(symtab)
       archdef = symtab.archdef
    @@ -377,12 +456,12 @@ 

     
     
    -3403
    -3404
    -3405
    +4223 +4224 +4225

    -
    # File 'lib/idl/ast.rb', line 3403
    +      
    # File 'lib/idl/ast.rb', line 4223
     
     def csr_known?(symtab)
       !csr_def(symtab).nil?
    @@ -407,14 +486,14 @@ 

     
     
    -3407
    -3408
    -3409
    -3410
    -3411
    +4227 +4228 +4229 +4230 +4231

    -
    # File 'lib/idl/ast.rb', line 3407
    +      
    # File 'lib/idl/ast.rb', line 4227
     
     def csr_name(symtab)
       internal_error "No CSR" unless csr_known?(symtab)
    @@ -424,6 +503,101 @@ 

    + + +
    +

    + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 204
    +
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  csr_text = "CSR[#{idx.text_value}]"
    +  if idx.text_value =~ /[0-9]+/
    +    csr_text
    +  else
    +    "%%LINK%csr;#{idx.text_value};#{csr_text}%%"
    +  end
    +end
    +
    +
    + +
    +

    + + #to_idlString + + + + + +

    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +4244
    +
    +
    # File 'lib/idl/ast.rb', line 4244
    +
    +def to_idl = "CSR[#{idx.text_value}]"
    +
    @@ -510,21 +684,21 @@

     
     
    -3346
    -3347
    -3348
    -3349
    -3350
    -3351
    -3352
    -3353
    -3354
    -3355
    -3356
    -3357
    +4166 +4167 +4168 +4169 +4170 +4171 +4172 +4173 +4174 +4175 +4176 +4177

    -
    # File 'lib/idl/ast.rb', line 3346
    +      
    # File 'lib/idl/ast.rb', line 4166
     
     def type(symtab)
       archdef = symtab.archdef
    @@ -623,30 +797,30 @@ 

     
     
    -3360
    -3361
    -3362
    -3363
    -3364
    -3365
    -3366
    -3367
    -3368
    -3369
    -3370
    -3371
    -3372
    -3373
    -3374
    -3375
    -3376
    -3377
    -3378
    -3379
    -3380
    +4180 +4181 +4182 +4183 +4184 +4185 +4186 +4187 +4188 +4189 +4190 +4191 +4192 +4193 +4194 +4195 +4196 +4197 +4198 +4199 +4200

    -
    # File 'lib/idl/ast.rb', line 3360
    +      
    # File 'lib/idl/ast.rb', line 4180
     
     def type_check(symtab)
       archdef = symtab.archdef
    @@ -683,23 +857,34 @@ 

    -

    +
    +
    + +

    Return the compile-time-known value of the node

    + + +
    +
    +
    + + +
     
     
    -3413
    -3414
    -3415
    -3416
    -3417
    -3418
    -3419
    -3420
    +4234 +4235 +4236 +4237 +4238 +4239 +4240 +4241
    -
    # File 'lib/idl/ast.rb', line 3413
    +      
    # File 'lib/idl/ast.rb', line 4234
     
     def value(symtab)
       cd = csr_def(symtab)
    @@ -712,6 +897,102 @@ 

    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -719,7 +1000,7 @@

    diff --git a/docs/ruby/Idl/CsrSoftwareReadAst.html b/docs/ruby/Idl/CsrSoftwareReadAst.html index bc60fcf93..b3e50e3ba 100644 --- a/docs/ruby/Idl/CsrSoftwareReadAst.html +++ b/docs/ruby/Idl/CsrSoftwareReadAst.html @@ -186,6 +186,30 @@

    + + + +
  • + + + #to_idl ⇒ String + + + + + + + + + + + + + +
    +

    Return valid IDL representation of the node (and its subtree).

    +
    +
  • @@ -252,6 +276,35 @@

    + + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
    +
  • @@ -287,12 +340,12 @@

     
     
    -3476
    -3477
    -3478
    +4306 +4307 +4308

    -
    # File 'lib/idl/ast.rb', line 3476
    +      
    # File 'lib/idl/ast.rb', line 4306
     
     def csr_def(symtab)
       csr.csr_def(symtab)
    @@ -339,12 +392,12 @@ 

     
     
    -3468
    -3469
    -3470
    +4298 +4299 +4300

    -
    # File 'lib/idl/ast.rb', line 3468
    +      
    # File 'lib/idl/ast.rb', line 4298
     
     def csr_known?(symtab)
       csr.csr_known?(symtab)
    @@ -369,12 +422,12 @@ 

     
     
    -3472
    -3473
    -3474
    +4302 +4303 +4304

    -
    # File 'lib/idl/ast.rb', line 3472
    +      
    # File 'lib/idl/ast.rb', line 4302
     
     def csr_name(symtab)
       csr.csr_name(symtab)
    @@ -382,6 +435,61 @@ 

    + + +
    +

    + + #to_idlString + + + + + +

    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +4320
    +
    +
    # File 'lib/idl/ast.rb', line 4320
    +
    +def to_idl = "CSR[#{csr.to_idl}].sw_read()"
    +
    @@ -399,18 +507,18 @@

     
     
    -3458
    -3459
    -3460
    -3461
    -3462
    -3463
    -3464
    -3465
    -3466
    +4288 +4289 +4290 +4291 +4292 +4293 +4294 +4295 +4296

    -
    # File 'lib/idl/ast.rb', line 3458
    +      
    # File 'lib/idl/ast.rb', line 4288
     
     def type(symtab)
       archdef = symtab.archdef
    @@ -441,12 +549,12 @@ 

     
     
    -3454
    -3455
    -3456
    +4284 +4285 +4286

    -
    # File 'lib/idl/ast.rb', line 3454
    +      
    # File 'lib/idl/ast.rb', line 4284
     
     def type_check(symtab)
       csr.type_check(symtab)
    @@ -488,19 +596,19 @@ 

     
     
    -3481
    -3482
    -3483
    -3484
    -3485
    -3486
    -3487
    +4311 +4312 +4313 +4314 +4315 +4316 +4317

    -
    # File 'lib/idl/ast.rb', line 3481
    +      
    # File 'lib/idl/ast.rb', line 4311
     
     def value(symtab)
    -  value_error "CSR not knowable" unless csr_known?
    +  value_error "CSR not knowable" unless csr_known?(symtab)
       cd = csr_def(symtab)
       cd.fields.each { |f| value_error "#{csr_name}.#{f.name} not RO" unless f.type == "RO" }
     
    @@ -509,6 +617,102 @@ 

    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -516,7 +720,7 @@

    diff --git a/docs/ruby/Idl/CsrSoftwareWriteAst.html b/docs/ruby/Idl/CsrSoftwareWriteAst.html index f157c8608..eebac8080 100644 --- a/docs/ruby/Idl/CsrSoftwareWriteAst.html +++ b/docs/ruby/Idl/CsrSoftwareWriteAst.html @@ -170,17 +170,12 @@

  • - #execute(symtab) ⇒ void + #execute(_symtab) ⇒ void - - included - from Executable - - @@ -193,6 +188,30 @@

    “execute” the statement by updating the variables in the symbol table.

    +

  • + + +
  • + + + #to_idl ⇒ String + + + + + + + + + + + + + +
    +

    Return valid IDL representation of the node (and its subtree).

    +
    +
  • @@ -235,7 +254,9 @@

    -
    +
    +

    Return the compile-time-known value of the node.

    +
    @@ -294,12 +315,12 @@

     
     
    -3437
    -3438
    -3439
    +4261 +4262 +4263

    -
    # File 'lib/idl/ast.rb', line 3437
    +      
    # File 'lib/idl/ast.rb', line 4261
     
     def csr_known?(symtab)
       csr.csr_known?(symtab)
    @@ -324,12 +345,12 @@ 

     
     
    -3441
    -3442
    -3443
    +4265 +4266 +4267

    -
    # File 'lib/idl/ast.rb', line 3441
    +      
    # File 'lib/idl/ast.rb', line 4265
     
     def csr_name(symtab)
       csr.csr_name(symtab)
    @@ -342,17 +363,12 @@ 

    - #execute(symtab) ⇒ void + #execute(_symtab) ⇒ void - - Originally defined in module - Executable - -

    This method returns an undefined value.

    @@ -402,7 +418,76 @@

    +

    + + + + +
    +
    +
    +
    +4275
    +
    +
    # File 'lib/idl/ast.rb', line 4275
    +
    +def execute(_symtab) = value_error "CSR writes are global"
    +
    + +
    +

    + + #to_idlString + + + + + +

    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +4278
    +
    +
    # File 'lib/idl/ast.rb', line 4278
    +
    +def to_idl = "CSR[#{csr.to_idl}].sw_write(#{expression.to_idl})"
    +
    @@ -420,19 +505,19 @@

     
     
    -3426
    -3427
    -3428
    -3429
    -3430
    -3431
    -3432
    -3433
    -3434
    -3435
    +4250 +4251 +4252 +4253 +4254 +4255 +4256 +4257 +4258 +4259

    -
    # File 'lib/idl/ast.rb', line 3426
    +      
    # File 'lib/idl/ast.rb', line 4250
     
     def type_check(symtab)
       archdef = symtab.archdef
    @@ -458,18 +543,29 @@ 

    -

    +
    +
    + +

    Return the compile-time-known value of the node

    + + +
    +
    +
    + + +
    @@ -578,17 +665,17 @@

     
     
    -609
    -610
    -611
    -612
    -613
    -614
    -615
    -616
    +645 +646 +647 +648 +649 +650 +651 +652

    @@ -887,10 +972,10 @@

     
     
    -603
    +639

    @@ -903,7 +988,7 @@

    diff --git a/docs/ruby/Idl/EnumRefAst.html b/docs/ruby/Idl/EnumRefAst.html index ba26f888f..a1e818278 100644 --- a/docs/ruby/Idl/EnumRefAst.html +++ b/docs/ruby/Idl/EnumRefAst.html @@ -103,7 +103,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/gen_adoc.rb
    +
    @@ -143,6 +145,98 @@

  • + #class_name ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + #gen_adoc(indent, indent_spaces: 2) ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + #initialize(input, interval, class_name, member_name) ⇒ EnumRefAst + + + + + + + constructor + + + + + + + + +
    +

    A new instance of EnumRefAst.

    +
    + +
  • + + +
  • + + + #member_name ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + #to_idl ⇒ String @@ -229,6 +323,35 @@

    +

  • + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
    +
  • @@ -243,14 +366,147 @@

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(input, interval, class_name, member_name) ⇒ EnumRefAst + + + + + +

    +
    + +

    Returns a new instance of EnumRefAst.

    + + +
    +
    +
    + + +

     
     
    -3445
    -3446
    -3447
    +4270 +4271 +4272
    -
    # File 'lib/idl/ast.rb', line 3445
    +      
    # File 'lib/idl/ast.rb', line 4270
     
     def value(_symtab)
       value_error "CSR writes are global"
    @@ -484,7 +580,7 @@ 

    diff --git a/docs/ruby/Idl/CsrType.html b/docs/ruby/Idl/CsrType.html index 2e1d54179..0b0100249 100644 --- a/docs/ruby/Idl/CsrType.html +++ b/docs/ruby/Idl/CsrType.html @@ -243,12 +243,12 @@

     
     
    -411
    -412
    -413
    +422 +423 +424

    -
    # File 'lib/idl/type.rb', line 411
    +      
    # File 'lib/idl/type.rb', line 422
     
     def initialize(csr, qualifiers: [])
       super(:csr, name: csr.name, csr: csr, qualifiers: qualifiers)
    @@ -291,12 +291,12 @@ 

     
     
    -409
    -410
    -411
    +420 +421 +422

    -
    # File 'lib/idl/type.rb', line 409
    +      
    # File 'lib/idl/type.rb', line 420
     
     def csr
       @csr
    @@ -328,12 +328,12 @@ 

     
     
    -415
    -416
    -417
    +426 +427 +428

    -
    # File 'lib/idl/type.rb', line 415
    +      
    # File 'lib/idl/type.rb', line 426
     
     def fields
       @csr.fields
    @@ -348,7 +348,7 @@ 

    diff --git a/docs/ruby/Idl/CsrWriteAst.html b/docs/ruby/Idl/CsrWriteAst.html index ff3981df9..b7763d0ed 100644 --- a/docs/ruby/Idl/CsrWriteAst.html +++ b/docs/ruby/Idl/CsrWriteAst.html @@ -148,7 +148,7 @@

  • - #execute(symtab) ⇒ Object + #execute(symtab) ⇒ void @@ -162,7 +162,9 @@

    -
    +
    +

    “execute” the statement by updating the variables in the symbol table.

    +

  • @@ -192,7 +194,7 @@

  • - #type(symtab) ⇒ Object + #to_idl ⇒ String @@ -206,7 +208,9 @@

    -
    +
    +

    Return valid IDL representation of the node (and its subtree).

    +

  • @@ -214,7 +218,7 @@

  • - #type_check(symtab) ⇒ Object + #type(symtab) ⇒ Type @@ -228,7 +232,33 @@

    -
    +
    +

    Given a specific symbol table, return the type of this node.

    +
    + +

  • + + +
  • + + + #type_check(symtab) ⇒ void + + + + + + + + + + + + + +
    +

    type check this node and all children.

    +
  • @@ -265,24 +295,24 @@

     
     
    -3506
    -3507
    -3508
    -3509
    -3510
    -3511
    -3512
    -3513
    -3514
    -3515
    -3516
    +4340 +4341 +4342 +4343 +4344 +4345 +4346 +4347 +4348 +4349 +4350

    -
    # File 'lib/idl/ast.rb', line 3506
    +      
    # File 'lib/idl/ast.rb', line 4340
     
     def csr_def(symtab)
       index =
    -    if idx.is_a?(IntAst)
    +    if idx.is_a?(IntLiteralAst)
           # make sure this value is a defined CSR
           symtab.archdef.csrs.index { |csr| csr.address == idx.text_value.to_i }
         else
    @@ -299,24 +329,73 @@ 

    - #execute(symtab) ⇒ Object + #execute(symtab) ⇒ void -

    +
    +
    +

    This method returns an undefined value.

    +

    “execute” the statement by updating the variables in the symbol table

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The symbol table for the context

      +
      + +
    • + +
    + +

    Raises:

    +
      + +
    • + + + + + + + +
      +

      ValueError if some part of the statement cannot be executed at compile time

      +
      + +
    • + +
    + +
     
     
    -3526
    -3527
    -3528
    +4362 +4363 +4364
    -
    # File 'lib/idl/ast.rb', line 3526
    +      
    # File 'lib/idl/ast.rb', line 4362
     
     def execute(symtab)
       value_error "CSR write"
    @@ -341,12 +420,12 @@ 

     
     
    -3522
    -3523
    -3524
    +4357 +4358 +4359

    -
    # File 'lib/idl/ast.rb', line 3522
    +      
    # File 'lib/idl/ast.rb', line 4357
     
     def name(symtab)
       csr_def(symtab).name
    @@ -354,29 +433,153 @@ 

    +
    + +
    +

    + + #to_idlString + + + + + +

    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +4367
    +
    +
    # File 'lib/idl/ast.rb', line 4367
    +
    +def to_idl = "CSR[#{idx.text_value}]"
    +

    - #type(symtab) ⇒ Object + #type(symtab) ⇒ Type -

    +
    +
    + +

    Given a specific symbol table, return the type of this node.

    + +

    Should not be called until #type_check is called with the same arguments

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      Symbol table for lookup

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Type) + + + + — +
      +

      The type of the node

      +
      + +
    • + +
    +

    Raises:

    +
      + +
    • + + + (AstNode::InternalError) + + + + — +
      +

      if the type is dependent on symtab, and type_check was not called first

      +
      + +
    • + +
    + +
    @@ -390,12 +490,12 @@

     
     
    -2252
    -2253
    -2254
    +2609 +2610 +2611

     
     
    -3518
    -3519
    -3520
    +4353 +4354 +4355
    -
    # File 'lib/idl/ast.rb', line 3518
    +      
    # File 'lib/idl/ast.rb', line 4353
     
     def type(symtab)
       CsrType.new(csr_def(symtab))
    @@ -389,36 +592,101 @@ 

    - #type_check(symtab) ⇒ Object + #type_check(symtab) ⇒ void -

    +
    +
    +

    This method returns an undefined value.

    +

    type check this node and all children

    + +

    Calls to #type and/or #value may depend on type_check being called first with the same symtab. If not, those functions may raise an AstNode::InternalError

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      Symbol table for lookup

      +
      + +
    • + +
    + +

    Raises:

    + + +
    @@ -322,12 +351,12 @@

     
     
    -2286
    -2287
    -2288
    +2643 +2644 +2645

     
     
    -3493
    -3494
    -3495
    -3496
    -3497
    -3498
    -3499
    -3500
    -3501
    -3502
    -3503
    -3504
    +4327 +4328 +4329 +4330 +4331 +4332 +4333 +4334 +4335 +4336 +4337 +4338
    -
    # File 'lib/idl/ast.rb', line 3493
    +      
    # File 'lib/idl/ast.rb', line 4327
     
     def type_check(symtab)
    -  if idx.is_a?(IntAst)
    +  if idx.is_a?(IntLiteralAst)
         # make sure this value is a defined CSR
         index = symtab.archdef.csrs.index { |csr| csr.address == idx.value(symtab) }
         type_error "No csr number '#{idx.value(symtab)}' was found" if index.nil?
    @@ -439,7 +707,7 @@ 

    diff --git a/docs/ruby/Idl/Declaration.html b/docs/ruby/Idl/Declaration.html new file mode 100644 index 000000000..262b1e952 --- /dev/null +++ b/docs/ruby/Idl/Declaration.html @@ -0,0 +1,232 @@ + + + + + + + Module: Idl::Declaration + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: Idl::Declaration + + + +

    +
    + + + + + + + + + +
    +
    Included in:
    +
    MultiVariableDeclarationAst, VariableDeclarationAst, VariableDeclarationWithInitializationAst
    +
    + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + +

    Overview

    +
    + +

    interface for any AstNode that introduces a new symbol into scope

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #add_symbol(symtab) ⇒ Object + + + + + +

    +
    + +

    Add symbol(s) at the outermost scope of the symbol table

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      Symbol table at the scope that the symbol(s) will be inserted

      +
      + +
    • + +
    + +

    Raises:

    +
      + +
    • + + + (NotImplementedError) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +416
    +
    +
    # File 'lib/idl/ast.rb', line 416
    +
    +def add_symbol(symtab) = raise NotImplementedError, "#{self.class.name} must implment add_symbol"
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/DontCareLvalueAst.html b/docs/ruby/Idl/DontCareLvalueAst.html index b72cc2f03..d1547d37d 100644 --- a/docs/ruby/Idl/DontCareLvalueAst.html +++ b/docs/ruby/Idl/DontCareLvalueAst.html @@ -212,6 +212,35 @@

    Return the compile-time-known value of the node.

    + + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
    +
  • @@ -247,10 +276,10 @@

     
     
    -2293
    +2650

    -
    # File 'lib/idl/ast.rb', line 2293
    +      
    # File 'lib/idl/ast.rb', line 2650
     
     def to_idl = "-"
    -
    # File 'lib/idl/ast.rb', line 2286
    +      
    # File 'lib/idl/ast.rb', line 2643
     
     def type(_symtab, _archdef)
       Type.new(:dontcare)
    @@ -352,12 +381,12 @@ 

     
     
    -2281
    -2282
    -2283
    +2638 +2639 +2640

    -
    # File 'lib/idl/ast.rb', line 2281
    +      
    # File 'lib/idl/ast.rb', line 2638
     
     def type_check(_symtab)
       # nothing to do!
    @@ -463,15 +492,111 @@ 

     
     
    -2291
    +2648

    -
    # File 'lib/idl/ast.rb', line 2291
    +      
    # File 'lib/idl/ast.rb', line 2648
     
     def value(_symtab, _archdef) = internal_error "Why are you calling value for an lval?"
    +
    + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -479,7 +604,7 @@

    diff --git a/docs/ruby/Idl/DontCareReturnAst.html b/docs/ruby/Idl/DontCareReturnAst.html index d0b472c78..be51be040 100644 --- a/docs/ruby/Idl/DontCareReturnAst.html +++ b/docs/ruby/Idl/DontCareReturnAst.html @@ -142,6 +142,32 @@

  • + #initialize(input, interval) ⇒ DontCareReturnAst + + + + + + + constructor + + + + + + + + +
    +

    A new instance of DontCareReturnAst.

    +
    + +
  • + + +
  • + + #set_expected_type(t) ⇒ Object @@ -250,6 +276,35 @@

    Return the compile-time-known value of the node.

    +

  • + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
    +
  • @@ -264,7 +319,52 @@

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(input, interval) ⇒ DontCareReturnAst + + + + + +

    +
    + +

    Returns a new instance of DontCareReturnAst.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +2599
    +2600
    +2601
    +
    +
    # File 'lib/idl/ast.rb', line 2599
    +
    +def initialize(input, interval)
    +  super(input, interval, [])
    +end
    +
    +
    +
    +

    Instance Method Details

    @@ -285,12 +385,12 @@

     
     
    -2270
    -2271
    -2272
    +2627 +2628 +2629

    -
    # File 'lib/idl/ast.rb', line 2270
    +      
    # File 'lib/idl/ast.rb', line 2627
     
     def set_expected_type(t)
       @expected_type = t
    @@ -315,10 +415,10 @@ 

     
     
    -2274
    +2631

    -
    # File 'lib/idl/ast.rb', line 2274
    +      
    # File 'lib/idl/ast.rb', line 2631
     
     def to_idl = "-"
    -
    # File 'lib/idl/ast.rb', line 2252
    +      
    # File 'lib/idl/ast.rb', line 2609
     
     def type(_symtab)
       Type.new(:dontcare)
    @@ -420,12 +520,12 @@ 

     
     
    -2247
    -2248
    -2249
    +2604 +2605 +2606

    -
    # File 'lib/idl/ast.rb', line 2247
    +      
    # File 'lib/idl/ast.rb', line 2604
     
     def type_check(_symtab)
       # nothing to do!
    @@ -531,21 +631,21 @@ 

     
     
    -2257
    -2258
    -2259
    -2260
    -2261
    -2262
    -2263
    -2264
    -2265
    -2266
    -2267
    -2268
    +2614 +2615 +2616 +2617 +2618 +2619 +2620 +2621 +2622 +2623 +2624 +2625

    -
    # File 'lib/idl/ast.rb', line 2257
    +      
    # File 'lib/idl/ast.rb', line 2614
     
     def value(_symtab, _archdef)
       internal_error "Must call set_expected_type first" if @expected_type.nil?
    @@ -562,6 +662,102 @@ 

    +
    + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -569,7 +765,7 @@

    diff --git a/docs/ruby/Idl/DontCareReturnSyntaxNode.html b/docs/ruby/Idl/DontCareReturnSyntaxNode.html new file mode 100644 index 000000000..f866b26d7 --- /dev/null +++ b/docs/ruby/Idl/DontCareReturnSyntaxNode.html @@ -0,0 +1,194 @@ + + + + + + + Class: Idl::DontCareReturnSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::DontCareReturnSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +2587
    +2588
    +2589
    +
    +
    # File 'lib/idl/ast.rb', line 2587
    +
    +def to_ast
    +  DontCareReturnAst.new(input, interval)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/ElseIfAst.html b/docs/ruby/Idl/ElseIfAst.html new file mode 100644 index 000000000..c15d7d7e7 --- /dev/null +++ b/docs/ruby/Idl/ElseIfAst.html @@ -0,0 +1,733 @@ + + + + + + + Class: Idl::ElseIfAst + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::ElseIfAst + + + +

    +
    + +
    +
    Inherits:
    +
    + AstNode + + + show all + +
    +
    + + + + + + +
    +
    Includes:
    +
    Returns
    +
    + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb,
    + lib/idl/passes/prune.rb
    +
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #body ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute body.

      +
      + +
    • + + +
    • + + + #cond ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute cond.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(cond, body_stmts) ⇒ ElseIfAst + + + + + +

    +
    + +

    Returns a new instance of ElseIfAst.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +3872
    +3873
    +3874
    +3875
    +3876
    +
    +
    # File 'lib/idl/ast.rb', line 3872
    +
    +def initialize(cond, body_stmts)
    +  @body = IfBodyAst.new(body_stmts)
    +  super(cond.input, cond.interval.first..body_stmts.last.interval.end, [cond, @body])
    +  @cond = cond
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #bodyObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute body.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +3870
    +3871
    +3872
    +
    +
    # File 'lib/idl/ast.rb', line 3870
    +
    +def body
    +  @body
    +end
    +
    +
    + + + +
    +

    + + #condObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute cond.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +3870
    +3871
    +3872
    +
    +
    # File 'lib/idl/ast.rb', line 3870
    +
    +def cond
    +  @cond
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #prune(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +155
    +156
    +157
    +
    +
    # File 'lib/idl/passes/prune.rb', line 155
    +
    +def prune(symtab)
    +  ElseIfAst.new(cond.prune(symtab), body.prune(symtab).stmts)
    +end
    +
    +
    + +
    +

    + + #return_value(symtab) ⇒ Object + + + + + + + Originally defined in module + Returns + + +

    +
    + + +
    +
    +
    + +

    Raises:

    +
      + +
    • + + + (NotImplementedError) + + + +
    • + +
    + +
    +
    + +
    +

    + + #return_values(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +3897
    +3898
    +3899
    +3900
    +3901
    +3902
    +3903
    +3904
    +3905
    +3906
    +
    +
    # File 'lib/idl/ast.rb', line 3897
    +
    +def return_values(symtab)
    +  if @cond.value(symtab)
    +    @body.return_values(symtab)
    +  else
    +    []
    +  end
    +rescue ValueError
    +  # might be taken, so add the possible return values
    +  @body.return_values(symtab)
    +end
    +
    +
    + +
    +

    + + #to_idlString + + + + + +

    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +3909
    +3910
    +3911
    +
    +
    # File 'lib/idl/ast.rb', line 3909
    +
    +def to_idl
    +  " else if (#{@cond.to_idl}) { #{@body.to_idl} }"
    +end
    +
    +
    + +
    +

    + + #type_check(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +3878
    +3879
    +3880
    +3881
    +3882
    +3883
    +3884
    +3885
    +3886
    +3887
    +3888
    +3889
    +3890
    +3891
    +3892
    +3893
    +3894
    +
    +
    # File 'lib/idl/ast.rb', line 3878
    +
    +def type_check(symtab)
    +  @cond.type_check(symtab)
    +  unless @cond.type(symtab).convertable_to?(:boolean)
    +    type_error "'#{@cond.text_value}' is not boolean"
    +  end
    +
    +  begin
    +    # only type check the body if it is reachable
    +    if @cond.value(symtab) == true
    +      @body.type_check(symtab)
    +      return # don't bother with the rest
    +    end
    +  rescue ValueError
    +    # condition isn't compile-time-known; have to check the body
    +    @body.type_check(symtab)
    +  end
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/EnumDefinitionAst.html b/docs/ruby/Idl/EnumDefinitionAst.html index d27ac2724..5b9c16bb7 100644 --- a/docs/ruby/Idl/EnumDefinitionAst.html +++ b/docs/ruby/Idl/EnumDefinitionAst.html @@ -147,6 +147,30 @@

  • + #add_symbol(symtab) ⇒ Object + + + + + + + + + + + + + +
    +

    Add symbol(s) at the outermost scope of the symbol table.

    +
    + +
  • + + +
  • + + #element_names ⇒ Array<String> @@ -328,7 +352,70 @@

    Instance Method Details

    -

    +

    + + #add_symbol(symtab) ⇒ Object + + + + + +

    +
    + +

    Add symbol(s) at the outermost scope of the symbol table

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      Symbol table at the scope that the symbol(s) will be inserted

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +628
    +629
    +630
    +631
    +
    +
    # File 'lib/idl/ast.rb', line 628
    +
    +def add_symbol(symtab)
    +  et = EnumerationType.new(user_type_name.text_value, element_names, element_values)
    +  symtab.add!(et.name, et)
    +end
    +
    +
    + +
    +

    #element_namesArray<String> @@ -371,14 +458,14 @@

     
     
    -557
    -558
    -559
    -560
    -561
    +588 +589 +590 +591 +592

  • -
    # File 'lib/idl/ast.rb', line 557
    +      
    # File 'lib/idl/ast.rb', line 588
     
     def element_names
       return @element_names unless @element_names.nil?
    @@ -434,27 +521,27 @@ 

     
     
    -566
    -567
    -568
    -569
    -570
    -571
    -572
    -573
    -574
    -575
    -576
    -577
    -578
    -579
    -580
    -581
    -582
    -583
    +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614

    -
    # File 'lib/idl/ast.rb', line 566
    +      
    # File 'lib/idl/ast.rb', line 597
     
     def element_values
       return @element_values unless @element_values.nil?
    @@ -523,10 +610,10 @@ 

     
     
    -606
    +642

    -
    # File 'lib/idl/ast.rb', line 606
    +      
    # File 'lib/idl/ast.rb', line 642
     
     def name = user_type_name.text_value
    -
    # File 'lib/idl/ast.rb', line 609
    +      
    # File 'lib/idl/ast.rb', line 645
     
     def to_idl
       idl = "enum #{name} { "
    @@ -667,12 +754,12 @@ 

     
     
    -598
    -599
    -600
    +634 +635 +636

    -
    # File 'lib/idl/ast.rb', line 598
    +      
    # File 'lib/idl/ast.rb', line 634
     
     def type(_symtab, _archdef)
       EnumerationType.new(user_type_name.text_value, element_names, element_values)
    @@ -762,19 +849,18 @@ 

     
     
    -586
    -587
    -588
    -589
    -590
    -591
    -592
    -593
    -594
    -595
    +617 +618 +619 +620 +621 +622 +623 +624 +625

    -
    # File 'lib/idl/ast.rb', line 586
    +      
    # File 'lib/idl/ast.rb', line 617
     
     def type_check(symtab)
       e.elements.each do |e|
    @@ -783,8 +869,7 @@ 

    end end - et = EnumerationType.new(user_type_name.text_value, element_names, element_values) - symtab.add!(et.name, et) + add_symbol(symtab) end

    -
    # File 'lib/idl/ast.rb', line 603
    +      
    # File 'lib/idl/ast.rb', line 639
     
     def value(_symtab, _archdef) = raise InternalError, "Enum defintions have no value"
    + + + + +
    +
    +
    +
    +2258
    +2259
    +2260
    +2261
    +2262
    +2263
    +
    +
    # File 'lib/idl/ast.rb', line 2258
    +
    +def initialize(input, interval, class_name, member_name)
    +  super(input, interval, [])
    +
    +  @enum_class_name = class_name
    +  @member_name = member_name
    +end
    +
    + + +

    Instance Method Details

    -

    +

    + + #class_nameObject + + + + + +

    + + + + +
    +
    +
    +
    +2255
    +
    +
    # File 'lib/idl/ast.rb', line 2255
    +
    +def class_name = @enum_class_name
    +
    +
    + +
    +

    + + #gen_adoc(indent, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +41
    +42
    +43
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 41
    +
    +def gen_adoc(indent, indent_spaces: 2)
    +  "#{class_name}::#{member_name}"
    +end
    +
    +
    + +
    +

    + + #member_nameObject + + + + + +

    + + + + +
    +
    +
    +
    +2256
    +
    +
    # File 'lib/idl/ast.rb', line 2256
    +
    +def member_name = @member_name
    +
    +
    + +
    +

    #to_idlString @@ -293,12 +549,12 @@

     
     
    -2000
    +2289

    -
    # File 'lib/idl/ast.rb', line 2000
    +      
    # File 'lib/idl/ast.rb', line 2289
     
    -def to_idl = "#{enum_class.to_idl}::#{member.to_idl}"
    +def to_idl = "#{@enum_class_name}::#{@member_name}"
    @@ -319,19 +575,19 @@

     
     
    -1986
    -1987
    -1988
    -1989
    -1990
    +2275 +2276 +2277 +2278 +2279

    -
    # File 'lib/idl/ast.rb', line 1986
    +      
    # File 'lib/idl/ast.rb', line 2275
     
     def type(symtab)
    -  internal_error "Must call type_check first" if symtab.get(enum_class.text_value).nil?
    +  internal_error "Must call type_check first" if symtab.get(@enum_class_name).nil?
     
    -  Type.new(:enum_ref, enum_class: symtab.get(enum_class.text_value))
    +  Type.new(:enum_ref, enum_class: symtab.get(@enum_class_name))
     end
    @@ -418,21 +674,23 @@

     
     
    -1978
    -1979
    -1980
    -1981
    -1982
    -1983
    +2266 +2267 +2268 +2269 +2270 +2271 +2272

    -
    # File 'lib/idl/ast.rb', line 1978
    +      
    # File 'lib/idl/ast.rb', line 2266
     
     def type_check(symtab)
    -  enum_def_type = symtab.get(enum_class.text_value)
    -  type_error "No symbol #{enum_class.text_value} has been defined" if enum_def_type.nil?
    +  enum_def_type = symtab.get(@enum_class_name)
    +  type_error "No symbol #{@enum_class_name} has been defined" if enum_def_type.nil?
     
    -  type_error "#{enum_class.text_value} is not an enum type" unless enum_def_type.is_a?(EnumerationType)
    +  type_error "#{@enum_class_name} is not an enum type" unless enum_def_type.is_a?(EnumerationType)
    +  type_error "#{@enum_class_name} has no member '#{@member_name}'" if enum_def_type.value(@member_name).nil?
     end
    @@ -454,23 +712,119 @@

     
     
    -1993
    -1994
    -1995
    -1996
    -1997
    +2282 +2283 +2284 +2285 +2286

    -
    # File 'lib/idl/ast.rb', line 1993
    +      
    # File 'lib/idl/ast.rb', line 2282
     
     def value(symtab)
    -  internal_error "Must call type_check first" if symtab.get(enum_class.text_value).nil?
    +  internal_error "Must call type_check first" if symtab.get(@enum_class_name).nil?
     
    -  symtab.get(enum_class.text_value).value(member.text_value)
    +  symtab.get(@enum_class_name).value(@member_name)
     end
    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -478,7 +832,7 @@

    diff --git a/docs/ruby/Idl/EnumRefSyntaxNode.html b/docs/ruby/Idl/EnumRefSyntaxNode.html new file mode 100644 index 000000000..5162f03d0 --- /dev/null +++ b/docs/ruby/Idl/EnumRefSyntaxNode.html @@ -0,0 +1,194 @@ + + + + + + + Class: Idl::EnumRefSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::EnumRefSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +2242
    +2243
    +2244
    +
    +
    # File 'lib/idl/ast.rb', line 2242
    +
    +def to_ast
    +  EnumRefAst.new(input, interval, enum_class.text_value, member.text_value)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/EnumerationType.html b/docs/ruby/Idl/EnumerationType.html index 8efcbd2e2..038c1a08a 100644 --- a/docs/ruby/Idl/EnumerationType.html +++ b/docs/ruby/Idl/EnumerationType.html @@ -312,25 +312,25 @@

     
     
    -346
    -347
    -348
    -349
    -350
    -351
    -352
    -353
    -354
    -355
    -356
     357
     358
     359
     360
    -361
    +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372

    -
    # File 'lib/idl/type.rb', line 346
    +      
    # File 'lib/idl/type.rb', line 357
     
     def initialize(type_name, element_names, element_values)
       width = element_values.max.bit_length
    @@ -386,12 +386,12 @@ 

     
     
    -344
    -345
    -346
    +355 +356 +357

    -
    # File 'lib/idl/type.rb', line 344
    +      
    # File 'lib/idl/type.rb', line 355
     
     def element_names
       @element_names
    @@ -429,12 +429,12 @@ 

     
     
    -344
    -345
    -346
    +355 +356 +357

    -
    # File 'lib/idl/type.rb', line 344
    +      
    # File 'lib/idl/type.rb', line 355
     
     def element_values
       @element_values
    @@ -472,12 +472,12 @@ 

     
     
    -344
    -345
    -346
    +355 +356 +357

    -
    # File 'lib/idl/type.rb', line 344
    +      
    # File 'lib/idl/type.rb', line 355
     
     def width
       @width
    @@ -509,12 +509,12 @@ 

     
     
    -363
    -364
    -365
    +374 +375 +376

    -
    # File 'lib/idl/type.rb', line 363
    +      
    # File 'lib/idl/type.rb', line 374
     
     def clone
       EnumerationType.new(@name, @element_names, @element_values)
    @@ -539,21 +539,21 @@ 

     
     
    -367
    -368
    -369
    -370
    -371
    -372
    +378 +379 +380 +381 +382 +383

    -
    # File 'lib/idl/type.rb', line 367
    +      
    # File 'lib/idl/type.rb', line 378
     
     def value(element_name)
       i = @element_names.index(element_name)
    -  raise "Could not find #{element_name} in enumeration #{@name}" if i.nil?
    +  return nil if i.nil?
     
    -  return @element_values[i]
    +  @element_values[i]
     end
    @@ -565,7 +565,7 @@

    diff --git a/docs/ruby/Idl/Executable.html b/docs/ruby/Idl/Executable.html index b88fc31d1..eb9abcf71 100644 --- a/docs/ruby/Idl/Executable.html +++ b/docs/ruby/Idl/Executable.html @@ -76,7 +76,7 @@
    Included in:
    -
    AssignmentAst, CsrSoftwareWriteAst, CsrWriteAst, ForLoopAst, FunctionBodyAst, FunctionCallExpressionAst, FunctionStatementAst, GlobalAst, GlobalWithInitializationAst, IfAst, InstructionOperationAst, PostDecrementExpressionAst, PostIncrementExpressionAst, StatementAst, VariableDeclarationAst, VariableDeclarationWithInitializationAst
    +
    AssignmentAst, CsrSoftwareWriteAst, CsrWriteAst, ForLoopAst, FunctionBodyAst, FunctionCallExpressionAst, GlobalAst, GlobalWithInitializationAst, IfAst, IfBodyAst, InstructionOperationAst, PostDecrementExpressionAst, PostIncrementExpressionAst, StatementAst, VariableDeclarationWithInitializationAst
    @@ -211,12 +211,12 @@

     
     
    -333
    +318

    -
    # File 'lib/idl/ast.rb', line 333
    +      
    # File 'lib/idl/ast.rb', line 318
     
    -def execute(symtab) = raise NotImplementedError, "#{self.class.name} must implement update_value"
    +def execute(symtab) = raise NotImplementedError, "#{self.class.name} must implement execute"
    @@ -227,7 +227,7 @@

    diff --git a/docs/ruby/Idl/ExecutionCommentAst.html b/docs/ruby/Idl/ExecutionCommentAst.html index 9039191f5..9727d0c30 100644 --- a/docs/ruby/Idl/ExecutionCommentAst.html +++ b/docs/ruby/Idl/ExecutionCommentAst.html @@ -170,10 +170,10 @@

     
     
    -2413
    +2805

    -
    # File 'lib/idl/ast.rb', line 2413
    +      
    # File 'lib/idl/ast.rb', line 2805
     
     def type_check(_symtab, _global); end
    @@ -186,7 +186,7 @@

    diff --git a/docs/ruby/Idl/FieldAssignmentAst.html b/docs/ruby/Idl/FieldAssignmentAst.html index a69cfef96..8fc8ce546 100644 --- a/docs/ruby/Idl/FieldAssignmentAst.html +++ b/docs/ruby/Idl/FieldAssignmentAst.html @@ -386,14 +386,14 @@

     
     
    -1099
    -1100
    -1101
    -1102
    -1103
    +1168 +1169 +1170 +1171 +1172

    -
    # File 'lib/idl/ast.rb', line 1099
    +      
    # File 'lib/idl/ast.rb', line 1168
     
     def bf_type(symtab)
       internal_error "Not a bitfield variable" unless kind(symtab) == :bitfield
    @@ -420,12 +420,12 @@ 

     
     
    -1158
    -1159
    -1160
    +1227 +1228 +1229

    -
    # File 'lib/idl/ast.rb', line 1158
    +      
    # File 'lib/idl/ast.rb', line 1227
     
     def execute(symtab)
       value_error "TODO: Field assignement execution"
    @@ -497,13 +497,13 @@ 

     
     
    -1107
    -1108
    -1109
    -1110
    +1176 +1177 +1178 +1179

    -
    # File 'lib/idl/ast.rb', line 1107
    +      
    # File 'lib/idl/ast.rb', line 1176
     
     def field(symtab)
       internal_error "Not a CSR field type" unless kind(symtab) == :csr
    @@ -558,12 +558,12 @@ 

     
     
    -1093
    -1094
    -1095
    +1162 +1163 +1164

    -
    # File 'lib/idl/ast.rb', line 1093
    +      
    # File 'lib/idl/ast.rb', line 1162
     
     def kind(symtab)
       var.type(symtab).kind
    @@ -617,10 +617,10 @@ 

     
     
    -1163
    +1232

    -
    # File 'lib/idl/ast.rb', line 1163
    +      
    # File 'lib/idl/ast.rb', line 1232
     
     def to_idl = "#{var.to_idl}.#{field_name.to_idl} = #{rval.to_idl}"
    @@ -712,27 +712,27 @@

     
     
    -1113
    -1114
    -1115
    -1116
    -1117
    -1118
    -1119
    -1120
    -1121
    -1122
    -1123
    -1124
    -1125
    -1126
    -1127
    -1128
    -1129
    -1130
    +1182 +1183 +1184 +1185 +1186 +1187 +1188 +1189 +1190 +1191 +1192 +1193 +1194 +1195 +1196 +1197 +1198 +1199

    -
    # File 'lib/idl/ast.rb', line 1113
    +      
    # File 'lib/idl/ast.rb', line 1182
     
     def type(symtab)
       case kind(symtab)
    @@ -837,33 +837,33 @@ 

     
     
    -1133
    -1134
    -1135
    -1136
    -1137
    -1138
    -1139
    -1140
    -1141
    -1142
    -1143
    -1144
    -1145
    -1146
    -1147
    -1148
    -1149
    -1150
    -1151
    -1152
    -1153
    -1154
    -1155
    -1156
    +1202 +1203 +1204 +1205 +1206 +1207 +1208 +1209 +1210 +1211 +1212 +1213 +1214 +1215 +1216 +1217 +1218 +1219 +1220 +1221 +1222 +1223 +1224 +1225

    -
    # File 'lib/idl/ast.rb', line 1133
    +      
    # File 'lib/idl/ast.rb', line 1202
     
     def type_check(symtab)
       var.type_check(symtab)
    @@ -899,7 +899,7 @@ 

    diff --git a/docs/ruby/Idl/FieldNameAst.html b/docs/ruby/Idl/FieldNameAst.html index a8bc49005..49dadb0d4 100644 --- a/docs/ruby/Idl/FieldNameAst.html +++ b/docs/ruby/Idl/FieldNameAst.html @@ -121,6 +121,30 @@

  • + #to_idl ⇒ String + + + + + + + + + + + + + +
    +

    Return valid IDL representation of the node (and its subtree).

    +
    + +
  • + + +
  • + + #type_check(_symtab, _archdef) ⇒ void @@ -158,7 +182,62 @@

    Instance Method Details

    -

    +

    + + #to_idlString + + + + + +

    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +3236
    +
    +
    # File 'lib/idl/ast.rb', line 3236
    +
    +def to_idl = text_value
    +
    +
    + +
    +

    #type_check(_symtab, _archdef) ⇒ void @@ -237,12 +316,12 @@

     
     
    -2709
    -2710
    -2711
    +3230 +3231 +3232

  • -
    # File 'lib/idl/ast.rb', line 2709
    +      
    # File 'lib/idl/ast.rb', line 3230
     
     def type_check(_symtab, _archdef)
       # nothing to do
    @@ -257,7 +336,7 @@ 

    diff --git a/docs/ruby/Idl/ForLoopAst.html b/docs/ruby/Idl/ForLoopAst.html index d15827e19..883f8d7c5 100644 --- a/docs/ruby/Idl/ForLoopAst.html +++ b/docs/ruby/Idl/ForLoopAst.html @@ -103,7 +103,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/gen_adoc.rb
    +
    @@ -112,6 +114,127 @@ +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #condition ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute condition.

      +
      + +
    • + + +
    • + + + #init ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute init.

      +
      + +
    • + + +
    • + + + #stmts ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute stmts.

      +
      + +
    • + + +
    • + + + #update ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute update.

      +
      + +
    • + + +
    + @@ -126,6 +249,54 @@

  • + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + #initialize(input, interval, init, condition, update, stmts) ⇒ ForLoopAst + + + + + + + constructor + + + + + + + + +
    +

    A new instance of ForLoopAst.

    +
    + +
  • + + +
  • + + #return_value(symtab) ⇒ Object @@ -144,6 +315,52 @@

    +

  • + + +
  • + + + #return_values(symtab) ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + #to_idl ⇒ String + + + + + + + + + + + + + +
    +

    Return valid IDL representation of the node (and its subtree).

    +
    +
  • @@ -184,14 +401,286 @@

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(input, interval, init, condition, update, stmts) ⇒ ForLoopAst + + + + + +

    +
    + +

    Returns a new instance of ForLoopAst.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +3682
    +3683
    +3684
    +3685
    +3686
    +3687
    +3688
    +3689
    +
    +
    # File 'lib/idl/ast.rb', line 3682
    +
    +def initialize(input, interval, init, condition, update, stmts)
    +  super(input, interval, [init, condition] + stmts)
    +
    +  @init = init
    +  @condition = condition
    +  @update = update
    +  @stmts = stmts
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #conditionObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute condition.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +3680
    +3681
    +3682
    +
    +
    # File 'lib/idl/ast.rb', line 3680
    +
    +def condition
    +  @condition
    +end
    +
    +
    + + + +
    +

    + + #initObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute init.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +3680
    +3681
    +3682
    +
    +
    # File 'lib/idl/ast.rb', line 3680
    +
    +def init
    +  @init
    +end
    +
    +
    + + + +
    +

    + + #stmtsObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute stmts.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +3680
    +3681
    +3682
    +
    +
    # File 'lib/idl/ast.rb', line 3680
    +
    +def stmts
    +  @stmts
    +end
    +
    +
    + + + +
    +

    + + #updateObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute update.

    + + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +3680
    +3681
    +3682
    +
    +
    # File 'lib/idl/ast.rb', line 3680
    +
    +def update
    +  @update
    +end
    +
    +
    + +
    + +

    Instance Method Details

    -

    +

    + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +95
    +96
    +97
    +98
    +99
    +100
    +101
    +102
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 95
    +
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  lines = ["#{' '*indent}for (#{init.gen_adoc(0, indent_spaces:)}; #{condition.gen_adoc(0, indent_spaces:)}; #{update.gen_adoc(0, indent_spaces:)}) {"]
    +  stmts.each do |s|
    +    lines << s.gen_adoc(indent + indent_spaces, indent_spaces:)
    +  end
    +  lines << "#{' '*indent}}"
    +  lines.join("\n")
    +end
    +
    +
    + +
    +

    #return_value(symtab) ⇒ Object @@ -209,59 +698,57 @@

     
     
    -3095
    -3096
    -3097
    -3098
    -3099
    -3100
    -3101
    -3102
    -3103
    -3104
    -3105
    -3106
    -3107
    -3108
    -3109
    -3110
    -3111
    -3112
    -3113
    -3114
    -3115
    -3116
    -3117
    -3118
    -3119
    -3120
    -3121
    -3122
    -3123
    +3705 +3706 +3707 +3708 +3709 +3710 +3711 +3712 +3713 +3714 +3715 +3716 +3717 +3718 +3719 +3720 +3721 +3722 +3723 +3724 +3725 +3726 +3727 +3728 +3729 +3730 +3731 +3732

    -
    # File 'lib/idl/ast.rb', line 3095
    +      
    # File 'lib/idl/ast.rb', line 3705
     
     def return_value(symtab)
       symtab.push
     
       begin
    -    single_declaration_with_initialization.execute(symtab)
    +    @init.execute(symtab)
     
    -    while condition.value(symtab)
    -      stmts.elements.each do |s|
    -        if s.s.is_a?(Returns)
    -          v = s.s.return_value(symtab)
    +    while @condition.value(symtab)
    +      @stmts.each do |s|
    +        if s.is_a?(Returns)
    +          v = s.return_value(symtab)
               unless v.nil?
                 symtab.pop
    -            puts "value = #{v}"
                 return v
               end
             else
    -          s.s.execute(symtab)
    +          s.execute(symtab)
             end
           end
    -      action.execute(symtab)
    +      @update.execute(symtab)
         end
       rescue ValueError => e
         symtab.pop
    @@ -274,6 +761,163 @@ 

    + + +
    +

    + + #return_values(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +3735
    +3736
    +3737
    +3738
    +3739
    +3740
    +3741
    +3742
    +3743
    +3744
    +3745
    +3746
    +3747
    +3748
    +3749
    +3750
    +3751
    +3752
    +3753
    +3754
    +3755
    +3756
    +3757
    +3758
    +3759
    +3760
    +3761
    +3762
    +3763
    +3764
    +3765
    +3766
    +
    +
    # File 'lib/idl/ast.rb', line 3735
    +
    +def return_values(symtab)
    +  # if there is a known return value, then we are done
    +  [return_value(symtab)]
    +rescue ValueError
    +  # see if we can collect a list
    +  values = []
    +  symtab.push
    +
    +  begin
    +    @init.execute(symtab)
    +
    +    while @condition.value(symtab)
    +      @stmts.each do |s|
    +        if s.is_a?(Returns)
    +          begin
    +            v = s.return_value(symtab)
    +            return values.push(v).uniq unless v.nil?
    +          rescue ValueError
    +            values += s.return_values(symtab)
    +          end
    +        else
    +          s.execute(symtab)
    +        end
    +      end
    +      @update.execute(symtab)
    +    end
    +  ensure
    +    symtab.pop
    +  end
    +
    +  values.uniq
    +end
    +
    +
    + +
    +

    + + #to_idlString + + + + + +

    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +3772
    +3773
    +3774
    +3775
    +3776
    +3777
    +3778
    +3779
    +
    +
    # File 'lib/idl/ast.rb', line 3772
    +
    +def to_idl
    +  idl = "for (#{@init.to_idl}; #{@condition.to_idl}; #{@update.to_idl}) {"
    +  @stmts.each do |s|
    +    idl << s.to_idl
    +  end
    +  idl << "}"
    +  idl
    +end
    +
    @@ -356,29 +1000,29 @@

     
     
    -3083
    -3084
    -3085
    -3086
    -3087
    -3088
    -3089
    -3090
    -3091
    -3092
    -3093
    +3692 +3693 +3694 +3695 +3696 +3697 +3698 +3699 +3700 +3701 +3702

    -
    # File 'lib/idl/ast.rb', line 3083
    +      
    # File 'lib/idl/ast.rb', line 3692
     
     def type_check(symtab)
       symtab.push
    -  single_declaration_with_initialization.type_check(symtab)
    -  condition.type_check(symtab)
    -  action.type_check(symtab)
    +  @init.type_check(symtab)
    +  @condition.type_check(symtab)
    +  @update.type_check(symtab)
     
    -  stmts.elements.each do |s|
    -    s.s.type_check(symtab)
    +  @stmts.each do |s|
    +    s.type_check(symtab)
       end
       symtab.pop
     end
    @@ -392,7 +1036,7 @@

    diff --git a/docs/ruby/Idl/ForLoopSyntaxNode.html b/docs/ruby/Idl/ForLoopSyntaxNode.html new file mode 100644 index 000000000..82fb2354e --- /dev/null +++ b/docs/ruby/Idl/ForLoopSyntaxNode.html @@ -0,0 +1,206 @@ + + + + + + + Class: Idl::ForLoopSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::ForLoopSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +3665
    +3666
    +3667
    +3668
    +3669
    +3670
    +3671
    +3672
    +3673
    +
    +
    # File 'lib/idl/ast.rb', line 3665
    +
    +def to_ast
    +  ForLoopAst.new(
    +    input, interval,
    +    single_declaration_with_initialization.to_ast,
    +    condition.to_ast,
    +    action.to_ast,
    +    stmts.elements.map(&:s).map(&:to_ast)
    +  )
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/FunctionBodyAst.html b/docs/ruby/Idl/FunctionBodyAst.html index cd92a5b18..5ee2614a7 100644 --- a/docs/ruby/Idl/FunctionBodyAst.html +++ b/docs/ruby/Idl/FunctionBodyAst.html @@ -104,7 +104,7 @@
    Defined in:
    lib/idl/ast.rb,
    - lib/idl/passes/find_return_values.rb
    + lib/idl/passes/prune.rb,
    lib/idl/passes/gen_adoc.rb,
    lib/idl/passes/find_return_values.rb
    @@ -128,6 +128,54 @@

  • + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + #initialize(input, interval, stmts) ⇒ FunctionBodyAst + + + + + + + constructor + + + + + + + + +
    +

    A new instance of FunctionBodyAst.

    +
    + +
  • + + +
  • + + #pass_find_return_values(symtab) ⇒ Array<Ast, Array<Ast>> @@ -146,6 +194,28 @@

    List of possible return values, along with the condition it occurs under.

    +

  • + + +
  • + + + #prune(symtab) ⇒ Object + + + + + + + + + + + + + +
    +
  • @@ -176,7 +246,7 @@

  • - #return_values(symtab) ⇒ Array + #return_values(symtab) ⇒ Object @@ -190,9 +260,7 @@

    -
    -

    An array of all possible return values.

    -
    +

  • @@ -278,14 +346,91 @@

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(input, interval, stmts) ⇒ FunctionBodyAst + + + +

    +
    + +

    Returns a new instance of FunctionBodyAst.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +3284
    +3285
    +3286
    +3287
    +
    +
    # File 'lib/idl/ast.rb', line 3284
    +
    +def initialize(input, interval, stmts)
    +  super(input, interval, stmts)
    +  @stmts = stmts
    +end
    +
    +
    + +
    + +

    Instance Method Details

    -

    +

    + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +187
    +188
    +189
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 187
    +
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  statements.map{ |s| "#{' ' * indent}#{s.gen_adoc(indent, indent_spaces:)}" }.join("\n")
    +end
    +
    +
    + +
    +

    #pass_find_return_values(symtab) ⇒ Array<Ast, Array<Ast>> @@ -351,6 +496,100 @@

    +

    + +
    +

    + + #prune(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +
    +
    # File 'lib/idl/passes/prune.rb', line 53
    +
    +def prune(symtab)
    +  symtab.push
    +  raise "?" if symtab.get("current_mode").nil?
    +  func_def = find_ancestor(FunctionDefAst)
    +  unless func_def.nil?
    +    return FunctionBodyAst.new(input, interval, statements) if func_def.templated? # can't prune a template because we don't have all types
    +
    +    # push template values
    +    func_def.template_names.each_with_index do |tname, idx|
    +      symtab.add(tname, Var.new(tname, func_def.template_types(symtab)[idx]))
    +    end
    +
    +    # push args
    +    func_def.arguments(symtab).each do |arg_type, arg_name|
    +      symtab.add(arg_name, Var.new(arg_name, arg_type))
    +    end
    +  end
    +  begin
    +    # go through the statements, and stop if we find one that retuns
    +    statements.each_with_index do |s, idx|
    +      if s.is_a?(Returns)
    +        v = s.return_value(symtab)
    +        return FunctionBodyAst.new(input, interval, statements[0..idx].map { |s| s.prune(symtab) }) unless v.nil?
    +      else
    +        s.execute(symtab)
    +      end
    +    end
    +
    +    FunctionBodyAst.new(input, interval, statements.map { |s| s.prune(symtab) })
    +  rescue ValueError
    +    FunctionBodyAst.new(input, interval, statements.map { |s| s.prune(symtab) })
    +  ensure
    +    symtab.pop
    +  end
    +end
    +
    @@ -389,26 +628,30 @@

     
     
    -2773
    -2774
    -2775
    -2776
    -2777
    -2778
    -2779
    -2780
    -2781
    -2782
    -2783
    -2784
    -2785
    +3320 +3321 +3322 +3323 +3324 +3325 +3326 +3327 +3328 +3329 +3330 +3331 +3332 +3333 +3334

    -
    # File 'lib/idl/ast.rb', line 2773
    +      
    # File 'lib/idl/ast.rb', line 3320
     
     def return_value(symtab)
    +  internal_error "Function bodies should be at global + 1 scope" unless symtab.levels == 2
    +
       # go through the statements, and return the first one that has a return value
    -  statements.each do |s|
    +  @stmts.each do |s|
         if s.is_a?(Returns)
           v = s.return_value(symtab)
           return v unless v.nil?
    @@ -417,7 +660,7 @@ 

    end end - internal_error "No function body statement returned a value" + value_error "No function body statement returned a value" end

    @@ -427,84 +670,73 @@

    - #return_values(symtab) ⇒ Array + #return_values(symtab) ⇒ Object -

    -
    - -
    - Note: -
    -

    arguments and template arguments must be put on the symtab before calling

    -
    -
    - - -

    Returns An array of all possible return values.

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Array) - - - - — -
      -

      An array of all possible return values

      -
      - -
    • - -
    - -
    +
    @@ -526,15 +758,15 @@

     
     
    -2744
    -2745
    -2746
    +3289 +3290 +3291

    @@ -556,22 +788,22 @@

     
     
    -2805
    -2806
    -2807
    -2808
    -2809
    -2810
    -2811
    -2812
    +3365 +3366 +3367 +3368 +3369 +3370 +3371 +3372

    @@ -434,15 +603,21 @@

     
     
    -47
    -48
    -49
    +178 +179 +180 +181 +182 +183

    @@ -464,15 +639,45 @@

     
     
    -2678
    -2679
    -2680
    +3191 +3192 +3193

    + +
     
     
    -2791
    -2792
    -2793
    -2794
    -2795
    -2796
    -2797
    -2798
    -2799
    -2800
    -2801
    -2802
    -2803
    +3338 +3339 +3340 +3341 +3342 +3343 +3344 +3345 +3346 +3347 +3348 +3349 +3350 +3351 +3352 +3353 +3354 +3355 +3356 +3357 +3358 +3359 +3360 +3361 +3362 +3363
    -
    # File 'lib/idl/ast.rb', line 2791
    +      
    # File 'lib/idl/ast.rb', line 3338
     
     def return_values(symtab)
    -  # go through the statements, and find all return values
    -  rts = []
    -  statements.each do |s|
    -    if s.is_a?(Returns)
    -      rts += s.return_values(symtab)
    -    else
    -      s.execute(symtab)
    +  internal_error "Function bodies should be at global + 1 scope" unless symtab.levels == 2
    +
    +  values = []
    +  begin
    +    # if there is a definate return value, then just return that
    +    return [return_value(symtab)]
    +  rescue ValueError
    +    # go through the statements, and collect return values
    +    # we can stop if we encounter a statement with a known return value
    +    @stmts.each do |s|
    +      if s.is_a?(Returns)
    +        begin
    +          v = s.return_value(symtab)
    +          return values.push(v).uniq unless v.nil?
    +        rescue ValueError
    +          values += s.return_values(symtab)
    +        end
    +      else
    +        s.execute(symtab)
    +      end
         end
       end
     
    -  rts
    +  values.uniq
     end
    -
    # File 'lib/idl/ast.rb', line 2744
    +      
    # File 'lib/idl/ast.rb', line 3289
     
     def statements
    -  func_stmt_list.elements.map(&:choice)
    +  @stmts
     end
    -
    # File 'lib/idl/ast.rb', line 2805
    +      
    # File 'lib/idl/ast.rb', line 3365
     
     def to_idl
       result = ""
       # go through the statements, and return the first one that has a return value
    -  statements.each do |s|
    +  @stmts.each do |s|
         result << s.to_idl
       end
       result
    @@ -661,42 +893,46 @@ 

     
     
    -2749
    -2750
    -2751
    -2752
    -2753
    -2754
    -2755
    -2756
    -2757
    -2758
    -2759
    -2760
    -2761
    -2762
    -2763
    -2764
    -2765
    -2766
    -2767
    -2768
    +3294 +3295 +3296 +3297 +3298 +3299 +3300 +3301 +3302 +3303 +3304 +3305 +3306 +3307 +3308 +3309 +3310 +3311 +3312 +3313 +3314 +3315

    -
    # File 'lib/idl/ast.rb', line 2749
    +      
    # File 'lib/idl/ast.rb', line 3294
     
     def type_check(symtab)
    +  internal_error "Function bodies should be at global + 1 scope (at #{symtab.levels})" unless symtab.levels == 2
    +
       return_value_might_be_known = true
     
    -  statements.each do |s|
    +  @stmts.each do |s|
         s.type_check(symtab)
    -    next if return_value_might_be_known
    +    next unless return_value_might_be_known
     
         begin
           if s.is_a?(Returns)
             s.return_value(symtab)
             # if we reach here, the return value is known, so we don't have to go futher
    -        return
    +        break
           else
             s.execute(symtab)
           end
    @@ -715,7 +951,7 @@ 

    diff --git a/docs/ruby/Idl/FunctionBodySyntaxNode.html b/docs/ruby/Idl/FunctionBodySyntaxNode.html new file mode 100644 index 000000000..cee62bf7e --- /dev/null +++ b/docs/ruby/Idl/FunctionBodySyntaxNode.html @@ -0,0 +1,194 @@ + + + + + + + Class: Idl::FunctionBodySyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::FunctionBodySyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +3275
    +3276
    +3277
    +
    +
    # File 'lib/idl/ast.rb', line 3275
    +
    +def to_ast
    +  FunctionBodyAst.new(input, interval, func_stmt_list.elements.map(&:choice).map(&:to_ast))
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/FunctionCallExpressionAst.html b/docs/ruby/Idl/FunctionCallExpressionAst.html index 090f0908c..297324a5c 100644 --- a/docs/ruby/Idl/FunctionCallExpressionAst.html +++ b/docs/ruby/Idl/FunctionCallExpressionAst.html @@ -104,7 +104,7 @@
    Defined in:
    lib/idl/ast.rb,
    - lib/idl/passes/gen_adoc.rb
    + lib/idl/passes/prune.rb,
    lib/idl/passes/gen_adoc.rb
    @@ -168,6 +168,32 @@

    + + + +
  • + + + #initialize(input, interval, function_name, targs, args) ⇒ FunctionCallExpressionAst + + + + + + + constructor + + + + + + + + +
    +

    A new instance of FunctionCallExpressionAst.

    +
    +
  • @@ -188,6 +214,28 @@

    +
    + + + + +
  • + + + #prune(symtab) ⇒ Object + + + + + + + + + + + + +
  • @@ -260,6 +308,30 @@

    + + + +
  • + + + #to_idl ⇒ String + + + + + + + + + + + + + +
    +

    Return valid IDL representation of the node (and its subtree).

    +
    +
  • @@ -334,6 +406,35 @@

    Return the compile-time-known value of the node.

    + + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
    +
  • @@ -350,7 +451,79 @@

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(input, interval, function_name, targs, args) ⇒ FunctionCallExpressionAst + + + + + +

    +
    + +

    Returns a new instance of FunctionCallExpressionAst.

    + + +
    +
    +
    + +

    Raises:

    +
      + +
    • + + + (ArgumentError) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +3076
    +3077
    +3078
    +3079
    +3080
    +3081
    +3082
    +3083
    +3084
    +3085
    +
    +
    # File 'lib/idl/ast.rb', line 3076
    +
    +def initialize(input, interval, function_name, targs, args)
    +  raise ArgumentError, "targs shoudl be an array" unless targs.is_a?(Array)
    +  raise ArgumentError, "args shoudl be an array" unless args.is_a?(Array)
    +
    +  super(input, interval, targs + args)
    +
    +  @name = function_name
    +  @targs = targs
    +  @args = args
    +end
    +
    +
    +
    +

    Instance Method Details

    @@ -400,19 +573,15 @@

     
     
    -2573
    -2574
    -2575
    -2576
    -2577
    +3104 +3105 +3106

    -
    # File 'lib/idl/ast.rb', line 2573
    +      
    # File 'lib/idl/ast.rb', line 3104
     
     def arg_nodes
    -  nodes = []
    -  nodes << function_arg_list.first unless function_arg_list.first.empty?
    -  nodes + function_arg_list.rest.elements.map(&:expression)
    +  @args
     end
    -
    # File 'lib/idl/passes/gen_adoc.rb', line 47
    +      
    # File 'lib/idl/passes/gen_adoc.rb', line 178
     
     def gen_adoc(indent = 0, indent_spaces: 2)
    -  "xref:funcs:funcs.adoc##{name}-func-def[#{name}]" << t.gen_adoc << "(#{function_arg_list.gen_adoc})"
    +  after_name = []
    +  after_name << "<#{template_arg_nodes.map { |t| t.gen_adoc(0, indent_spaces:)}.join(', ')}>" unless template_arg_nodes.empty?
    +  after_name << "(#{arg_nodes.map { |a| a.gen_adoc(0, indent_spaces: ) }.join(', ')})"
    +  "%%LINK%func;#{name};#{name}%%#{after_name.join ''}"
     end
    -
    # File 'lib/idl/ast.rb', line 2678
    +      
    # File 'lib/idl/ast.rb', line 3191
     
     def name
    -  function_name.text_value
    +  @name
    +end
    +
    +
    + +
    +

    + + #prune(symtab) ⇒ Object + + + + + +

    + + + @@ -523,15 +728,15 @@

     
     
    -2555
    -2556
    -2557
    +3088 +3089 +3090

    @@ -582,19 +787,15 @@

     
     
    -2560
    -2561
    -2562
    -2563
    -2564
    +3093 +3094 +3095

    @@ -616,14 +817,14 @@

     
     
    -2566
    -2567
    -2568
    -2569
    -2570
    +3097 +3098 +3099 +3100 +3101

    +
    +
    +
    +48
    +49
    +50
    +
    +
    # File 'lib/idl/passes/prune.rb', line 48
    +
    +def prune(symtab)
    +  FunctionCallExpressionAst.new(input, interval, name, @targs.map { |t| t.prune(symtab) }, @args.map { |a| a.prune(symtab)} )
     end
    -
    # File 'lib/idl/ast.rb', line 2555
    +      
    # File 'lib/idl/ast.rb', line 3088
     
     def template?
    -  !t.empty?
    +  !@targs.empty?
     end
    -
    # File 'lib/idl/ast.rb', line 2560
    +      
    # File 'lib/idl/ast.rb', line 3093
     
     def template_arg_nodes
    -  return [] unless template?
    -
    -  [t.targs.first] + t.targs.rest.elements.map(&:arg)
    +  @targs
     end
    -
    # File 'lib/idl/ast.rb', line 2566
    +      
    # File 'lib/idl/ast.rb', line 3097
     
     def template_values(symtab)
       return [] unless template?
    @@ -633,6 +834,73 @@ 

    +
    + +
    +

    + + #to_idlString + + + + + +

    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +3196
    +3197
    +3198
    +3199
    +3200
    +3201
    +3202
    +
    +
    # File 'lib/idl/ast.rb', line 3196
    +
    +def to_idl
    +  if template?
    +    "#{name}<#{template_arg_nodes.map(&:to_idl).join(',')}>(#{arg_nodes.map(&:to_idl).join(',')})"
    +  else
    +    "#{name}(#{arg_nodes.map(&:to_idl).join(',')})"
    +  end
    +end
    +
    @@ -719,17 +987,17 @@

     
     
    -2633
    -2634
    -2635
    -2636
    +3162 +3163 +3164 +3165

    -
    # File 'lib/idl/ast.rb', line 2633
    +      
    # File 'lib/idl/ast.rb', line 3162
     
     def type(symtab)
       func_def_type = symtab.get(name)
    -  func_def_type.return_type(template_values(symtab), arg_nodes, symtab)
    +  func_def_type.return_type(template_values(symtab))
     end
    @@ -816,74 +1084,74 @@

     
     
    -2580
    -2581
    -2582
    -2583
    -2584
    -2585
    -2586
    -2587
    -2588
    -2589
    -2590
    -2591
    -2592
    -2593
    -2594
    -2595
    -2596
    -2597
    -2598
    -2599
    -2600
    -2601
    -2602
    -2603
    -2604
    -2605
    -2606
    -2607
    -2608
    -2609
    -2610
    -2611
    -2612
    -2613
    -2614
    -2615
    -2616
    -2617
    -2618
    -2619
    -2620
    -2621
    -2622
    -2623
    -2624
    -2625
    -2626
    -2627
    -2628
    -2629
    -2630
    +3109 +3110 +3111 +3112 +3113 +3114 +3115 +3116 +3117 +3118 +3119 +3120 +3121 +3122 +3123 +3124 +3125 +3126 +3127 +3128 +3129 +3130 +3131 +3132 +3133 +3134 +3135 +3136 +3137 +3138 +3139 +3140 +3141 +3142 +3143 +3144 +3145 +3146 +3147 +3148 +3149 +3150 +3151 +3152 +3153 +3154 +3155 +3156 +3157 +3158 +3159

    -
    # File 'lib/idl/ast.rb', line 2580
    +      
    # File 'lib/idl/ast.rb', line 3109
     
     def type_check(symtab)
       level = symtab.levels
     
    -  func_def_type = symtab.get(name)
    -  type_error "No symbol #{name}" if func_def_type.nil?
    +  func_def_type = symtab.get(@name)
    +  type_error "No symbol #{@name}" if func_def_type.nil?
     
       unless func_def_type.is_a?(FunctionType)
    -    type_error "#{name} is not a function (it's a #{func_def_type.class.name})"
    +    type_error "#{@name} is not a function (it's a #{func_def_type.class.name})"
       end
     
    -  type_error "Missing template arguments in call to #{name}" if template? && func_def_type.template_names.empty?
    +  type_error "Missing template arguments in call to #{@name}" if template? && func_def_type.template_names.empty?
     
    -  type_error "Template arguments provided in call to non-template function #{name}" if !template? && !func_def_type.template_names.empty?
    +  type_error "Template arguments provided in call to non-template function #{@name}" if !template? && !func_def_type.template_names.empty?
     
       if template?
         num_targs = template_arg_nodes.size
    @@ -893,7 +1161,7 @@ 

    template_arg_nodes.each_with_index do |t, idx| t.type_check(symtab) - unless t.type(symtab).convertable_to?(func_def_type.template_types[idx]) + unless t.type(symtab).convertable_to?(func_def_type.template_types(symtab)[idx]) type_error "Template argument #{idx + 1} has wrong type" end end @@ -907,7 +1175,7 @@

    if func_def_type.num_args != num_args type_error "Wrong number of arguments to '#{name}' function call. Expecting #{func_def_type.num_args}, got #{num_args}" end - arg_nodes.each_with_index do |a, idx| + arg_nodes.each do |a| a.type_check(symtab) end arg_nodes.each_with_index do |a, idx| @@ -916,7 +1184,7 @@

    end end - if func_def_type.return_type(template_values(symtab), arg_nodes, symtab).nil? + if func_def_type.return_type(template_values(symtab)).nil? internal_error "No type determined for function" end @@ -957,87 +1225,151 @@

     
     
    -2639
    -2640
    -2641
    -2642
    -2643
    -2644
    -2645
    -2646
    -2647
    -2648
    -2649
    -2650
    -2651
    -2652
    -2653
    -2654
    -2655
    -2656
    -2657
    -2658
    -2659
    -2660
    -2661
    -2662
    -2663
    -2664
    -2665
    -2666
    -2667
    -2668
    -2669
    -2670
    -2671
    -2672
    -2673
    -2674
    -2675
    +3168 +3169 +3170 +3171 +3172 +3173 +3174 +3175 +3176 +3177 +3178 +3179 +3180 +3181 +3182 +3183 +3184 +3185 +3186 +3187 +3188

    -
    # File 'lib/idl/ast.rb', line 2639
    +      
    # File 'lib/idl/ast.rb', line 3168
     
     def value(symtab)
       func_def_type = symtab.get(name)
    +  type_error "not a function" unless func_def_type.is_a?(FunctionType)
       if func_def_type.builtin?
         if name == "implemented?"
    -      extname = arg_nodes[0].text_value
    -      return symtab.archdef.ext?(extname)
    +      extname_ref = arg_nodes[0]
    +      type_error "First argument should be a ExtensionName" unless extname_ref.type(symtab).kind == :enum_ref && extname_ref.class_name == "ExtensionName"
    +
    +      return symtab.archdef.ext?(arg_nodes[0].member_name)
         else
           value_error "value of builtin function cannot be known"
         end
       end
     
    -  symtab.push
    -
    -  begin
    -    template_arg_nodes.each_with_index do |targ, idx|
    -      targ_name = func_def_type.template_names[idx]
    -      targ_type = func_def_type.template_types[idx]
    -      symtab.add(targ_name, Var.new(targ_name, targ_type, targ.value(symtab)))
    -    end
    -
    -    arg_nodes.each_with_index do |arg, idx|
    -      arg_name = func_def_type.argument_name(idx, template_values(symtab))
    -      arg_type = func_def_type.argument_type(idx, template_values(symtab), arg_nodes, symtab)
    -      begin
    -        symtab.add!(arg_name, Var.new(arg_name, arg_type, arg.value(symtab)))
    -      rescue SymbolTable::DuplicateSymError
    -        type_error "Argument '#{arg_name}' shadows another symbol (level = #{symtab.levels})"
    -      end
    -    end
    -
    -    v = func_def_type.body.return_value(symtab)
    -  ensure
    -    symtab.pop
    +  template_values = []
    +  template_arg_nodes.each do |targ|
    +    template_values << targ.value(symtab)
       end
     
    -  v
    +  func_def_type.return_value(template_values, arg_nodes, symtab)
     end
    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -1045,7 +1377,7 @@

    diff --git a/docs/ruby/Idl/FunctionCallExpressionSyntaxNode.html b/docs/ruby/Idl/FunctionCallExpressionSyntaxNode.html new file mode 100644 index 000000000..89e9b49ad --- /dev/null +++ b/docs/ruby/Idl/FunctionCallExpressionSyntaxNode.html @@ -0,0 +1,202 @@ + + + + + + + Class: Idl::FunctionCallExpressionSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::FunctionCallExpressionSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +3062
    +3063
    +3064
    +3065
    +3066
    +3067
    +3068
    +
    +
    # File 'lib/idl/ast.rb', line 3062
    +
    +def to_ast
    +  targs = t.empty? ? [] : [t.targs.first.to_ast] + t.targs.rest.elements.map { |e| e.arg.to_ast }
    +  args = []
    +  args << function_arg_list.first.to_ast unless function_arg_list.first.empty?
    +  args += function_arg_list.rest.elements.map { |e| e.expression.to_ast }
    +  FunctionCallExpressionAst.new(input, interval, function_name.text_value, targs, args)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/FunctionDefAst.html b/docs/ruby/Idl/FunctionDefAst.html index 9997bc6aa..0b7bbe6d8 100644 --- a/docs/ruby/Idl/FunctionDefAst.html +++ b/docs/ruby/Idl/FunctionDefAst.html @@ -107,42 +107,21 @@ -

    Instance Attribute Summary collapse

    -
    -
    # File 'lib/idl/ast.rb', line 2831
    +      
    # File 'lib/idl/ast.rb', line 3391
     
     def arguments(symtab)
       if templated?
    @@ -826,19 +795,19 @@ 

     
     
    -2858
    -2859
    -2860
    -2861
    -2862
    -2863
    -2864
    -2865
    -2866
    -2867
    +3418 +3419 +3420 +3421 +3422 +3423 +3424 +3425 +3426 +3427

    -
    # File 'lib/idl/ast.rb', line 2858
    +      
    # File 'lib/idl/ast.rb', line 3418
     
     def arguments_list_str
       list = []
    @@ -870,14 +839,14 @@ 

     
     
    -3056
    -3057
    -3058
    -3059
    -3060
    +3642 +3643 +3644 +3645 +3646

    -
    # File 'lib/idl/ast.rb', line 3056
    +      
    # File 'lib/idl/ast.rb', line 3642
     
     def body
       internal_error "Function has no body" if builtin?
    @@ -939,12 +908,12 @@ 

     
     
    -3072
    -3073
    -3074
    +3658 +3659 +3660

    -
    # File 'lib/idl/ast.rb', line 3072
    +      
    # File 'lib/idl/ast.rb', line 3658
     
     def builtin?
       !respond_to?(:body_block)
    @@ -969,12 +938,12 @@ 

     
     
    -2816
    -2817
    -2818
    +3376 +3377 +3378

    -
    # File 'lib/idl/ast.rb', line 2816
    +      
    # File 'lib/idl/ast.rb', line 3376
     
     def description
       unindent(desc.text_value)
    @@ -999,12 +968,12 @@ 

     
     
    -2927
    -2928
    -2929
    +3478 +3479 +3480

    -
    # File 'lib/idl/ast.rb', line 2927
    +      
    # File 'lib/idl/ast.rb', line 3478
     
     def name
       function_name.text_value
    @@ -1029,14 +998,14 @@ 

     
     
    -2824
    -2825
    -2826
    -2827
    -2828
    +3384 +3385 +3386 +3387 +3388

    -
    # File 'lib/idl/ast.rb', line 2824
    +      
    # File 'lib/idl/ast.rb', line 3384
     
     def num_args
       return 0 if args.empty?
    @@ -1074,39 +1043,47 @@ 

     
     
    -2883
    -2884
    -2885
    -2886
    -2887
    -2888
    -2889
    -2890
    -2891
    -2892
    -2893
    -2894
    -2895
    -2896
    -2897
    -2898
    -2899
    -2900
    -2901
    -2902
    -2903
    -2904
    -2905
    -2906
    -2907
    -2908
    -2909
    -2910
    +3430 +3431 +3432 +3433 +3434 +3435 +3436 +3437 +3438 +3439 +3440 +3441 +3442 +3443 +3444 +3445 +3446 +3447 +3448 +3449 +3450 +3451 +3452 +3453 +3454 +3455 +3456 +3457 +3458 +3459 +3460 +3461

    -
    # File 'lib/idl/ast.rb', line 2883
    +      
    # File 'lib/idl/ast.rb', line 3430
     
     def return_type(symtab)
    +  unless symtab.levels == 2
    +    internal_error "Function bodies should be at global + 1 scope (at global + #{symtab.levels - 1})"
    +  end
    +
       if templated?
         template_names.each do |tname|
           internal_error "Template values missing" unless symtab.get(tname)
    @@ -1165,21 +1142,21 @@ 

     
     
    -2914
    -2915
    -2916
    -2917
    -2918
    -2919
    -2920
    -2921
    -2922
    -2923
    -2924
    -2925
    +3465 +3466 +3467 +3468 +3469 +3470 +3471 +3472 +3473 +3474 +3475 +3476

    -
    # File 'lib/idl/ast.rb', line 2914
    +      
    # File 'lib/idl/ast.rb', line 3465
     
     def return_type_list_str
       list = []
    @@ -1199,9 +1176,9 @@ 

    -

    +

    - #return_types(symtab) ⇒ Object + #template_namesArray<String> @@ -1210,13 +1187,31 @@

    -

    return an array of all the return types, in order function (or template instance) must be resolved

    +

    Returns Template arugment names, in order.

    +

    Returns:

    +
      + +
    • + + + (Array<String>) + + + + — +
      +

      Template arugment names, in order

      +
      + +
    • + +
    @@ -1224,29 +1219,128 @@

     
     
    -2871
    -2872
    -2873
    -2874
    -2875
    -2876
    -2877
    -2878
    -2879
    -2880
    +3536 +3537 +3538 +3539 +3540 +3541 +3542 +3543 +3544

    + +
    -
    # File 'lib/idl/ast.rb', line 2871
    -
    -def return_types(symtab)
    -  t = return_type(symtab)
    -  if t.kind == :tuple
    -    t.tuple_types
    -  elsif t.kind == :void
    -    []
    -  else
    -    [t]
    +      
    # File 'lib/idl/ast.rb', line 3536
    +
    +def template_names
    +  return [] unless templated?
    +
    +  tnames = [targs.first.id.text_value]
    +  targs.rest.elements.each do |a|
    +    tnames << a.function_argument_definition.id.text_value
       end
    +  tnames
    +end
    +
    +
    + +
    +

    + + #template_types(symtab) ⇒ Array<Type> + + + + + +

    +
    + +

    Returns Template argument types, in order.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for evaluation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Type>) + + + + — +
      +

      Template argument types, in order

      +
      + +
    • + +
    + +
    + + + @@ -1290,12 +1384,12 @@

     
     
    -2820
    -2821
    -2822
    +3380 +3381 +3382

    @@ -1439,32 +1519,32 @@

     
     
    -3021
    -3022
    -3023
    -3024
    -3025
    -3026
    -3027
    -3028
    -3029
    -3030
    -3031
    -3032
    -3033
    -3034
    -3035
    -3036
    -3037
    -3038
    -3039
    -3040
    -3041
    -3042
    -3043
    +3607 +3608 +3609 +3610 +3611 +3612 +3613 +3614 +3615 +3616 +3617 +3618 +3619 +3620 +3621 +3622 +3623 +3624 +3625 +3626 +3627 +3628 +3629

    @@ -776,10 +808,10 @@

     
     
    -433
    +444

    @@ -802,12 +834,12 @@

     
     
    -429
    -430
    -431
    +440 +441 +442

    @@ -846,7 +878,7 @@

    - #return_type(template_values, argument_nodes, call_site_symtab) ⇒ Object + #return_type(template_values) ⇒ Object @@ -880,22 +912,6 @@

    -
  • - - argument_nodes - - - (Array<Ast::Node>) - - - - — -
    -

    Arguments at the call site

    -
    - -
  • -
  • call_site_symtab @@ -921,20 +937,20 @@

     
     
    -488
    -489
    -490
    -491
    -492
    -493
    +508 +509 +510 +511 +512 +513

  • @@ -1006,15 +1022,15 @@

     
     
    -497
    -498
    -499
    -500
    -501
    -502
    +524 +525 +526 +527 +528 +529

    +
    +
    +
    +3548
    +3549
    +3550
    +3551
    +3552
    +3553
    +3554
    +3555
    +3556
    +3557
    +3558
    +3559
    +3560
    +3561
    +
    +
    # File 'lib/idl/ast.rb', line 3548
    +
    +def template_types(symtab)
    +  return [] unless templated?
    +
    +  ttype = targs.first.type_name.type(symtab)
    +  ttype = Type.new(:enum_ref, enum_class: ttype) if ttype.kind == :enum
    +
    +  ttypes = [ttype.clone]
    +  targs.rest.elements.each do |a|
    +    ttype = a.function_argument_definition.type_name.type(symtab)
    +    ttype = Type.new(:enum_ref, enum_class: ttype) if ttype.kind == :enum
    +    ttypes << ttype
    +  end
    +  ttypes
     end
    -
    # File 'lib/idl/ast.rb', line 2820
    +      
    # File 'lib/idl/ast.rb', line 3380
     
     def templated?
       !targs.empty?
    @@ -1385,39 +1479,25 @@ 

     
     
    -2959
    -2960
    -2961
    -2962
    -2963
    -2964
    -2965
    -2966
    -2967
    -2968
    -2969
    -2970
    -2971
    -2972
    -2973
    +3514 +3515 +3516 +3517 +3518 +3519 +3520 +3521

    -
    # File 'lib/idl/ast.rb', line 2959
    +      
    # File 'lib/idl/ast.rb', line 3514
     
     def type_check(symtab)
       internal_error "Functions must be declared at global scope (at #{symtab.levels})" unless symtab.levels == 1
     
       type_check_targs(symtab)
     
    -  # now add the function in global scope
    -  def_type = FunctionType.new(
    -      name,
    -      self,
    -      symtab.deep_clone
    -    )
    -
       # recursion isn't supported (doesn't map well to hardware), so we can add the function after type checking the body
    -  symtab.add!(name, def_type)
    +  add_symbol(symtab)
     end
    -
    # File 'lib/idl/ast.rb', line 3021
    +      
    # File 'lib/idl/ast.rb', line 3607
     
     def type_check_args(symtab)
       @arguments = []
    @@ -1509,19 +1589,19 @@ 

     
     
    -3045
    -3046
    -3047
    -3048
    -3049
    -3050
    -3051
    -3052
    -3053
    -3054
    +3631 +3632 +3633 +3634 +3635 +3636 +3637 +3638 +3639 +3640

    -
    # File 'lib/idl/ast.rb', line 3045
    +      
    # File 'lib/idl/ast.rb', line 3631
     
     def type_check_body(symtab)
     
    @@ -1564,21 +1644,25 @@ 

     
     
    -2947
    -2948
    -2949
    -2950
    -2951
    -2952
    -2953
    -2954
    -2955
    -2956
    +3500 +3501 +3502 +3503 +3504 +3505 +3506 +3507 +3508 +3509 +3510 +3511

    -
    # File 'lib/idl/ast.rb', line 2947
    +      
    # File 'lib/idl/ast.rb', line 3500
     
     def type_check_from_call(symtab)
    +  internal_error "Function definitions should be at global + 1 scope" unless symtab.levels == 2
    +
       global_scope = symtab.deep_clone
       global_scope.pop while global_scope.levels != 1
     
    @@ -1608,25 +1692,25 @@ 

     
     
    -3004
    -3005
    -3006
    -3007
    -3008
    -3009
    -3010
    -3011
    -3012
    -3013
    -3014
    -3015
    -3016
    -3017
    -3018
    -3019
    +3590 +3591 +3592 +3593 +3594 +3595 +3596 +3597 +3598 +3599 +3600 +3601 +3602 +3603 +3604 +3605

    -
    # File 'lib/idl/ast.rb', line 3004
    +      
    # File 'lib/idl/ast.rb', line 3590
     
     def type_check_return(symtab)
       return if ret.empty?
    @@ -1664,35 +1748,35 @@ 

     
     
    -2977
    -2978
    -2979
    -2980
    -2981
    -2982
    -2983
    -2984
    -2985
    -2986
    -2987
    -2988
    -2989
    -2990
    -2991
    -2992
    -2993
    -2994
    -2995
    -2996
    -2997
    -2998
    -2999
    -3000
    -3001
    -3002
    +3563 +3564 +3565 +3566 +3567 +3568 +3569 +3570 +3571 +3572 +3573 +3574 +3575 +3576 +3577 +3578 +3579 +3580 +3581 +3582 +3583 +3584 +3585 +3586 +3587 +3588

    -
    # File 'lib/idl/ast.rb', line 2977
    +      
    # File 'lib/idl/ast.rb', line 3563
     
     def type_check_targs(symtab)
       @template_names = []
    @@ -1769,22 +1853,26 @@ 

     
     
    -2932
    -2933
    -2934
    -2935
    -2936
    -2937
    -2938
    -2939
    -2940
    -2941
    -2942
    +3483 +3484 +3485 +3486 +3487 +3488 +3489 +3490 +3491 +3492 +3493 +3494 +3495

    -
    # File 'lib/idl/ast.rb', line 2932
    +      
    # File 'lib/idl/ast.rb', line 3483
     
     def type_check_template_instance(symtab)
    +  internal_error "Function definitions should be at global + 1 scope" unless symtab.levels == 2
    +
       internal_error "Not a template function" unless templated?
     
       template_names.each do |tname|
    @@ -1805,7 +1893,7 @@ 

    diff --git a/docs/ruby/Idl/FunctionStatementAst.html b/docs/ruby/Idl/FunctionStatementAst.html deleted file mode 100644 index 75f8eb99f..000000000 --- a/docs/ruby/Idl/FunctionStatementAst.html +++ /dev/null @@ -1,1037 +0,0 @@ - - - - - - - Module: Idl::FunctionStatementAst - - — Documentation by YARD 0.9.36 - - - - - - - - - - - - - - - - - - - -
    - - -

    Module: Idl::FunctionStatementAst - - - -

    -
    - - - - - - -
    -
    Includes:
    -
    AstNodeFuncs, Executable
    -
    - - - - - - -
    -
    Defined in:
    -
    lib/idl/ast.rb
    -
    - -
    - - - - - - - - - -

    - Instance Method Summary - collapse -

    - - - - - - - - - - -
    -

    Instance Method Details

    - - -
    -

    - - #childrenArray<AstNode> - - - - - - - Originally defined in module - AstNodeFuncs - - -

    -
    - -

    Returns list of children, or an empty array for a terminal.

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Array<AstNode>) - - - - — -
      -

      list of children, or an empty array for a terminal

      -
      - -
    • - -
    - -
    -
    - -
    -

    - - #execute(symtab) ⇒ Object - - - - - -

    - - - - -
    -
    -
    -
    -2718
    -2719
    -2720
    -
    -
    # File 'lib/idl/ast.rb', line 2718
    -
    -def execute(symtab)
    -  raise "WHere is this AST?"
    -end
    -
    -
    - -
    -

    - - #internal_error(reason) ⇒ Object - - - - - - - Originally defined in module - AstNodeFuncs - - -

    -
    - -

    raise an internal error

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - reason - - - (String) - - - - — -
      -

      Error message

      -
      - -
    • - -
    - -

    Raises:

    - - -
    -
    - -
    -

    - - #nodesArray<AstNode> - - - - - - - Originally defined in module - AstNodeFuncs - - -

    -
    - -

    Returns an array of AST sub nodes (notably, excludes anything, like whitespace, that wasn’t subclassed to AST).

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Array<AstNode>) - - - - — -
      -

      an array of AST sub nodes (notably, excludes anything, like whitespace, that wasn’t subclassed to AST)

      -
      - -
    • - -
    - -
    -
    - -
    -
    -
    - -

    pretty print the AST rooted at this node

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - indent - - - (Integer) - - - (defaults to: 0) - - - — -
      -

      The starting indentation, in # of spaces

      -
      - -
    • - -
    • - - indent_size - - - (Integer) - - - (defaults to: 2) - - - — -
      -

      The extra indentation applied to each level of the tree

      -
      - -
    • - -
    • - - io - - - (IO) - - - (defaults to: $stdout) - - - — -
      -

      Where to write the output

      -
      - -
    • - -
    - - -
    -
    - -
    -

    - - #to_idlString - - - - - - - Originally defined in module - AstNodeFuncs - - -

    -
    -
    - This method is abstract. -
    -
    - -

    Return valid IDL representation of the node (and its subtree)

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (String) - - - - — -
      -

      IDL code for the node

      -
      - -
    • - -
    -

    Raises:

    -
      - -
    • - - - (NotImplementedError) - - - -
    • - -
    - -
    -
    - -
    -

    - - #type_check(symtab) ⇒ void - - - - - - - Originally defined in module - AstNodeFuncs - - -

    -
    -
    - This method is abstract. -
    -
    -

    This method returns an undefined value.

    -

    type check this node and all children

    - -

    Calls to #type and/or #value may depend on type_check being called first with the same symtab. If not, those functions may raise an AstNode::InternalError

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - symtab - - - (SymbolTable) - - - - — -
      -

      Symbol table for lookup

      -
      - -
    • - -
    - -

    Raises:

    - - -
    -
    - -
    -

    - - #type_error(reason) ⇒ Object - - - - - - - Originally defined in module - AstNodeFuncs - - -

    -
    - -

    raise a type error

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - reason - - - (String) - - - - — -
      -

      Error message

      -
      - -
    • - -
    - -

    Raises:

    - - -
    -
    - -
    -

    - - #unindent(s) ⇒ String - - - - - - - Originally defined in module - AstNodeFuncs - - -

    -
    - -

    unindent a multiline string, getting rid of all common leading whitespace (like <<~ heredocs)

    - -

    borrowed from stackoverflow.com/questions/33527064/multiline-strings-with-no-indent

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - s - - - (String) - - - - — -
      -

      A string (presumably with newlines)

      -
      - -
    • - -
    - -

    Returns:

    -
      - -
    • - - - (String) - - - - — -
      -

      Unindented string

      -
      - -
    • - -
    - -
    -
    - -
    -

    - - #value_error(reason) ⇒ Object - - - - - - - Originally defined in module - AstNodeFuncs - - -

    -
    - -

    raise a value error, indicating that the value is not known at compile time

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - reason - - - (String) - - - - — -
      -

      Error message

      -
      - -
    • - -
    - -

    Raises:

    - - -
    -
    - -
    - -
    - - - -
    - - \ No newline at end of file diff --git a/docs/ruby/Idl/FunctionType.html b/docs/ruby/Idl/FunctionType.html index ca1eb7dd3..553492205 100644 --- a/docs/ruby/Idl/FunctionType.html +++ b/docs/ruby/Idl/FunctionType.html @@ -323,7 +323,7 @@

  • - #return_type(template_values, argument_nodes, call_site_symtab) ⇒ Object + #return_type(template_values) ⇒ Object @@ -365,6 +365,28 @@

    Return types.

    +

  • + + +
  • + + + #return_value(template_values, argument_nodes, call_site_symtab) ⇒ Object + + + + + + + + + + + + + +
    +
  • @@ -393,7 +415,7 @@

  • - #template_types ⇒ Object + #template_types(symtab) ⇒ Object @@ -490,21 +512,21 @@

     
     
    -421
    -422
    -423
    -424
    -425
    -426
    -427
    +432 +433 +434 +435 +436 +437 +438

  • -
    # File 'lib/idl/type.rb', line 421
    +      
    # File 'lib/idl/type.rb', line 432
     
     def initialize(func_name, func_def_ast, symtab)
       super(:function, name: func_name)
       @func_def_ast = func_def_ast
    -  @symtab = symtab.deep_clone
    +  @symtab = symtab
     
       raise "symtab should be at level 1" unless symtab.levels == 1
     end
    @@ -546,20 +568,20 @@

     
     
    -472
    -473
    -474
    -475
    -476
    -477
    -478
    -479
    -480
    -481
    -482
    +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503

    -
    # File 'lib/idl/type.rb', line 472
    +      
    # File 'lib/idl/type.rb', line 493
     
     def apply_arguments(symtab, argument_nodes, call_site_symtab)
       idx = 0
    @@ -592,23 +614,28 @@ 

     
     
    -455
    -456
    -457
    -458
    -459
    -460
    -461
    -462
    -463
    -464
    -465
    -466
    -467
    -468
    +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489

    -
    # File 'lib/idl/type.rb', line 455
    +      
    # File 'lib/idl/type.rb', line 471
     
     def apply_template_values(template_values = [])
       raise "Missing template values" if templated? && template_values.empty?
    @@ -616,11 +643,16 @@ 

    raise "wrong number of template values" unless template_names.size == template_values.size symtab = @symtab.deep_clone + symtab.pop while symtab.levels != 1 + + raise "Symbol table should be at global scope" unless symtab.levels == 1 symtab.push template_values.each_with_index do |value, idx| - symtab.add!(template_names[idx], Var.new(template_names[idx], template_types[idx], value)) + raise "template value should be an Integer" unless value.is_a?(Integer) + + symtab.add!(template_names[idx], Var.new(template_names[idx], template_types(symtab)[idx], value, template_index: idx, function_name: @func_def_ast.name)) end symtab end

    @@ -644,18 +676,18 @@

     
     
    -514
    -515
    -516
    -517
    -518
    -519
    -520
    -521
    -522
    +541 +542 +543 +544 +545 +546 +547 +548 +549

    -
    # File 'lib/idl/type.rb', line 514
    +      
    # File 'lib/idl/type.rb', line 541
     
     def argument_name(index, template_values = [])
       return nil if index >= @func_def_ast.num_args
    @@ -686,18 +718,18 @@ 

     
     
    -504
    -505
    -506
    -507
    -508
    -509
    -510
    -511
    -512
    +531 +532 +533 +534 +535 +536 +537 +538 +539

    -
    # File 'lib/idl/type.rb', line 504
    +      
    # File 'lib/idl/type.rb', line 531
     
     def argument_type(index, template_values, argument_nodes, call_site_symtab)
       return nil if index >= @func_def_ast.num_args
    @@ -728,10 +760,10 @@ 

     
     
    -524
    +551

    -
    # File 'lib/idl/type.rb', line 524
    +      
    # File 'lib/idl/type.rb', line 551
     
     def body = @func_def_ast.body
    -
    # File 'lib/idl/type.rb', line 433
    +      
    # File 'lib/idl/type.rb', line 444
     
     def builtin? = @func_def_ast.builtin?
    -
    # File 'lib/idl/type.rb', line 429
    +      
    # File 'lib/idl/type.rb', line 440
     
     def clone
       FunctionType.new(name, @func_def_ast, @symtab)
    @@ -832,10 +864,10 @@ 

     
     
    -435
    +446

    -
    # File 'lib/idl/type.rb', line 435
    +      
    # File 'lib/idl/type.rb', line 446
     
     def num_args = @func_def_ast.num_args
    -
    # File 'lib/idl/type.rb', line 488
    +      
    # File 'lib/idl/type.rb', line 508
     
    -def return_type(template_values, argument_nodes, call_site_symtab)
    +def return_type(template_values)
       symtab = apply_template_values(template_values)
    -  apply_arguments(symtab, argument_nodes, call_site_symtab)
    -
    +  # apply_arguments(symtab, argument_nodes, call_site_symtab)
    +
       @func_def_ast.return_type(symtab).clone
     end
    -
    # File 'lib/idl/type.rb', line 497
    +      
    # File 'lib/idl/type.rb', line 524
     
     def return_types(template_values, argument_nodes, call_site_symtab)
       symtab = apply_template_values(template_values)
    @@ -1025,6 +1041,42 @@ 

    +
    + +
    +

    + + #return_value(template_values, argument_nodes, call_site_symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +515
    +516
    +517
    +518
    +519
    +520
    +
    +
    # File 'lib/idl/type.rb', line 515
    +
    +def return_value(template_values, argument_nodes, call_site_symtab)
    +  symtab = apply_template_values(template_values)
    +  apply_arguments(symtab, argument_nodes, call_site_symtab)
    +
    +  @func_def_ast.body.return_value(symtab)
    +end
    +
    @@ -1042,10 +1094,10 @@

     
     
    -449
    +465

    -
    # File 'lib/idl/type.rb', line 449
    +      
    # File 'lib/idl/type.rb', line 465
     
     def template_names = @func_def_ast.template_names
    @@ -1056,7 +1108,7 @@

    - #template_typesObject + #template_types(symtab) ⇒ Object @@ -1068,12 +1120,12 @@

     
     
    -451
    +467

    -
    # File 'lib/idl/type.rb', line 451
    +      
    # File 'lib/idl/type.rb', line 467
     
    -def template_types = @func_def_ast.template_types
    +def template_types(symtab) = @func_def_ast.template_types(symtab)
    @@ -1116,10 +1168,10 @@

     
     
    -453
    +469

    -
    # File 'lib/idl/type.rb', line 453
    +      
    # File 'lib/idl/type.rb', line 469
     
     def templated? = @func_def_ast.templated?
    @@ -1142,30 +1194,40 @@

     
     
    -437
    -438
    -439
    -440
    -441
    -442
    -443
    -444
    -445
    -446
    -447
    +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463

    -
    # File 'lib/idl/type.rb', line 437
    +      
    # File 'lib/idl/type.rb', line 448
     
     def type_check_call(template_values = [])
    -  raise "Missing template values" if templated? and template_values.empty?
    +  raise "Missing template values" if templated? && template_values.empty?
     
       if templated?
         symtab = apply_template_values(template_values)
     
         @func_def_ast.type_check_template_instance(symtab)
       else
    -    @func_def_ast.type_check_from_call(@symtab)
    +    symtab = @symtab.deep_clone
    +    symtab.pop while symtab.levels != 1
    +
    +    symtab.push # to keep things consistent with template functions, push a scope
    +
    +    @func_def_ast.type_check_from_call(symtab)
       end
     end
    @@ -1178,7 +1240,7 @@

    diff --git a/docs/ruby/Idl/GlobalAst.html b/docs/ruby/Idl/GlobalAst.html index 232835243..320eb0140 100644 --- a/docs/ruby/Idl/GlobalAst.html +++ b/docs/ruby/Idl/GlobalAst.html @@ -294,12 +294,12 @@

     
     
    -469
    -470
    -471
    +500 +501 +502

    -
    # File 'lib/idl/ast.rb', line 469
    +      
    # File 'lib/idl/ast.rb', line 500
     
     def type(symtab)
       declaration.type
    @@ -324,12 +324,12 @@ 

     
     
    -465
    -466
    -467
    +496 +497 +498

    -
    # File 'lib/idl/ast.rb', line 465
    +      
    # File 'lib/idl/ast.rb', line 496
     
     def type_check(symtab)
       declaration.type_check(symtab)
    @@ -344,7 +344,7 @@ 

    diff --git a/docs/ruby/Idl/GlobalWithInitializationAst.html b/docs/ruby/Idl/GlobalWithInitializationAst.html index fc2e7265f..65ed74366 100644 --- a/docs/ruby/Idl/GlobalWithInitializationAst.html +++ b/docs/ruby/Idl/GlobalWithInitializationAst.html @@ -358,12 +358,12 @@

     
     
    -457
    -458
    -459
    +488 +489 +490

    -
    # File 'lib/idl/ast.rb', line 457
    +      
    # File 'lib/idl/ast.rb', line 488
     
     def to_idl
       "TODO"
    @@ -388,12 +388,12 @@ 

     
     
    -449
    -450
    -451
    +480 +481 +482

    -
    # File 'lib/idl/ast.rb', line 449
    +      
    # File 'lib/idl/ast.rb', line 480
     
     def type(symtab)
       single_declartion_with_initialization.type(symtab)
    @@ -418,16 +418,14 @@ 

     
     
    -444
    -445
    -446
    -447
    +476 +477 +478

    -
    # File 'lib/idl/ast.rb', line 444
    +      
    # File 'lib/idl/ast.rb', line 476
     
     def type_check(symtab)
    -  puts "global #{text_value}"
       single_declaration_with_initialization.type_check(symtab)
     end
    @@ -450,12 +448,12 @@

     
     
    -453
    -454
    -455
    +484 +485 +486

    -
    # File 'lib/idl/ast.rb', line 453
    +      
    # File 'lib/idl/ast.rb', line 484
     
     def value(symtab)
       single_declartion_with_initialization.value(symtab)
    @@ -470,7 +468,7 @@ 

    diff --git a/docs/ruby/Idl/IdAst.html b/docs/ruby/Idl/IdAst.html index 90bf95bb5..29c184a4f 100644 --- a/docs/ruby/Idl/IdAst.html +++ b/docs/ruby/Idl/IdAst.html @@ -103,7 +103,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/gen_adoc.rb
    +
    @@ -139,6 +141,54 @@

  • + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + #initialize(input, interval, id_name) ⇒ IdAst + + + + + + + constructor + + + + + + + + +
    +

    A new instance of IdAst.

    +
    + +
  • + + +
  • + + #name ⇒ String @@ -249,6 +299,35 @@

    +

  • + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
    +
  • @@ -263,14 +342,91 @@

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(input, interval, id_name) ⇒ IdAst + + + +

    +
    + +

    Returns a new instance of IdAst.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +429
    +430
    +431
    +432
    +
    +
    # File 'lib/idl/ast.rb', line 429
    +
    +def initialize(input, interval, id_name)
    +  super(input, interval, [])
    +  @name = id_name
    +end
    +
    +
    + +
    + +

    Instance Method Details

    -

    +

    + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +57
    +58
    +59
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 57
    +
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  text_value
    +end
    +
    +
    + +
    +

    #nameString @@ -313,12 +469,12 @@

     
     
    -408
    +440

    -
    # File 'lib/idl/ast.rb', line 408
    +      
    # File 'lib/idl/ast.rb', line 440
     
    -def name = text_value
    +def name = @name
    @@ -368,12 +524,12 @@

     
     
    -429
    +461

    -
    # File 'lib/idl/ast.rb', line 429
    +      
    # File 'lib/idl/ast.rb', line 461
     
    -def to_idl = text_value
    +def to_idl = @name
    @@ -394,19 +550,19 @@

     
     
    -411
    -412
    -413
    -414
    -415
    +443 +444 +445 +446 +447

    -
    # File 'lib/idl/ast.rb', line 411
    +      
    # File 'lib/idl/ast.rb', line 443
     
     def type(symtab)
    -  internal_error "Symbol not found (should have called type_check)" if symtab.get(text_value).nil?
    +  internal_error "Symbol '#{@name}' not found (should have called type_check)" if symtab.get(@name).nil?
     
    -  symtab.get(text_value).type
    +  symtab.get(@name).type
     end
    @@ -493,15 +649,15 @@

     
     
    -403
    -404
    -405
    +435 +436 +437

    -
    # File 'lib/idl/ast.rb', line 403
    +      
    # File 'lib/idl/ast.rb', line 435
     
     def type_check(symtab)
    -  type_error "no symbol named '#{text_value}' on line #{lineno}" if symtab.get(text_value).nil?
    +  type_error "no symbol named '#{@name}' on line #{lineno}" if symtab.get(@name).nil?
     end
    @@ -523,31 +679,127 @@

     
     
    -418
    -419
    -420
    -421
    -422
    -423
    -424
    -425
    -426
    +450 +451 +452 +453 +454 +455 +456 +457 +458

    -
    # File 'lib/idl/ast.rb', line 418
    +      
    # File 'lib/idl/ast.rb', line 450
     
     def value(symtab)
    -  var = symtab.get(text_value)
    +  var = symtab.get(@name)
     
    -  internal_error "Var was not found, call type_check first!" if var.nil?
    +  type_error "Variable '#{@name}' was not found" if var.nil?
     
    -  value_error "Value of '#{text_value}' not known" if var.value.nil?
    +  value_error "Value of '#{@name}' not known" if var.value.nil?
     
       var.value
     end
    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -555,7 +807,7 @@

    diff --git a/docs/ruby/Idl/IdSyntaxNode.html b/docs/ruby/Idl/IdSyntaxNode.html new file mode 100644 index 000000000..62e795928 --- /dev/null +++ b/docs/ruby/Idl/IdSyntaxNode.html @@ -0,0 +1,190 @@ + + + + + + + Class: Idl::IdSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::IdSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +420
    +
    +
    # File 'lib/idl/ast.rb', line 420
    +
    +def to_ast = IdAst.new(input, interval, text_value)
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/IfAst.html b/docs/ruby/Idl/IfAst.html index dd5249f61..ea5d47b28 100644 --- a/docs/ruby/Idl/IfAst.html +++ b/docs/ruby/Idl/IfAst.html @@ -104,7 +104,7 @@
    Defined in:
    lib/idl/ast.rb,
    - lib/idl/passes/find_return_values.rb
    + lib/idl/passes/prune.rb,
    lib/idl/passes/gen_adoc.rb,
    lib/idl/passes/find_return_values.rb
    @@ -114,6 +114,127 @@ +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #elseifs ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute elseifs.

      +
      + +
    • + + +
    • + + + #final_else_body ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute final_else_body.

      +
      + +
    • + + +
    • + + + #if_body ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute if_body.

      +
      + +
    • + + +
    • + + + #if_cond ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute if_cond.

      +
      + +
    • + + +
    + @@ -128,17 +249,36 @@

  • - #execute(symtab) ⇒ void + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + #initialize(if_cond, if_body, elseifs, final_else_body) ⇒ IfAst - - included - from Executable - + constructor @@ -148,7 +288,7 @@

    -

    “execute” the statement by updating the variables in the symbol table.

    +

    A new instance of IfAst.

  • @@ -173,6 +313,30 @@

    + + + +
  • + + + #prune(symtab) ⇒ AstNode + + + + + + + + + + + + + +
    +

    A new abstract syntax tree with all dead/unreachable code removed.

    +
    +
  • @@ -183,6 +347,8 @@

    + (also: #execute) + @@ -201,7 +367,7 @@

  • - #return_values(symtab) ⇒ Object + #return_values(symtab) ⇒ Array<Integer,Bool> @@ -215,7 +381,9 @@

    -
    +
    +

    Returns a list of all possible return values, if known.

    +

  • @@ -247,7 +415,7 @@

  • - #to_idl ⇒ Object + #to_idl ⇒ String @@ -261,7 +429,9 @@

    -
    +
    +

    Return valid IDL representation of the node (and its subtree).

    +

  • @@ -303,76 +473,334 @@

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(if_cond, if_body, elseifs, final_else_body) ⇒ IfAst + + + + + +

    +
    + +

    Returns a new instance of IfAst.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +3953
    +3954
    +3955
    +3956
    +3957
    +3958
    +3959
    +3960
    +3961
    +3962
    +3963
    +3964
    +3965
    +3966
    +3967
    +3968
    +3969
    +3970
    +3971
    +3972
    +3973
    +
    +
    # File 'lib/idl/ast.rb', line 3953
    +
    +def initialize(if_cond, if_body, elseifs, final_else_body)
    +  children_nodes = [if_cond, if_body]
    +  children_nodes += elseifs
    +  children_nodes << final_else_body
    +
    +  interval_end =
    +    if !final_else_body.stmts.empty?
    +      final_else_body.stmts.last.interval.end
    +    elsif !elseifs.empty?
    +      elseifs.last.body.stmts.last.interval.end
    +    else
    +      if_body.stmts.last.interval.end
    +    end
    +
    +  super(if_cond.input, if_cond.interval.first..interval_end, children_nodes)
    +
    +  @if_cond = if_cond
    +  @if_body = if_body
    +  @elseifs = elseifs
    +  @final_else_body = final_else_body
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #elseifsObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute elseifs.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +3951
    +3952
    +3953
    +
    +
    # File 'lib/idl/ast.rb', line 3951
    +
    +def elseifs
    +  @elseifs
    +end
    +
    +
    + + + +
    +

    + + #final_else_bodyObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute final_else_body.

    + + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +3951
    +3952
    +3953
    +
    +
    # File 'lib/idl/ast.rb', line 3951
    +
    +def final_else_body
    +  @final_else_body
    +end
    +
    +
    + + + +
    +

    + + #if_bodyObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute if_body.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +3951
    +3952
    +3953
    +
    +
    # File 'lib/idl/ast.rb', line 3951
    +
    +def if_body
    +  @if_body
    +end
    +
    +
    + + + +
    +

    + + #if_condObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute if_cond.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +3951
    +3952
    +3953
    +
    +
    # File 'lib/idl/ast.rb', line 3951
    +
    +def if_cond
    +  @if_cond
    +end
    +
    +
    + +
    + +

    Instance Method Details

    -

    +

    - #execute(symtab) ⇒ void + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object - - Originally defined in module - Executable - - -

    -
    -

    This method returns an undefined value.

    -

    “execute” the statement by updating the variables in the symbol table

    +

    + + + + +
    +
     
     
    -  
    -
    -
    -

    Parameters:

    -
      - -
    • - - symtab - - - (SymbolTable) - - - - — -
      -

      The symbol table for the context

      -
      - -
    • - -
    +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 215
     
    -

    Raises:

    -
      - -
    • - - - - - - - -
      -

      ValueError if some part of the statement cannot be executed at compile time

      -
      - -
    • - -
    +def gen_adoc(indent = 0, indent_spaces: 2) + lines = ["if (#{if_cond.gen_adoc(0, indent_spaces:)}) {"] + if_body.stmts.each do |s| + lines << s.gen_adoc(indent + indent_spaces, indent_spaces:) + end + elseifs.each do |eif| + lines << "} else if (#{eif.cond.gen_adoc(0, indent_spaces:)}) {" + eif.body.stmts.each do |s| + lines << s.gen_adoc(indent + indent_spaces, indent_spaces:) + end + end + unless final_else_body.stmts.empty? + lines << "} else {" + final_else_body.stmts.each do |s| + lines << s.gen_adoc(indent + indent_spaces, indent_spaces:) + end + end + lines << "}" - + lines.map { |l| "#{' ' * indent}#{l}"}.join("\n") +end
    +
    @@ -453,6 +881,155 @@

    +

    + +
    +

    + + #prune(symtab) ⇒ AstNode + + + + + +

    +
    + +

    Returns A new abstract syntax tree with all dead/unreachable code removed.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (Idl::SymbolTable) + + + + — +
      +

      Context of the compilation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (AstNode) + + + + — +
      +

      A new abstract syntax tree with all dead/unreachable code removed

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +162
    +163
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +181
    +182
    +183
    +184
    +185
    +186
    +187
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +
    +
    # File 'lib/idl/passes/prune.rb', line 162
    +
    +def prune(symtab)
    +  if if_cond.value(symtab)
    +    if_body.prune(symtab)
    +  elsif !elseifs.empty?
    +    # we know that the if condition is false, so now we treat the else if
    +    # as the starting point and try again
    +    IfAst.new(
    +      elseifs[0].cond.prune(symtab),
    +      elseifs[0].body.prune(symtab),
    +      elseifs[1..].map { |e| e.prune(symtab) },
    +      final_else_body.prune(symtab))
    +  elsif !final_else_body.stmts.empty?
    +    # the if is false, and there are no else ifs, so the result of the prune is just the pruned else body
    +    final_else_body.prune(symtab)
    +  else
    +    # the if is false, and there are no else ifs or elses. This is just a no-op
    +    NoopAst.new
    +  end
    +rescue ValueError
    +  # we don't know the value of the if condition
    +  # we still might know the value of an else if
    +  unknown_elsifs = []
    +  elseifs.each do |eif|
    +    begin
    +      if eif.cond.value(symtab)
    +        # this elseif is true, so turn it into an else and then we are done
    +        return IfAst.new(if_cond.prune(symtab), if_body.prune(symtab), unknown_elsifs.map { |u| u.prune(symtab)}, eif.body.prune(symtab))
    +      else
    +        # this elseif is false, so we can remove it
    +        next
    +      end
    +    rescue ValueError
    +      unknown_elsifs << eif
    +    end
    +  end
    +  # we get here, then we don't know the value of anything. just return this if with everything pruned
    +  IfAst.new(if_cond.prune(symtab), if_body.prune(symtab), elseifs.map { |eif| eif.prune(symtab)}, final_else_body.prune(symtab))
    +end
    +
    @@ -462,6 +1039,10 @@

    + Also known as: + execute + +

    @@ -470,55 +1051,23 @@

     
     
    -3224
    -3225
    -3226
    -3227
    -3228
    -3229
    -3230
    -3231
    -3232
    -3233
    -3234
    -3235
    -3236
    -3237
    -3238
    -3239
    -3240
    -3241
    -3242
    -3243
    -3244
    -3245
    -3246
    +4023 +4024 +4025 +4026 +4027 +4028 +4029

    @@ -528,41 +1077,114 @@

    - #return_values(symtab) ⇒ Object + #return_values(symtab) ⇒ Array<Integer,Bool> -

    -
    # File 'lib/idl/ast.rb', line 3224
    +      
    # File 'lib/idl/ast.rb', line 4023
     
     def return_value(symtab)
     
       body = taken_body(symtab)
       return nil if body.nil?
     
    -  symtab.push
    -  begin
    -    body.elements.each do |e|
    -      if e.e.is_a?(Returns)
    -        v = e.e.return_value(symtab)
    -        unless v.nil?
    -          return v
    -        end
    -      else
    -        e.e.execute(symtab)
    -      end
    -    end
    -  ensure
    -    symtab.pop
    -  end
    -
    -  nil
    +  body.return_value(symtab)
     end
    +
    +
    + +

    Returns a list of all possible return values, if known. Otherwise, raises a ValueError

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      Context for the evaluation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer,Bool>) + + + + — +
      +

      List of all possible return values

      +
      + +
    • + +
    +

    Raises:

    +
      + +
    • + + + + + + + +
      +

      ValueError if it is not possible to determine all return values at compile time

      +
      + +
    • + +
    + +
    @@ -631,31 +1253,31 @@

     
     
    -3201
    -3202
    -3203
    -3204
    -3205
    -3206
    -3207
    -3208
    -3209
    -3210
    -3211
    +4010 +4011 +4012 +4013 +4014 +4015 +4016 +4017 +4018 +4019 +4020

    @@ -665,63 +1287,78 @@

    - #to_idlObject + #to_idlString -

     
     
    -3213
    -3214
    -3215
    -3216
    -3217
    -3218
    -3219
    -3220
    -3221
    -3222
    +4064 +4065 +4066 +4067 +4068 +4069 +4070 +4071 +4072 +4073 +4074 +4075 +4076
    -
    # File 'lib/idl/ast.rb', line 3213
    +      
    # File 'lib/idl/ast.rb', line 4064
     
     def return_values(symtab)
    -  begin
    -    # the if condition is known
    -    if if_cond.value(symtab)
    -
    -    else
    -    end
    -  rescue ValueError
    +  if_cond_value = @if_cond.value(symtab)
    +  if if_cond_value
    +    # if is taken, so the only possible return values are those in the if body
    +    @if_body.return_values(symtab)
    +  else
    +    # if cond not taken; check else ifs and possibly final else
    +    return_values_after_if(symtab)
       end
    +rescue ValueError
    +  # if condition not known; both paths are possible
    +  (@if_body.return_values(symtab) + return_values_after_if(symtab)).uniq
     end
    -
    # File 'lib/idl/ast.rb', line 3201
    +      
    # File 'lib/idl/ast.rb', line 4010
     
     def taken_body(symtab)
    -  return if_body if if_cond.value(symtab)
    +  return @if_body if @if_cond.value(symtab)
     
    -  unless elseifs.empty?
    -    elseifs.elements.each do |eif|
    -      return eif.body if eif.expression.value(symtab)
    +  unless @elseifs.empty?
    +    @elseifs.each do |eif|
    +      return eif.body if eif.cond.value(symtab)
         end
       end
     
    -  final_else.empty? ? nil : final_else.body
    +  @final_else_body.stmts.empty? ? nil : @final_else_body
     end
    +
    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    @@ -808,75 +1445,40 @@

     
     
    -3132
    -3133
    -3134
    -3135
    -3136
    -3137
    -3138
    -3139
    -3140
    -3141
    -3142
    -3143
    -3144
    -3145
    -3146
    -3147
    -3148
    -3149
    -3150
    -3151
    -3152
    -3153
    -3154
    -3155
    -3156
    -3157
    -3158
    -3159
    -3160
    -3161
    -3162
    -3163
    -3164
    -3165
    -3166
    -3167
    -3168
    -3169
    -3170
    -3171
    -3172
    -3173
    -3174
    -3175
    -3176
    -3177
    -3178
    -3179
    -3180
    -3181
    -3182
    -3183
    -3184
    -3185
    -3186
    -3187
    -3188
    -3189
    -3190
    -3191
    -3192
    -3193
    -3194
    -3195
    -3196
    -3197
    +3976 +3977 +3978 +3979 +3980 +3981 +3982 +3983 +3984 +3985 +3986 +3987 +3988 +3989 +3990 +3991 +3992 +3993 +3994 +3995 +3996 +3997 +3998 +3999 +4000 +4001 +4002 +4003 +4004 +4005 +4006

     
     
    -3248
    -3249
    -3250
    -3251
    -3252
    -3253
    -3254
    -3255
    -3256
    -3257
    -3258
    -3259
    -3260
    -3261
    -3262
    -3263
    -3264
    -3265
    -3266
    -3267
    -3268
    +4079 +4080 +4081 +4082 +4083 +4084 +4085 +4086 +4087 +4088 +4089 +4090 +4091 +4092
    -
    # File 'lib/idl/ast.rb', line 3248
    +      
    # File 'lib/idl/ast.rb', line 4079
     
     def to_idl
    -  result = "if (#{if_cond.to_idl}) { "
    -  if_body.elements.each do |e|
    -    result << e.e.to_idl
    -  end
    +  result = "if (#{@if_cond.to_idl}) { "
    +  result << @if_body.to_idl
       result << "} "
    -  elseifs.elements.each do |eif|
    -    result << " else if (#{eif.expression.to_idl}) { "
    -    eif.body.elements.each do |e|
    -      result << e.e.to_idl
    -    end
    -    result << "} "
    +  @elseifs.each do |eif|
    +    result << eif.to_idl
       end
    -  unless final_else.empty?
    +  unless @final_else_body.stmts.empty?
         result << " else { "
    -    final_else.body.elements.each do |e|
    -      result << e.e.to_idl
    -    end
    +    result << @final_else_body.to_idl
         result << "} "
       end
    +  result
     end
    -
    # File 'lib/idl/ast.rb', line 3132
    +      
    # File 'lib/idl/ast.rb', line 3976
     
     def type_check(symtab)
       level = symtab.levels
    @@ -884,63 +1486,28 @@ 

    type_error "'#{if_cond.text_value}' is not boolean" unless if_cond.type(symtab).convertable_to?(:boolean) - symtab.push - begin # only type check the body if it is reachable - if if_cond.value(symtab) == true - if_body.elements.each do |e| - e.e.type_check(symtab) - end + if @if_cond.value(symtab) == true + @if_body.type_check(symtab) return # don't bother with the rest end rescue ValueError # we don't know if the body is reachable; type check it - if_body.elements.each do |e| - e.e.type_check(symtab) - end - ensure - symtab.pop + @if_body.type_check(symtab) end internal_error "not at same level #{level} #{symtab.levels}" unless level == symtab.levels - unless elseifs.empty? - elseifs.elements.each do |eif| - eif.expression.type_check(symtab) - unless eif.expression.type(symtab).convertable_to?(:boolean) - type_error "'#{eif.expression.text_value}' is not boolean" - end - - symtab.push - begin - # only type check the body if it is reachable - if eif.expression.value(symtab) == true - eif.body.elements.each do |e| - e.e.type_check(symtab) - end - return # don't bother with the rest - end - rescue ValueError - # condition isn't compile-time-known; have to check the body - eif.body.elements.each do |e| - e.e.type_check(symtab) - end - ensure - symtab.pop - end + unless @elseifs.empty? + @elseifs.each do |eif| + eif.type_check(symtab) end end - return if final_else.empty? - internal_error "not at same level #{level} #{symtab.levels}" unless level == symtab.levels - symtab.push - final_else.body.elements.each do |e| - e.e.type_check(symtab) - end - symtab.pop + @final_else_body.type_check(symtab) internal_error "not at same level #{level} #{symtab.levels}" unless level == symtab.levels end

    @@ -954,7 +1521,7 @@

    diff --git a/docs/ruby/Idl/IfBodyAst.html b/docs/ruby/Idl/IfBodyAst.html new file mode 100644 index 000000000..027a1f669 --- /dev/null +++ b/docs/ruby/Idl/IfBodyAst.html @@ -0,0 +1,877 @@ + + + + + + + Class: Idl::IfBodyAst + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::IfBodyAst + + + +

    +
    + +
    +
    Inherits:
    +
    + AstNode + + + show all + +
    +
    + + + + + + +
    +
    Includes:
    +
    Executable, Returns
    +
    + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb,
    + lib/idl/passes/prune.rb
    +
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #stmts ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute stmts.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(body_stmts) ⇒ IfBodyAst + + + + + +

    +
    + +

    Returns a new instance of IfBodyAst.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +3788
    +3789
    +3790
    +3791
    +3792
    +3793
    +3794
    +3795
    +
    +
    # File 'lib/idl/ast.rb', line 3788
    +
    +def initialize(body_stmts)
    +  if body_stmts.empty?
    +    super("", 0...0, [])
    +  else
    +    super(body_stmts[0].input, body_stmts.first.interval.first..body_stmts.last.interval.end, body_stmts)
    +  end
    +  @stmts = body_stmts
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #stmtsObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute stmts.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +3786
    +3787
    +3788
    +
    +
    # File 'lib/idl/ast.rb', line 3786
    +
    +def stmts
    +  @stmts
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #execute(symtab) ⇒ void + + + + + +

    +
    +

    This method returns an undefined value.

    +

    “execute” the statement by updating the variables in the symbol table

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The symbol table for the context

      +
      + +
    • + +
    + +

    Raises:

    +
      + +
    • + + + + + + + +
      +

      ValueError if some part of the statement cannot be executed at compile time

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +3854
    +3855
    +3856
    +3857
    +3858
    +
    +
    # File 'lib/idl/ast.rb', line 3854
    +
    +def execute(symtab)
    +  stmts.each do |s|
    +    s.execute(symtab)
    +  end
    +end
    +
    +
    + +
    +

    + + #prune(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +145
    +146
    +147
    +148
    +149
    +150
    +151
    +
    +
    # File 'lib/idl/passes/prune.rb', line 145
    +
    +def prune(symtab)
    +  pruned_stmts = []
    +  stmts.each do |s|
    +    pruned_stmts << s.prune(symtab)
    +  end
    +  IfBodyAst.new(pruned_stmts)
    +end
    +
    +
    + +
    +

    + + #return_value(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +3809
    +3810
    +3811
    +3812
    +3813
    +3814
    +3815
    +3816
    +3817
    +3818
    +3819
    +3820
    +3821
    +3822
    +3823
    +3824
    +3825
    +3826
    +3827
    +
    +
    # File 'lib/idl/ast.rb', line 3809
    +
    +def return_value(symtab)
    +  symtab.push
    +  begin
    +    @stmts.each do |s|
    +      if s.is_a?(Returns)
    +        v = s.return_value(symtab)
    +        unless v.nil?
    +          return v
    +        end
    +      else
    +        s.execute(symtab)
    +      end
    +    end
    +  ensure
    +    symtab.pop
    +  end
    +
    +  nil
    +end
    +
    +
    + +
    +

    + + #return_values(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +3830
    +3831
    +3832
    +3833
    +3834
    +3835
    +3836
    +3837
    +3838
    +3839
    +3840
    +3841
    +3842
    +3843
    +3844
    +3845
    +3846
    +3847
    +3848
    +3849
    +3850
    +3851
    +
    +
    # File 'lib/idl/ast.rb', line 3830
    +
    +def return_values(symtab)
    +  values = []
    +  symtab.push
    +  begin
    +    @stmts.each do |s|
    +      if s.is_a?(Returns)
    +        begin
    +          v = s.return_value(symtab)
    +          return values.push(v).uniq unless v.nil?
    +        rescue ValueError
    +          values += s.return_values(symtab)
    +        end
    +      else
    +        s.execute(symtab)
    +      end
    +    end
    +  ensure
    +    symtab.pop
    +  end
    +
    +  values.uniq
    +end
    +
    +
    + +
    +

    + + #to_idlString + + + + + +

    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +3861
    +3862
    +3863
    +
    +
    # File 'lib/idl/ast.rb', line 3861
    +
    +def to_idl
    +  stmts.map(&:to_idl).join("")
    +end
    +
    +
    + +
    +

    + + #type_check(symtab) ⇒ void + + + + + +

    +
    +

    This method returns an undefined value.

    +

    type check this node and all children

    + +

    Calls to #type and/or #value may depend on type_check being called first with the same symtab. If not, those functions may raise an AstNode::InternalError

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      Symbol table for lookup

      +
      + +
    • + +
    + +

    Raises:

    + + +
    + + + + +
    +
    +
    +
    +3798
    +3799
    +3800
    +3801
    +3802
    +3803
    +3804
    +3805
    +3806
    +
    +
    # File 'lib/idl/ast.rb', line 3798
    +
    +def type_check(symtab)
    +  symtab.push
    +
    +  @stmts.each do |s|
    +    s.type_check(symtab)
    +  end
    +
    +  symtab.pop
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/IfSyntaxNode.html b/docs/ruby/Idl/IfSyntaxNode.html new file mode 100644 index 000000000..b68c56b91 --- /dev/null +++ b/docs/ruby/Idl/IfSyntaxNode.html @@ -0,0 +1,248 @@ + + + + + + + Class: Idl::IfSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::IfSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +3915
    +3916
    +3917
    +3918
    +3919
    +3920
    +3921
    +3922
    +3923
    +3924
    +3925
    +3926
    +3927
    +3928
    +3929
    +3930
    +3931
    +3932
    +3933
    +3934
    +3935
    +3936
    +3937
    +3938
    +3939
    +3940
    +3941
    +3942
    +3943
    +3944
    +
    +
    # File 'lib/idl/ast.rb', line 3915
    +
    +def to_ast
    +  if_body_stmts = []
    +  if_body.elements.each do |e|
    +    if_body_stmts << e.e.to_ast
    +  end
    +  eifs = []
    +  unless elseifs.empty?
    +    elseifs.elements.each do |eif|
    +      stmts = []
    +      eif.body.elements.each do |e|
    +        stmts << e.e.to_ast
    +      end
    +      eifs << ElseIfAst.new(eif.expression.to_ast, stmts)
    +    end
    +  end
    +  final_else_stmts = []
    +  unless final_else.empty?
    +    final_else.body.elements.each do |e|
    +      final_else_stmts << e.e.to_ast
    +    end
    +  end
    +  if_body_ast = IfBodyAst.new(if_body_stmts)
    +  final_else_ast = IfBodyAst.new(final_else_stmts)
    +  ast = IfAst.new(if_cond.to_ast, if_body_ast, eifs, final_else_ast)
    +  ast.parent = parent
    +  if_body_ast.parent = ast
    +  eifs.each { |eif| eif.parent = ast }
    +  final_else_ast.parent = ast
    +  ast
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/InstructionOperationAst.html b/docs/ruby/Idl/InstructionOperationAst.html index 83d0c4e85..2c0c5ea2b 100644 --- a/docs/ruby/Idl/InstructionOperationAst.html +++ b/docs/ruby/Idl/InstructionOperationAst.html @@ -140,6 +140,28 @@

    +
    + + + + +
  • + + + #to_idl ⇒ Object + + + + + + + + + + + + +
  • @@ -201,14 +223,14 @@

     
     
    -2733
    -2734
    -2735
    -2736
    -2737
    +3264 +3265 +3266 +3267 +3268

    -
    # File 'lib/idl/ast.rb', line 2733
    +      
    # File 'lib/idl/ast.rb', line 3264
     
     def execute(symtab)
       op_stmt_list.elements.each do |e|
    @@ -218,6 +240,32 @@ 

    +
    + +
    +

    + + #to_idlObject + + + + + +

    + + + + +
    +
    +
    +
    +3270
    +
    +
    # File 'lib/idl/ast.rb', line 3270
    +
    +def to_idl = op_stmt_list.elements.map { |e| e.choice.to_idl }.join("")
    +
    @@ -300,14 +348,14 @@

     
     
    -2727
    -2728
    -2729
    -2730
    -2731
    +3258 +3259 +3260 +3261 +3262

    -
    # File 'lib/idl/ast.rb', line 2727
    +      
    # File 'lib/idl/ast.rb', line 3258
     
     def type_check(symtab)
       op_stmt_list.elements.each do |e|
    @@ -324,7 +372,7 @@ 

    diff --git a/docs/ruby/Idl/InstructionOperationSyntaxNode.html b/docs/ruby/Idl/InstructionOperationSyntaxNode.html new file mode 100644 index 000000000..1300b3614 --- /dev/null +++ b/docs/ruby/Idl/InstructionOperationSyntaxNode.html @@ -0,0 +1,211 @@ + + + + + + + Class: Idl::InstructionOperationSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::InstructionOperationSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + +

    Overview

    +
    + +

    def execute(symtab)

    + +
      raise "WHere is this AST?"
    +end
    +
    + +

    end

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +3249
    +3250
    +3251
    +
    +
    # File 'lib/idl/ast.rb', line 3249
    +
    +def to_ast
    +  FunctionBodyAst.new(input, interval, op_stmt_list.elements.map(&:choice).map(&:to_ast) )
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/IntAst.html b/docs/ruby/Idl/IntAst.html deleted file mode 100644 index 7b487cf03..000000000 --- a/docs/ruby/Idl/IntAst.html +++ /dev/null @@ -1,1296 +0,0 @@ - - - - - - - Module: Idl::IntAst - - — Documentation by YARD 0.9.36 - - - - - - - - - - - - - - - - - - - -
    - - -

    Module: Idl::IntAst - - - -

    -
    - - - - - - -
    -
    Includes:
    -
    AstNodeFuncs, Rvalue
    -
    - - - - - - -
    -
    Defined in:
    -
    lib/idl/ast.rb
    -
    - -
    - - - - - - - - - -

    - Instance Method Summary - collapse -

    - - - - - - - - - - -
    -

    Instance Method Details

    - - -
    -

    - - #childrenArray<AstNode> - - - - - - - Originally defined in module - AstNodeFuncs - - -

    -
    - -

    Returns list of children, or an empty array for a terminal.

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Array<AstNode>) - - - - — -
      -

      list of children, or an empty array for a terminal

      -
      - -
    • - -
    - -
    -
    - -
    -

    - - #internal_error(reason) ⇒ Object - - - - - - - Originally defined in module - AstNodeFuncs - - -

    -
    - -

    raise an internal error

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - reason - - - (String) - - - - — -
      -

      Error message

      -
      - -
    • - -
    - -

    Raises:

    - - -
    -
    - -
    -

    - - #nodesArray<AstNode> - - - - - - - Originally defined in module - AstNodeFuncs - - -

    -
    - -

    Returns an array of AST sub nodes (notably, excludes anything, like whitespace, that wasn’t subclassed to AST).

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Array<AstNode>) - - - - — -
      -

      an array of AST sub nodes (notably, excludes anything, like whitespace, that wasn’t subclassed to AST)

      -
      - -
    • - -
    - -
    -
    - -
    -
    -
    - -

    pretty print the AST rooted at this node

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - indent - - - (Integer) - - - (defaults to: 0) - - - — -
      -

      The starting indentation, in # of spaces

      -
      - -
    • - -
    • - - indent_size - - - (Integer) - - - (defaults to: 2) - - - — -
      -

      The extra indentation applied to each level of the tree

      -
      - -
    • - -
    • - - io - - - (IO) - - - (defaults to: $stdout) - - - — -
      -

      Where to write the output

      -
      - -
    • - -
    - - -
    -
    - -
    -

    - - #to_idlString - - - - - -

    -
    - -

    Return valid IDL representation of the node (and its subtree)

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (String) - - - - — -
      -

      IDL code for the node

      -
      - -
    • - -
    - -
    - - - - -
    -
    -
    -
    -2546
    -
    -
    # File 'lib/idl/ast.rb', line 2546
    -
    -def to_idl = text_value
    -
    -
    - -
    -

    - - #type(symtab) ⇒ Type - - - - - -

    -
    - -

    Given a specific symbol table, return the type of this node.

    - -

    Should not be called until #type_check is called with the same arguments

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - symtab - - - (SymbolTable) - - - - — -
      -

      Symbol table for lookup

      -
      - -
    • - -
    - -

    Returns:

    -
      - -
    • - - - (Type) - - - - — -
      -

      The type of the node

      -
      - -
    • - -
    -

    Raises:

    -
      - -
    • - - - (AstNode::InternalError) - - - - — -
      -

      if the type is dependent on symtab, and type_check was not called first

      -
      - -
    • - -
    - -
    - - - - -
    -
    -
    -
    -2534
    -2535
    -2536
    -
    -
    # File 'lib/idl/ast.rb', line 2534
    -
    -def type(symtab)
    -  @type
    -end
    -
    -
    - -
    -

    - - #type_check(symtab) ⇒ void - - - - - -

    -
    -

    This method returns an undefined value.

    -

    type check this node and all children

    - -

    Calls to #type and/or #value may depend on type_check being called first with the same symtab. If not, those functions may raise an AstNode::InternalError

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - symtab - - - (SymbolTable) - - - - — -
      -

      Symbol table for lookup

      -
      - -
    • - -
    - -

    Raises:

    - - -
    - - - - -
    -
    -
    -
    -2465
    -2466
    -2467
    -2468
    -2469
    -2470
    -2471
    -2472
    -2473
    -2474
    -2475
    -2476
    -2477
    -2478
    -2479
    -2480
    -2481
    -2482
    -2483
    -2484
    -2485
    -2486
    -2487
    -2488
    -2489
    -2490
    -2491
    -2492
    -2493
    -2494
    -2495
    -2496
    -2497
    -2498
    -2499
    -2500
    -2501
    -2502
    -2503
    -2504
    -2505
    -2506
    -2507
    -2508
    -2509
    -2510
    -2511
    -2512
    -2513
    -2514
    -2515
    -2516
    -2517
    -2518
    -2519
    -2520
    -2521
    -2522
    -2523
    -2524
    -2525
    -2526
    -2527
    -2528
    -2529
    -2530
    -2531
    -
    -
    # File 'lib/idl/ast.rb', line 2465
    -
    -def type_check(symtab)
    -  archdef = symtab.archdef
    -  text_value_no_underscores = text_value.delete("_")
    -  if text_value_no_underscores =~ /([0-9]+)?'(s?)([bodh]?)(.*)/
    -    width = ::Regexp.last_match(1)
    -    signed = ::Regexp.last_match(2)
    -    radix_id = ::Regexp.last_match(3)
    -    value = ::Regexp.last_match(4)
    -
    -    width = archdef.config_params["XLEN"] if width.nil?
    -    radix_id = "d" if radix_id.empty?
    -
    -    # ensure we actually have enough bits to represent the value
    -    case radix_id
    -    when "b"
    -      @value = value.to_i(2)
    -      type_error("#{value} cannot be represented in #{width} bits") if @value.bit_length > width.to_i
    -    when "o"
    -      @value = value.to_i(8)
    -      type_error("#{value} cannot be represented in #{width} bits") if @value.bit_length > width.to_i
    -    when "d"
    -      @value = value.to_i(10)
    -      type_error("#{value} cannot be represented in #{width} bits") if @value.bit_length > width.to_i
    -    when "h"
    -      @value = value.to_i(16)
    -      type_error("#{value} cannot be represented in #{width} bits") if @value.bit_length > width.to_i
    -    end
    -
    -    qualifiers = signed == "s" ? [:signed, :const] : [:const]
    -    @type = Type.new(:bits, width: width.to_i, qualifiers:)
    -  elsif text_value_no_underscores =~ /0([bdx]?)([0-9a-fA-F]*)(s?)/
    -    radix_id = ::Regexp.last_match(1)
    -    value = ::Regexp.last_match(2)
    -    signed = ::Regexp.last_match(3)
    -
    -    radix_id = "o" if radix_id.empty?
    -
    -    case radix_id
    -    when "b"
    -      @value = value.to_i(2)
    -    when "o"
    -      @value = value.to_i(8)
    -    when "d"
    -      @value = value.to_i(10)
    -    when "x"
    -      @value = value.to_i(16)
    -    end
    -
    -    qualifiers = signed == "s" ? [:signed, :const] : [:const]
    -    width = signed == "s" ? @value.bit_length + 1 : @value.bit_length
    -    width = 1 if width.zero? # happens when the literal is '0'
    -    @type = Type.new(:bits, width:, qualifiers:)
    -  elsif text_value_no_underscores =~ /([0-9]*)(s?)/
    -    value = ::Regexp.last_match(1)
    -    signed = ::Regexp.last_match(2)
    -
    -    @value = value.to_i(10)
    -
    -    qualifiers = signed == "s" ? [:signed, :const] : [:const]
    -    width = signed == "s" ? @value.bit_length + 1 : @value.bit_length
    -    width = 1 if width.zero? # happens when the literal is '0'
    -    @type = Type.new(:bits, width:, qualifiers:)
    -  else
    -    internal_error "Unhandled int value"
    -  end
    -  type_error(text_value) if @value.nil?
    -end
    -
    -
    - -
    -

    - - #type_error(reason) ⇒ Object - - - - - - - Originally defined in module - AstNodeFuncs - - -

    -
    - -

    raise a type error

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - reason - - - (String) - - - - — -
      -

      Error message

      -
      - -
    • - -
    - -

    Raises:

    - - -
    -
    - -
    -

    - - #unindent(s) ⇒ String - - - - - - - Originally defined in module - AstNodeFuncs - - -

    -
    - -

    unindent a multiline string, getting rid of all common leading whitespace (like <<~ heredocs)

    - -

    borrowed from stackoverflow.com/questions/33527064/multiline-strings-with-no-indent

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - s - - - (String) - - - - — -
      -

      A string (presumably with newlines)

      -
      - -
    • - -
    - -

    Returns:

    -
      - -
    • - - - (String) - - - - — -
      -

      Unindented string

      -
      - -
    • - -
    - -
    -
    - -
    -

    - - #value(symtab) ⇒ Object - - - - - -

    -
    - -

    Return the compile-time-known value of the node

    - - -
    -
    -
    - - -
    - - - - -
    -
    -
    -
    -2539
    -2540
    -2541
    -2542
    -2543
    -
    -
    # File 'lib/idl/ast.rb', line 2539
    -
    -def value(symtab)
    -  internal_error("Did not type check #{text_value}") if @value.nil?
    -
    -  @value
    -end
    -
    -
    - -
    -

    - - #value_error(reason) ⇒ Object - - - - - - - Originally defined in module - AstNodeFuncs - - -

    -
    - -

    raise a value error, indicating that the value is not known at compile time

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - reason - - - (String) - - - - — -
      -

      Error message

      -
      - -
    • - -
    - -

    Raises:

    - - -
    -
    - -
    - -
    - - - -
    - - \ No newline at end of file diff --git a/docs/ruby/Idl/IntLiteralAst.html b/docs/ruby/Idl/IntLiteralAst.html new file mode 100644 index 000000000..faa03dd2d --- /dev/null +++ b/docs/ruby/Idl/IntLiteralAst.html @@ -0,0 +1,1871 @@ + + + + + + + Class: Idl::IntLiteralAst + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::IntLiteralAst + + + +

    +
    + +
    +
    Inherits:
    +
    + AstNode + + + show all + +
    +
    + + + + + + +
    +
    Includes:
    +
    AstNodeFuncs, Rvalue
    +
    + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb,
    + lib/idl/passes/gen_adoc.rb
    +
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(input, interval) ⇒ IntLiteralAst + + + + + +

    +
    + +

    Returns a new instance of IntLiteralAst.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +2880
    +2881
    +2882
    +
    +
    # File 'lib/idl/ast.rb', line 2880
    +
    +def initialize(input, interval)
    +  super(input, interval, [])
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #childrenArray<AstNode> + + + + + + + Originally defined in module + AstNodeFuncs + + +

    +
    + +

    Returns list of children, or an empty array for a terminal.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Array<AstNode>) + + + + — +
      +

      list of children, or an empty array for a terminal

      +
      + +
    • + +
    + +
    +
    + +
    +

    + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +51
    +52
    +53
    +54
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 51
    +
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  raise "?" if text_value.empty?
    +  text_value
    +end
    +
    +
    + +
    +

    + + #internal_error(reason) ⇒ Object + + + + + + + Originally defined in module + AstNodeFuncs + + +

    +
    + +

    raise an internal error

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + reason + + + (String) + + + + — +
      +

      Error message

      +
      + +
    • + +
    + +

    Raises:

    + + +
    +
    + +
    +

    + + #nodesArray<AstNode> + + + + + + + Originally defined in module + AstNodeFuncs + + +

    +
    + +

    Returns an array of AST sub nodes (notably, excludes anything, like whitespace, that wasn’t subclassed to AST).

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Array<AstNode>) + + + + — +
      +

      an array of AST sub nodes (notably, excludes anything, like whitespace, that wasn’t subclassed to AST)

      +
      + +
    • + +
    + +
    +
    + +
    +
    +
    + +

    pretty print the AST rooted at this node

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + indent + + + (Integer) + + + (defaults to: 0) + + + — +
      +

      The starting indentation, in # of spaces

      +
      + +
    • + +
    • + + indent_size + + + (Integer) + + + (defaults to: 2) + + + — +
      +

      The extra indentation applied to each level of the tree

      +
      + +
    • + +
    • + + io + + + (IO) + + + (defaults to: $stdout) + + + — +
      +

      Where to write the output

      +
      + +
    • + +
    + + +
    +
    + +
    +

    + + #to_idlString + + + + + +

    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +3058
    +
    +
    # File 'lib/idl/ast.rb', line 3058
    +
    +def to_idl = text_value
    +
    +
    + +
    +

    + + #type(symtab) ⇒ Type + + + + + +

    +
    + +

    Given a specific symbol table, return the type of this node.

    + +

    Should not be called until #type_check is called with the same arguments

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      Symbol table for lookup

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Type) + + + + — +
      +

      The type of the node

      +
      + +
    • + +
    +

    Raises:

    +
      + +
    • + + + (AstNode::InternalError) + + + + — +
      +

      if the type is dependent on symtab, and type_check was not called first

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +2902
    +2903
    +2904
    +2905
    +2906
    +2907
    +2908
    +2909
    +2910
    +2911
    +2912
    +2913
    +2914
    +2915
    +2916
    +2917
    +2918
    +2919
    +2920
    +2921
    +2922
    +2923
    +2924
    +2925
    +2926
    +2927
    +2928
    +2929
    +2930
    +2931
    +2932
    +2933
    +2934
    +2935
    +2936
    +
    +
    # File 'lib/idl/ast.rb', line 2902
    +
    +def type(symtab)
    +  return @type unless @type.nil?
    +
    +  case text_value.delete("_")
    +  when /([0-9]+)?'(s?)([bodh]?)(.*)/
    +    # verilog-style literal
    +    width = ::Regexp.last_match(1)
    +    signed = ::Regexp.last_match(2)
    +
    +    memoize = true
    +    if width.nil?
    +      width = symtab.archdef.config_params["XLEN"]
    +      memoize = false
    +    end
    +
    +    qualifiers = signed == "s" ? [:signed, :const] : [:const]
    +    t = Type.new(:bits, width: width.to_i, qualifiers:)
    +    @type = t if memoize
    +    t
    +  when /0([bdx]?)([0-9a-fA-F]*)(s?)/
    +    # C++-style literal
    +    signed = ::Regexp.last_match(3)
    +
    +    qualifiers = signed == "s" ? [:signed, :const] : [:const]
    +    @type = Type.new(:bits, width: width(symtab), qualifiers:)
    +  when /([0-9]*)(s?)/
    +    # basic decimal
    +    signed = ::Regexp.last_match(2)
    +
    +    qualifiers = signed == "s" ? [:signed, :const] : [:const]
    +    @type = Type.new(:bits, width: width(symtab), qualifiers:)
    +  else
    +    internal_error "Unhandled int value"
    +  end
    +end
    +
    +
    + +
    +

    + + #type_check(symtab) ⇒ void + + + + + +

    +
    +

    This method returns an undefined value.

    +

    type check this node and all children

    + +

    Calls to #type and/or #value may depend on type_check being called first with the same symtab. If not, those functions may raise an AstNode::InternalError

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      Symbol table for lookup

      +
      + +
    • + +
    + +

    Raises:

    + + +
    + + + + +
    +
    +
    +
    +2885
    +2886
    +2887
    +2888
    +2889
    +2890
    +2891
    +2892
    +2893
    +2894
    +2895
    +2896
    +2897
    +2898
    +2899
    +
    +
    # File 'lib/idl/ast.rb', line 2885
    +
    +def type_check(symtab)
    +  if text_value.delete("_") =~ /([0-9]+)?'(s?)([bodh]?)(.*)/
    +    # verilog-style literal
    +    width = ::Regexp.last_match(1)
    +    value_text = ::Regexp.last_match(4)
    +
    +    if width.nil?
    +      width = symtab.archdef.config_params["XLEN"]
    +      memoize = false
    +    end
    +
    +    # ensure we actually have enough bits to represent the value
    +    type_error("#{value_text} cannot be represented in #{width} bits") if unsigned_value.bit_length > width.to_i
    +  end
    +end
    +
    +
    + +
    +

    + + #type_error(reason) ⇒ Object + + + + + + + Originally defined in module + AstNodeFuncs + + +

    +
    + +

    raise a type error

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + reason + + + (String) + + + + — +
      +

      Error message

      +
      + +
    • + +
    + +

    Raises:

    + + +
    +
    + +
    +

    + + #unindent(s) ⇒ String + + + + + + + Originally defined in module + AstNodeFuncs + + +

    +
    + +

    unindent a multiline string, getting rid of all common leading whitespace (like <<~ heredocs)

    + +

    borrowed from stackoverflow.com/questions/33527064/multiline-strings-with-no-indent

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + s + + + (String) + + + + — +
      +

      A string (presumably with newlines)

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      Unindented string

      +
      + +
    • + +
    + +
    +
    + +
    +

    + + #unsigned_valueInteger + + + + + +

    +
    + +

    Returns the unsigned value of this literal (i.e., treating it as unsigned even if the signed specifier is present).

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      the unsigned value of this literal (i.e., treating it as unsigned even if the signed specifier is present)

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +3004
    +3005
    +3006
    +3007
    +3008
    +3009
    +3010
    +3011
    +3012
    +3013
    +3014
    +3015
    +3016
    +3017
    +3018
    +3019
    +3020
    +3021
    +3022
    +3023
    +3024
    +3025
    +3026
    +3027
    +3028
    +3029
    +3030
    +3031
    +3032
    +3033
    +3034
    +3035
    +3036
    +3037
    +3038
    +3039
    +3040
    +3041
    +3042
    +3043
    +3044
    +3045
    +3046
    +3047
    +3048
    +3049
    +3050
    +3051
    +3052
    +3053
    +3054
    +3055
    +
    +
    # File 'lib/idl/ast.rb', line 3004
    +
    +def unsigned_value
    +  return @unsigned_value unless @unsigned_value.nil?
    +
    +  case text_value.delete("_")
    +  when /([0-9]+)?'(s?)([bodh]?)(.*)/
    +    # verilog-style literal
    +    radix_id = ::Regexp.last_match(3)
    +    value = ::Regexp.last_match(4)
    +
    +    radix_id = "d" if radix_id.empty?
    +
    +    # ensure we actually have enough bits to represent the value
    +    @unsigned_value =
    +      case radix_id
    +      when "b"
    +        value.to_i(2)
    +      when "o"
    +        value.to_i(8)
    +      when "d"
    +        value.to_i(10)
    +      when "h"
    +        value.to_i(16)
    +      end
    +  when /0([bdx]?)([0-9a-fA-F]*)(s?)/
    +    # C++-style literal
    +    radix_id = ::Regexp.last_match(1)
    +    value = ::Regexp.last_match(2)
    +    signed = ::Regexp.last_match(3)
    +
    +    radix_id = "o" if radix_id.empty?
    +
    +    @unsigned_value =
    +      case radix_id
    +      when "b"
    +        value.to_i(2)
    +      when "o"
    +        value.to_i(8)
    +      when "d"
    +        value.to_i(10)
    +      when "x"
    +        value.to_i(16)
    +      end
    +  when /([0-9]*)(s?)/
    +    # basic decimal
    +    value = ::Regexp.last_match(1)
    +    signed = ::Regexp.last_match(2)
    +
    +    @unsigned_value = value.to_i(10)
    +  else
    +    internal_error "Unhandled int value"
    +  end
    +end
    +
    +
    + +
    +

    + + #value(symtab) ⇒ Object + + + + + +

    +
    + +

    Return the compile-time-known value of the node

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +2974
    +2975
    +2976
    +2977
    +2978
    +2979
    +2980
    +2981
    +2982
    +2983
    +2984
    +2985
    +2986
    +2987
    +2988
    +2989
    +2990
    +2991
    +2992
    +2993
    +2994
    +2995
    +2996
    +2997
    +2998
    +2999
    +3000
    +
    +
    # File 'lib/idl/ast.rb', line 2974
    +
    +def value(symtab)
    +  return @value unless @value.nil?
    +
    +  if text_value.delete("_") =~ /([0-9]+)?'(s?)([bodh]?)(.*)/
    +    # verilog-style literal
    +    width = ::Regexp.last_match(1)
    +    signed = ::Regexp.last_match(2)
    +
    +    memoize = true
    +    if width.nil?
    +      width = symtab.archdef.config_params["XLEN"]
    +      memoize = false
    +    end
    +
    +    v =
    +      if !signed.empty? && ((unsigned_value >> (width.to_i - 1)) == 1)
    +        -(2**width.to_i - unsigned_value) 
    +      else
    +        unsigned_value
    +      end
    +
    +    @value = v if memoize
    +    v
    +  else
    +    @value = unsigned_value
    +  end
    +end
    +
    +
    + +
    +

    + + #value_error(reason) ⇒ Object + + + + + + + Originally defined in module + AstNodeFuncs + + +

    +
    + +

    raise a value error, indicating that the value is not known at compile time

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + reason + + + (String) + + + + — +
      +

      Error message

      +
      + +
    • + +
    + +

    Raises:

    + + +
    +
    + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    +
    + +
    +

    + + #width(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +2938
    +2939
    +2940
    +2941
    +2942
    +2943
    +2944
    +2945
    +2946
    +2947
    +2948
    +2949
    +2950
    +2951
    +2952
    +2953
    +2954
    +2955
    +2956
    +2957
    +2958
    +2959
    +2960
    +2961
    +2962
    +2963
    +2964
    +2965
    +2966
    +2967
    +2968
    +2969
    +2970
    +2971
    +
    +
    # File 'lib/idl/ast.rb', line 2938
    +
    +def width(symtab)
    +  return @width unless @width.nil?
    +
    +  text_value_no_underscores = text_value.delete("_")
    +
    +  case text_value_no_underscores
    +  when /([0-9]+)?'(s?)([bodh]?)(.*)/
    +    # verilog-style literal
    +    width = ::Regexp.last_match(1)
    +    memoize = true
    +    if width.nil?
    +      width = archdef.config_params["XLEN"]
    +      memoize = false
    +    end
    +    @width = width if memoize
    +    width
    +  when /0([bdx]?)([0-9a-fA-F]*)(s?)/
    +    signed = ::Regexp.last_match(3)
    +
    +    @width = signed == "s" ? value(symtab).bit_length + 1 : value(symtab).bit_length
    +    @width = 1 if @width.zero? # happens when the literal is '0'
    +
    +    @width
    +  when /([0-9]*)(s?)/
    +    signed = ::Regexp.last_match(3)
    +
    +    @width = signed == "s" ? value(symtab).bit_length + 1 : value(symtab).bit_length
    +    @width = 1 if @width.zero? # happens when the literal is '0'
    +
    +    @width
    +  else
    +    internal_error "No match on int literal"
    +  end
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/IntLiteralSyntaxNode.html b/docs/ruby/Idl/IntLiteralSyntaxNode.html new file mode 100644 index 000000000..b2b449554 --- /dev/null +++ b/docs/ruby/Idl/IntLiteralSyntaxNode.html @@ -0,0 +1,174 @@ + + + + + + + Module: Idl::IntLiteralSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: Idl::IntLiteralSyntaxNode + + + +

    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +2871
    +2872
    +2873
    +
    +
    # File 'lib/idl/ast.rb', line 2871
    +
    +def to_ast
    +  IntLiteralAst.new(input, interval)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/IsaAst.html b/docs/ruby/Idl/IsaAst.html index 35c15fbf9..52b9bc1ed 100644 --- a/docs/ruby/Idl/IsaAst.html +++ b/docs/ruby/Idl/IsaAst.html @@ -315,18 +315,18 @@

     
     
    -503
    -504
    -505
    -506
    -507
    -508
    -509
    -510
    -511
    +534 +535 +536 +537 +538 +539 +540 +541 +542

    -
    # File 'lib/idl/ast.rb', line 503
    +      
    # File 'lib/idl/ast.rb', line 534
     
     def bitfields
       return @bitfields unless @bitfields.nil?
    @@ -357,12 +357,12 @@ 

     
     
    -476
    -477
    -478
    +507 +508 +509

    -
    # File 'lib/idl/ast.rb', line 476
    +      
    # File 'lib/idl/ast.rb', line 507
     
     def children
       enums + bitfields + functions + globals
    @@ -398,19 +398,19 @@ 

     
     
    -492
    -493
    -494
    -495
    -496
    -497
    -498
    -499
    -500
    -501
    +523 +524 +525 +526 +527 +528 +529 +530 +531 +532

    -
    # File 'lib/idl/ast.rb', line 492
    +      
    # File 'lib/idl/ast.rb', line 523
     
     def enums
       return @enums unless @enums.nil?
    @@ -442,19 +442,19 @@ 

     
     
    -513
    -514
    -515
    -516
    -517
    -518
    -519
    -520
    -521
    -522
    +544 +545 +546 +547 +548 +549 +550 +551 +552 +553

    -
    # File 'lib/idl/ast.rb', line 513
    +      
    # File 'lib/idl/ast.rb', line 544
     
     def functions
       return @functions unless @functions.nil?
    @@ -486,19 +486,19 @@ 

     
     
    -480
    -481
    -482
    -483
    -484
    -485
    -486
    -487
    -488
    -489
    +511 +512 +513 +514 +515 +516 +517 +518 +519 +520

    -
    # File 'lib/idl/ast.rb', line 480
    +      
    # File 'lib/idl/ast.rb', line 511
     
     def globals
       return @globals unless @globals.nil?
    @@ -530,18 +530,18 @@ 

     
     
    -533
    -534
    -535
    -536
    -537
    -538
    -539
    -540
    -541
    +564 +565 +566 +567 +568 +569 +570 +571 +572

    -
    # File 'lib/idl/ast.rb', line 533
    +      
    # File 'lib/idl/ast.rb', line 564
     
     def instructions
       return @instructions unless @instructions.nil?
    @@ -572,17 +572,17 @@ 

     
     
    -524
    -525
    -526
    -527
    -528
    -529
    -530
    -531
    +555 +556 +557 +558 +559 +560 +561 +562

    -
    # File 'lib/idl/ast.rb', line 524
    +      
    # File 'lib/idl/ast.rb', line 555
     
     def type_check(symtab)
       definitions.elements.each do |e|
    @@ -602,7 +602,7 @@ 

    diff --git a/docs/ruby/Idl/MultiVariableAssignmentAst.html b/docs/ruby/Idl/MultiVariableAssignmentAst.html index 5d0350449..2bdc3d185 100644 --- a/docs/ruby/Idl/MultiVariableAssignmentAst.html +++ b/docs/ruby/Idl/MultiVariableAssignmentAst.html @@ -286,24 +286,24 @@

     
     
    -1211
    -1212
    -1213
    -1214
    -1215
    -1216
    -1217
    -1218
    -1219
    -1220
    -1221
    -1222
    +1280 +1281 +1282 +1283 +1284 +1285 +1286 +1287 +1288 +1289 +1290 +1291

    -
    # File 'lib/idl/ast.rb', line 1211
    +      
    # File 'lib/idl/ast.rb', line 1280
     
     def execute(symtab)
    -  values = functin_call.execute(symtab)
    +  values = function_call.execute(symtab)
     
       i = 0
       vars.each do |v|
    @@ -334,12 +334,12 @@ 

     
     
    -1176
    -1177
    -1178
    +1245 +1246 +1247

    -
    # File 'lib/idl/ast.rb', line 1176
    +      
    # File 'lib/idl/ast.rb', line 1245
     
     def rhs
       function_call
    @@ -393,10 +393,10 @@ 

     
     
    -1225
    +1294

    -
    # File 'lib/idl/ast.rb', line 1225
    +      
    # File 'lib/idl/ast.rb', line 1294
     
     def to_idl = "(#{vars.map(&:to_idl).join(', ')}) = #{function_call.to_idl}"
    @@ -484,38 +484,38 @@

     
     
    -1181
    -1182
    -1183
    -1184
    -1185
    -1186
    -1187
    -1188
    -1189
    -1190
    -1191
    -1192
    -1193
    -1194
    -1195
    -1196
    -1197
    -1198
    -1199
    -1200
    -1201
    -1202
    -1203
    -1204
    -1205
    -1206
    -1207
    -1208
    -1209
    +1250 +1251 +1252 +1253 +1254 +1255 +1256 +1257 +1258 +1259 +1260 +1261 +1262 +1263 +1264 +1265 +1266 +1267 +1268 +1269 +1270 +1271 +1272 +1273 +1274 +1275 +1276 +1277 +1278

    -
    # File 'lib/idl/ast.rb', line 1181
    +      
    # File 'lib/idl/ast.rb', line 1250
     
     def type_check(symtab)
       function_call.type_check(symtab)
    @@ -595,12 +595,12 @@ 

     
     
    -1172
    -1173
    -1174
    +1241 +1242 +1243

    -
    # File 'lib/idl/ast.rb', line 1172
    +      
    # File 'lib/idl/ast.rb', line 1241
     
     def vars
       [first] + rest.elements.map(&:var)
    @@ -615,7 +615,7 @@ 

    diff --git a/docs/ruby/Idl/MultiVariableDeclarationAst.html b/docs/ruby/Idl/MultiVariableDeclarationAst.html index 42fb4dc83..a1a380f61 100644 --- a/docs/ruby/Idl/MultiVariableDeclarationAst.html +++ b/docs/ruby/Idl/MultiVariableDeclarationAst.html @@ -69,7 +69,7 @@
    Inherits:
    - AssignmentAst + AstNode @@ -93,6 +91,11 @@ +
    +
    Includes:
    +
    Declaration
    +
    + @@ -140,7 +143,7 @@

  • - #execute(symtab) ⇒ Object + #add_symbol(symtab) ⇒ Object @@ -154,7 +157,9 @@

    -
    +
    +

    Add symbol(s) at the outermost scope of the symbol table.

    +

  • @@ -243,40 +248,69 @@

    - -

    Instance Method Details

    -

    +

    - #execute(symtab) ⇒ Object + #add_symbol(symtab) ⇒ Object -

    +
    +
    + +

    Add symbol(s) at the outermost scope of the symbol table

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      Symbol table at the scope that the symbol(s) will be inserted

      +
      + +
    • + +
    + + +
    @@ -328,10 +362,10 @@

     
     
    -1284
    +1354

    @@ -419,27 +453,23 @@

     
     
    -1267
    -1268
    -1269
    -1270
    -1271
    -1272
    -1273
    -1274
    -1275
    +1338 +1339 +1340 +1341 +1342 +1343 +1344

    @@ -490,19 +520,19 @@

     
     
    -1255
    -1256
    -1257
    -1258
    -1259
    -1260
    -1261
    -1262
    -1263
    -1264
    +1326 +1327 +1328 +1329 +1330 +1331 +1332 +1333 +1334 +1335

    @@ -346,10 +350,10 @@

     
     
    -1865
    +2102

    @@ -372,12 +376,12 @@

     
     
    -1853
    -1854
    -1855
    +2088 +2089 +2090

    @@ -476,12 +476,12 @@

     
     
    -1882
    -1883
    -1884
    +2154 +2155 +2156

    @@ -593,7 +595,7 @@

    diff --git a/docs/ruby/Idl/ReplicationExpressionAst.html b/docs/ruby/Idl/ReplicationExpressionAst.html index 57c6fc520..05501b279 100644 --- a/docs/ruby/Idl/ReplicationExpressionAst.html +++ b/docs/ruby/Idl/ReplicationExpressionAst.html @@ -103,7 +103,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/gen_adoc.rb
    +
    @@ -128,6 +130,69 @@

    Overview

    +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #n ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute n.

      +
      + +
    • + + +
    • + + + #v ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute v.

      +
      + +
    • + + +
    + @@ -142,6 +207,54 @@

  • + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + #initialize(input, interval, n, v) ⇒ ReplicationExpressionAst + + + + + + + constructor + + + + + + + + +
    +

    A new instance of ReplicationExpressionAst.

    +
    + +
  • + + +
  • + + #to_idl ⇒ String @@ -232,6 +345,35 @@

    Return the compile-time-known value of the node.

  • + + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
    +
  • @@ -246,14 +388,186 @@

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(input, interval, n, v) ⇒ ReplicationExpressionAst + + + + + +

    +
    + +

    Returns a new instance of ReplicationExpressionAst.

    + + +
    +
    +
    + + +

     
     
    -1277
    -1278
    -1279
    -1280
    -1281
    +1347 +1348 +1349 +1350 +1351
    -
    # File 'lib/idl/ast.rb', line 1277
    +      
    # File 'lib/idl/ast.rb', line 1347
     
    -def execute(symtab)
    -  var_names.each do |name|
    -    symtab.add(name, Var.new(name, type.clone))
    +def add_symbol(symtab)
    +  var_names.each do |vname|
    +    symtab.add(vname, Var.new(vname, type.clone, type.default))
       end
     end
    -
    # File 'lib/idl/ast.rb', line 1284
    +      
    # File 'lib/idl/ast.rb', line 1354
     
     def to_idl = "#{type.to_idl} #{var_names.map(&:to_idl).join(', ')}"
    -
    # File 'lib/idl/ast.rb', line 1267
    +      
    # File 'lib/idl/ast.rb', line 1338
     
     def type_check(symtab)
       type_error "No type named '#{type_name.text_value}' on line #{lineno}" if type.nil?
     
       type_error "Attempt to write read-only/constant variable #{text_value}" if type.const?
     
    -  var_names.each do |vname|
    -    symtab.add(vname, Var.new(vname, type.clone))
    -  end
    +  add_symbol(symtab)
     end
    -
    # File 'lib/idl/ast.rb', line 1255
    +      
    # File 'lib/idl/ast.rb', line 1326
     
     def var_names
       return @var_names unless @var_names.nil?
    @@ -524,7 +554,7 @@ 

    diff --git a/docs/ruby/Idl/BitsTypeAst.html b/docs/ruby/Idl/NoopAst.html similarity index 57% rename from docs/ruby/Idl/BitsTypeAst.html rename to docs/ruby/Idl/NoopAst.html index 5102fe4e9..7616caa04 100644 --- a/docs/ruby/Idl/BitsTypeAst.html +++ b/docs/ruby/Idl/NoopAst.html @@ -4,7 +4,7 @@ - Class: Idl::BitsTypeAst + Class: Idl::NoopAst — Documentation by YARD 0.9.36 @@ -15,7 +15,7 @@ <link rel="stylesheet" href="../css/common.css" type="text/css" /> <script type="text/javascript"> - pathId = "Idl::BitsTypeAst"; + pathId = "Idl::NoopAst"; relpath = '../'; </script> @@ -36,10 +36,10 @@ <div id="header"> <div id="menu"> - <a href="../_index.html">Index (B)</a> » + <a href="../_index.html">Index (N)</a> » <span class='title'><span class='object_link'><a href="../Idl.html" title="Idl (module)">Idl</a></span></span> » - <span class="title">BitsTypeAst</span> + <span class="title">NoopAst</span> </div> @@ -59,7 +59,7 @@ <div class="clear"></div> </div> - <div id="content"><h1>Class: Idl::BitsTypeAst + <div id="content"><h1>Class: Idl::NoopAst @@ -78,7 +78,7 @@ <li class="next"><span class='object_link'><a href="AstNode.html" title="Idl::AstNode (class)">AstNode</a></span></li> - <li class="next">Idl::BitsTypeAst</li> + <li class="next">Idl::NoopAst</li> </ul> <a href="#" class="inheritanceTree">show all</a> @@ -121,7 +121,7 @@ <h2> <li class="public "> <span class="summary_signature"> - <a href="#type-instance_method" title="#type (instance method)">#<strong>type</strong>(symtab) ⇒ Type </a> + <a href="#execute-instance_method" title="#execute (instance method)">#<strong>execute</strong>(symtab) ⇒ void </a> @@ -136,9 +136,57 @@ <h2> <span class="summary_desc"><div class='inline'> -<p>Given a specific symbol table, return the type of this node.</p> +<p>“execute” the statement by updating the variables in the symbol table.</p> </div></span> +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong> ⇒ NoopAst </a> + + + + </span> + + + <span class="note title constructor">constructor</span> + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>A new instance of NoopAst.</p> +</div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#to_idl-instance_method" title="#to_idl (instance method)">#<strong>to_idl</strong> ⇒ Object </a> + + + + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'></div></span> + </li> @@ -175,16 +223,61 @@ <h2> + <div id="constructor_details" class="method_details_list"> + <h2>Constructor Details</h2> + + <div class="method_details first"> + <h3 class="signature first" id="initialize-instance_method"> + + #<strong>initialize</strong> ⇒ <tt><span class='object_link'><a href="" title="Idl::NoopAst (class)">NoopAst</a></span></tt> + + + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Returns a new instance of NoopAst.</p> + + + </div> +</div> +<div class="tags"> + + +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +2496 +2497 +2498</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2496</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span> + <span class='kw'>super</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='int'>0</span><span class='op'>...</span><span class='int'>0</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + +</div> + + <div id="instance_method_details" class="method_details_list"> <h2>Instance Method Details</h2> <div class="method_details first"> - <h3 class="signature first" id="type-instance_method"> + <h3 class="signature first" id="execute-instance_method"> - #<strong>type</strong>(symtab) ⇒ <tt><span class='object_link'><a href="Type.html" title="Idl::Type (class)">Type</a></span></tt> + #<strong>execute</strong>(symtab) ⇒ <tt>void</tt> @@ -192,10 +285,8 @@ <h3 class="signature first" id="type-instance_method"> </h3><div class="docstring"> <div class="discussion"> - -<p>Given a specific symbol table, return the type of this node.</p> - -<p>Should not be called until <span class='object_link'><a href="#type_check-instance_method" title="Idl::BitsTypeAst#type_check (method)">#type_check</a></span> is called with the same arguments</p> + <p class="note returns_void">This method returns an undefined value.</p> +<p>“execute” the statement by updating the variables in the symbol table</p> </div> @@ -215,44 +306,26 @@ <h3 class="signature first" id="type-instance_method"> — <div class='inline'> -<p>Symbol table for lookup</p> +<p>The symbol table for the context</p> </div> </li> </ul> -<p class="tag_title">Returns:</p> -<ul class="return"> - - <li> - - - <span class='type'>(<tt><span class='object_link'><a href="Type.html" title="Idl::Type (class)">Type</a></span></tt>)</span> - - - - — - <div class='inline'> -<p>The type of the node</p> -</div> - - </li> - -</ul> <p class="tag_title">Raises:</p> <ul class="raise"> <li> - <span class='type'>(<tt><span class='object_link'><a href="AstNode/InternalError.html" title="Idl::AstNode::InternalError (class)">AstNode::InternalError</a></span></tt>)</span> + <span class='type'></span> - — + <div class='inline'> -<p>if the type is dependent on symtab, and type_check was not called first</p> +<p>ValueError if some part of the statement cannot be executed at compile time</p> </div> </li> @@ -265,16 +338,38 @@ <h3 class="signature first" id="type-instance_method"> <pre class="lines"> -2430 -2431 -2432</pre> +2504</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2430</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2504</span> -<span class='kw'>def</span> <span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> - <span class='const'><span class='object_link'><a href="Type.html" title="Idl::Type (class)">Type</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Type.html#initialize-instance_method" title="Idl::Type#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='symbol'>:bits</span><span class='comma'>,</span> <span class='label'>width:</span> <span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='rparen'>)</span> -<span class='kw'>end</span></pre> +<span class='kw'>def</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <h3 class="signature " id="to_idl-instance_method"> + + #<strong>to_idl</strong> ⇒ <tt>Object</tt> + + + + + +</h3><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +2507</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2507</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_to_idl'>to_idl</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span></pre> </td> </tr> </table> @@ -294,7 +389,7 @@ <h3 class="signature " id="type_check-instance_method"> <p class="note returns_void">This method returns an undefined value.</p> <p>type check this node and all children</p> -<p>Calls to <span class='object_link'><a href="#type-instance_method" title="Idl::BitsTypeAst#type (method)">#type</a></span> and/or #value may depend on type_check being called first with the same symtab. If not, those functions may raise an AstNode::InternalError</p> +<p>Calls to #type and/or #value may depend on type_check being called first with the same symtab. If not, those functions may raise an AstNode::InternalError</p> </div> @@ -360,30 +455,12 @@ <h3 class="signature " id="type_check-instance_method"> <pre class="lines"> -2418 -2419 -2420 -2421 -2422 -2423 -2424 -2425 -2426 -2427</pre> +2501</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2418</span> - -<span class='kw'>def</span> <span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> - <span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 2501</span> - <span class='kw'>begin</span> - <span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> - <span class='kw'>rescue</span> <span class='const'><span class='object_link'><a href="AstNode/ValueError.html" title="Idl::AstNode::ValueError (class)">ValueError</a></span></span> - <span class='id identifier rubyid_type_error'>type_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Bit width is not compile-time known</span><span class='tstring_end'>"</span></span> - <span class='kw'>end</span> - <span class='id identifier rubyid_type_error'>type_error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Bit widht must be integral</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_integral?'>integral?</span> -<span class='kw'>end</span></pre> +<span class='kw'>def</span> <span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='kw'>end</span></pre> </td> </tr> </table> @@ -394,7 +471,7 @@ <h3 class="signature " id="type_check-instance_method"> </div> <div id="footer"> - Generated on Fri Jul 12 07:33:11 2024 by + Generated on Thu Jul 18 13:55:46 2024 by <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.36 (ruby-3.2.3). </div> diff --git a/docs/ruby/Idl/ParenExpressionAst.html b/docs/ruby/Idl/ParenExpressionAst.html index b1556749c..710aa42a9 100644 --- a/docs/ruby/Idl/ParenExpressionAst.html +++ b/docs/ruby/Idl/ParenExpressionAst.html @@ -103,7 +103,9 @@ <dl> <dt>Defined in:</dt> - <dd>lib/idl/ast.rb</dd> + <dd>lib/idl/ast.rb<span class="defines">,<br /> + lib/idl/passes/gen_adoc.rb</span> +</dd> </dl> </div> @@ -128,6 +130,40 @@ <h2>Overview</h2><div class="docstring"> + <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2> + <ul class="summary"> + + <li class="public "> + <span class="summary_signature"> + + <a href="#expression-instance_method" title="#expression (instance method)">#<strong>expression</strong> ⇒ Object </a> + + + + </span> + + + + + <span class="note title readonly">readonly</span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Returns the value of attribute expression.</p> +</div></span> + +</li> + + + </ul> + @@ -142,6 +178,54 @@ <h2> <li class="public "> <span class="summary_signature"> + <a href="#gen_adoc-instance_method" title="#gen_adoc (instance method)">#<strong>gen_adoc</strong>(indent = 0, indent_spaces: 2) ⇒ Object </a> + + + + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'></div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(input, interval, expression) ⇒ ParenExpressionAst </a> + + + + </span> + + + <span class="note title constructor">constructor</span> + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>A new instance of ParenExpressionAst.</p> +</div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + <a href="#invert-instance_method" title="#invert (instance method)">#<strong>invert</strong>(symtab) ⇒ Object </a> @@ -254,6 +338,35 @@ <h2> <p>Return the compile-time-known value of the node.</p> </div></span> +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#values-instance_method" title="#values (instance method)">#<strong>values</strong>(symtab) ⇒ Array<Integer>, ... </a> + + + + </span> + + <span class="note title not_defined_here"> + included + from <span class='object_link'><a href="Rvalue.html#values-instance_method" title="Idl::Rvalue#values (method)">Rvalue</a></span> + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.</p> +</div></span> + </li> @@ -268,14 +381,139 @@ <h2> + <div id="constructor_details" class="method_details_list"> + <h2>Constructor Details</h2> + + <div class="method_details first"> + <h3 class="signature first" id="initialize-instance_method"> + + #<strong>initialize</strong>(input, interval, expression) ⇒ <tt><span class='object_link'><a href="" title="Idl::ParenExpressionAst (class)">ParenExpressionAst</a></span></tt> + + + + + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Returns a new instance of ParenExpressionAst.</p> + + + </div> +</div> +<div class="tags"> +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +1925 +1926 +1927 +1928</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1925</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_interval'>interval</span><span class='comma'>,</span> <span class='id identifier rubyid_expression'>expression</span><span class='rparen'>)</span> + <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_interval'>interval</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='id identifier rubyid_expression'>expression</span><span class='rbracket'>]</span><span class='rparen'>)</span> + <span class='ivar'>@expression</span> <span class='op'>=</span> <span class='id identifier rubyid_expression'>expression</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + +</div> + + <div id="instance_attr_details" class="attr_details"> + <h2>Instance Attribute Details</h2> + + + <span id=""></span> + <div class="method_details first"> + <h3 class="signature first" id="expression-instance_method"> + + #<strong>expression</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span> + + + + + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Returns the value of attribute expression.</p> + + + </div> +</div> +<div class="tags"> + + +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +1923 +1924 +1925</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1923</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_expression'>expression</span> + <span class='ivar'>@expression</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + </div> + + <div id="instance_method_details" class="method_details_list"> <h2>Instance Method Details</h2> <div class="method_details first"> - <h3 class="signature first" id="invert-instance_method"> + <h3 class="signature first" id="gen_adoc-instance_method"> + + #<strong>gen_adoc</strong>(indent = 0, indent_spaces: 2) ⇒ <tt>Object</tt> + + + + + +</h3><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +46 +47 +48</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/idl/passes/gen_adoc.rb', line 46</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_gen_adoc'>gen_adoc</span><span class='lparen'>(</span><span class='id identifier rubyid_indent'>indent</span> <span class='op'>=</span> <span class='int'>0</span><span class='comma'>,</span> <span class='label'>indent_spaces:</span> <span class='int'>2</span><span class='rparen'>)</span> + <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_expression'>expression</span><span class='period'>.</span><span class='id identifier rubyid_gen_adoc'>gen_adoc</span><span class='lparen'>(</span><span class='id identifier rubyid_indent'>indent</span><span class='comma'>,</span> <span class='label'>indent_spaces:</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>)</span><span class='tstring_end'>"</span></span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <h3 class="signature " id="invert-instance_method"> #<strong>invert</strong>(symtab) ⇒ <tt>Object</tt> @@ -289,12 +527,12 @@ <h3 class="signature first" id="invert-instance_method"> <pre class="lines"> -1710</pre> +1930</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1710</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1930</span> -<span class='kw'>def</span> <span class='id identifier rubyid_invert'>invert</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_invert'>invert</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span></pre> +<span class='kw'>def</span> <span class='id identifier rubyid_invert'>invert</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='id identifier rubyid_expression'>expression</span><span class='period'>.</span><span class='id identifier rubyid_invert'>invert</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span></pre> </td> </tr> </table> @@ -344,10 +582,10 @@ <h3 class="signature " id="to_idl-instance_method"> <pre class="lines"> -1722</pre> +1942</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1722</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1942</span> <span class='kw'>def</span> <span class='id identifier rubyid_to_idl'>to_idl</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_idl'>to_idl</span><span class='embexpr_end'>}</span><span class='tstring_content'>)</span><span class='tstring_end'>"</span></span></pre> </td> @@ -439,12 +677,12 @@ <h3 class="signature " id="type-instance_method"> <pre class="lines"> -1716</pre> +1936</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1716</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1936</span> -<span class='kw'>def</span> <span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span></pre> +<span class='kw'>def</span> <span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='id identifier rubyid_expression'>expression</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span></pre> </td> </tr> </table> @@ -530,12 +768,12 @@ <h3 class="signature " id="type_check-instance_method"> <pre class="lines"> -1713</pre> +1933</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1713</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1933</span> -<span class='kw'>def</span> <span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span></pre> +<span class='kw'>def</span> <span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='id identifier rubyid_expression'>expression</span><span class='period'>.</span><span class='id identifier rubyid_type_check'>type_check</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span></pre> </td> </tr> </table> @@ -567,15 +805,111 @@ <h3 class="signature " id="value-instance_method"> <pre class="lines"> -1719</pre> +1939</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1719</span> + <pre class="code"><span class="info file"># File 'lib/idl/ast.rb', line 1939</span> -<span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span></pre> +<span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='id identifier rubyid_expression'>expression</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_symtab'>symtab</span><span class='rparen'>)</span></pre> </td> </tr> </table> +</div> + + <div class="method_details "> + <h3 class="signature " id="values-instance_method"> + + #<strong>values</strong>(symtab) ⇒ <tt>Array<Integer></tt>, ... + + + + + + <span class="not_defined_here"> + Originally defined in module + <span class='object_link'><a href="Rvalue.html#values-instance_method" title="Idl::Rvalue#values (method)">Rvalue</a></span> + </span> + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined</p> + +<p>For most AstNodes, this will just be a single-entry array</p> + + + </div> +</div> +<div class="tags"> + <p class="tag_title">Parameters:</p> +<ul class="param"> + + <li> + + <span class='name'>symtab</span> + + + <span class='type'>(<tt><span class='object_link'><a href="SymbolTable.html" title="Idl::SymbolTable (class)">SymbolTable</a></span></tt>)</span> + + + + — + <div class='inline'> +<p>The context for the evaulation</p> +</div> + + </li> + +</ul> + +<p class="tag_title">Returns:</p> +<ul class="return"> + + <li> + + + <span class='type'>(<tt>Array<Integer></tt>)</span> + + + + — + <div class='inline'> +<p>The complete list of compile-time-known values, when they are integral</p> +</div> + + </li> + + <li> + + + <span class='type'>(<tt>Array<Boolean></tt>)</span> + + + + — + <div class='inline'> +<p>The complete list of compile-time-known values, when they are booleans</p> +</div> + + </li> + + <li> + + + <span class='type'>(<tt><span class='object_link'><a href="AstNode/ValueError.html" title="Idl::AstNode::ValueError (class)">AstNode::ValueError</a></span></tt>)</span> + + + + — + <div class='inline'> +<p>if the list of values is not knowable at compile time</p> +</div> + + </li> + +</ul> + +</div> </div> </div> @@ -583,7 +917,7 @@ <h3 class="signature " id="value-instance_method"> </div> <div id="footer"> - Generated on Fri Jul 12 07:33:11 2024 by + Generated on Thu Jul 18 13:55:45 2024 by <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.36 (ruby-3.2.3). </div> diff --git a/docs/ruby/Idl/ParenExpressionSyntaxNode.html b/docs/ruby/Idl/ParenExpressionSyntaxNode.html new file mode 100644 index 000000000..c466426bc --- /dev/null +++ b/docs/ruby/Idl/ParenExpressionSyntaxNode.html @@ -0,0 +1,194 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> +<title> + Class: Idl::ParenExpressionSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::ParenExpressionSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +1911
    +1912
    +1913
    +
    +
    # File 'lib/idl/ast.rb', line 1911
    +
    +def to_ast
    +  ParenExpressionAst.new(input, interval, e.to_ast)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/PostDecrementExpressionAst.html b/docs/ruby/Idl/PostDecrementExpressionAst.html index 0f5932a84..8b869756a 100644 --- a/docs/ruby/Idl/PostDecrementExpressionAst.html +++ b/docs/ruby/Idl/PostDecrementExpressionAst.html @@ -310,20 +310,24 @@

     
     
    -1858
    -1859
    -1860
    -1861
    -1862
    -1863
    +2093 +2094 +2095 +2096 +2097 +2098 +2099 +2100

    -
    # File 'lib/idl/ast.rb', line 1858
    +      
    # File 'lib/idl/ast.rb', line 2093
     
     def execute(symtab)
       var = symtab.get(rval.text_value)
       internal_error "No symbol #{rval.text_value}" if var.nil?
     
    +  value_error "value of variable '#{rval.text_value}' not know" if var.value.nil?
    +
       var.value = var.value - 1
     end
    -
    # File 'lib/idl/ast.rb', line 1865
    +      
    # File 'lib/idl/ast.rb', line 2102
     
     def to_idl = "#{rval.to_idl}--"
    -
    # File 'lib/idl/ast.rb', line 1853
    +      
    # File 'lib/idl/ast.rb', line 2088
     
     def type(symtab)
       rval.type(symtab)
    @@ -402,13 +406,13 @@ 

     
     
    -1848
    -1849
    -1850
    -1851
    +2083 +2084 +2085 +2086

    -
    # File 'lib/idl/ast.rb', line 1848
    +      
    # File 'lib/idl/ast.rb', line 2083
     
     def type_check(symtab)
       rval.type_check(symtab)
    @@ -424,7 +428,7 @@ 

    diff --git a/docs/ruby/Idl/PostIncrementExpressionAst.html b/docs/ruby/Idl/PostIncrementExpressionAst.html index 4035b614a..fbf06f6aa 100644 --- a/docs/ruby/Idl/PostIncrementExpressionAst.html +++ b/docs/ruby/Idl/PostIncrementExpressionAst.html @@ -316,19 +316,19 @@

     
     
    -1887
    -1888
    -1889
    -1890
    -1891
    -1892
    +2159 +2160 +2161 +2162 +2163 +2164

    -
    # File 'lib/idl/ast.rb', line 1887
    +      
    # File 'lib/idl/ast.rb', line 2159
     
     def execute(symtab)
    -  var = symtab.get(rval)
    -  internal_error "Call type check first" if var.nil?
    +  var = symtab.get(rval.text_value)
    +  internal_error "No symbol named '#{rval.text_value}'" if var.nil?
     
       var.value = var.value + 1
     end
    @@ -381,10 +381,10 @@

     
     
    -1895
    +2167

    -
    # File 'lib/idl/ast.rb', line 1895
    +      
    # File 'lib/idl/ast.rb', line 2167
     
     def to_idl = "#{rval.to_idl}++"
    -
    # File 'lib/idl/ast.rb', line 1882
    +      
    # File 'lib/idl/ast.rb', line 2154
     
     def type(symtab)
       rval.type(symtab)
    @@ -571,17 +571,19 @@ 

     
     
    -1876
    -1877
    -1878
    -1879
    +2147 +2148 +2149 +2150 +2151

    -
    # File 'lib/idl/ast.rb', line 1876
    +      
    # File 'lib/idl/ast.rb', line 2147
     
     def type_check(symtab)
       rval.type_check(symtab)
       var = symtab.get(rval.text_value)
    +  type_error "Post increment variable must be integral" unless var.type.integral?
     end
    + + + + +
    +
    +
    +
    +2038
    +2039
    +2040
    +2041
    +2042
    +
    +
    # File 'lib/idl/ast.rb', line 2038
    +
    +def initialize(input, interval, n, v)
    +  super(input, interval, [n, v])
    +  @n = n
    +  @v = v
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #nObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute n.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +2036
    +2037
    +2038
    +
    +
    # File 'lib/idl/ast.rb', line 2036
    +
    +def n
    +  @n
    +end
    +
    +
    + + + +
    +

    + + #vObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute v.

    + + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +2036
    +2037
    +2038
    +
    +
    # File 'lib/idl/ast.rb', line 2036
    +
    +def v
    +  @v
    +end
    +
    +
    + +
    + +

    Instance Method Details

    -

    +

    + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +165
    +166
    +167
    +168
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 165
    +
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  puts v.class.name
    +  "{#{n.gen_adoc(indent, indent_spaces:)}{#{v.gen_adoc(indent, indent_spaces:)}}}"
    +end
    +
    +
    + +
    +

    #to_idlString @@ -296,10 +610,10 @@

     
     
    -1838
    +2073

    -
    # File 'lib/idl/ast.rb', line 1838
    +      
    # File 'lib/idl/ast.rb', line 2073
     
     def to_idl = "{#{n.to_idl}{#{v.to_idl}}}"
    @@ -391,13 +705,13 @@

     
     
    -1832
    -1833
    -1834
    -1835
    +2067 +2068 +2069 +2070

    -
    # File 'lib/idl/ast.rb', line 1832
    +      
    # File 'lib/idl/ast.rb', line 2067
     
     def type(symtab)
       width = (n.value(symtab) * v.type(symtab).width)
    @@ -488,20 +802,20 @@ 

     
     
    -1810
    -1811
    -1812
    -1813
    -1814
    -1815
    -1816
    -1817
    -1818
    -1819
    -1820
    +2045 +2046 +2047 +2048 +2049 +2050 +2051 +2052 +2053 +2054 +2055

    -
    # File 'lib/idl/ast.rb', line 1810
    +      
    # File 'lib/idl/ast.rb', line 2045
     
     def type_check(symtab)
       n.type_check(symtab)
    @@ -545,16 +859,16 @@ 

     
     
    -1823
    -1824
    -1825
    -1826
    -1827
    -1828
    -1829
    +2058 +2059 +2060 +2061 +2062 +2063 +2064

    -
    # File 'lib/idl/ast.rb', line 1823
    +      
    # File 'lib/idl/ast.rb', line 2058
     
     def value(symtab)
       result = 0
    @@ -566,6 +880,102 @@ 

    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -573,7 +983,7 @@

    diff --git a/docs/ruby/Idl/ReplicationExpressionSyntaxNode.html b/docs/ruby/Idl/ReplicationExpressionSyntaxNode.html new file mode 100644 index 000000000..f8c8314c6 --- /dev/null +++ b/docs/ruby/Idl/ReplicationExpressionSyntaxNode.html @@ -0,0 +1,194 @@ + + + + + + + Class: Idl::ReplicationExpressionSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::ReplicationExpressionSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +2024
    +2025
    +2026
    +
    +
    # File 'lib/idl/ast.rb', line 2024
    +
    +def to_ast
    +  ReplicationExpressionAst.new(input, interval, n.to_ast, v.to_ast)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/ReturnStatementAst.html b/docs/ruby/Idl/ReturnStatementAst.html index 72ca92d5e..70abffc00 100644 --- a/docs/ruby/Idl/ReturnStatementAst.html +++ b/docs/ruby/Idl/ReturnStatementAst.html @@ -104,7 +104,7 @@
    Defined in:
    lib/idl/ast.rb,
    - lib/idl/passes/find_return_values.rb
    + lib/idl/passes/gen_adoc.rb,
    lib/idl/passes/find_return_values.rb
    @@ -189,6 +189,28 @@

    The expected return type (as defined by the encolsing function).

    + + + +
  • + + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + + + + + + + + + +
    +
  • @@ -285,7 +307,7 @@

  • - #return_value_nodes ⇒ Object + #return_value_nodes ⇒ Array<AstNode> @@ -300,9 +322,31 @@

    -

    list of return value nodes.

    +

    List of return value nodes.

    +

  • + + +
  • + + + #return_values(symtab) ⇒ Object + + + + + + + + + + + + + +
    +
  • @@ -384,12 +428,12 @@

     
     
    -2377
    -2378
    -2379
    +2747 +2748 +2749

    -
    # File 'lib/idl/ast.rb', line 2377
    +      
    # File 'lib/idl/ast.rb', line 2747
     
     def enclosing_function
       find_ancestor(FunctionDefAst)
    @@ -443,21 +487,35 @@ 

     
     
    -2328
    -2329
    -2330
    -2331
    -2332
    -2333
    -2334
    -2335
    -2336
    -2337
    -2338
    -2339
    +2685 +2686 +2687 +2688 +2689 +2690 +2691 +2692 +2693 +2694 +2695 +2696 +2697 +2698 +2699 +2700 +2701 +2702 +2703 +2704 +2705 +2706 +2707 +2708 +2709 +2710

    -
    # File 'lib/idl/ast.rb', line 2328
    +      
    # File 'lib/idl/ast.rb', line 2685
     
     def expected_return_type(symtab)
       func_def = find_ancestor(FunctionDefAst)
    @@ -468,12 +526,58 @@ 

    symtab.get("__expected_return_type") else - func_def.return_type(symtab) + # need to find the type to get the right symbol table + func_type = symtab.get_global(func_def.name) + internal_error "Couldn't find function type for '#{func_def.name}' #{symtab.keys} " if func_type.nil? + + # to get the return type, we need to find the template values in case this is + # a templated function definition + # + # that information should be up the stack in the symbol table + template_values = symtab.find_all(single_scope: true) do |o| + o.is_a?(Var) && o.template_value_for?(func_def.name) + end + unless template_values.size == func_type.template_names.size + internal_error "Did not find correct number of template arguments (found #{template_values.size}, need #{func_type.template_names.size}) #{symtab.keys_pretty}" + end + func_type.return_type(template_values.sort { |a, b| a.template_index <=> b.template_index }.map(&:value)) end end

    + + +
    +

    + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +158
    +159
    +160
    +161
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 158
    +
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  values = [first.gen_adoc(0, indent_spaces:)] + rest.elements.each { |e| e.e.gen_adoc(0, indent_spaces: )}
    +  "#{' ' * indent}return #{values.join(', ')};"
    +end
    +
    @@ -541,17 +645,17 @@

     
     
    -2318
    -2319
    -2320
    -2321
    -2322
    -2323
    -2324
    -2325
    +2675 +2676 +2677 +2678 +2679 +2680 +2681 +2682

    -
    # File 'lib/idl/ast.rb', line 2318
    +      
    # File 'lib/idl/ast.rb', line 2675
     
     def return_type(symtab)
       types = return_types(symtab)
    @@ -610,20 +714,20 @@ 

     
     
    -2305
    -2306
    -2307
    -2308
    -2309
    -2310
    -2311
    -2312
    -2313
    -2314
    -2315
    +2662 +2663 +2664 +2665 +2666 +2667 +2668 +2669 +2670 +2671 +2672

    -
    # File 'lib/idl/ast.rb', line 2305
    +      
    # File 'lib/idl/ast.rb', line 2662
     
     def return_types(symtab)
       if first.type(symtab).kind == :tuple
    @@ -656,16 +760,16 @@ 

     
     
    -2381
    -2382
    -2383
    -2384
    -2385
    -2386
    -2387
    +2752 +2753 +2754 +2755 +2756 +2757 +2758

    -
    # File 'lib/idl/ast.rb', line 2381
    +      
    # File 'lib/idl/ast.rb', line 2752
     
     def return_value(symtab)
       if return_value_nodes.size == 1
    @@ -682,7 +786,7 @@ 

    - #return_value_nodesObject + #return_value_nodesArray<AstNode> @@ -691,13 +795,31 @@

    -

    list of return value nodes

    +

    Returns List of return value nodes.

    +

    Returns:

    +
      + +
    • + + + (Array<AstNode>) + + + + — +
      +

      List of return value nodes

      +
      + +
    • + +
    @@ -705,18 +827,18 @@

     
     
    -2367
    -2368
    -2369
    -2370
    -2371
    -2372
    -2373
    -2374
    -2375
    +2737 +2738 +2739 +2740 +2741 +2742 +2743 +2744 +2745

    -
    # File 'lib/idl/ast.rb', line 2367
    +      
    # File 'lib/idl/ast.rb', line 2737
     
     def return_value_nodes
       v = [first]
    @@ -730,6 +852,44 @@ 

    +
    + +
    +

    + + #return_values(symtab) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +2761
    +2762
    +2763
    +2764
    +2765
    +2766
    +2767
    +
    +
    # File 'lib/idl/ast.rb', line 2761
    +
    +def return_values(symtab)
    +  if return_value_nodes.size == 1
    +    return_value_nodes[0].values(symtab)
    +  else
    +    return_value_nodes.map { |v| v.values(symtab) }.flatten.uniq
    +  end
    +end
    +
    @@ -747,10 +907,10 @@

     
     
    -2389
    +2769

    -
    # File 'lib/idl/ast.rb', line 2389
    +      
    # File 'lib/idl/ast.rb', line 2769
     
     def to_idl = "return #{return_value_nodes.map(&:to_idl).join(',')};"
    @@ -838,32 +998,31 @@

     
     
    -2342
    -2343
    -2344
    -2345
    -2346
    -2347
    -2348
    -2349
    -2350
    -2351
    -2352
    -2353
    -2354
    -2355
    -2356
    -2357
    -2358
    -2359
    -2360
    -2361
    -2362
    -2363
    -2364
    +2713 +2714 +2715 +2716 +2717 +2718 +2719 +2720 +2721 +2722 +2723 +2724 +2725 +2726 +2727 +2728 +2729 +2730 +2731 +2732 +2733 +2734

    -
    # File 'lib/idl/ast.rb', line 2342
    +      
    # File 'lib/idl/ast.rb', line 2713
     
     def type_check(symtab)
       first.type_check(symtab)
    @@ -874,7 +1033,6 @@ 

    types = [] if first.type(symtab).kind == :tuple type_error("Can't combine tuple types in return") unless rest.elements.empty? - num_values = first.type(symtab).tuple_types.size types = first.type(symtab).tuple_types else types = [first.type(symtab)] @@ -898,7 +1056,7 @@

    diff --git a/docs/ruby/Idl/Returns.html b/docs/ruby/Idl/Returns.html index d6c367cee..ba68d6269 100644 --- a/docs/ruby/Idl/Returns.html +++ b/docs/ruby/Idl/Returns.html @@ -76,7 +76,7 @@
    Included in:
    -
    ConditionalReturnStatementAst, ForLoopAst, FunctionBodyAst, IfAst, ReturnStatementAst
    +
    ConditionalReturnStatementAst, ElseIfAst, ForLoopAst, FunctionBodyAst, IfAst, IfBodyAst, ReturnStatementAst
    @@ -131,6 +131,28 @@

    +
    + + + + +
  • + + + #return_values(symtab) ⇒ Object + + + + + + + + + + + + +
  • @@ -154,6 +176,54 @@

    +

    +
    + + +
    +
    +
    + +

    Raises:

    +
      + +
    • + + + (NotImplementedError) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +335
    +
    +
    # File 'lib/idl/ast.rb', line 335
    +
    +def return_value(symtab) = raise NotImplementedError, "#{self.class.name} must implement return_value"
    +
    + + +
    +

    + + #return_values(symtab) ⇒ Object + + + + +

    @@ -187,7 +257,7 @@

    # File 'lib/idl/ast.rb', line 348
     
    -def return_value(symtab) = raise NotImplementedError, "#{self.class.name} must implement return_value"
    +def return_values(symtab) = raise NotImplementedError, "#{self.class.name} must implement return_values"

    @@ -198,7 +268,7 @@

    diff --git a/docs/ruby/Idl/Rvalue.html b/docs/ruby/Idl/Rvalue.html index 0256b8e65..cce511876 100644 --- a/docs/ruby/Idl/Rvalue.html +++ b/docs/ruby/Idl/Rvalue.html @@ -76,7 +76,7 @@
    Included in:
    -
    ArrayLiteralAst, AryElementAccessAst, AryRangeAccessAst, BinaryExpressionAst, BitfieldAccessExpressionAst, BitsCastAst, ConcatenationExpressionAst, CsrFieldReadExpressionAst, CsrReadExpressionAst, CsrSoftwareReadAst, DontCareLvalueAst, DontCareReturnAst, EnumRefAst, FunctionCallExpressionAst, IdAst, IntAst, ParenExpressionAst, ReplicationExpressionAst, SignCastAst, TernaryOperatorExpressionAst, UnaryOperatorExpressionAst, VarReadExpressionAst
    +
    ArrayLiteralAst, AryElementAccessAst, AryRangeAccessAst, BinaryExpressionAst, BitfieldAccessExpressionAst, BitsCastAst, ConcatenationExpressionAst, CsrFieldReadExpressionAst, CsrReadExpressionAst, CsrSoftwareReadAst, DontCareLvalueAst, DontCareReturnAst, EnumRefAst, FunctionCallExpressionAst, IdAst, IntLiteralAst, ParenExpressionAst, ReplicationExpressionAst, SignCastAst, TernaryOperatorExpressionAst, UnaryOperatorExpressionAst
    @@ -159,6 +159,30 @@

    Return the compile-time-known value of the node.

    + + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
    +
  • @@ -322,6 +346,111 @@

    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +407
    +
    +
    # File 'lib/idl/ast.rb', line 407
    +
    +def values(symtab) = [value(symtab)]
    +
    @@ -329,7 +458,7 @@

    diff --git a/docs/ruby/Idl/SignCastAst.html b/docs/ruby/Idl/SignCastAst.html index 11eecf15c..d847472ff 100644 --- a/docs/ruby/Idl/SignCastAst.html +++ b/docs/ruby/Idl/SignCastAst.html @@ -103,7 +103,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/gen_adoc.rb
    +
    @@ -112,6 +114,40 @@ +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #expression ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute expression.

      +
      + +
    • + + +
    + @@ -126,6 +162,54 @@

  • + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + #initialize(input, interval, expression) ⇒ SignCastAst + + + + + + + constructor + + + + + + + + +
    +

    A new instance of SignCastAst.

    +
    + +
  • + + +
  • + + #to_idl ⇒ String @@ -216,6 +300,35 @@

    Return the compile-time-known value of the node.

    +

  • + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
    +
  • @@ -230,14 +343,139 @@

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(input, interval, expression) ⇒ SignCastAst + + + + + +

    +
    + +

    Returns a new instance of SignCastAst.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +1575
    +1576
    +1577
    +1578
    +
    +
    # File 'lib/idl/ast.rb', line 1575
    +
    +def initialize(input, interval, expression)
    +  super(input, interval, [expression])
    +  @expression = expression
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #expressionObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute expression.

    + + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +1573
    +1574
    +1575
    +
    +
    # File 'lib/idl/ast.rb', line 1573
    +
    +def expression
    +  @expression
    +end
    +
    +
    + +
    + +

    Instance Method Details

    -

    +

    + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +62
    +63
    +64
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 62
    +
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  "$signed(#{expression.gen_adoc(0, indent_spaces:)})"
    +end
    +
    +
    + +
    +

    #to_idlString @@ -280,10 +518,10 @@

     
     
    -1477
    +1603

    -
    # File 'lib/idl/ast.rb', line 1477
    +      
    # File 'lib/idl/ast.rb', line 1603
     
     def to_idl = "$signed(#{expression.to_idl})"
    @@ -375,10 +613,10 @@

     
     
    -1460
    +1586

    -
    # File 'lib/idl/ast.rb', line 1460
    +      
    # File 'lib/idl/ast.rb', line 1586
     
     def type(symtab) = expression.type(symtab).clone.make_signed
    @@ -466,12 +704,12 @@

     
     
    -1455
    -1456
    -1457
    +1581 +1582 +1583

    -
    # File 'lib/idl/ast.rb', line 1455
    +      
    # File 'lib/idl/ast.rb', line 1581
     
     def type_check(symtab)
       expression.type_check(symtab)
    @@ -507,21 +745,21 @@ 

     
     
    -1463
    -1464
    -1465
    -1466
    -1467
    -1468
    -1469
    -1470
    -1471
    -1472
    -1473
    -1474
    +1589 +1590 +1591 +1592 +1593 +1594 +1595 +1596 +1597 +1598 +1599 +1600

    -
    # File 'lib/idl/ast.rb', line 1463
    +      
    # File 'lib/idl/ast.rb', line 1589
     
     def value(symtab)
       t = expression.type(symtab)
    @@ -538,6 +776,102 @@ 

    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -545,7 +879,7 @@

    diff --git a/docs/ruby/Idl/SignCastSyntaxNode.html b/docs/ruby/Idl/SignCastSyntaxNode.html new file mode 100644 index 000000000..b48600d65 --- /dev/null +++ b/docs/ruby/Idl/SignCastSyntaxNode.html @@ -0,0 +1,194 @@ + + + + + + + Class: Idl::SignCastSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::SignCastSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +1565
    +1566
    +1567
    +
    +
    # File 'lib/idl/ast.rb', line 1565
    +
    +def to_ast
    +  SignCastAst.new(input, interval, expression.to_ast)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/StatementAst.html b/docs/ruby/Idl/StatementAst.html index 1acd09a30..8ad01faa3 100644 --- a/docs/ruby/Idl/StatementAst.html +++ b/docs/ruby/Idl/StatementAst.html @@ -103,7 +103,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/prune.rb,
    lib/idl/passes/gen_adoc.rb
    +
    @@ -126,13 +128,43 @@

    Overview

    -
    -

    Direct Known Subclasses

    -

    ConditionalStatementAst

    +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #action ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute action.

      +
      + +
    • + + +
    @@ -148,7 +180,7 @@

  • - #action ⇒ Object + #execute(symtab) ⇒ void @@ -162,7 +194,9 @@

    -
    +
    +

    “execute” the statement by updating the variables in the symbol table.

    +

  • @@ -170,7 +204,7 @@

  • - #execute(symtab) ⇒ Object + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object @@ -192,7 +226,33 @@

  • - #to_idl ⇒ Object + #initialize(action) ⇒ StatementAst + + + + + + + constructor + + + + + + + + +
    +

    A new instance of StatementAst.

    +
    + +
  • + + +
  • + + + #prune(symtab) ⇒ Object @@ -208,6 +268,30 @@

    +

  • + + +
  • + + + #to_idl ⇒ String + + + + + + + + + + + + + +
    +

    Return valid IDL representation of the node (and its subtree).

    +
    +
  • @@ -246,42 +330,200 @@

    +
    +

    Constructor Details

    + +
    +

    + #initialize(action) ⇒ StatementAst + + + + + +

    +
    + +

    Returns a new instance of StatementAst.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +2521
    +2522
    +2523
    +2524
    +
    +
    # File 'lib/idl/ast.rb', line 2521
    +
    +def initialize(action)
    +  super(action.input, action.interval, [action])
    +  @action = action
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #actionObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute action.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +2519
    +2520
    +2521
    +
    +
    # File 'lib/idl/ast.rb', line 2519
    +
    +def action
    +  @action
    +end
    +
    +
    + +
    +

    Instance Method Details

    -

    +

    - #actionObject + #execute(symtab) ⇒ void -

    +
    +
    +

    This method returns an undefined value.

    +

    “execute” the statement by updating the variables in the symbol table

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The symbol table for the context

      +
      + +
    • + +
    + +

    Raises:

    +
      + +
    • + + + + + + + +
      +

      ValueError if some part of the statement cannot be executed at compile time

      +
      + +
    • + +
    + +
     
     
    -2198
    +2532 +2533 +2534 +2535 +2536 +2537 +2538 +2539
    -
    # File 'lib/idl/ast.rb', line 2198
    +      
    # File 'lib/idl/ast.rb', line 2532
     
    -def action = a
    +def execute(symtab) + if @action.is_a?(Declaration) + @action.add_symbol(symtab) + end + if @action.is_a?(Executable) + @action.execute(symtab) + end +end
    -

    +

    - #execute(symtab) ⇒ Object + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object @@ -293,15 +535,15 @@

     
     
    -2205
    -2206
    -2207
    +146 +147 +148

  • -
    # File 'lib/idl/ast.rb', line 2205
    +      
    # File 'lib/idl/passes/gen_adoc.rb', line 146
     
    -def execute(symtab)
    -  a.execute(symtab)
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  "#{' ' * indent}#{action.gen_adoc(0, indent_spaces:)};"
     end
    @@ -309,9 +551,9 @@

    -

    +

    - #to_idlObject + #prune(symtab) ⇒ Object @@ -323,12 +565,93 @@

     
     
    -2209
    +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103

    + + +
    # File 'lib/idl/passes/prune.rb', line 90
    +
    +def prune(symtab)
    +  pruned_action = action.prune(symtab)
    +  if pruned_action.is_a?(Declaration)
    +    pruned_action.add_symbol(symtab)
    +  end
    +  if pruned_action.is_a?(Executable)
    +    begin
    +      pruned_action.execute(symtab)
    +    rescue ValueError
    +      # ok
    +    end
    +  end
    +  StatementAst.new(pruned_action)
    +end
    + + + + + +
    +

    + + #to_idlString + + + + + +

    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    + +
    +
    +
    +
    +2542
    -
    # File 'lib/idl/ast.rb', line 2209
    +      
    # File 'lib/idl/ast.rb', line 2542
     
    -def to_idl = "#{action.to_idl};"
    +def to_idl = "#{@action.to_idl};"
    @@ -414,15 +737,15 @@

     
     
    -2201
    -2202
    -2203
    +2527 +2528 +2529

    -
    # File 'lib/idl/ast.rb', line 2201
    +      
    # File 'lib/idl/ast.rb', line 2527
     
     def type_check(symtab)
    -  a.type_check(symtab)
    +  @action.type_check(symtab)
     end
    @@ -434,7 +757,7 @@

    diff --git a/docs/ruby/Idl/StatementSyntaxNode.html b/docs/ruby/Idl/StatementSyntaxNode.html new file mode 100644 index 000000000..91d7ca1e5 --- /dev/null +++ b/docs/ruby/Idl/StatementSyntaxNode.html @@ -0,0 +1,200 @@ + + + + + + + Class: Idl::StatementSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::StatementSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + AstNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +2490
    +2491
    +2492
    +
    +
    # File 'lib/idl/ast.rb', line 2490
    +
    +def to_ast
    +  StatementAst.new(a.to_ast)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/SymbolTable.html b/docs/ruby/Idl/SymbolTable.html index 42ab969d7..b554b1e26 100644 --- a/docs/ruby/Idl/SymbolTable.html +++ b/docs/ruby/Idl/SymbolTable.html @@ -186,7 +186,9 @@

    -
    +
    +

    add a new symbol at the outermost scope.

    +
    @@ -209,7 +211,7 @@

    -

    add, and make sure name is unique.

    +

    add a new symbol at the outermost scope, unless that symbol is already defined.

    @@ -266,7 +268,31 @@

  • - #deep_clone(clone_values: false) ⇒ Object + #deep_clone(clone_values: false) ⇒ SymbolTable + + + + + + + + + + + + + +
    +

    A deep clone of this SymbolTable.

    +
    + +
  • + + +
  • + + + #find_all(single_scope: false) {|obj| ... } ⇒ Array<Object> @@ -281,7 +307,7 @@

    -

    return a deep clone of this SymbolTable.

    +

    searches the symbol table scope-by-scope to find all entries for which the block returns true.

  • @@ -304,8 +330,56 @@

    +
    +

    searches the symbol table scope-by-scope to find ‘name’.

    +
    + + + + +
  • + + + #get_from(name, level) ⇒ Object + + + + + + + + + + + + +
    +
  • + + +
  • + + + #get_global(name) ⇒ Object + + + + + + + + + + + + + +
    +

    The symbol named ‘name’ from global scope, or nil if not found.

    +
    +
  • @@ -352,7 +426,9 @@

    -
    +
    +

    Whether or not any symbol ‘name’ is defined at any level in the symbol table.

    +
    @@ -360,7 +436,7 @@

  • - #levels ⇒ Object + #keys_pretty ⇒ Object @@ -376,6 +452,30 @@

    +

  • + + +
  • + + + #levels ⇒ Integer + + + + + + + + + + + + + +
    +

    Number of scopes on the symbol table (global at 1).

    +
    +
  • @@ -396,7 +496,9 @@

    -
    +
    +

    pops the top of the scope stack.

    +
    @@ -418,7 +520,9 @@

    -
    +
    +

    pretty-print the symbol table contents.

    +
    @@ -440,7 +544,9 @@

    -
    +
    +

    pushes a new scope.

    +
    @@ -477,26 +583,6 @@

     
     
    -54
    -55
    -56
    -57
    -58
    -59
    -60
    -61
    -62
    -63
    -64
    -65
    -66
    -67
    -68
    -69
    -70
    -71
    -72
    -73
     74
     75
     76
    @@ -549,10 +635,30 @@ 

    123 124 125 -126

    +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146

    -
    # File 'lib/idl/symbol_table.rb', line 54
    +      
    # File 'lib/idl/symbol_table.rb', line 74
     
     def initialize(arch_def)
       @archdef = arch_def
    @@ -665,12 +771,12 @@ 

     
     
    -49
    -50
    -51
    +69 +70 +71

    -
    # File 'lib/idl/symbol_table.rb', line 49
    +      
    # File 'lib/idl/symbol_table.rb', line 69
     
     def archdef
       @archdef
    @@ -696,18 +802,65 @@ 

    -

    +
    +
    + +

    add a new symbol at the outermost scope

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + name + + + (#to_s) + + + + — +
      +

      Symbol name

      +
      + +
    • + +
    • + + var + + + (Object) + + + + — +
      +

      Symbol object (usually a Var or a Type)

      +
      + +
    • + +
    + + +
    @@ -541,19 +624,19 @@

     
     
    -2013
    -2014
    -2015
    -2016
    -2017
    -2018
    -2019
    -2020
    -2021
    -2022
    +2302 +2303 +2304 +2305 +2306 +2307 +2308 +2309 +2310 +2311

     
     
    -154
    -155
    -156
    +226 +227 +228
    -
    # File 'lib/idl/symbol_table.rb', line 154
    +      
    # File 'lib/idl/symbol_table.rb', line 226
     
     def add(name, var)
       @scopes.last[name] = var
    @@ -729,23 +882,64 @@ 

    -

    add, and make sure name is unique

    +

    add a new symbol at the outermost scope, unless that symbol is already defined

    +

    Parameters:

    +
      + +
    • + + name + + + (#to_s) + + + + — +
      +

      Symbol name

      +
      + +
    • + +
    • + + var + + + (Object) + + + + — +
      +

      Symbol object (usually a Var or a Type)

      +
      + +
    • +
    +

    Raises:

    • - (DuplicateSymError) + (DuplicationSymError) + — +
      +

      if ‘name’ is already in the symbol table

      +
      +
    @@ -756,14 +950,14 @@

     
     
    -159
    -160
    -161
    -162
    -163
    +235 +236 +237 +238 +239

    -
    # File 'lib/idl/symbol_table.rb', line 159
    +      
    # File 'lib/idl/symbol_table.rb', line 235
     
     def add!(name, var)
       raise DuplicateSymError, "Symbol #{name} already defined as #{get(name)}" unless @scopes.select { |h| h.key? name }.empty?
    @@ -801,16 +995,16 @@ 

     
     
    -166
    -167
    -168
    -169
    -170
    -171
    -172
    +242 +243 +244 +245 +246 +247 +248

    -
    # File 'lib/idl/symbol_table.rb', line 166
    +      
    # File 'lib/idl/symbol_table.rb', line 242
     
     def add_above!(name, var)
       raise "There is only one scope" if @scopes.size <= 1
    @@ -850,16 +1044,16 @@ 

     
     
    -175
    -176
    -177
    -178
    -179
    -180
    -181
    +251 +252 +253 +254 +255 +256 +257

    -
    # File 'lib/idl/symbol_table.rb', line 175
    +      
    # File 'lib/idl/symbol_table.rb', line 251
     
     def add_at!(level, name, var)
       raise "Level #{level} is too large #{@scopes.size}" if  level >= @scopes.size
    @@ -876,7 +1070,7 @@ 

    - #deep_clone(clone_values: false) ⇒ Object + #deep_clone(clone_values: false) ⇒ SymbolTable @@ -885,13 +1079,31 @@

    -

    return a deep clone of this SymbolTable

    +

    Returns a deep clone of this SymbolTable.

    +

    Returns:

    +
      + +
    • + + + (SymbolTable) + + + + — +
      +

      a deep clone of this SymbolTable

      +
      + +
    • + +
    @@ -899,26 +1111,26 @@

     
     
    -196
    -197
    -198
    -199
    -200
    -201
    -202
    -203
    -204
    -205
    -206
    -207
    -208
    -209
    -210
    -211
    -212
    +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290

    + + +
    -
    # File 'lib/idl/symbol_table.rb', line 196
    +      
    # File 'lib/idl/symbol_table.rb', line 274
     
     def deep_clone(clone_values: false)
       copy = SymbolTable.new(@archdef)
    @@ -943,45 +1155,9 @@ 

    -

    - - #get(name) ⇒ Object - - - - - -

    - - - - -
    -
    -
    -
    -147
    -148
    -149
    -150
    -151
    -152
    -
    -
    # File 'lib/idl/symbol_table.rb', line 147
    -
    -def get(name)
    -  @scopes.reverse_each do |s|
    -    return s[name] if s.key?(name)
    -  end
    -  nil
    -end
    -
    -
    - -
    -

    +

    - #key?(name) ⇒ Boolean + #find_all(single_scope: false) {|obj| ... } ⇒ Array<Object> @@ -990,12 +1166,360 @@

    +

    searches the symbol table scope-by-scope to find all entries for which the block returns true

    +
    +

    Parameters:

    +
      -

      Returns:

      +
    • + + single_scope + + + (Boolean) + + + (defaults to: false) + + + — +
      +

      If true, stop searching more scope as soon as there are matches

      +
      + +
    • + +
    + +

    Yield Parameters:

    +
      + +
    • + + obj + + + (Object) + + + + — +
      +

      A object stored in the symbol table

      +
      + +
    • + +
    +

    Yield Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      Whether or not the object is the one you are looking for

      +
      + +
    • + +
    +

    Returns:

    +
      + +
    • + + + (Array<Object>) + + + + — +
      +

      All matches

      +
      + +
    • + +
    +

    Raises:

    +
      + +
    • + + + (ArgumentError) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +220
    +
    +
    # File 'lib/idl/symbol_table.rb', line 206
    +
    +def find_all(single_scope: false, &block)
    +  raise ArgumentError, "Block needed" unless block_given?
    +
    +  raise ArgumentError, "Find block takes one argument" unless block.arity == 1
    +
    +  matches = []
    +
    +  @scopes.reverse_each do |s|
    +    s.each_value do |v|
    +      matches << v if yield v
    +    end
    +    break if single_scope && !matches.empty?
    +  end
    +  matches
    +end
    +
    +
    + +
    +

    + + #get(name) ⇒ Object + + + + + +

    +
    + +

    searches the symbol table scope-by-scope to find ‘name’

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      A symbol named ‘name’, or nil if not found

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +177
    +178
    +179
    +180
    +181
    +182
    +
    +
    # File 'lib/idl/symbol_table.rb', line 177
    +
    +def get(name)
    +  @scopes.reverse_each do |s|
    +    return s[name] if s.key?(name)
    +  end
    +  nil
    +end
    +
    +
    + +
    +

    + + #get_from(name, level) ⇒ Object + + + + + +

    +
    + + +
    +
    +
    + +

    Raises:

    +
      + +
    • + + + (ArgumentError) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +184
    +185
    +186
    +187
    +188
    +189
    +190
    +191
    +192
    +193
    +
    +
    # File 'lib/idl/symbol_table.rb', line 184
    +
    +def get_from(name, level)
    +  raise ArgumentError, "level must be positive" unless level.positive?
    +
    +  raise "There is no level #{level}" unless level < levels
    +
    +  @scopes[0..level - 1].reverse_each do |s|
    +    return s[name] if s.key?(name)
    +  end
    +  nil
    +end
    +
    +
    + +
    +

    + + #get_global(name) ⇒ Object + + + + + +

    +
    + +

    Returns the symbol named ‘name’ from global scope, or nil if not found.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      the symbol named ‘name’ from global scope, or nil if not found

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +196
    +197
    +198
    +
    +
    # File 'lib/idl/symbol_table.rb', line 196
    +
    +def get_global(name)
    +  get_from(name, 1)
    +end
    +
    +
    + +
    +

    + + #key?(name) ⇒ Boolean + + + + + +

    +
    + +

    Returns whether or not any symbol ‘name’ is defined at any level in the symbol table.

    + + +
    +
    +
    + +

    Returns:

    • @@ -1005,6 +1529,11 @@

      + — +
      +

      whether or not any symbol ‘name’ is defined at any level in the symbol table

      +
      +

    @@ -1015,12 +1544,12 @@

     
     
    -143
    -144
    -145
    +166 +167 +168

    -
    # File 'lib/idl/symbol_table.rb', line 143
    +      
    # File 'lib/idl/symbol_table.rb', line 166
     
     def key?(name)
       @scopes.each { |s| return true if s.key?(name) }
    @@ -1031,9 +1560,9 @@ 

    -

    +

    - #levelsObject + #keys_prettyObject @@ -1045,12 +1574,71 @@

     
     
    -183
    -184
    -185
    +170 +171 +172

    +
    +
    # File 'lib/idl/symbol_table.rb', line 170
    +
    +def keys_pretty
    +  @scopes.map { |s| s.map { |k, v| v.is_a?(Var) && v.template_val? ? "#{k} (template)" : k }}
    +end
    +
    +
    + +
    +

    + + #levelsInteger + + + + + +

    +
    + +

    Returns Number of scopes on the symbol table (global at 1).

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Number of scopes on the symbol table (global at 1)

      +
      + +
    • + +
    + +
    + +
    +
    +
    +
    +260
    +261
    +262
    -
    # File 'lib/idl/symbol_table.rb', line 183
    +      
    # File 'lib/idl/symbol_table.rb', line 260
     
     def levels
       @scopes.size
    @@ -1069,27 +1657,38 @@ 

    -

    +
    +
    + +

    pops the top of the scope stack

    + + +
    +
    +
    + + +
     
     
    -135
    -136
    -137
    -138
    -139
    -140
    -141
    +157 +158 +159 +160 +161 +162 +163
    -
    # File 'lib/idl/symbol_table.rb', line 135
    +      
    # File 'lib/idl/symbol_table.rb', line 157
     
     def pop
       # puts "pop #{caller[0]}"
       # puts "    from #{@scope_caller.pop}"
    -  raise 'Error: popping the symbol table would remove global scope' if @scopes.size == 1
    +  raise "Error: popping the symbol table would remove global scope" if @scopes.size == 1
     
       @scopes.pop
     end
    @@ -1107,22 +1706,33 @@ +
    +
    + +

    pretty-print the symbol table contents

    + + +
    +
    +
    + + +
    @@ -760,15 +983,128 @@

     
     
    -2147
    -2148
    -2149
    +2439 +2440 +2441

    + +
     
     
    -187
    -188
    -189
    -190
    -191
    -192
    -193
    +265 +266 +267 +268 +269 +270 +271
    -
    # File 'lib/idl/symbol_table.rb', line 187
    +      
    # File 'lib/idl/symbol_table.rb', line 265
     
     def print
       @scopes.each do |s|
    @@ -1145,21 +1755,32 @@ 

    -

    +
    +
    + +

    pushes a new scope

    + + +
    +
    +
    + + +
     
     
    -128
    -129
    -130
    -131
    -132
    -133
    +149 +150 +151 +152 +153 +154
    -
    # File 'lib/idl/symbol_table.rb', line 128
    +      
    # File 'lib/idl/symbol_table.rb', line 149
     
     def push
       # puts "push #{caller[0]}"
    @@ -1177,7 +1798,7 @@ 

    diff --git a/docs/ruby/Idl/SymbolTable/DuplicateSymError.html b/docs/ruby/Idl/SymbolTable/DuplicateSymError.html index 302a3cf00..cb1a525e8 100644 --- a/docs/ruby/Idl/SymbolTable/DuplicateSymError.html +++ b/docs/ruby/Idl/SymbolTable/DuplicateSymError.html @@ -114,7 +114,7 @@ diff --git a/docs/ruby/Idl/TemplateFunctionType.html b/docs/ruby/Idl/TemplateFunctionType.html deleted file mode 100644 index 957870845..000000000 --- a/docs/ruby/Idl/TemplateFunctionType.html +++ /dev/null @@ -1,376 +0,0 @@ - - - - - - - Class: Idl::TemplateFunctionType - - — Documentation by YARD 0.9.36 - - - - - - - - - - - - - - - - - - - -
    - - -

    Class: Idl::TemplateFunctionType - - - -

    -
    - -
    -
    Inherits:
    -
    - Type - -
      -
    • Object
    • - - - - - -
    - show all - -
    -
    - - - - - - - - - - - -
    -
    Defined in:
    -
    lib/idl/type.rb
    -
    - -
    - -

    Overview

    -
    - -

    a function that is templated, and hasn’t been fully typed checked yet because it needs to have template arguments resolved

    - - -
    -
    -
    - - -
    - - - -

    Instance Attribute Summary collapse

    -
      - -
    • - - - #ast ⇒ Object - - - - - - - - - readonly - - - - - - - - - -
      -

      Returns the value of attribute ast.

      -
      - -
    • - - -
    • - - - #template_types ⇒ Object - - - - - - - - - readonly - - - - - - - - - -
      -

      Returns the value of attribute template_types.

      -
      - -
    • - - -
    - - - - - -

    - Instance Method Summary - collapse -

    - - - - - - -
    -

    Constructor Details

    - -
    -

    - - #initialize(func_name, template_types, ast) ⇒ TemplateFunctionType - - - - - -

    -
    - -

    Returns a new instance of TemplateFunctionType.

    - - -
    -
    -
    - - -
    - - - - -
    -
    -
    -
    -532
    -533
    -534
    -535
    -536
    -
    -
    # File 'lib/idl/type.rb', line 532
    -
    -def initialize(func_name, template_types, ast)
    -  super(:template_function, name: func_name, arguments: arguments)
    -  @template_types = template_types
    -  @ast = ast
    -end
    -
    -
    - -
    - -
    -

    Instance Attribute Details

    - - - -
    -

    - - #astObject (readonly) - - - - - -

    -
    - -

    Returns the value of attribute ast.

    - - -
    -
    -
    - - -
    - - - - -
    -
    -
    -
    -530
    -531
    -532
    -
    -
    # File 'lib/idl/type.rb', line 530
    -
    -def ast
    -  @ast
    -end
    -
    -
    - - - -
    -

    - - #template_typesObject (readonly) - - - - - -

    -
    - -

    Returns the value of attribute template_types.

    - - -
    -
    -
    - - -
    - - - - -
    -
    -
    -
    -530
    -531
    -532
    -
    -
    # File 'lib/idl/type.rb', line 530
    -
    -def template_types
    -  @template_types
    -end
    -
    -
    - -
    - - -
    - - - -
    - - \ No newline at end of file diff --git a/docs/ruby/Idl/TernaryOperatorExpressionAst.html b/docs/ruby/Idl/TernaryOperatorExpressionAst.html index 6601a91c3..2ba060938 100644 --- a/docs/ruby/Idl/TernaryOperatorExpressionAst.html +++ b/docs/ruby/Idl/TernaryOperatorExpressionAst.html @@ -103,7 +103,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/gen_adoc.rb
    +
    @@ -129,6 +131,98 @@

    Overview

    +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #condition ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute condition.

      +
      + +
    • + + +
    • + + + #false_expression ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute false_expression.

      +
      + +
    • + + +
    • + + + #true_expression ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute true_expression.

      +
      + +
    • + + +
    + @@ -143,7 +237,7 @@

  • - #condition ⇒ Object + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object @@ -165,13 +259,15 @@

  • - #false_expression ⇒ Object + #initialize(input, interval, condition, true_expression, false_expression) ⇒ TernaryOperatorExpressionAst + constructor + @@ -179,7 +275,9 @@

    -
    +
    +

    A new instance of TernaryOperatorExpressionAst.

    +

  • @@ -211,7 +309,7 @@

  • - #true_expression ⇒ Object + #type(symtab) ⇒ Type @@ -225,7 +323,9 @@

    -
    +
    +

    Given a specific symbol table, return the type of this node.

    +

  • @@ -233,7 +333,7 @@

  • - #type(symtab) ⇒ Type + #type_check(symtab) ⇒ void @@ -248,7 +348,7 @@

    -

    Given a specific symbol table, return the type of this node.

    +

    type check this node and all children.

  • @@ -257,7 +357,7 @@

  • - #type_check(symtab) ⇒ void + #value(symtab) ⇒ Object @@ -272,7 +372,7 @@

    -

    type check this node and all children.

    +

    Return the compile-time-known value of the node.

  • @@ -281,7 +381,7 @@

  • - #value(symtab) ⇒ Object + #values(symtab) ⇒ Array<Integer>, ... @@ -296,7 +396,7 @@

    -

    Return the compile-time-known value of the node.

    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

  • @@ -313,76 +413,155 @@

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(input, interval, condition, true_expression, false_expression) ⇒ TernaryOperatorExpressionAst -
    -

    Instance Method Details

    + + + +

    +
    + +

    Returns a new instance of TernaryOperatorExpressionAst.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +2384
    +2385
    +2386
    +2387
    +2388
    +2389
    +2390
    +
    +
    # File 'lib/idl/ast.rb', line 2384
    +
    +def initialize(input, interval, condition, true_expression, false_expression)
    +  super(input, interval, [condition, true_expression, false_expression])
    +
    +  @condition = condition
    +  @true_expression = true_expression
    +  @false_expression = false_expression
    +end
    +
    +
    + +
    +
    +

    Instance Attribute Details

    + +

    - #conditionObject + #conditionObject (readonly) -

    +
    +
    + +

    Returns the value of attribute condition.

    + + +
    +
    +
    + + +
     
     
    -2134
    -2135
    -2136
    +2382 +2383 +2384
    -
    # File 'lib/idl/ast.rb', line 2134
    +      
    # File 'lib/idl/ast.rb', line 2382
     
     def condition
    -  p9_binary_expression
    +  @condition
     end
    + +

    - #false_expressionObject + #false_expressionObject (readonly) -

    +
    +
    + +

    Returns the value of attribute false_expression.

    + + +
    +
    +
    + + +
     
     
    -2142
    -2143
    -2144
    +2382 +2383 +2384
    -
    # File 'lib/idl/ast.rb', line 2142
    +      
    # File 'lib/idl/ast.rb', line 2382
     
     def false_expression
    -  f
    +  @false_expression
     end
    + +
    -

    +

    - #to_idlString + #true_expressionObject (readonly) @@ -391,31 +570,13 @@

    -

    Return valid IDL representation of the node (and its subtree)

    +

    Returns the value of attribute true_expression.

    -

    Returns:

    -
      - -
    • - - - (String) - - - - — -
      -

      IDL code for the node

      -
      - -
    • - -
    @@ -423,21 +584,32 @@

     
     
    -2152
    +2382 +2383 +2384

    -
    # File 'lib/idl/ast.rb', line 2152
    +      
    # File 'lib/idl/ast.rb', line 2382
     
    -def to_idl = "#{condition.to_idl} ? #{true_expression.to_idl} : #{false_expression.to_idl}"
    +def true_expression + @true_expression +end
    -
    -

    +

    + + +
    +

    Instance Method Details

    + + +
    +

    - #true_expressionObject + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object @@ -449,19 +621,74 @@

     
     
    -2138
    -2139
    -2140
    +79 +80 +81

  • -
    # File 'lib/idl/ast.rb', line 2138
    +      
    # File 'lib/idl/passes/gen_adoc.rb', line 79
     
    -def true_expression
    -  t
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  "#{' ' * indent}#{condition.gen_adoc(0, indent_spaces:)} ? #{true_expression.gen_adoc(0, indent_spaces:)} : #{false_expression.gen_adoc(0, indent_spaces:)}"
     end
    + + +
    +

    + + #to_idlString + + + + + +

    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +2451
    +
    +
    # File 'lib/idl/ast.rb', line 2451
    +
    +def to_idl = "#{@condition.to_idl} ? #{@true_expression.to_idl} : #{@false_expression.to_idl}"
    +
    @@ -548,43 +775,43 @@

     
     
    -2115
    -2116
    -2117
    -2118
    -2119
    -2120
    -2121
    -2122
    -2123
    -2124
    -2125
    -2126
    -2127
    -2128
    -2129
    -2130
    -2131
    -2132
    +2419 +2420 +2421 +2422 +2423 +2424 +2425 +2426 +2427 +2428 +2429 +2430 +2431 +2432 +2433 +2434 +2435 +2436

    -
    # File 'lib/idl/ast.rb', line 2115
    +      
    # File 'lib/idl/ast.rb', line 2419
     
     def type(symtab)
    -  p9_binary_expression.type_check(symtab)
    +  @condition.type_check(symtab)
       begin
    -    cond = p9_binary_expression.value(symtab)
    +    cond = @condition.value(symtab)
         # if the condition is compile-time-known, only check the used field
         if (cond)
    -      t.type(symtab)
    +      @true_expression.type(symtab)
         else
    -      f.type(symtab)
    +      @false_expression.type(symtab)
         end
       rescue ValueError
    -    if t.type(symtab).kind == :bits && f.type(symtab).kind == :bits
    -      Type.new(:bits, width: [t.type(symtab).width, f.type(symtab).width].max)
    +    if @true_expression.type(symtab).kind == :bits && @false_expression.type(symtab).kind == :bits
    +      Type.new(:bits, width: [@true_expression.type(symtab).width, @false_expression.type(symtab).width].max)
         else
    -      t.type(symtab)
    +      @true_expression.type(symtab)
         end
       end
     end
    @@ -673,61 +900,57 @@

     
     
    -2087
    -2088
    -2089
    -2090
    -2091
    -2092
    -2093
    -2094
    -2095
    -2096
    -2097
    -2098
    -2099
    -2100
    -2101
    -2102
    -2103
    -2104
    -2105
    -2106
    -2107
    -2108
    -2109
    -2110
    -2111
    -2112
    +2393 +2394 +2395 +2396 +2397 +2398 +2399 +2400 +2401 +2402 +2403 +2404 +2405 +2406 +2407 +2408 +2409 +2410 +2411 +2412 +2413 +2414 +2415 +2416

    -
    # File 'lib/idl/ast.rb', line 2087
    +      
    # File 'lib/idl/ast.rb', line 2393
     
     def type_check(symtab)
    -  p9_binary_expression.type_check(symtab)
    +  @condition.type_check(symtab)
    +  type_error "ternary selector must be bool" unless @condition.type(symtab).kind == :boolean
    +
       begin
    -    cond = p9_binary_expression.value(symtab)
    +    cond = @condition.value(symtab)
         # if the condition is compile-time-known, only check the used field
         if (cond)
    -      t.type_check(symtab)
    +      @true_expression.type_check(symtab)
         else
    -      f.type_check(symtab)
    +      @false_expression.type_check(symtab)
         end
       rescue ValueError
    -    t.type_check(symtab)
    -    f.type_check(symtab)
    +    @true_expression.type_check(symtab)
    +    @false_expression.type_check(symtab)
     
    -    unless t.type(symtab).equal_to?(f.type(symtab))
    +    unless @true_expression.type(symtab).equal_to?(@false_expression.type(symtab))
           # we'll allow dissimilar if they are both bits type
    -      unless t.type(symtab).kind == :bits && f.type(symtab).kind == :bits
    -        type_error "True and false options must be same type (have #{t.type(symtab)} and #{f.type(symtab)})"
    +      unless @true_expression.type(symtab).kind == :bits && @false_expression.type(symtab).kind == :bits
    +        type_error "True and false options must be same type (have #{@true_expression.type(symtab)} and #{@false_expression.type(symtab)})"
           end
         end
       end
    -
    -  type_error "ternary selector must be bool" unless p9_binary_expression.type(symtab).kind == :boolean
    -
    -
     end
    -
    # File 'lib/idl/ast.rb', line 2147
    +      
    # File 'lib/idl/ast.rb', line 2439
     
     def value(symtab)
    -  condition.value(symtab) ? t.value(symtab) : f.value(symtab)
    +  @condition.value(symtab) ? @true_expression.value(symtab) : @false_expression.value(symtab)
    +end
    +
    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    + + + @@ -780,7 +1116,7 @@

    diff --git a/docs/ruby/Idl/TernaryOperatorExpressionSyntaxNode.html b/docs/ruby/Idl/TernaryOperatorExpressionSyntaxNode.html new file mode 100644 index 000000000..abfa1cf39 --- /dev/null +++ b/docs/ruby/Idl/TernaryOperatorExpressionSyntaxNode.html @@ -0,0 +1,194 @@ + + + + + + + Class: Idl::TernaryOperatorExpressionSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::TernaryOperatorExpressionSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    +
    +
    +
    +2444
    +2445
    +2446
    +2447
    +2448
    +
    +
    # File 'lib/idl/ast.rb', line 2444
    +
    +def values(symtab)
    +  @condition.value(symtab) ? @true_expression.values(symtab) : @false_expression.values(symtab)
    +rescue ValueError
    +  (@true_expression.values(symtab) + @false_expression.values(symtab)).uniq
     end
    + + + + +
    +
    +
    +
    +2369
    +2370
    +2371
    +
    +
    # File 'lib/idl/ast.rb', line 2369
    +
    +def to_ast
    +  TernaryOperatorExpressionAst.new(input, interval, p9_binary_expression.to_ast, t.to_ast, f.to_ast)
    +end
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/docs/ruby/Idl/Type.html b/docs/ruby/Idl/Type.html index b9d1c7f92..9a90007ac 100644 --- a/docs/ruby/Idl/Type.html +++ b/docs/ruby/Idl/Type.html @@ -112,7 +112,7 @@

    Overview

    @@ -569,6 +569,28 @@

    returns true if self can be converted to ‘type’ ‘type’ can be a Type object or a kind (as a Symbol).

    + + + +
  • + + + #default ⇒ Object + + + + + + + + + + + + + +
    +
  • @@ -878,17 +900,6 @@

     
     
    -51
    -52
    -53
    -54
    -55
    -56
    -57
    -58
    -59
    -60
    -61
     62
     63
     64
    @@ -923,10 +934,21 @@ 

    93 94 95 -96

    +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107

    -
    # File 'lib/idl/type.rb', line 51
    +      
    # File 'lib/idl/type.rb', line 62
     
     def initialize(kind, qualifiers: [], width: nil, sub_type: nil, name: nil, tuple_types: nil, return_type: nil, arguments: nil, enum_class: nil, csr: nil)
       raise "Invalid kind '#{kind}'" unless KINDS.include?(kind)
    @@ -1012,12 +1034,12 @@ 

     
     
    -30
    -31
    -32
    +41 +42 +43

    -
    # File 'lib/idl/type.rb', line 30
    +      
    # File 'lib/idl/type.rb', line 41
     
     def arguments
       @arguments
    @@ -1055,12 +1077,12 @@ 

     
     
    -30
    -31
    -32
    +41 +42 +43

    -
    # File 'lib/idl/type.rb', line 30
    +      
    # File 'lib/idl/type.rb', line 41
     
     def enum_class
       @enum_class
    @@ -1098,12 +1120,12 @@ 

     
     
    -30
    -31
    -32
    +41 +42 +43

    -
    # File 'lib/idl/type.rb', line 30
    +      
    # File 'lib/idl/type.rb', line 41
     
     def kind
       @kind
    @@ -1141,12 +1163,12 @@ 

     
     
    -30
    -31
    -32
    +41 +42 +43

    -
    # File 'lib/idl/type.rb', line 30
    +      
    # File 'lib/idl/type.rb', line 41
     
     def qualifiers
       @qualifiers
    @@ -1184,12 +1206,12 @@ 

     
     
    -30
    -31
    -32
    +41 +42 +43

    -
    # File 'lib/idl/type.rb', line 30
    +      
    # File 'lib/idl/type.rb', line 41
     
     def return_type
       @return_type
    @@ -1227,12 +1249,12 @@ 

     
     
    -30
    -31
    -32
    +41 +42 +43

    -
    # File 'lib/idl/type.rb', line 30
    +      
    # File 'lib/idl/type.rb', line 41
     
     def sub_type
       @sub_type
    @@ -1270,12 +1292,12 @@ 

     
     
    -30
    -31
    -32
    +41 +42 +43

    -
    # File 'lib/idl/type.rb', line 30
    +      
    # File 'lib/idl/type.rb', line 41
     
     def tuple_types
       @tuple_types
    @@ -1313,12 +1335,12 @@ 

     
     
    -30
    -31
    -32
    +41 +42 +43

    -
    # File 'lib/idl/type.rb', line 30
    +      
    # File 'lib/idl/type.rb', line 41
     
     def width
       @width
    @@ -1350,21 +1372,21 @@ 

     
     
    -38
    -39
    -40
    -41
    -42
    -43
    -44
    -45
    -46
    -47
    -48
    -49
    +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60

    -
    # File 'lib/idl/type.rb', line 38
    +      
    # File 'lib/idl/type.rb', line 49
     
     def self.from_typename(type_name, arch_def)
       case type_name
    @@ -1426,12 +1448,12 @@ 

     
     
    -315
    -316
    -317
    +326 +327 +328

    -
    # File 'lib/idl/type.rb', line 315
    +      
    # File 'lib/idl/type.rb', line 326
     
     def ary?
       @kind == :array
    @@ -1467,16 +1489,16 @@ 

     
     
    -167
    -168
    -169
    -170
    -171
    -172
    -173
    +178 +179 +180 +181 +182 +183 +184

    -
    # File 'lib/idl/type.rb', line 167
    +      
    # File 'lib/idl/type.rb', line 178
     
     def ary_type(ary)
       if ary.sub_type == :array
    @@ -1505,23 +1527,23 @@ 

     
     
    -98
    -99
    -100
    -101
    -102
    -103
    -104
    -105
    -106
    -107
    -108
     109
     110
    -111
    +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122

    -
    # File 'lib/idl/type.rb', line 98
    +      
    # File 'lib/idl/type.rb', line 109
     
     def clone
       Type.new(
    @@ -1581,17 +1603,6 @@ 

     
     
    -115
    -116
    -117
    -118
    -119
    -120
    -121
    -122
    -123
    -124
    -125
     126
     127
     128
    @@ -1608,10 +1619,21 @@ 

    139 140 141 -142

    +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153

    -
    # File 'lib/idl/type.rb', line 115
    +      
    # File 'lib/idl/type.rb', line 126
     
     def comparable_to?(type)
       if type.is_a?(Symbol)
    @@ -1683,12 +1705,12 @@ 

     
     
    -319
    -320
    -321
    +330 +331 +332

    -
    # File 'lib/idl/type.rb', line 319
    +      
    # File 'lib/idl/type.rb', line 330
     
     def const?
       @qualifiers.include?(:const)
    @@ -1737,17 +1759,6 @@ 

     
     
    -177
    -178
    -179
    -180
    -181
    -182
    -183
    -184
    -185
    -186
    -187
     188
     189
     190
    @@ -1793,10 +1804,21 @@ 

    230 231 232 -233

    +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244

    -
    # File 'lib/idl/type.rb', line 177
    +      
    # File 'lib/idl/type.rb', line 188
     
     def convertable_to?(type)
       if type.is_a?(Symbol)
    @@ -1858,6 +1880,50 @@ 

    + + +
    +

    + + #defaultObject + + + + + +

    + + + + +
    +
    +
    +
    +30
    +31
    +32
    +33
    +34
    +35
    +36
    +37
    +38
    +39
    +
    +
    # File 'lib/idl/type.rb', line 30
    +
    +def default
    +  case @kind
    +  when :bits, :enum_ref, :bitfield
    +    0
    +  when :boolean
    +    false
    +  else
    +    raise "No default for #{@kind}"
    +  end
    +end
    +
    @@ -1899,17 +1965,6 @@

     
     
    -145
    -146
    -147
    -148
    -149
    -150
    -151
    -152
    -153
    -154
    -155
     156
     157
     158
    @@ -1918,10 +1973,21 @@ 

    161 162 163 -164

    +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175

    -
    # File 'lib/idl/type.rb', line 145
    +      
    # File 'lib/idl/type.rb', line 156
     
     def equal_to?(type)
       if type.is_a?(Symbol)
    @@ -2017,13 +2083,13 @@ 

     
     
    -336
    -337
    -338
    -339
    +347 +348 +349 +350

    -
    # File 'lib/idl/type.rb', line 336
    +      
    # File 'lib/idl/type.rb', line 347
     
     def make_const
       @qualifiers.append(:const).uniq!
    @@ -2049,13 +2115,13 @@ 

     
     
    -331
    -332
    -333
    -334
    +342 +343 +344 +345

    -
    # File 'lib/idl/type.rb', line 331
    +      
    # File 'lib/idl/type.rb', line 342
     
     def make_signed
       @qualifiers.append(:signed).uniq!
    @@ -2103,12 +2169,12 @@ 

     
     
    -323
    -324
    -325
    +334 +335 +336

    -
    # File 'lib/idl/type.rb', line 323
    +      
    # File 'lib/idl/type.rb', line 334
     
     def mutable?
       return !const?
    @@ -2133,26 +2199,26 @@ 

     
     
    -297
    -298
    -299
    -300
    -301
    -302
    -303
    -304
    -305
    -306
    -307
     308
     309
     310
     311
     312
    -313
    +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324

    -
    # File 'lib/idl/type.rb', line 297
    +      
    # File 'lib/idl/type.rb', line 308
     
     def name
       if @kind == :bits
    @@ -2191,14 +2257,14 @@ 

     
     
    -32
    -33
    -34
    -35
    -36
    +43 +44 +45 +46 +47

    -
    # File 'lib/idl/type.rb', line 32
    +      
    # File 'lib/idl/type.rb', line 43
     
     def qualify(qualifier)
       @qualifiers << qualifier
    @@ -2247,12 +2313,12 @@ 

     
     
    -327
    -328
    -329
    +338 +339 +340

    -
    # File 'lib/idl/type.rb', line 327
    +      
    # File 'lib/idl/type.rb', line 338
     
     def signed?
       @qualifiers.include?(:signed)
    @@ -2277,13 +2343,13 @@ 

     
     
    -292
    -293
    -294
    -295
    +303 +304 +305 +306

    -
    # File 'lib/idl/type.rb', line 292
    +      
    # File 'lib/idl/type.rb', line 303
     
     def to_cxx
       ((@qualifiers.nil? || @qualifiers.empty?) ? '' : "#{@qualifiers.include?(:const) ? 'const' : ''} ") + \
    @@ -2309,17 +2375,6 @@ 

     
     
    -263
    -264
    -265
    -266
    -267
    -268
    -269
    -270
    -271
    -272
    -273
     274
     275
     276
    @@ -2336,10 +2391,21 @@ 

    287 288 289 -290

    +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301

    -
    # File 'lib/idl/type.rb', line 263
    +      
    # File 'lib/idl/type.rb', line 274
     
     def to_cxx_no_qualifiers
         if @kind == :bits
    @@ -2393,17 +2459,6 @@ 

     
     
    -235
    -236
    -237
    -238
    -239
    -240
    -241
    -242
    -243
    -244
    -245
     246
     247
     248
    @@ -2418,10 +2473,21 @@ 

    257 258 259 -260

    +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271

    -
    # File 'lib/idl/type.rb', line 235
    +      
    # File 'lib/idl/type.rb', line 246
     
     def to_s
       ((@qualifiers.nil? || @qualifiers.empty?) ? '' : "#{@qualifiers.map(&:to_s).join(' ')} ") + \
    @@ -2459,7 +2525,7 @@ 

    diff --git a/docs/ruby/Idl/UnaryOperatorExpressionAst.html b/docs/ruby/Idl/UnaryOperatorExpressionAst.html index 7fecbe0f7..0789ec85f 100644 --- a/docs/ruby/Idl/UnaryOperatorExpressionAst.html +++ b/docs/ruby/Idl/UnaryOperatorExpressionAst.html @@ -103,7 +103,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/gen_adoc.rb
    +
    @@ -162,6 +164,28 @@

    return the operated-on expression.

    + + + +
  • + + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + + + + + + + + + +
    +
  • @@ -282,6 +306,35 @@

    Return the compile-time-known value of the node.

    + + + +
  • + + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + included + from Rvalue + + + + + + + + + + +
    +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.

    +
    +
  • @@ -328,12 +381,12 @@

     
     
    -2065
    -2066
    -2067
    +2355 +2356 +2357

    -
    # File 'lib/idl/ast.rb', line 2065
    +      
    # File 'lib/idl/ast.rb', line 2355
     
     def exp
       e
    @@ -341,6 +394,36 @@ 

    +
    + +
    +

    + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +152
    +153
    +154
    +
    +
    # File 'lib/idl/passes/gen_adoc.rb', line 152
    +
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  "#{op}#{exp.gen_adoc(0, indent_spaces:)}"
    +end
    +
    @@ -387,12 +470,12 @@

     
     
    -2070
    -2071
    -2072
    +2360 +2361 +2362

    -
    # File 'lib/idl/ast.rb', line 2070
    +      
    # File 'lib/idl/ast.rb', line 2360
     
     def op
       o.text_value
    @@ -446,10 +529,10 @@ 

     
     
    -2075
    +2365

    -
    # File 'lib/idl/ast.rb', line 2075
    +      
    # File 'lib/idl/ast.rb', line 2365
     
     def to_idl = "#{op}#{e.to_idl}"
    -
    # File 'lib/idl/ast.rb', line 2013
    +      
    # File 'lib/idl/ast.rb', line 2302
     
     def type(symtab)
       case op
    @@ -650,31 +733,31 @@ 

     
     
    -2025
    -2026
    -2027
    -2028
    -2029
    -2030
    -2031
    -2032
    -2033
    -2034
    -2035
    -2036
    -2037
    -2038
    -2039
    -2040
    -2041
    -2042
    -2043
    -2044
    -2045
    -2046
    +2314 +2315 +2316 +2317 +2318 +2319 +2320 +2321 +2322 +2323 +2324 +2325 +2326 +2327 +2328 +2329 +2330 +2331 +2332 +2333 +2334 +2335

    -
    # File 'lib/idl/ast.rb', line 2025
    +      
    # File 'lib/idl/ast.rb', line 2314
     
     def type_check(symtab)
       exp.type_check(symtab)
    @@ -685,8 +768,8 @@ 

    type_error "#{exp.type(symtab)} does not support unary #{op} operator" end - type_error "Unary minus only works on signed values" unless exp.type(symtab).signed? - when "~" + # type_error "Unary minus only works on signed values" unless exp.type(symtab).signed? + when "~" unless [:bits, :bitfield].include?(exp.type(symtab).kind) type_error "#{exp.type(symtab)} does not support unary #{op} operator" end @@ -729,41 +812,139 @@

     
     
    -2049
    -2050
    -2051
    -2052
    -2053
    -2054
    -2055
    -2056
    -2057
    -2058
    -2059
    -2060
    -2061
    -2062
    +2338 +2339 +2340 +2341 +2342 +2343 +2344 +2345 +2346 +2347 +2348 +2349 +2350 +2351 +2352

    -
    # File 'lib/idl/ast.rb', line 2049
    +      
    # File 'lib/idl/ast.rb', line 2338
     
     def value(symtab)
    -  val = eval("#{op}#{exp.value(symtab)}", binding, __FILE__, __LINE__)
    -  if type(symtab).integral? && type(symtab).width > val.bit_length
    -    # need to truncate
    -    val &= ((1 << type(symtab).width) - 1)
    -    if type(symtab).signed? && ((((val >> (type(symtab).width - 1))) & 1) == 1)
    +  val = val_trunc = eval("#{op}#{exp.value(symtab)}", binding, __FILE__, __LINE__)
    +  if type(symtab).integral?
    +    val_trunc = val & ((1 << type(symtab).width) - 1)
    +    if type(symtab).signed? && ((((val_trunc >> (type(symtab).width - 1))) & 1) == 1)
           # need to make this negative!
           # take the twos compliment
    -      val = -((1 << type(symtab).width) - val)
    +      val_trunc = -((1 << type(symtab).width) - val_trunc)
         end
       end
     
    -  val
    +  warn "#{text_value} is truncated due to insufficient bit width (from #{val} to #{val_trunc})" if val_trunc != val
    +
    +  val_trunc
     end
    + + +
    +

    + + #values(symtab) ⇒ Array<Integer>, ... + + + + + + + Originally defined in module + Rvalue + + +

    +
    + +

    Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined

    + +

    For most AstNodes, this will just be a single-entry array

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The context for the evaulation

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Integer>) + + + + — +
      +

      The complete list of compile-time-known values, when they are integral

      +
      + +
    • + +
    • + + + (Array<Boolean>) + + + + — +
      +

      The complete list of compile-time-known values, when they are booleans

      +
      + +
    • + +
    • + + + (AstNode::ValueError) + + + + — +
      +

      if the list of values is not knowable at compile time

      +
      + +
    • + +
    + +
    @@ -771,7 +952,7 @@

    diff --git a/docs/ruby/Idl/UserTypeNameAst.html b/docs/ruby/Idl/UserTypeNameAst.html index 1503f2d68..8db4ba01b 100644 --- a/docs/ruby/Idl/UserTypeNameAst.html +++ b/docs/ruby/Idl/UserTypeNameAst.html @@ -265,10 +265,10 @@

     
     
    -2704
    +3225

    -
    # File 'lib/idl/ast.rb', line 2704
    +      
    # File 'lib/idl/ast.rb', line 3225
     
     def to_idl = text_value
    @@ -291,12 +291,12 @@

     
     
    -2699
    -2700
    -2701
    +3220 +3221 +3222

    -
    # File 'lib/idl/ast.rb', line 2699
    +      
    # File 'lib/idl/ast.rb', line 3220
     
     def type(symtab)
       symtab.get(text_value)
    @@ -386,14 +386,14 @@ 

     
     
    -2692
    -2693
    -2694
    -2695
    -2696
    +3213 +3214 +3215 +3216 +3217

    -
    # File 'lib/idl/ast.rb', line 2692
    +      
    # File 'lib/idl/ast.rb', line 3213
     
     def type_check(symtab)
       type = symtab.get(text_value)
    @@ -410,7 +410,7 @@ 

    diff --git a/docs/ruby/Idl/Var.html b/docs/ruby/Idl/Var.html index 6bcbe39d4..0a97d558a 100644 --- a/docs/ruby/Idl/Var.html +++ b/docs/ruby/Idl/Var.html @@ -284,7 +284,7 @@

  • - #initialize(name, type, value = nil, decode_var: false) ⇒ Var + #initialize(name, type, value = nil, decode_var: false, template_index: nil, function_name: nil) ⇒ Var @@ -304,6 +304,76 @@

    A new instance of Var.

    +

  • + + +
  • + + + #template_index ⇒ Integer + + + + + + + + + + + + + +
    +

    The template value position.

    +
    + +
  • + + +
  • + + + #template_val? ⇒ Boolean + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + #template_value_for?(function_name) ⇒ Boolean + + + + + + + + + + + + + +
    +

    Whether or not this variable is a function template argument from a call site for the function ‘function_name’.

    +
    +
  • @@ -338,7 +408,7 @@

    Constructor Details

    - #initialize(name, type, value = nil, decode_var: false) ⇒ Var + #initialize(name, type, value = nil, decode_var: false, template_index: nil, function_name: nil) ⇒ Var @@ -354,6 +424,19 @@

    +

    Raises:

    +
      + +
    • + + + (ArgumentError) + + + +
    • + +
    @@ -370,20 +453,24 @@

    16 17 18 -19 +19 +20 +21

    @@ -546,17 +633,17 @@

     
     
    -21
    -22
     23
     24
     25
     26
     27
    -28
    +28 +29 +30

    # File 'lib/idl/symbol_table.rb', line 10
     
    -def initialize(name, type, value = nil, decode_var: false)
    +def initialize(name, type, value = nil, decode_var: false, template_index: nil, function_name: nil)
       @name = name
    -  raise 'unexpected' unless type.is_a?(Type)
    +  raise ArgumentError, "Expecting a Type, got #{type.class.name}" unless type.is_a?(Type)
     
       @type = type
       @value = value
       raise 'unexpected' unless decode_var.is_a?(TrueClass) || decode_var.is_a?(FalseClass)
     
       @decode_var = decode_var
    +  @template_index = template_index
    +  @function_name = function_name
     end
    -
    # File 'lib/idl/symbol_table.rb', line 21
    +      
    # File 'lib/idl/symbol_table.rb', line 23
     
     def clone
       Var.new(
    @@ -608,12 +695,12 @@ 

     
     
    -30
    -31
    -32
    +32 +33 +34

    -
    # File 'lib/idl/symbol_table.rb', line 30
    +      
    # File 'lib/idl/symbol_table.rb', line 32
     
     def const?
       @type.const?
    @@ -660,12 +747,12 @@ 

     
     
    -34
    -35
    -36
    +36 +37 +38

    -
    # File 'lib/idl/symbol_table.rb', line 34
    +      
    # File 'lib/idl/symbol_table.rb', line 36
     
     def decode_var?
       @decode_var
    @@ -673,6 +760,218 @@ 

    + + +
    +

    + + #template_indexInteger + + + + + +

    +
    + +

    Returns the template value position.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      the template value position

      +
      + +
    • + +
    +

    Raises:

    +
      + +
    • + + + + + + + +
      +

      if Var is not a template value

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +48
    +49
    +50
    +51
    +52
    +
    +
    # File 'lib/idl/symbol_table.rb', line 48
    +
    +def template_index
    +  raise "Not a template value" if @template_index.nil?
    +
    +  @template_index
    +end
    +
    +
    + +
    +

    + + #template_val?Boolean + + + + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +54
    +55
    +56
    +
    +
    # File 'lib/idl/symbol_table.rb', line 54
    +
    +def template_val?
    +  !@template_index.nil?
    +end
    +
    +
    + +
    +

    + + #template_value_for?(function_name) ⇒ Boolean + + + + + +

    +
    + +

    Returns whether or not this variable is a function template argument from a call site for the function ‘function_name’.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + function_name + + + (#to_s) + + + + — +
      +

      A function name

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      whether or not this variable is a function template argument from a call site for the function ‘function_name’

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +42
    +43
    +44
    +
    +
    # File 'lib/idl/symbol_table.rb', line 42
    +
    +def template_value_for?(function_name)
    +  !@template_index.nil? && (function_name.to_s == @function_name)
    +end
    +
    @@ -690,12 +989,12 @@

     
     
    -38
    -39
    -40
    +58 +59 +60

    -
    # File 'lib/idl/symbol_table.rb', line 38
    +      
    # File 'lib/idl/symbol_table.rb', line 58
     
     def to_cxx
       @name
    @@ -710,7 +1009,7 @@ 

    diff --git a/docs/ruby/Idl/VarReadExpressionAst.html b/docs/ruby/Idl/VarReadExpressionAst.html deleted file mode 100644 index a467df070..000000000 --- a/docs/ruby/Idl/VarReadExpressionAst.html +++ /dev/null @@ -1,455 +0,0 @@ - - - - - - - Module: Idl::VarReadExpressionAst - - — Documentation by YARD 0.9.36 - - - - - - - - - - - - - - - - - - - -
    - - -

    Module: Idl::VarReadExpressionAst - - - -

    -
    - - - - - - -
    -
    Includes:
    -
    Rvalue
    -
    - - - - - - -
    -
    Defined in:
    -
    lib/idl/ast.rb
    -
    - -
    - - - - - - - - - -

    - Instance Method Summary - collapse -

    - - - - - - - - -
    -

    Instance Method Details

    - - -
    -

    - - #to_idlString - - - - - -

    -
    - -

    Return valid IDL representation of the node (and its subtree)

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (String) - - - - — -
      -

      IDL code for the node

      -
      - -
    • - -
    - -
    - - - - -
    -
    -
    -
    -2186
    -
    -
    # File 'lib/idl/ast.rb', line 2186
    -
    -def to_idl = text_value
    -
    -
    - -
    -

    - - #type(symtab) ⇒ Object - - - - - -

    - - - - -
    -
    -
    -
    -2168
    -2169
    -2170
    -2171
    -2172
    -
    -
    # File 'lib/idl/ast.rb', line 2168
    -
    -def type(symtab)
    -  internal_error "While checking VarRead type, no symbol '#{text_value}' found" if symtab.get(text_value).nil?
    -
    -  symtab.get(text_value).type
    -end
    -
    -
    - -
    -

    - - #type_check(symtab) ⇒ void - - - - - -

    -
    -

    This method returns an undefined value.

    -

    type check this node and all children

    - -

    Calls to #type and/or #value may depend on type_check being called first with the same symtab. If not, those functions may raise an AstNode::InternalError

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - symtab - - - (SymbolTable) - - - - — -
      -

      Symbol table for lookup

      -
      - -
    • - -
    - -

    Raises:

    - - -
    - - - - -
    -
    -
    -
    -2159
    -2160
    -2161
    -2162
    -2163
    -2164
    -2165
    -
    -
    # File 'lib/idl/ast.rb', line 2159
    -
    -def type_check(symtab)
    -  var = symtab.get(text_value)
    -
    -  type_error "No symbol named '#{text_value}'" if var.nil?
    -
    -  type_error "'#{text_value}' is not a variable" unless var.is_a?(Var)
    -end
    -
    -
    - -
    -

    - - #value(symtab) ⇒ Object - - - - - -

    - - - - -
    -
    -
    -
    -2175
    -2176
    -2177
    -2178
    -2179
    -2180
    -2181
    -2182
    -2183
    -
    -
    # File 'lib/idl/ast.rb', line 2175
    -
    -def value(symtab)
    -  var = symtab.get(text_value)
    -
    -  internal_error "Call type_check first" if var.nil?
    -
    -  value_error "The value of '#{text_value}' is not known" if var.value.nil?
    -  
    -  var.value
    -end
    -
    -
    - -
    - -
    - - - -
    - - \ No newline at end of file diff --git a/docs/ruby/Idl/VariableAssignmentAst.html b/docs/ruby/Idl/VariableAssignmentAst.html index 6124d35d7..ca3a3902f 100644 --- a/docs/ruby/Idl/VariableAssignmentAst.html +++ b/docs/ruby/Idl/VariableAssignmentAst.html @@ -69,7 +69,7 @@
    Inherits:
    - AssignmentAst + AstNode @@ -100,7 +98,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/gen_adoc.rb
    +
    @@ -126,6 +126,69 @@

    Overview

    +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #lhs ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute lhs.

      +
      + +
    • + + +
    • + + + #rhs ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute rhs.

      +
      + +
    • + + +
    + @@ -162,7 +225,7 @@

  • - #lhs ⇒ Object + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object @@ -184,13 +247,15 @@

  • - #rhs ⇒ Object + #initialize(input, interval, lhs_ast, rhs_ast) ⇒ VariableAssignmentAst + constructor + @@ -198,7 +263,9 @@

    -
    +
    +

    A new instance of VariableAssignmentAst.

    +

  • @@ -260,58 +327,156 @@

    +
    +

    Constructor Details

    +
    +

    + #initialize(input, interval, lhs_ast, rhs_ast) ⇒ VariableAssignmentAst + + +

    +
    + +

    Returns a new instance of VariableAssignmentAst.

    + + +
    +
    +
    + + +
    + + + + +
    +
     
    -  
    -

    Instance Method Details

    +986 +987 +988 +989 +990
    +
    +
    # File 'lib/idl/ast.rb', line 986
    +
    +def initialize(input, interval, lhs_ast, rhs_ast)
    +  super(input, interval, [lhs_ast, rhs_ast])
    +  @lhs = lhs_ast
    +  @rhs = rhs_ast
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + +
    -

    +

    - #execute(symtab) ⇒ Object + #lhsObject (readonly) -

    +
    +
    + +

    Returns the value of attribute lhs.

    + + +
    +
    +
    + + +
    + +
     
     
    -944
    -945
    -946
    -947
    -948
    -949
    -950
    +984 +985 +986
    -
    # File 'lib/idl/ast.rb', line 944
    +      
    # File 'lib/idl/ast.rb', line 984
     
    -def execute(symtab)
    -  var = symtab.get(var.text_value)
    +def lhs
    +  @lhs
    +end
    +
    +
    + + + +
    +

    + + #rhsObject (readonly) + - internal_error "Call type check first" if var.nil? + - var.value = rval.value(symtab) + +

    +
    + +

    Returns the value of attribute rhs.

    + + +
    +
    +
    + + +
    + + +
    +
    +
    +
    +984
    +985
    +986
    +
    +
    # File 'lib/idl/ast.rb', line 984
    +
    +def rhs
    +  @rhs
     end
    -
    -

    +

    + + +
    +

    Instance Method Details

    + + +
    +

    - #lhsObject + #execute(symtab) ⇒ Object @@ -323,15 +488,31 @@

     
     
    -936
    -937
    -938
    +1001 +1002 +1003 +1004 +1005 +1006 +1007 +1008 +1009 +1010 +1011

  • -
    # File 'lib/idl/ast.rb', line 936
    +      
    # File 'lib/idl/ast.rb', line 1001
     
    -def lhs
    -  var
    +def execute(symtab)
    +  if @lhs.is_a?(CsrWriteAst)
    +    value_error "CSR writes are never compile-time-known"
    +  else
    +    variable = symtab.get(@lhs.text_value)
    +
    +    internal_error "No variable #{@lhs.text_value}" if variable.nil?
    +
    +    variable.value = @rhs.value(symtab)
    +  end
     end
    @@ -339,9 +520,9 @@

    -

    +

    - #rhsObject + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object @@ -353,15 +534,15 @@

     
     
    -940
    -941
    -942
    +134 +135 +136

    -
    # File 'lib/idl/ast.rb', line 940
    +      
    # File 'lib/idl/passes/gen_adoc.rb', line 134
     
    -def rhs
    -  rval
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  "#{lhs.gen_adoc(0, indent_spaces:)} = #{rhs.gen_adoc(0, indent_spaces:)}"
     end
    @@ -412,12 +593,12 @@

     
     
    -953
    +1014

    -
    # File 'lib/idl/ast.rb', line 953
    +      
    # File 'lib/idl/ast.rb', line 1014
     
    -def to_idl = "#{var.to_idl} = #{rval.to_idl}"
    +def to_idl = "#{@lhs.to_idl} = #{@rhs.to_idl}"
    @@ -503,22 +684,22 @@

     
     
    -928
    -929
    -930
    -931
    -932
    -933
    -934
    +993 +994 +995 +996 +997 +998 +999

    -
    # File 'lib/idl/ast.rb', line 928
    +      
    # File 'lib/idl/ast.rb', line 993
     
     def type_check(symtab)
    -  var.type_check(symtab)
    -  rval.type_check(symtab)
    -  unless rval.type(symtab).convertable_to?(var.type(symtab))
    -    type_error "Incompatible type in assignment (#{var.type(symtab)}, #{rval.type(symtab)}) on line #{lineno}"
    +  @lhs.type_check(symtab)
    +  @rhs.type_check(symtab)
    +  unless @rhs.type(symtab).convertable_to?(@lhs.type(symtab))
    +    type_error "Incompatible type in assignment (#{@lhs.type(symtab)}, #{@rhs.type(symtab)})"
       end
     end
    @@ -531,7 +712,7 @@

    diff --git a/docs/ruby/Idl/VariableAssignmentSyntaxNode.html b/docs/ruby/Idl/VariableAssignmentSyntaxNode.html new file mode 100644 index 000000000..4d5211a4e --- /dev/null +++ b/docs/ruby/Idl/VariableAssignmentSyntaxNode.html @@ -0,0 +1,194 @@ + + + + + + + Class: Idl::VariableAssignmentSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::VariableAssignmentSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

    + + + + +
    +
    +
    +
    +973
    +974
    +975
    +
    +
    # File 'lib/idl/ast.rb', line 973
    +
    +def to_ast
    +  VariableAssignmentAst.new(input, interval, var.to_ast, rval.to_ast)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Idl/VariableDeclarationAst.html b/docs/ruby/Idl/VariableDeclarationAst.html index fb9e56c55..7eb66a2f8 100644 --- a/docs/ruby/Idl/VariableDeclarationAst.html +++ b/docs/ruby/Idl/VariableDeclarationAst.html @@ -93,7 +93,7 @@
    Includes:
    -
    Executable
    +
    Declaration
    @@ -103,7 +103,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/gen_adoc.rb
    +
    @@ -143,6 +145,30 @@

  • + #add_symbol(symtab) ⇒ Object + + + + + + + + + + + + + +
    +

    Add symbol(s) at the outermost scope of the symbol table.

    +
    + +
  • + + +
  • + + #decl_type(symtab) ⇒ Object @@ -165,7 +191,7 @@

  • - #execute(symtab) ⇒ Object + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object @@ -250,7 +276,68 @@

    Instance Method Details

    -

    +

    + + #add_symbol(symtab) ⇒ Object + + + + + +

    +
    + +

    Add symbol(s) at the outermost scope of the symbol table

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      Symbol table at the scope that the symbol(s) will be inserted

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +1412
    +1413
    +1414
    +
    +
    # File 'lib/idl/ast.rb', line 1412
    +
    +def add_symbol(symtab)
    +  symtab.add(var_write.text_value, Var.new(var_write.text_value, decl_type(symtab), decl_type(symtab).default))
    +end
    +
    +
    + +
    +

    #decl_type(symtab) ⇒ Object @@ -264,36 +351,50 @@

     
     
    -1295
    -1296
    -1297
    -1298
    -1299
    -1300
    -1301
    -1302
    -1303
    -1304
    -1305
    -1306
    -1307
    -1308
    -1309
    +1365 +1366 +1367 +1368 +1369 +1370 +1371 +1372 +1373 +1374 +1375 +1376 +1377 +1378 +1379 +1380 +1381 +1382 +1383 +1384 +1385 +1386

  • -
    # File 'lib/idl/ast.rb', line 1295
    +      
    # File 'lib/idl/ast.rb', line 1365
     
     def decl_type(symtab)
       dtype = type_name.type(symtab)
     
       return nil if dtype.nil?
     
    -  dtype = Type.new(:enum_ref, enum_class: dtype) if dtype.kind == :enum
    +  qualifiers =
    +    if var_write.text_value[0].upcase == var_write.text_value[0]
    +      [:const]
    +    else
    +      []
    +    end
    +
    +  dtype = Type.new(:enum_ref, enum_class: dtype, qualifiers:) if dtype.kind == :enum
     
       dtype = dtype.clone.qualify(q.text_value.to_sym) unless q.empty?
     
       unless ary_size.empty?
    -    dtype = Type.new(:array, width: ary_size.expression.value(symtab), sub_type: dtype.clone)
    +    dtype = Type.new(:array, width: ary_size.expression.value(symtab), sub_type: dtype.clone, qualifiers:)
       end
     
       dtype
    @@ -304,9 +405,9 @@ 

    -

    +

    - #execute(symtab) ⇒ Object + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object @@ -318,17 +419,15 @@

     
     
    -1334
    -1335
    -1336
    -1337
    +73 +74 +75

    -
    # File 'lib/idl/ast.rb', line 1334
    +      
    # File 'lib/idl/passes/gen_adoc.rb', line 73
     
    -def execute(symtab)
    -  value_error "TODO: array declration execution" unless ary_size.empty?
    -  symtab.add(var_write.text_value, Var.new(var_write.text_value, decl_type(symtab)))
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  "#{' ' * indent}#{type_name.gen_adoc(0, indent_spaces:)} #{var_write.gen_adoc(0, indent_spaces:)};"
     end
    @@ -379,22 +478,22 @@

     
     
    -1340
    -1341
    -1342
    -1343
    -1344
    -1345
    -1346
    +1417 +1418 +1419 +1420 +1421 +1422 +1423

    -
    # File 'lib/idl/ast.rb', line 1340
    +      
    # File 'lib/idl/ast.rb', line 1417
     
     def to_idl
       if ary_size.empty?
    -    "#{type.to_idl} #{var_write.to_idl}"
    +    "#{type_name.to_idl} #{var_write.to_idl}"
       else
    -    "#{type.to_idl} #{var_write.to_idl}[#{ary_size.expression.to_idl}]"
    +    "#{type_name.to_idl} #{var_write.to_idl}[#{ary_size.expression.to_idl}]"
       end
     end
    @@ -482,30 +581,30 @@

     
     
    -1312
    -1313
    -1314
    -1315
    -1316
    -1317
    -1318
    -1319
    -1320
    -1321
    -1322
    -1323
    -1324
    -1325
    -1326
    -1327
    -1328
    -1329
    -1330
    -1331
    -1332
    +1389 +1390 +1391 +1392 +1393 +1394 +1395 +1396 +1397 +1398 +1399 +1400 +1401 +1402 +1403 +1404 +1405 +1406 +1407 +1408 +1409

    -
    # File 'lib/idl/ast.rb', line 1312
    +      
    # File 'lib/idl/ast.rb', line 1389
     
     def type_check(symtab)
       type_name.type_check(symtab)
    @@ -518,13 +617,13 @@ 

    unless ary_size.empty? ary_size.expression.type_check(symtab) begin - ary_size_value = ary_size.expression.value(symtab) + ary_size.expression.value(symtab) rescue ValueError type_error "Array size must be known at compile time" end end - symtab.add(var_write.text_value, Var.new(var_write.text_value, decl_type(symtab))) + add_symbol(symtab) var_write.type_check(symtab) end

    @@ -538,7 +637,7 @@

    diff --git a/docs/ruby/Idl/VariableDeclarationWithInitializationAst.html b/docs/ruby/Idl/VariableDeclarationWithInitializationAst.html index e104fd190..d4771d047 100644 --- a/docs/ruby/Idl/VariableDeclarationWithInitializationAst.html +++ b/docs/ruby/Idl/VariableDeclarationWithInitializationAst.html @@ -69,7 +69,7 @@
    Inherits:
    - AssignmentAst + AstNode @@ -95,7 +93,7 @@
    Includes:
    -
    Executable
    +
    Declaration, Executable
    @@ -105,7 +103,9 @@
    Defined in:
    -
    lib/idl/ast.rb
    +
    lib/idl/ast.rb,
    + lib/idl/passes/gen_adoc.rb
    +
    @@ -131,6 +131,98 @@

    Overview

    +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #lhs ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute lhs.

      +
      + +
    • + + +
    • + + + #rhs ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute rhs.

      +
      + +
    • + + +
    • + + + #type_name ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute type_name.

      +
      + +
    • + + +
    + @@ -145,7 +237,7 @@

  • - #execute(symtab) ⇒ Object + #add_symbol(symtab) ⇒ Object @@ -159,7 +251,9 @@

    -
    +
    +

    Add symbol(s) at the outermost scope of the symbol table.

    +

  • @@ -167,7 +261,31 @@

  • - #lhs ⇒ Object + #execute(symtab) ⇒ void + + + + + + + + + + + + + +
    +

    “execute” the statement by updating the variables in the symbol table.

    +
    + +
  • + + +
  • + + + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object @@ -183,6 +301,32 @@

    +

  • + + +
  • + + + #initialize(input, interval, type_name_ast, var_write_ast, ary_size, rval_ast) ⇒ VariableDeclarationWithInitializationAst + + + + + + + constructor + + + + + + + + +
    +

    A new instance of VariableDeclarationWithInitializationAst.

    +
    +
  • @@ -211,7 +355,7 @@

  • - #rhs ⇒ Object + #to_idl ⇒ String @@ -225,7 +369,9 @@

    -
    +
    +

    Return valid IDL representation of the node (and its subtree).

    +

  • @@ -233,7 +379,7 @@

  • - #type_check(symtab) ⇒ Object + #type_check(symtab) ⇒ void @@ -247,7 +393,9 @@

    -
    +
    +

    type check this node and all children.

    +

  • @@ -265,37 +413,346 @@

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(input, interval, type_name_ast, var_write_ast, ary_size, rval_ast) ⇒ VariableDeclarationWithInitializationAst + + + + + +

    +
    + +

    Returns a new instance of VariableDeclarationWithInitializationAst.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +1447
    +1448
    +1449
    +1450
    +1451
    +1452
    +1453
    +1454
    +1455
    +1456
    +1457
    +
    +
    # File 'lib/idl/ast.rb', line 1447
    +
    +def initialize(input, interval, type_name_ast, var_write_ast, ary_size, rval_ast)
    +  if ary_size.nil?
    +    super(input, interval, [type_name_ast, var_write_ast, rval_ast])
    +  else
    +    super(input, interval, [type_name_ast, var_write_ast, ary_size, rval_ast])
    +  end
    +  @type_name = type_name_ast
    +  @lhs = var_write_ast
    +  @ary_size = ary_size
    +  @rhs = rval_ast
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #lhsObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute lhs.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +1445
    +1446
    +1447
    +
    +
    # File 'lib/idl/ast.rb', line 1445
    +
    +def lhs
    +  @lhs
    +end
    +
    +
    + + + +
    +

    + + #rhsObject (readonly) + + + + +

    +
    + +

    Returns the value of attribute rhs.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +1445
    +1446
    +1447
    +
    +
    # File 'lib/idl/ast.rb', line 1445
    +
    +def rhs
    +  @rhs
    +end
    +
    +
    + + + +
    +

    + + #type_nameObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute type_name.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +1445
    +1446
    +1447
    +
    +
    # File 'lib/idl/ast.rb', line 1445
    +
    +def type_name
    +  @type_name
    +end
    +
    +
    + +
    +

    Instance Method Details

    -

    +

    - #execute(symtab) ⇒ Object + #add_symbol(symtab) ⇒ Object -

    +
    +
    + +

    Add symbol(s) at the outermost scope of the symbol table

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      Symbol table at the scope that the symbol(s) will be inserted

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +1516
    +1517
    +1518
    +1519
    +1520
    +
    +
    # File 'lib/idl/ast.rb', line 1516
    +
    +def add_symbol(symtab)
    +  symtab.add(lhs.text_value, Var.new(lhs.text_value, lhs_type(symtab), rhs.value(symtab)))
    +rescue ValueError
    +  symtab.add(lhs.text_value, Var.new(lhs.text_value, lhs_type(symtab)))
    +end
    +
    +
    + +
    +

    + + #execute(symtab) ⇒ void + + + + + +

    +
    +

    This method returns an undefined value.

    +

    “execute” the statement by updating the variables in the symbol table

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      The symbol table for the context

      +
      + +
    • + +
    + +

    Raises:

    +
      + +
    • + + + + + + + +
      +

      ValueError if some part of the statement cannot be executed at compile time

      +
      + +
    • + +
    + +
    @@ -304,9 +761,9 @@

    -

    +

    - #lhsObject + #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object @@ -318,15 +775,23 @@

     
     
    -1405
    -1406
    -1407
    +112 +113 +114 +115 +116 +117 +118

    @@ -348,19 +813,34 @@

     
     
    -1357
    -1358
    -1359
    -1360
    -1361
    -1362
    -1363
    -1364
    -1365
    -1366
    +1459 +1460 +1461 +1462 +1463 +1464 +1465 +1466 +1467 +1468 +1469 +1470 +1471 +1472 +1473 +1474 +1475 +1476 +1477 +1478 +1479 +1480 +1481 +1482 +1483

     
     
    -1420
    -1421
    -1422
    -1423
    +1523 +1524 +1525 +1526
    -
    # File 'lib/idl/ast.rb', line 1420
    +      
    # File 'lib/idl/ast.rb', line 1523
     
     def execute(symtab)
    -  value_error "TODO: Array declaration" unless ary_size.empty?
    +  value_error "TODO: Array declaration" unless @ary_size.nil?
       symtab.add(lhs.text_value, Var.new(lhs.text_value, lhs_type(symtab), rhs.value(symtab)))
     end
    -
    # File 'lib/idl/ast.rb', line 1405
    +      
    # File 'lib/idl/passes/gen_adoc.rb', line 112
     
    -def lhs
    -  var_write
    +def gen_adoc(indent = 0, indent_spaces: 2)
    +  if @ary_size.nil?
    +    "#{' ' * indent}#{type_name.gen_adoc(0, indent_spaces:)} #{lhs.gen_adoc(0, indent_spaces:)} = #{rhs.gen_adoc(0, indent_spaces:)};"
    +  else
    +    "#{' ' * indent}#{type_name.gen_adoc(0, indent_spaces:)} #{lhs.gen_adoc(0, indent_spaces:)}[#{@ary_size.gen_adoc(0, indent_spaces:)}] = #{rhs.gen_adoc(0, indent_spaces:)};"
    +  end
     end
    -
    # File 'lib/idl/ast.rb', line 1357
    +      
    # File 'lib/idl/ast.rb', line 1459
     
     def lhs_type(symtab)
       decl_type = type_name.type(symtab).clone
    @@ -368,7 +848,22 @@ 

    decl_type = Type.new(:enum_ref, enum_class: decl_type) if decl_type.kind == :enum - decl_type = decl_type.clone.qualify(q.text_value.to_sym) unless q.empty? + # decl_type = decl_type.clone.qualify(q.text_value.to_sym) unless q.empty? + + if @lhs.text_value[0].upcase == @lhs.text_value[0] + decl_type.make_const + end + + unless @ary_size.nil? + begin + decl_type = Type.new(:array, sub_type: decl_type, width: @ary_size.value(symtab)) + rescue ValueError + type_error "Array size must be known at compile time" + end + if @lhs.text_value[0].upcase == @lhs.text_value[0] + decl_type.make_const + end + end decl_type end

    @@ -378,43 +873,66 @@

    -

    +

    - #rhsObject + #to_idlString -

    +
    +
    + +

    Return valid IDL representation of the node (and its subtree)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      IDL code for the node

      +
      + +
    • + +
    + +
    @@ -424,93 +942,142 @@

    - #type_check(symtab) ⇒ Object + #type_check(symtab) ⇒ void -

     
     
    -1409
    -1410
    -1411
    -1412
    -1413
    -1414
    -1415
    -1416
    -1417
    -1418
    +1529 +1530 +1531 +1532 +1533 +1534 +1535
    -
    # File 'lib/idl/ast.rb', line 1409
    +      
    # File 'lib/idl/ast.rb', line 1529
     
    -def rhs
    -  # if rhs is nil, this is the non-initializing variant
    -  return nil unless respond_to?(:rval)
    -
    -  return rval if rval.is_a?(Rvalue)
    -
    -  internal_error "unexpected #{rval.inspect}" unless rval.is_a?(MemoryRValAst)
    -
    -  rval
    +def to_idl
    +  if @ary_size.nil?
    +    "#{type_name.to_idl} #{lhs.to_idl} = #{rhs.to_idl}"
    +  else
    +    "#{type_name.to_idl} #{lhs.to_idl}[#{@ary_size.to_idl}] = #{rhs.to_idl}"
    +  end
     end
    +
    +
    +

    This method returns an undefined value.

    +

    type check this node and all children

    + +

    Calls to #type and/or #value may depend on type_check being called first with the same symtab. If not, those functions may raise an AstNode::InternalError

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + symtab + + + (SymbolTable) + + + + — +
      +

      Symbol table for lookup

      +
      + +
    • + +
    + +

    Raises:

    + + +
    @@ -522,7 +1089,7 @@

    diff --git a/docs/ruby/Idl/VariableDeclarationWithInitializationSyntaxNode.html b/docs/ruby/Idl/VariableDeclarationWithInitializationSyntaxNode.html new file mode 100644 index 000000000..3554d92be --- /dev/null +++ b/docs/ruby/Idl/VariableDeclarationWithInitializationSyntaxNode.html @@ -0,0 +1,202 @@ + + + + + + + Class: Idl::VariableDeclarationWithInitializationSyntaxNode + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Idl::VariableDeclarationWithInitializationSyntaxNode + + + +

    +
    + +
    +
    Inherits:
    +
    + Treetop::Runtime::SyntaxNode + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/ast.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #to_astObject + + + + + +

     
     
    -1368
    -1369
    -1370
    -1371
    -1372
    -1373
    -1374
    -1375
    -1376
    -1377
    -1378
    -1379
    -1380
    -1381
    -1382
    -1383
    -1384
    -1385
    -1386
    -1387
    -1388
    -1389
    -1390
    -1391
    -1392
    -1393
    -1394
    -1395
    -1396
    -1397
    -1398
    -1399
    -1400
    -1401
    -1402
    -1403
    +1486 +1487 +1488 +1489 +1490 +1491 +1492 +1493 +1494 +1495 +1496 +1497 +1498 +1499 +1500 +1501 +1502 +1503 +1504 +1505 +1506 +1507 +1508 +1509 +1510 +1511 +1512 +1513
    -
    # File 'lib/idl/ast.rb', line 1368
    +      
    # File 'lib/idl/ast.rb', line 1486
     
     def type_check(symtab)
    -  rval.type_check(symtab)
    +  @rhs.type_check(symtab)
     
    -  type_name.type_check(symtab)
    +  @type_name.type_check(symtab)
     
    -  decl_type = lhs_type(symtab)
    +  @ary_size&.type_check(symtab)
     
    -  unless ary_size.empty?
    -    ary_size.expression.type_check(symtab)
    -    begin
    -      ary_size_value = ary_size.expression.value(symtab)
    -    rescue ValueError
    -      type_error "Array size must be known at compile time"
    -    end
    +  decl_type = lhs_type(symtab)
     
    -    decl_type = Type.new(:array, width: ary_size_value, sub_type: decl_type)
    -  end
     
    -  if (var_write.text_value == var_write.text_value.upcase) && ary_size.empty?
    +  if decl_type.const?
         # this is a constant; ensure we are assigning a constant value
         begin
    -      symtab.add(var_write.text_value, Var.new(var_write.text_value, decl_type.clone.make_const, rval.value(symtab)))
    +      symtab.add(@lhs.text_value, Var.new(@lhs.text_value, decl_type.clone, @rhs.value(symtab)))
         rescue ValueError => e
           type_error "Declaring constant with a non-constant value (#{e})"
         end
       else
    -    symtab.add(var_write.text_value, Var.new(var_write.text_value, decl_type.clone))
    +    symtab.add(@lhs.text_value, Var.new(@lhs.text_value, decl_type.clone))
       end
     
    -  var_write.type_check(symtab)
    +  @lhs.type_check(symtab)
     
       # now check that the assignment is compatible
    -  return if rval.type(symtab).convertable_to?(decl_type)
    +  return if @rhs.type(symtab).convertable_to?(decl_type)
     
    -  type_error "Incompatible type (#{decl_type}, #{rval.type(symtab)}) in assignment"
    +  type_error "Incompatible type (#{decl_type}, #{@rhs.type(symtab)}) in assignment"
     end
    + + + + +
    +
    +
    +
    +1427
    +1428
    +1429
    +1430
    +1431
    +1432
    +1433
    +
    +
    # File 'lib/idl/ast.rb', line 1427
    +
    +def to_ast
    +  ary_size_ast = ary_size.empty? ? nil : ary_size.expression.to_ast
    +  VariableDeclarationWithInitializationAst.new(
    +    input, interval,
    +    type_name.to_ast, var_write.to_ast, ary_size_ast, rval.to_ast
    +  )
    +end
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/docs/ruby/Idl/XregType.html b/docs/ruby/Idl/XregType.html index 9e5d5dec1..db833fb34 100644 --- a/docs/ruby/Idl/XregType.html +++ b/docs/ruby/Idl/XregType.html @@ -231,12 +231,12 @@

     
     
    -542
    -543
    -544
    +569 +570 +571

    -
    # File 'lib/idl/type.rb', line 542
    +      
    # File 'lib/idl/type.rb', line 569
     
     def initialize(xlen)
       super(:bits, width: xlen)
    @@ -268,12 +268,12 @@ 

     
     
    -550
    -551
    -552
    +577 +578 +579

    -
    # File 'lib/idl/type.rb', line 550
    +      
    # File 'lib/idl/type.rb', line 577
     
     def to_cxx
       'XReg'
    @@ -298,12 +298,12 @@ 

     
     
    -546
    -547
    -548
    +573 +574 +575

    -
    # File 'lib/idl/type.rb', line 546
    +      
    # File 'lib/idl/type.rb', line 573
     
     def to_s
       'XReg'
    @@ -318,7 +318,7 @@ 

    diff --git a/docs/ruby/Instruction.html b/docs/ruby/Instruction.html index 0562db108..c343c424e 100644 --- a/docs/ruby/Instruction.html +++ b/docs/ruby/Instruction.html @@ -222,7 +222,53 @@

  • - #encoding(base) ⇒ String + #defined_by?(*args) ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + #encoding(base) ⇒ Encoding + + + + + + + + + + + + + +
    +

    The encoding.

    +
    + +
  • + + +
  • + + + #encoding_width ⇒ Integer @@ -237,7 +283,7 @@

    -

    The encoding as, e.g.,: 0000101———-001—–0110011.

    +

    The width of the encoding.

  • @@ -246,7 +292,7 @@

  • - #extension ⇒ String+ + #excluded_by?(*args) ⇒ Object @@ -268,14 +314,60 @@

  • - #initialize(inst_data, full_opcode_data, sym_table, arch_def) ⇒ Instruction + #exists_in_cfg?(possible_xlens, extensions) ⇒ Boolean + + + + + + + + + + + + + +
    +

    Whether or not the instruction is implemented given the supplies config options.

    +
    + +
  • + + +
  • + + + #extension_exclusions ⇒ Array<ExtensionRequirement> - constructor + + + + + + + +
    +

    Extension exclusions for the instruction.

    +
    + +
  • + + +
  • + + + #extension_requirements ⇒ Array<ExtensionRequirement> + + + + + @@ -285,7 +377,7 @@

    -

    A new instance of Instruction.

    +

    Extension requirements for the instruction.

  • @@ -318,7 +410,79 @@

  • - #operation_ast ⇒ Idl::AstNode + #operation_ast(idl_compiler) ⇒ FunctionBodyAst + + + + + + + + + + + + + +
    +

    The abstract syntax tree of the instruction operation.

    +
    + +
  • + + +
  • + + + #pruned_operation_ast(global_symtab) ⇒ Idl::FunctionBodyAst + + + + + + + + + + + + + +
    +

    A pruned abstract syntax tree.

    +
    + +
  • + + +
  • + + + #rv32? ⇒ Boolean + + + + + + + + + + + + + +
    +

    Whether or not this instruction is defined for RV32.

    +
    + +
  • + + +
  • + + + #rv64? ⇒ Boolean @@ -333,7 +497,7 @@

    -

    Abstract syntax tree of the instruction operation().

    +

    Whether or not this instruction is defined for RV64.

  • @@ -342,7 +506,7 @@

  • - #operation_source ⇒ String + #type_check_operation(global_symtab) ⇒ Object @@ -357,7 +521,7 @@

    -

    The operation() IDL code.

    +

    type check the instruction operation in the context of symtab.

  • @@ -396,25 +560,828 @@

    Constructor Details

    -
    -

    +

    This class inherits a constructor from ArchDefObject

    + +

    +
    +

    Dynamic Method Handling

    +

    + This class handles dynamic methods through the method_missing method + + in the class ArchDefObject + +

    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #arch_defArchDef (readonly) + + + + + +

    +
    + +

    Returns The architecture definition.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (ArchDef) + + + + — +
      +

      The architecture definition

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +903
    +904
    +905
    +
    +
    # File 'lib/arch_def.rb', line 903
    +
    +def arch_def
    +  @arch_def
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #access_detail?Boolean - #initialize(inst_data, full_opcode_data, sym_table, arch_def) ⇒ Instruction + + + +

    +
    + +

    Returns true if the instruction has an ‘access_detail’ field.

    + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the instruction has an ‘access_detail’ field

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +1031
    +1032
    +1033
    +
    +
    # File 'lib/arch_def.rb', line 1031
    +
    +def access_detail?
    +  @data.key?("access_detail")
    +end
    +
    +
    + +
    +

    + + #decode_variables(base) ⇒ Array<DecodeVariable> + + + + + +

    +
    + +

    Returns The decode variables.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Array<DecodeVariable>) + + + + — +
      +

      The decode variables

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +1026
    +1027
    +1028
    +
    +
    # File 'lib/arch_def.rb', line 1026
    +
    +def decode_variables(base)
    +  encoding(base).decode_variables
    +end
    +
    +
    + +
    +

    + + + #defined_by?(ext_name, ext_version) ⇒ Boolean + + #defined_by?(ext_version) ⇒ Boolean + + + + + + +

    +
    + + +
    +
    +
    + +

    Overloads:

    +
      + + +
    • + #defined_by?(ext_name, ext_version) ⇒ Boolean +
      +
      + +

      Returns Whether or not the instruction is defined by extesion ‘ext`, version `version`.

      + + +
      +
      +
      +

      Parameters:

      +
        + +
      • + + ext_name + + + (#to_s) + + + + — +
        +

        An extension name

        +
        + +
      • + +
      • + + ext_version + + + (#to_s) + + + + — +
        +

        A specific extension version

        +
        + +
      • + +
      + +

      Returns:

      +
        + +
      • + + + (Boolean) + + + + — +
        +

        Whether or not the instruction is defined by extesion ‘ext`, version `version`

        +
        + +
      • + +
      + +
      +
    • + + +
    • + #defined_by?(ext_version) ⇒ Boolean +
      +
      + +

      Returns Whether or not the instruction is defined by ext_version.

      + + +
      +
      +
      +

      Parameters:

      +
        + +
      • + + ext_version + + + (ExtensionVersion) + + + + — +
        +

        An extension version

        +
        + +
      • + +
      + +

      Returns:

      +
        + +
      • + + + (Boolean) + + + + — +
        +

        Whether or not the instruction is defined by ext_version

        +
        + +
      • + +
      + +
      +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +1134
    +1135
    +1136
    +1137
    +1138
    +1139
    +1140
    +1141
    +1142
    +1143
    +1144
    +1145
    +1146
    +1147
    +1148
    +1149
    +
    +
    # File 'lib/arch_def.rb', line 1134
    +
    +def defined_by?(*args)
    +  if args.size == 1
    +    raise ArgumentError, "Parameter must be an ExtensionVersion" unless args[0].is_a?(ExtensionVersion)
    +
    +    extension_requirements.any? do |r|
    +      r.satisfied_by?(args[0])
    +    end
    +  elsif args.size == 2
    +    raise ArgumentError, "First parameter must be an extension name" unless args[0].respond_to?(:to_s)
    +    raise ArgumentError, "Second parameter must be an extension version" unless args[0].respond_to?(:to_s)
    +
    +    extension_requirements.any? do |r|
    +      r.satisfied_by?(args[0].to_s, args[1].to_s)
    +    end
    +  end
    +end
    +
    +
    + +
    +

    + + #encoding(base) ⇒ Encoding + + + + + +

    +
    + +

    Returns the encoding.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + base + + + (Integer) + + + + — +
      +

      32 or 64

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Encoding) + + + + — +
      +

      the encoding

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +1012
    +1013
    +1014
    +1015
    +1016
    +
    +
    # File 'lib/arch_def.rb', line 1012
    +
    +def encoding(base)
    +  load_encoding if @encodings.nil?
    +
    +  @encodings[base]
    +end
    +
    +
    + +
    +

    + + #encoding_widthInteger + + + + + +

    +
    + +

    Returns the width of the encoding.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      the width of the encoding

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +1019
    +1020
    +1021
    +1022
    +1023
    +
    +
    # File 'lib/arch_def.rb', line 1019
    +
    +def encoding_width
    +  raise "unexpected: encodings are different sizes" unless encoding(32).size == encoding(64).size
    +
    +  encoding(64).size
    +end
    +
    +
    + +
    +

    + + + #excluded_by?(ext_name, ext_version) ⇒ Boolean + + #excluded_by?(ext_version) ⇒ Boolean + + + + + + +

    +
    + + +
    +
    +
    + +

    Overloads:

    +
      + + +
    • + #excluded_by?(ext_name, ext_version) ⇒ Boolean +
      +
      + +

      Returns Whether or not the instruction is excluded by extesion ‘ext`, version `version`.

      + + +
      +
      +
      +

      Parameters:

      +
        + +
      • + + ext_name + + + (#to_s) + + + + — +
        +

        An extension name

        +
        + +
      • + +
      • + + ext_version + + + (#to_s) + + + + — +
        +

        A specific extension version

        +
        + +
      • + +
      + +

      Returns:

      +
        + +
      • + + + (Boolean) + + + + — +
        +

        Whether or not the instruction is excluded by extesion ‘ext`, version `version`

        +
        + +
      • + +
      + +
      +
    • + + +
    • + #excluded_by?(ext_version) ⇒ Boolean +
      +
      + +

      Returns Whether or not the instruction is excluded by ext_version.

      + + +
      +
      +
      +

      Parameters:

      +
        + +
      • + + ext_version + + + (ExtensionVersion) + + + + — +
        +

        An extension version

        +
        + +
      • + +
      + +

      Returns:

      +
        + +
      • + + + (Boolean) + + + + — +
        +

        Whether or not the instruction is excluded by ext_version

        +
        + +
      • + +
      + +
      +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +1158
    +1159
    +1160
    +1161
    +1162
    +1163
    +1164
    +1165
    +1166
    +1167
    +1168
    +1169
    +1170
    +1171
    +1172
    +1173
    +
    +
    # File 'lib/arch_def.rb', line 1158
    +
    +def excluded_by?(*args)
    +  if args.size == 1
    +    raise ArgumentError, "Parameter must be an ExtensionVersion" unless args[0].is_a?(ExtensionVersion)
    +
    +    extension_exclusions.any? do |r|
    +      r.satisfied_by?(args[0])
    +    end
    +  elsif args.size == 2
    +    raise ArgumentError, "First parameter must be an extension name" unless args[0].respond_to?(:to_s)
    +    raise ArgumentError, "Second parameter must be an extension version" unless args[0].respond_to?(:to_s)
    +
    +    extension_exclusions.any? do |r|
    +      r.satisfied_by?(args[0].to_s, args[1].to_s)
    +    end
    +  end
    +end
    +
    +
    + +
    +

    + + #exists_in_cfg?(possible_xlens, extensions) ⇒ Boolean + + + + + +

    +
    + +

    Returns whether or not the instruction is implemented given the supplies config options.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + possible_xlens + + + (Array<Integer>) + + + + — +
      +

      List of xlens that be used in any implemented mode

      +
      + +
    • + +
    • + + extensions + + + (Array<ExtensionVersion>) + + + + — +
      +

      List of extensions implemented

      +
      + +
    • +
    +

    Returns:

    +
      -

    -
    - -

    Returns a new instance of Instruction.

    - - -
    +
  • + + + (Boolean) + + + + — +
    +

    whether or not the instruction is implemented given the supplies config options

    -
    + +
  • + @@ -422,164 +1389,29 @@

     
     
    -952
    -953
    -954
    -955
    -956
    -957
    -958
    -959
    -960
    -961
    -962
    -963
    -964
    -965
    -966
    -967
    -968
    -969
    -970
    -971
    -972
    -973
    -974
    -975
    -976
    -977
    -978
    -979
    -980
    -981
    -982
    -983
    -984
    -985
    -986
    -987
    -988
    -989
    -990
    -991
    -992
    -993
    -994
    -995
    -996
    -997
    -998
    -999
    -1000
    -1001
    -1002
    -1003
    -1004
    -1005
    -1006
    -1007
    -1008
    -1009
    -1010
    -1011
    -1012
    -1013
    -1014
    -1015
    +1178 +1179 +1180 +1181 +1182

    -
    # File 'lib/arch_def.rb', line 952
    -
    -def initialize(inst_data, full_opcode_data, sym_table, arch_def)
    -  @arch_def = arch_def
    -  @sym_table = sym_table.deep_clone
    -
    -  super(inst_data)
    -
    -  if inst_data.key?("encoding")
    -    load_encoding
    -  else
    -    opcode_data_key = name.downcase.gsub(".", "_")
    -    raise "opcode data not found for #{name}" unless full_opcode_data.key?(opcode_data_key)
    -
    -    opcode_data = full_opcode_data[opcode_data_key]
    -    encoding_mask = opcode_data["encoding"]
    -
    -    opcode_fields = []
    -    msb = encoding_mask.size
    -    encoding_mask.split("-").each do |e|
    -      if e.empty?
    -        msb -= 1
    -      else
    -        opcode_fields << Encoding::Field.new(e, (msb - e.size + 1)..msb)
    -        msb -= e.size
    -      end
    -    end
    -
    -
    -    decode_variables = []
    -    opcode_data["variable_fields"].to_a.each do |f|
    -      decode_field_data = RiscvOpcodes::VARIABLE_FIELDS.to_a.select do |d|
    -        d[0] == f || (d[0].is_a?(Array) && d[0].any?(f))
    -      end
    -      raise "didn't find '#{f}' in DECODER_RING" if decode_field_data.empty?
    -
    -      raise "Found multiple matches for '#{f}' in DECODER_RING" if decode_field_data.size > 1
    -
    -      data = decode_field_data[0][1]
    -      names = []
    -      if data.key?(:decode_variable)
    -        if data[:decode_variable].is_a?(String)
    -          names << data[:decode_variable]
    -        else
    -          raise "unexpected" unless data[:decode_variable].is_a?(Array)
    -
    -          names = data[:decode_variable]
    -        end
    -      else
    -        raise "?" unless decode_field_data[0][0].is_a?(String)
    -
    -        names = [decode_field_data[0][0]]
    -      end
    +      
    # File 'lib/arch_def.rb', line 1178
     
    -      names.each do |name|
    -        decode_variables << DecodeField.new(self, name, decode_field_data[0][0], decode_field_data[0][1])
    -      end
    -    end
    -    decode_variables.uniq!
    -
    -    @encodings ||= {}
    -    klass = Struct.new(:opcode_fields, :decode_variables)
    -    @encodings[32] = klass.new(opcode_fields, decode_variables)
    -    @encodings[64] = klass.new(opcode_fields, decode_variables)
    -  end
    +def exists_in_cfg?(possible_xlens, extensions)
    +  (@data["base"].nil? || (possible_xlens.include?(@data["base"]))) &&
    +    extensions.any? { |e| defined_by?(e) } &&
    +    extensions.none? { |e| excluded_by?(e) }
     end
    - - -
    -

    Dynamic Method Handling

    -

    - This class handles dynamic methods through the method_missing method - - in the class ArchDefObject - -

    - -
    - -
    -

    Instance Attribute Details

    - - -
    -

    +
    +

    - #arch_defArchDef (readonly) + #extension_exclusionsArray<ExtensionRequirement> @@ -588,7 +1420,7 @@

    -

    Returns The architecture definition.

    +

    Returns Extension exclusions for the instruction. If any exclusion is met, the instruction is not defined.

    @@ -601,13 +1433,13 @@

  • - (ArchDef) + (Array<ExtensionRequirement>)
    -

    The architecture definition

    +

    Extension exclusions for the instruction. If any exclusion is met, the instruction is not defined

  • @@ -620,32 +1452,63 @@

     
     
    -863
    -864
    -865
    +1104 +1105 +1106 +1107 +1108 +1109 +1110 +1111 +1112 +1113 +1114 +1115 +1116 +1117 +1118 +1119 +1120 +1121 +1122 +1123 +1124 +1125

    -
    # File 'lib/arch_def.rb', line 863
    +      
    # File 'lib/arch_def.rb', line 1104
     
    -def arch_def
    -  @arch_def
    +def extension_exclusions
    +  return @extension_exclusions unless @extension_excludions.nil?
    +
    +  @extension_exclusions = []
    +  if @data.key?("excludedBy")
    +    if @data["exludedBy"].is_a?(Array)
    +      # could be either a single extension with exclusion, or a list of exclusions
    +      if extension_exclusion?(@data["definedBy"][0])
    +        @extension_exclusions << to_extension_requirement(@data["excludedBy"][0])
    +      else
    +        # this is a list
    +        @data["excludeddBy"].each do |r|
    +          @extension_exclusions << to_extension_exclusion(r)
    +        end
    +      end
    +    else
    +      @extension_exclusions << to_extension_requirement(@data["excludedBy"])
    +    end
    +  end
    +
    +  @extension_exclusions
     end
    -
    - - -
    -

    Instance Method Details

    - - -
    -

    +
    +

    - #access_detail?Boolean + #extension_requirementsArray<ExtensionRequirement> @@ -654,7 +1517,7 @@

    -

    Returns true if the instruction has an ‘access_detail’ field.

    +

    Returns Extension requirements for the instruction. If any requirement is met, the instruction is defined.

    @@ -667,13 +1530,13 @@

  • - (Boolean) + (Array<ExtensionRequirement>)
    -

    true if the instruction has an ‘access_detail’ field

    +

    Extension requirements for the instruction. If any requirement is met, the instruction is defined

  • @@ -686,15 +1549,53 @@

     
     
    +1080
    +1081
    +1082
    +1083
    +1084
    +1085
    +1086
    +1087
    +1088
    +1089
    +1090
    +1091
     1092
     1093
    -1094
    +1094 +1095 +1096 +1097 +1098 +1099 +1100 +1101

    -
    # File 'lib/arch_def.rb', line 1092
    +      
    # File 'lib/arch_def.rb', line 1080
    +
    +def extension_requirements
    +  return @extension_requirements unless @extension_requirements.nil?
    +
    +  @extension_requirements = []
    +  if @data["definedBy"].is_a?(Array)
    +    # could be either a single extension with requirement, or a list of requirements
    +    if extension_requirement?(@data["definedBy"][0])
    +      @extension_requirements << to_extension_requirement(@data["definedBy"][0])
    +    else
    +      # this is a list
    +      @data["definedBy"].each do |r|
    +        @extension_requirements << to_extension_requirement(r)
    +      end
    +    end
    +  else
    +    @extension_requirements << to_extension_requirement(@data["definedBy"])
    +  end
     
    -def access_detail?
    -  @data.key?("access_detail")
    +  raise "empty requirements" if @extension_requirements.empty?
    +
    +  @extension_requirements
     end
    @@ -702,9 +1603,9 @@

    -

    +

    - #decode_variables(base) ⇒ Array<DecodeVariable> + #multi_encoding?Boolean @@ -713,7 +1614,7 @@

    -

    Returns The decode variables.

    +

    Returns whether or not this instruction has different encodings depending on XLEN.

    @@ -726,13 +1627,13 @@

  • - (Array<DecodeVariable>) + (Boolean)
    -

    The decode variables

    +

    whether or not this instruction has different encodings depending on XLEN

  • @@ -745,15 +1646,15 @@

     
     
    -1071
    -1072
    -1073
    +989 +990 +991

    -
    # File 'lib/arch_def.rb', line 1071
    +      
    # File 'lib/arch_def.rb', line 989
     
    -def decode_variables(base)
    -  @encodings[base].decode_variables
    +def multi_encoding?
    +  @data.key?("encoding") && @data["encoding"].key?("RV32")
     end
    @@ -761,9 +1662,9 @@

    -

    +

    - #encoding(base) ⇒ String + #operation_ast(idl_compiler) ⇒ FunctionBodyAst @@ -772,7 +1673,7 @@

    -

    Returns the encoding as, e.g.,: 0000101———-001—–0110011.

    +

    Returns The abstract syntax tree of the instruction operation.

    @@ -785,13 +1686,13 @@

  • - (String) + (FunctionBodyAst)
    -

    the encoding as, e.g.,: 0000101———-001—–0110011

    +

    The abstract syntax tree of the instruction operation

  • @@ -804,15 +1705,39 @@

     
     
    -1066
    -1067
    -1068
    +994 +995 +996 +997 +998 +999 +1000 +1001 +1002 +1003 +1004 +1005 +1006 +1007 +1008

    -
    # File 'lib/arch_def.rb', line 1066
    +      
    # File 'lib/arch_def.rb', line 994
     
    -def encoding(base)
    -  @encodings[base].format
    +def operation_ast(idl_compiler)
    +  return @operation_ast unless @operation_ast.nil?
    +  return nil if @data["operation()"].nil?
    +
    +  # now, parse the operation
    +
    +  @operation_ast = idl_compiler.compile_inst_operation(
    +    self,
    +    input_file: "Instruction #{name}"
    +  )
    +
    +  raise "unexpected #{@operation_ast.class}" unless @operation_ast.is_a?(Idl::FunctionBodyAst)
    +
    +  @operation_ast
     end
    @@ -820,9 +1745,9 @@

    -

    +

    - #extensionString+ + #pruned_operation_ast(global_symtab) ⇒ Idl::FunctionBodyAst @@ -831,38 +1756,46 @@

    +

    Returns A pruned abstract syntax tree.

    +
    - -

    Returns:

    -
      +

      Parameters:

      +
      • + global_symtab - (String) + + (Idl::SymbolTable)
        -

        the extension that defines this instruction

        +

        Symbol table with global scope populated and a configuration loaded

      • +
      + +

      Returns:

      +
        +
      • - (Array<String>) + (Idl::FunctionBodyAst)
        -

        the extensions that define this instruction

        +

        A pruned abstract syntax tree

      • @@ -875,37 +1808,29 @@

         
         
        -1081
        -1082
        -1083
        -1084
        -1085
        -1086
        -1087
        -1088
        -1089
        +896 +897 +898 +899 +900

    -
    # File 'lib/arch_def.rb', line 1081
    -
    -def extension
    -  @data["definedBy"]
    -  # parts = @data["extension"][0].split("_")
    -  # if @data["definedBy"].is_a?(String)
    -  #   parts[1].capitalize
    -  # else
    -  #   parts[1..].map(&:capitalize)
    -  # end
    -end
    +
    # File 'lib/arch_def.rb', line 896
    +
    +def pruned_operation_ast(global_symtab)
    +  type_check_operation(global_symtab)
    +  puts "PRUNING        #{name}"
    +  operation_ast(global_symtab.archdef.idl_compiler).prune(fill_symtab(global_symtab))
    +end
    -

    +

    - #multi_encoding?Boolean + #rv32?Boolean @@ -914,7 +1839,7 @@

    -

    Returns whether or not this instruction has different encodings depending on XLEN.

    +

    Returns whether or not this instruction is defined for RV32.

    @@ -933,7 +1858,7 @@

    -

    whether or not this instruction has different encodings depending on XLEN

    +

    whether or not this instruction is defined for RV32

    @@ -946,15 +1871,15 @@

     
     
    -1018
    -1019
    -1020
    +1055 +1056 +1057

    -
    # File 'lib/arch_def.rb', line 1018
    +      
    # File 'lib/arch_def.rb', line 1055
     
    -def multi_encoding?
    -  @data.key?("encoding") && @data["encoding"].key?("RV32")
    +def rv32?
    +  !@data.key?("base") || base == 32
     end
    @@ -962,9 +1887,9 @@

    -

    +

    - #operation_astIdl::AstNode + #rv64?Boolean @@ -973,7 +1898,7 @@

    -

    Returns Abstract syntax tree of the instruction operation().

    +

    Returns whether or not this instruction is defined for RV64.

    @@ -986,13 +1911,13 @@

  • - (Idl::AstNode) + (Boolean)
    -

    Abstract syntax tree of the instruction operation()

    +

    whether or not this instruction is defined for RV64

  • @@ -1005,19 +1930,15 @@

     
     
    -856
    -857
    -858
    -859
    -860
    +1060 +1061 +1062

    -
    # File 'lib/arch_def.rb', line 856
    -
    -def operation_ast
    -  parse_operation(@sym_table) if @operation_ast.nil?
    +      
    # File 'lib/arch_def.rb', line 1060
     
    -  @operation_ast
    +def rv64?
    +  !@data.key?("base") || base == 64
     end
    @@ -1025,9 +1946,9 @@

    -

    +

    - #operation_sourceString + #type_check_operation(global_symtab) ⇒ Object @@ -1036,26 +1957,46 @@

    -

    Returns The operation() IDL code.

    +

    type check the instruction operation in the context of symtab

    - -

    Returns:

    -
      +

      Parameters:

      +
      • + global_symtab - (String) + + (Idl::SymbolTable)
        -

        The operation() IDL code

        +

        A symbol table with global scope populated

        +
        + +
      • + +
      + +

      Raises:

      +
        + +
      • + + + + + + + +
        +

        Idl::AstNode::TypeError if there is a type problem

      • @@ -1068,22 +2009,24 @@

         
         
        -1023
        -1024
        -1025
        -1026
        -1027
        -1028
        +886 +887 +888 +889 +890 +891 +892

    -
    # File 'lib/arch_def.rb', line 1023
    -
    -def operation_source
    -  return "" if @data["operation()"].nil?
    -
    -  operation_ast.gen_adoc.gsub("{{", '\((')
    -  # @data['operation']
    -end
    +
    # File 'lib/arch_def.rb', line 886
    +
    +def type_check_operation(global_symtab)
    +  global_symtab.archdef.idl_compiler.type_check(
    +    operation_ast(global_symtab.archdef.idl_compiler),
    +    fill_symtab(global_symtab),
    +    "#{name}.operation()"
    +  )
    +end
    @@ -1153,31 +2096,31 @@

     
     
    -1100
    -1101
    -1102
    -1103
    -1104
    -1105
    -1106
    -1107
    -1108
    -1109
    -1110
    -1111
    -1112
    -1113
    +1039 +1040 +1041 +1042 +1043 +1044 +1045 +1046 +1047 +1048 +1049 +1050 +1051 +1052

    -
    # File 'lib/arch_def.rb', line 1100
    +      
    # File 'lib/arch_def.rb', line 1039
     
     def wavedrom_desc(base)
       desc = {
         "reg" => []
       }
     
    -  display_fields = @encodings[base].opcode_fields
    -  display_fields += @encodings[base].decode_variables.map(&:grouped_encoding_fields).flatten
    +  display_fields = encoding(base).opcode_fields
    +  display_fields += encoding(base).decode_variables.map(&:grouped_encoding_fields).flatten
     
       display_fields.sort { |a, b| b.range.last <=> a.range.last }.reverse.each do |e|
         desc["reg"] << { "bits" => e.range.size, "name" => e.name, "type" => (e.opcode? ? 2 : 4) }
    @@ -1195,7 +2138,7 @@ 

    diff --git a/docs/ruby/Instruction/Encoding.html b/docs/ruby/Instruction/Encoding.html index 26edd8a54..1988b8d74 100644 --- a/docs/ruby/Instruction/Encoding.html +++ b/docs/ruby/Instruction/Encoding.html @@ -345,28 +345,28 @@

     
     
    -907
    -908
    -909
    -910
    -911
    -912
    -913
    -914
    -915
    -916
    -917
    -918
    -919
    -920
    -921
    -922
    -923
    -924
    -925
    +947 +948 +949 +950 +951 +952 +953 +954 +955 +956 +957 +958 +959 +960 +961 +962 +963 +964 +965

    -
    # File 'lib/arch_def.rb', line 907
    +      
    # File 'lib/arch_def.rb', line 947
     
     def initialize(format, decode_vars)
       @format = format
    @@ -383,7 +383,7 @@ 

    end @decode_variables = [] - decode_vars.each do |var| + decode_vars&.each do |var| @decode_variables << DecodeVariable.new(self, var) end end

    @@ -443,12 +443,12 @@

     
     
    -878
    -879
    -880
    +918 +919 +920

    -
    # File 'lib/arch_def.rb', line 878
    +      
    # File 'lib/arch_def.rb', line 918
     
     def decode_variables
       @decode_variables
    @@ -516,12 +516,12 @@ 

     
     
    -870
    -871
    -872
    +910 +911 +912

    -
    # File 'lib/arch_def.rb', line 870
    +      
    # File 'lib/arch_def.rb', line 910
     
     def format
       @format
    @@ -589,12 +589,12 @@ 

     
     
    -875
    -876
    -877
    +915 +916 +917

    -
    # File 'lib/arch_def.rb', line 875
    +      
    # File 'lib/arch_def.rb', line 915
     
     def opcode_fields
       @opcode_fields
    @@ -655,12 +655,12 @@ 

     
     
    -928
    -929
    -930
    +968 +969 +970

    -
    # File 'lib/arch_def.rb', line 928
    +      
    # File 'lib/arch_def.rb', line 968
     
     def size
       @format.size
    @@ -675,7 +675,7 @@ 

    diff --git a/docs/ruby/Instruction/Encoding/Field.html b/docs/ruby/Instruction/Encoding/Field.html index 7fdfb286c..7ed0989ab 100644 --- a/docs/ruby/Instruction/Encoding/Field.html +++ b/docs/ruby/Instruction/Encoding/Field.html @@ -306,13 +306,13 @@

     
     
    -894
    -895
    -896
    -897
    +934 +935 +936 +937

    -
    # File 'lib/arch_def.rb', line 894
    +      
    # File 'lib/arch_def.rb', line 934
     
     def initialize(name, range)
       @name = name.to_s
    @@ -393,12 +393,12 @@ 

     
     
    -887
    -888
    -889
    +927 +928 +929

    -
    # File 'lib/arch_def.rb', line 887
    +      
    # File 'lib/arch_def.rb', line 927
     
     def name
       @name
    @@ -454,12 +454,12 @@ 

     
     
    -890
    -891
    -892
    +930 +931 +932

    -
    # File 'lib/arch_def.rb', line 890
    +      
    # File 'lib/arch_def.rb', line 930
     
     def range
       @range
    @@ -520,12 +520,12 @@ 

     
     
    -900
    -901
    -902
    +940 +941 +942

    -
    # File 'lib/arch_def.rb', line 900
    +      
    # File 'lib/arch_def.rb', line 940
     
     def opcode?
       name.match?(/^[01]+$/)
    @@ -540,7 +540,7 @@ 

    diff --git a/docs/ruby/MockArchDef.html b/docs/ruby/MockArchDef.html new file mode 100644 index 000000000..1d631e21a --- /dev/null +++ b/docs/ruby/MockArchDef.html @@ -0,0 +1,245 @@ + + + + + + + Class: MockArchDef + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: MockArchDef + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/tests/helpers.rb
    +
    + +
    + +

    Overview

    +
    + +

    ArchDef mock that knows about XLEN and extensions

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #config_paramsObject + + + + + +

    + + + + +
    +
    +
    +
    +13
    +
    +
    # File 'lib/idl/tests/helpers.rb', line 13
    +
    +def config_params = { "XLEN" => 32 }
    +
    +
    + +
    +

    + + #extensionsObject + + + + + +

    + + + + +
    +
    +
    +
    +14
    +
    +
    # File 'lib/idl/tests/helpers.rb', line 14
    +
    +def extensions = [MockExtension.new("I")]
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/MockExtension.html b/docs/ruby/MockExtension.html new file mode 100644 index 000000000..84065ad6f --- /dev/null +++ b/docs/ruby/MockExtension.html @@ -0,0 +1,296 @@ + + + + + + + Class: MockExtension + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: MockExtension + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/idl/tests/helpers.rb
    +
    + +
    + +

    Overview

    +
    + +

    Extension mock that returns an extension name

    + + +
    +
    +
    + + +
    + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #name ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute name.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(name) ⇒ MockExtension + + + + + +

    +
    + +

    Returns a new instance of MockExtension.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +6
    +7
    +8
    +
    +
    # File 'lib/idl/tests/helpers.rb', line 6
    +
    +def initialize(name)
    +  @name = name
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #nameObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute name.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +5
    +6
    +7
    +
    +
    # File 'lib/idl/tests/helpers.rb', line 5
    +
    +def name
    +  @name
    +end
    +
    +
    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Opcodes.html b/docs/ruby/Opcodes.html index 9351ed69e..8699c1e95 100644 --- a/docs/ruby/Opcodes.html +++ b/docs/ruby/Opcodes.html @@ -408,16 +408,16 @@

     
     
    -607
    -608
    -609
    -610
    -611
    -612
    -613
    +614 +615 +616 +617 +618 +619 +620

    -
    # File 'lib/opcodes.rb', line 607
    +      
    # File 'lib/opcodes.rb', line 614
     
     def self.insn_table
       return @insn_table unless @insn_table.nil?
    @@ -436,7 +436,7 @@ 

    diff --git a/docs/ruby/RiscvOpcodes.html b/docs/ruby/RiscvOpcodes.html index 9790b2c30..d723ab3ad 100644 --- a/docs/ruby/RiscvOpcodes.html +++ b/docs/ruby/RiscvOpcodes.html @@ -370,7 +370,7 @@

    diff --git a/docs/ruby/TestExpressions.html b/docs/ruby/TestExpressions.html new file mode 100644 index 000000000..35663d586 --- /dev/null +++ b/docs/ruby/TestExpressions.html @@ -0,0 +1,613 @@ + + + + + + + Class: TestExpressions + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: TestExpressions + + + +

    +
    + +
    +
    Inherits:
    +
    + Minitest::Test + +
      +
    • Object
    • + + + + + +
    + show all + +
    +
    + + + + + + +
    +
    Includes:
    +
    TestMixin
    +
    + + + + + + +
    +
    Defined in:
    +
    lib/idl/tests/test_expressions.rb
    +
    + +
    + +

    Overview

    +
    + +

    Test IDL expressions

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #setupObject + + + + + + + Originally defined in module + TestMixin + + +

    +
    + +
    +

    + + #test_that_integer_literals_give_correct_valuesObject + + + + + +

    + + + + +
    +
    +
    +
    +48
    +49
    +50
    +51
    +52
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +97
    +98
    +99
    +100
    +101
    +102
    +103
    +104
    +105
    +106
    +107
    +108
    +109
    +110
    +111
    +112
    +113
    +114
    +115
    +116
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +124
    +125
    +126
    +127
    +
    +
    # File 'lib/idl/tests/test_expressions.rb', line 48
    +
    +def test_that_integer_literals_give_correct_values
    +  idl = "8'd13"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal 13, ast.value(@symtab)
    +
    +  idl = "16'hd"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal 13, ast.value(@symtab)
    +
    +  idl = "12'o15"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal 13, ast.value(@symtab)
    +
    +  idl = "4'b1101"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal 13, ast.value(@symtab)
    +
    +  idl = "-8'sd13"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal(-13, ast.value(@symtab))
    +
    +  idl = "-16'shd"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal(-13, ast.value(@symtab))
    +
    +  idl = "-12'so15"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal(-13, ast.value(@symtab))
    +
    +  idl = "-4'sb1101"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal 3, ast.value(@symtab)
    +
    +  idl = "4'sb1101"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal(-3, ast.value(@symtab))
    +
    +  idl = "32'h80000000"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal 0x80000000, ast.value(@symtab)
    +
    +  idl = "32'h8000_0000"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal 0x80000000, ast.value(@symtab)
    +
    +  idl = "8'13"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal 13, ast.value(@symtab)
    +
    +  # 13 decimal, unsigned XLEN-bit wide
    +  idl = "'13"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal 13, ast.value(@symtab)
    +
    +  # 13 decimal, signed XLEN-bit wide
    +  idl = "'s13"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal 13, ast.value(@symtab)
    +
    +  # compilation error: 300 does not fit in 8 bits
    +  idl = "'h1_0000_0000"
    +  assert_raises(Idl::AstNode::TypeError) { @compiler.compile_expression(idl, @symtab, pass_error: true) }
    +
    +  # 3 decimal: the literal is 13, unsigned, in 4-bits. when negated, the sign bit is lost
    +  idl = "-4'd13"
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal 3, ast.value(@symtab)
    +
    +  # compilation error: 300 does not fit in 8 bits
    +  idl = "8'sd300"
    +  assert_raises(Idl::AstNode::TypeError) { @compiler.compile_expression(idl, @symtab, pass_error: true) }
    +
    +  # compilation error: bit width must be positive
    +  idl = "0'15"
    +  assert_raises(Idl::AstNode::TypeError) { @compiler.compile_expression(idl, @symtab, pass_error: true) }
    +
    +  # compilation error: value does not fit in four bita
    +  idl = "4'hff"
    +  assert_raises(Idl::AstNode::TypeError) { @compiler.compile_expression(idl, @symtab, pass_error: true) }
    +end
    +
    +
    + +
    +

    + + #test_that_multplication_is_higher_precedence_than_additionObject + + + + + +

    + + + + +
    +
    +
    +
    +38
    +39
    +40
    +41
    +42
    +43
    +44
    +45
    +46
    +
    +
    # File 'lib/idl/tests/test_expressions.rb', line 38
    +
    +def test_that_multplication_is_higher_precedence_than_addition
    +  idl = <<~IDL.strip
    +    4 + 5'd3 * 2
    +  IDL
    +
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  refute_equal 14, ast.value(@symtab)
    +  assert_equal 10, ast.value(@symtab)
    +end
    +
    +
    + +
    +

    + + #test_that_operators_are_left_recusriveObject + + + + + +

    + + + + +
    +
    +
    +
    +12
    +13
    +14
    +15
    +16
    +17
    +18
    +19
    +20
    +
    +
    # File 'lib/idl/tests/test_expressions.rb', line 12
    +
    +def test_that_operators_are_left_recusrive
    +  idl = <<~IDL.strip
    +    4 - 3 - 1
    +  IDL
    +
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal 0, ast.value(@symtab)
    +  assert_equal "((4 - 3) - 1)", ast.to_idl
    +end
    +
    +
    + +
    +

    + + #test_that_values_are_tuncatedObject + + + + + +

    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +25
    +26
    +27
    +28
    +29
    +30
    +31
    +32
    +33
    +34
    +35
    +36
    +
    +
    # File 'lib/idl/tests/test_expressions.rb', line 22
    +
    +def test_that_values_are_tuncated
    +  idl = <<~IDL.strip
    +    4'hf + 4'h1
    +  IDL
    +
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal 0, ast.value(@symtab)
    +
    +  idl = <<~IDL.strip
    +    4'hf + 5'h1
    +  IDL
    +
    +  ast = @compiler.compile_expression(idl, @symtab)
    +  assert_equal 16, ast.value(@symtab)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/TestMixin.html b/docs/ruby/TestMixin.html new file mode 100644 index 000000000..eeaf1a5f0 --- /dev/null +++ b/docs/ruby/TestMixin.html @@ -0,0 +1,183 @@ + + + + + + + Module: TestMixin + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: TestMixin + + + +

    +
    + + + + + + + + + +
    +
    Included in:
    +
    TestExpressions, TestVariables
    +
    + + + +
    +
    Defined in:
    +
    lib/idl/tests/helpers.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #setupObject + + + + + +

    + + + + +
    +
    +
    +
    +18
    +19
    +20
    +21
    +22
    +
    +
    # File 'lib/idl/tests/helpers.rb', line 18
    +
    +def setup
    +  @archdef = MockArchDef.new
    +  @symtab = Idl::SymbolTable.new(@archdef)
    +  @compiler = Idl::Compiler.new(@archdef)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/TestVariables.html b/docs/ruby/TestVariables.html new file mode 100644 index 000000000..c433f2b58 --- /dev/null +++ b/docs/ruby/TestVariables.html @@ -0,0 +1,269 @@ + + + + + + + Class: TestVariables + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: TestVariables + + + +

    +
    + +
    +
    Inherits:
    +
    + Minitest::Test + +
      +
    • Object
    • + + + + + +
    + show all + +
    +
    + + + + + + +
    +
    Includes:
    +
    TestMixin
    +
    + + + + + + +
    +
    Defined in:
    +
    lib/idl/tests/test_variables.rb
    +
    + +
    + +

    Overview

    +
    + +

    test IDL variables

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #setupObject + + + + + + + Originally defined in module + TestMixin + + +

    +
    + +
    +

    + + #test_that_constants_are_read_onlyObject + + + + + +

    + + + + +
    +
    +
    +
    +12
    +13
    +14
    +15
    +16
    +17
    +18
    +19
    +20
    +21
    +
    +
    # File 'lib/idl/tests/test_variables.rb', line 12
    +
    +def test_that_constants_are_read_only
    +  idl = <<~IDL.strip
    +    XReg MyConstant = 15;
    +    MyContant = 0;
    +  IDL
    +
    +  assert_raises(Idl::AstNode::TypeError) do
    +    @compiler.compile_func_body(idl, symtab: @symtab, no_rescue: true)
    +  end
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/ruby/Treetop.html b/docs/ruby/Treetop.html index 96dcd45d3..8a88384f5 100644 --- a/docs/ruby/Treetop.html +++ b/docs/ruby/Treetop.html @@ -79,7 +79,7 @@
    Defined in:
    lib/idl/passes/find_return_values.rb,
    - lib/idl.rb,
    lib/idl/ast.rb
    + lib/idl.rb,
    lib/idl/ast.rb,
    lib/idl/passes/prune.rb
    @@ -118,7 +118,7 @@

    Overview

    diff --git a/docs/ruby/Treetop/Runtime.html b/docs/ruby/Treetop/Runtime.html index b4412f310..797bbcecf 100644 --- a/docs/ruby/Treetop/Runtime.html +++ b/docs/ruby/Treetop/Runtime.html @@ -79,7 +79,7 @@
    Defined in:
    lib/idl.rb,
    - lib/idl/ast.rb,
    lib/idl/passes/find_return_values.rb
    + lib/idl/ast.rb,
    lib/idl/passes/prune.rb,
    lib/idl/passes/find_return_values.rb
    @@ -107,7 +107,7 @@

    Defined Under Namespace

    diff --git a/docs/ruby/Treetop/Runtime/CompiledParser.html b/docs/ruby/Treetop/Runtime/CompiledParser.html index acaff4d34..6e8e82637 100644 --- a/docs/ruby/Treetop/Runtime/CompiledParser.html +++ b/docs/ruby/Treetop/Runtime/CompiledParser.html @@ -405,7 +405,7 @@

    diff --git a/docs/ruby/Treetop/Runtime/SyntaxNode.html b/docs/ruby/Treetop/Runtime/SyntaxNode.html index b53ef33ee..ae31bf960 100644 --- a/docs/ruby/Treetop/Runtime/SyntaxNode.html +++ b/docs/ruby/Treetop/Runtime/SyntaxNode.html @@ -95,7 +95,7 @@
    Defined in:
    lib/idl/ast.rb,
    - lib/idl/passes/gen_adoc.rb,
    lib/idl/passes/find_return_values.rb
    + lib/idl/passes/prune.rb,
    lib/idl/passes/find_return_values.rb
    @@ -114,7 +114,7 @@

    Overview

    @@ -210,28 +210,6 @@

    The first ancestor that is_a?(klass), or nil if none is found.

    - - - -
  • - - - #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object - - - - - - - - - - - - - -
    -
  • @@ -310,7 +288,7 @@

  • - #make_left ⇒ SyntaxNode + #pass_find_return_values(values, current_conditions) ⇒ Object @@ -324,9 +302,7 @@

    -
    -

    Fix up left recursion for the PEG.

    -
    +

  • @@ -334,7 +310,7 @@

  • - #parsing_in_template? ⇒ Boolean + #prune(symtab) ⇒ AstNode @@ -349,7 +325,7 @@

    -

    Whether or not this SyntaxNode is being parsed as a template argument without being enclosed in parenthesis.

    +

    A new abstract syntax tree with all dead/unreachable code removed.

  • @@ -358,7 +334,7 @@

  • - #pass_find_return_values(values, current_conditions) ⇒ Object + #set_input_file(filename, starting_line = 0) ⇒ Object @@ -372,7 +348,9 @@

    -
    +
    +

    remember where the code for this SyntaxNode comes from.

    +

  • @@ -380,7 +358,7 @@

  • - #set_input_file(filename, starting_line = 0) ⇒ Object + #to_ast ⇒ SyntaxNode @@ -395,7 +373,7 @@

    -

    remember where the code for this SyntaxNode comes from.

    +

    convert SyntaxNode into an AstNode.

  • @@ -502,6 +480,21 @@

     
     
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
     93
     94
     95
    @@ -509,25 +502,10 @@ 

    97 98 99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115

    +100

    -
    # File 'lib/idl/ast.rb', line 93
    +      
    # File 'lib/idl/ast.rb', line 78
     
     def clone
       new_elements = nil
    @@ -601,18 +579,18 @@ 

     
     
    -82
    -83
    -84
    -85
    -86
    -87
    -88
    -89
    -90
    +67 +68 +69 +70 +71 +72 +73 +74 +75

    -
    # File 'lib/idl/ast.rb', line 82
    +      
    # File 'lib/idl/ast.rb', line 67
     
     def find_ancestor(klass)
       if parent.nil?
    @@ -626,76 +604,6 @@ 

    - - -
    -

    - - #gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object - - - - - -

    - - - - -
    -
    -
    -
    -4
    -5
    -6
    -7
    -8
    -9
    -10
    -11
    -12
    -13
    -14
    -15
    -16
    -17
    -18
    -19
    -20
    -21
    -22
    -23
    -24
    -25
    -26
    -
    -
    # File 'lib/idl/passes/gen_adoc.rb', line 4
    -
    -def gen_adoc(indent = 0, indent_spaces: 2)
    -  if terminal?
    -    text_value
    -  else
    -    adoc = ''
    -    next_pos = interval.begin
    -    elements.each do |e|
    -      if e.interval.size > 0 &&  e.interval.begin != next_pos
    -        adoc << input[next_pos..(e.interval.begin - 1)]
    -      end
    -      adoc << e.gen_adoc(indent+2, indent_spaces: 2)
    -      next_pos = e.interval.exclude_end? ? e.interval.end : (e.interval.end + 1)
    -    end
    -    if next_pos != (interval.exclude_end? ? interval.end : (interval.end + 1))
    -      end_pos = interval.exclude_end? ? interval.end - 1 : interval.end
    -      adoc << input[next_pos..end_pos]
    -    end
    -    if adoc != text_value && !text_value.index('xref').nil?
    -      raise
    -    end
    -    adoc
    -  end
    -end
    -
    @@ -872,12 +780,12 @@

     
     
    -77
    -78
    -79
    +62 +63 +64

    -
    # File 'lib/idl/ast.rb', line 77
    +      
    # File 'lib/idl/ast.rb', line 62
     
     def lineno
       input[0..interval.first].count("\n") + 1 + (@starting_line.nil? ? 0 : @starting_line)
    @@ -888,76 +796,33 @@ 

    -

    +

    - #make_leftSyntaxNode + #pass_find_return_values(values, current_conditions) ⇒ Object -

    -
    - -
    - Note: -
    -

    This may alter the SyntaxTree. You shouldn’t use pointers within the tree from before a call to make_left

    -
    -
    - - -

    Fix up left recursion for the PEG

    - -

    This is the default for anything that isn’t a left-recursive binary op

    - -

    Only left-recursive binary ops need to override this

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (SyntaxNode) - - - - — -
      -

      A fixed syntax tree

      -
      - -
    • - -
    - -
    +
    @@ -965,9 +830,9 @@

    -

    +

    - #parsing_in_template?Boolean + #prune(symtab) ⇒ AstNode @@ -976,26 +841,46 @@

    -

    Returns whether or not this SyntaxNode is being parsed as a template argument without being enclosed in parenthesis.

    +

    Returns A new abstract syntax tree with all dead/unreachable code removed.

    +

    Parameters:

    +
      + +
    • + + symtab + + + (Idl::SymbolTable) + + + + — +
      +

      Context of the compilation

      +
      + +
    • +
    +

    Returns:

    • - (Boolean) + (AstNode)
      -

      whether or not this SyntaxNode is being parsed as a template argument without being enclosed in parenthesis

      +

      A new abstract syntax tree with all dead/unreachable code removed

    • @@ -1008,77 +893,59 @@

       
       
      +11
      +12
      +13
      +14
      +15
      +16
      +17
      +18
      +19
      +20
      +21
      +22
      +23
      +24
      +25
      +26
      +27
      +28
      +29
      +30
      +31
       32
       33
       34
      -35
      -36
      -37
      -38
      -39
      -40
      -41
      -42
      -43
      -44
      -45
      -46
      -47
      -48
      +35

    - -
     
     
    -59
    -60
    -61
    -62
    -63
    -64
    +8 +9 +10 +11 +12
    -
    # File 'lib/idl/ast.rb', line 59
    +      
    # File 'lib/idl/passes/find_return_values.rb', line 8
     
    -def make_left
    -  elements.nil? || elements.length.times do |i|
    -    elements[i] = elements[i].make_left
    +def pass_find_return_values(values, current_conditions)
    +  children.each do |c|
    +    c.pass_find_return_values(values, current_conditions)
       end
    -  self
     end
    -
    # File 'lib/idl/ast.rb', line 32
    -
    -def parsing_in_template?
    -  # since this is called in the middle of parsing, the parent pointer hasn't been set up yet
    -  puts self.class.ancestors
    -  puts "text = #{text_value}"
    -  puts parent.class.name
    -  exit
    -  if parent.nil?
    -    nil
    -  elsif parent.is_a?(ParenExpressionAst)
    -    false # once we hit a paren expression, we are cleared
    -  elsif parent.is_a?(BitsTypeAst)
    -    puts "FOund bits!!"
    -    true # must be the expression on the BitsType
    -  else
    -    parent.parsing_in_template?
    +      
    # File 'lib/idl/passes/prune.rb', line 11
    +
    +def prune(symtab)
    +  new_elements = elements.nil? ? [] : elements.map { |e| e.prune(symtab) }
    +  new_node = clone # self.class.new(input, interval, new_elements)
    +  new_node.elements.clear
    +  new_node.elements.concat(new_elements)
    +
    +  # extension_modules.each do |m|
    +    # new_node.extend m
    +  # end
    +
    +  if is_a?(Idl::AstNode)
    +    begin
    +      if new_node.is_a?(Idl::Declaration)
    +        new_node.add_symbol(symtab)
    +      end
    +      if new_node.is_a?(Idl::Executable)
    +        new_node.execute(symtab) # to update values
    +      end
    +    rescue Idl::AstNode::ValueError
    +      # new_node.type_check(symtab)
    +    end
       end
    -end
    -
    -
    - -
    -

    - - #pass_find_return_values(values, current_conditions) ⇒ Object - - - - -

    - - - @@ -1149,23 +1016,110 @@

     
     
    -70
    -71
    -72
    -73
    -74
    +52 +53 +54 +55 +56 +57 +58 +59

    -
    -
    -
    -8
    -9
    -10
    -11
    -12
    -
    -
    # File 'lib/idl/passes/find_return_values.rb', line 8
    -
    -def pass_find_return_values(values, current_conditions)
    -  children.each do |c|
    -    c.pass_find_return_values(values, current_conditions)
    -  end
    +  new_node
     end
    -
    # File 'lib/idl/ast.rb', line 70
    +      
    # File 'lib/idl/ast.rb', line 52
     
     def set_input_file(filename, starting_line = 0)
       @input_file = filename
       @starting_line = starting_line
    +  elements.nil? || elements.length.times do |i|
    +    elements[i].set_input_file(filename, starting_line)
    +  end
       raise "?" if @starting_line.nil?
     end
    +
    + +
    +

    + + #to_astSyntaxNode + + + + + +

    +
    + +
    + Note: +
    +

    This may alter the SyntaxTree. You shouldn’t use pointers within the tree from before a call to to_ast

    +
    +
    + + +

    convert SyntaxNode into an AstNode

    + +

    Mostly, there is a 1:1 correspondence between SyntaxNode and AstNode. A few exceptions:

    + +
    * Left recusrion needs fixed up, so BinaryExpreesions are converted
    +* If statements are converted to a more friendly format
    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (SyntaxNode) + + + + — +
      +

      A fixed syntax tree

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +40
    +41
    +42
    +43
    +44
    +45
    +46
    +
    +
    # File 'lib/idl/ast.rb', line 40
    +
    +def to_ast
    +  elements.nil? || elements.length.times do |i|
    +    elements[i] = elements[i].to_ast
    +    elements[i].parent = self
    +  end
    +  self
    +end
    +
    @@ -1173,7 +1127,7 @@

    diff --git a/docs/ruby/Validator.html b/docs/ruby/Validator.html index 4f6873123..1ea0c8632 100644 --- a/docs/ruby/Validator.html +++ b/docs/ruby/Validator.html @@ -655,7 +655,7 @@

    diff --git a/docs/ruby/Validator/SchemaError.html b/docs/ruby/Validator/SchemaError.html index ae7b30392..f425aae4c 100644 --- a/docs/ruby/Validator/SchemaError.html +++ b/docs/ruby/Validator/SchemaError.html @@ -299,7 +299,7 @@

    diff --git a/docs/ruby/Validator/ValidationError.html b/docs/ruby/Validator/ValidationError.html index 7ad3deeaf..23f18055c 100644 --- a/docs/ruby/Validator/ValidationError.html +++ b/docs/ruby/Validator/ValidationError.html @@ -369,7 +369,7 @@

    diff --git a/docs/ruby/_index.html b/docs/ruby/_index.html index da2c6fcac..d57ba1be3 100644 --- a/docs/ruby/_index.html +++ b/docs/ruby/_index.html @@ -110,7 +110,7 @@

    Namespace Listing A-Z

  • - AryAccess + AryAccessSyntaxNode (Idl) @@ -130,6 +130,13 @@

    Namespace Listing A-Z

  • +
  • + AryElementAssignmentSyntaxNode + + (Idl) + +
  • +
  • AryRangeAccessAst @@ -181,7 +188,7 @@

    Namespace Listing A-Z

  • - BinaryExpressionRightAst + BinaryExpressionRightSyntaxNode (Idl) @@ -216,21 +223,35 @@

    Namespace Listing A-Z

  • - BitsTypeAst + BuiltinEnumDefinitionAst (Idl)
  • - BuiltinEnumDefinitionAst + BuiltinTypeNameAst (Idl)
  • - BuiltinTypeNameAst + BuiltinTypeNameSyntaxNode + + (Idl) + +
  • + +
  • + BuiltinVariableAst + + (Idl) + +
  • + +
  • + BuiltinVariableSyntaxNode (Idl) @@ -279,6 +300,13 @@

    Namespace Listing A-Z

  • +
  • + ConditionalStatementSyntaxNode + + (Idl) + +
  • +
  • Csr @@ -339,6 +367,13 @@

    Namespace Listing A-Z

  • D
  • +
    + + + + + +
    +
    Note
    +
    +If you forget, don’t worry. Setup will be invoked by any program in bin/ if necessary. +
    +
    +
    +

    VSCode

    If using Visual Studio Code and want to use development tools, you will need to restart the editor after setup.

    @@ -128,6 +176,11 @@

    Setup

    +
    +

    The .vscode/settings.json file in the repo will ensure that Solargraph works without any additional +configuration (assuming you’ve already run ./bin/setup).

    +
    +
    diff --git a/docs/ruby/index.html b/docs/ruby/index.html index 3f8bc7a60..990e16bdd 100644 --- a/docs/ruby/index.html +++ b/docs/ruby/index.html @@ -57,7 +57,41 @@
    -
    +
    +
    +
    +

    The RISC-V Unified Database is intended to hold all the information needed to describe RISC-V, +including a list of extensions, instruction specifications, CSR specifications, and documentation prose. The vision is that anything one would need for RISC-V can be generated from the information in this repository.

    +
    +
    +

    This repository contains:

    +
    +
    +
      +
    • +

      A (eventually complete) description of the RISC-V specification in a machine-readable format.

      +
    • +
    • +

      A tool to generate multiple views of that spec, including:

      +
      +
        +
      • +

        A configuration-specific, human-readable documentation webpage

        +
      • +
      • +

        [COMING SOON] A configuration-specific Instruction Set Simulator

        +
      • +
      • +

        More backends are planned

        +
      • +
      +
      +
    • +
    +
    +
    +
    +

    Prerequisites

    @@ -105,6 +139,20 @@

    Setup

    # DEVELOPMENT=1 ./bin/setup
    +
    + + + + + +
    +
    Note
    +
    +If you forget, don’t worry. Setup will be invoked by any program in bin/ if necessary. +
    +
    +
    +

    VSCode

    If using Visual Studio Code and want to use development tools, you will need to restart the editor after setup.

    @@ -128,6 +176,11 @@

    Setup

    +
    +

    The .vscode/settings.json file in the repo will ensure that Solargraph works without any additional +configuration (assuming you’ve already run ./bin/setup).

    +
    +
    diff --git a/docs/ruby/method_list.html b/docs/ruby/method_list.html index 8ebbff803..25dc25cdb 100644 --- a/docs/ruby/method_list.html +++ b/docs/ruby/method_list.html @@ -117,6 +117,62 @@

    Method List

  • +
    + #add_symbol + Idl::Declaration +
    +
  • + + +
  • +
    + #add_symbol + Idl::EnumDefinitionAst +
    +
  • + + +
  • +
    + #add_symbol + Idl::BitfieldDefinitionAst +
    +
  • + + +
  • +
    + #add_symbol + Idl::MultiVariableDeclarationAst +
    +
  • + + +
  • +
    + #add_symbol + Idl::VariableDeclarationAst +
    +
  • + + +
  • +
    + #add_symbol + Idl::VariableDeclarationWithInitializationAst +
    +
  • + + +
  • +
    + #add_symbol + Idl::FunctionDefAst +
    +
  • + + +
  • #alias DecodeVariable @@ -124,7 +180,7 @@

    Method List

  • -
  • +
  • #alias CsrField @@ -132,7 +188,7 @@

    Method List

  • -
  • +
  • #all_known_csr_names ArchDef @@ -140,7 +196,7 @@

    Method List

  • -
  • +
  • #all_known_exts ArchGen @@ -148,7 +204,7 @@

    Method List

  • -
  • +
  • #apply_arguments Idl::FunctionType @@ -156,7 +212,7 @@

    Method List

  • -
  • +
  • #apply_template_values Idl::FunctionType @@ -164,7 +220,7 @@

    Method List

  • -
  • +
  • #arch_def CsrField @@ -172,7 +228,7 @@

    Method List

  • -
  • +
  • #arch_def Csr @@ -180,7 +236,7 @@

    Method List

  • -
  • +
  • #arch_def Instruction @@ -188,7 +244,7 @@

    Method List

  • -
  • +
  • #arch_def Extension @@ -196,14 +252,6 @@

    Method List

  • -
  • -
    - #arch_def - ExtensionVersion -
    -
  • - -
  • #archdef @@ -277,14 +325,6 @@

    Method List

  • -
    - #ast - Idl::TemplateFunctionType -
    -
  • - - -
  • #base32_only? CsrField @@ -292,7 +332,7 @@

    Method List

  • -
  • +
  • #base64_only? CsrField @@ -300,7 +340,7 @@

    Method List

  • -
  • +
  • #bf_type Idl::FieldAssignmentAst @@ -308,7 +348,7 @@

    Method List

  • -
  • +
  • #bitfields Idl::IsaAst @@ -316,7 +356,7 @@

    Method List

  • -
  • +
  • #bits DecodeVariable @@ -324,7 +364,7 @@

    Method List

  • -
  • +
  • #bits DecodeField @@ -332,7 +372,7 @@

    Method List

  • -
  • +
  • #body Idl::FunctionDefAst @@ -340,6 +380,14 @@

    Method List

  • +
  • +
    + #body + Idl::ElseIfAst +
    +
  • + +
  • #body @@ -405,6 +453,14 @@

    Method List

  • +
    + #class_name + Idl::EnumRefAst +
    +
  • + + +
  • #clone Treetop::Runtime::SyntaxNode @@ -412,7 +468,7 @@

    Method List

  • -
  • +
  • #clone Idl::Type @@ -420,7 +476,7 @@

    Method List

  • -
  • +
  • #clone Idl::EnumerationType @@ -428,7 +484,7 @@

    Method List

  • -
  • +
  • #clone Idl::BitfieldType @@ -436,7 +492,7 @@

    Method List

  • -
  • +
  • #clone Idl::FunctionType @@ -444,7 +500,7 @@

    Method List

  • -
  • +
  • #clone Idl::Var @@ -452,7 +508,7 @@

    Method List

  • -
  • +
  • #comparable_to? Idl::Type @@ -460,6 +516,14 @@

    Method List

  • +
  • +
    + #compile_expression + Idl::Compiler +
    +
  • + +
  • #compile_file @@ -485,6 +549,14 @@

    Method List

  • +
    + #cond + Idl::ElseIfAst +
    +
  • + + +
  • #condition Idl::TernaryOperatorExpressionAst @@ -492,7 +564,7 @@

    Method List

  • -
  • +
  • #condition Idl::ConditionalStatementAst @@ -500,7 +572,7 @@

    Method List

  • -
  • +
  • #condition Idl::ConditionalReturnStatementAst @@ -508,6 +580,14 @@

    Method List

  • +
  • +
    + #condition + Idl::ForLoopAst +
    +
  • + +
  • #config_params @@ -517,6 +597,14 @@

    Method List

  • +
    + #config_params + MockArchDef +
    +
  • + + +
  • #const? Idl::Type @@ -524,7 +612,7 @@

    Method List

  • -
  • +
  • #const? Idl::Var @@ -532,7 +620,7 @@

    Method List

  • -
  • +
  • #convertable_to? Idl::Type @@ -540,7 +628,7 @@

    Method List

  • -
  • +
  • #csr ArchDef @@ -548,7 +636,7 @@

    Method List

  • -
  • +
  • #csr Idl::CsrType @@ -556,7 +644,7 @@

    Method List

  • -
  • +
  • #csr_def Idl::CsrFieldReadExpressionAst @@ -564,7 +652,7 @@

    Method List

  • -
  • +
  • #csr_def Idl::CsrReadExpressionAst @@ -572,7 +660,7 @@

    Method List

  • -
  • +
  • #csr_def Idl::CsrSoftwareReadAst @@ -580,7 +668,7 @@

    Method List

  • -
  • +
  • #csr_def Idl::CsrWriteAst @@ -588,7 +676,7 @@

    Method List

  • -
  • +
  • #csr_hash ArchDef @@ -596,7 +684,7 @@

    Method List

  • -
  • +
  • #csr_known? Idl::CsrReadExpressionAst @@ -604,7 +692,7 @@

    Method List

  • -
  • +
  • #csr_known? Idl::CsrSoftwareWriteAst @@ -612,7 +700,7 @@

    Method List

  • -
  • +
  • #csr_known? Idl::CsrSoftwareReadAst @@ -620,7 +708,7 @@

    Method List

  • -
  • +
  • #csr_name Idl::CsrFieldReadExpressionAst @@ -628,7 +716,7 @@

    Method List

  • -
  • +
  • #csr_name Idl::CsrReadExpressionAst @@ -636,7 +724,7 @@

    Method List

  • -
  • +
  • #csr_name Idl::CsrSoftwareWriteAst @@ -644,7 +732,7 @@

    Method List

  • -
  • +
  • #csr_name Idl::CsrSoftwareReadAst @@ -652,7 +740,7 @@

    Method List

  • -
  • +
  • #csrs ArchDef @@ -660,7 +748,7 @@

    Method List

  • -
  • +
  • #data ArchDef @@ -668,7 +756,7 @@

    Method List

  • -
  • +
  • #decl_type Idl::VariableDeclarationAst @@ -676,7 +764,7 @@

    Method List

  • -
  • +
  • #decode_var? Idl::Var @@ -684,7 +772,7 @@

    Method List

  • -
  • +
  • #decode_variable DecodeField @@ -692,7 +780,7 @@

    Method List

  • -
  • +
  • #decode_variables Instruction::Encoding @@ -700,7 +788,7 @@

    Method List

  • -
  • +
  • #decode_variables Instruction @@ -708,7 +796,7 @@

    Method List

  • -
  • +
  • #deep_clone Idl::SymbolTable @@ -716,7 +804,23 @@

    Method List

  • +
  • +
    + #default + Idl::Type +
    +
  • + +
  • +
    + #defined_by? + Instruction +
    +
  • + + +
  • #defined_in_all_bases? CsrField @@ -724,7 +828,7 @@

    Method List

  • -
  • +
  • #description Idl::FunctionDefAst @@ -732,7 +836,7 @@

    Method List

  • -
  • +
  • #description_html Csr @@ -740,7 +844,7 @@

    Method List

  • -
  • +
  • #dynamic_length? Csr @@ -748,7 +852,7 @@

    Method List

  • -
  • +
  • #dynamic_location? CsrField @@ -756,7 +860,7 @@

    Method List

  • -
  • +
  • #element_names Idl::EnumDefinitionAst @@ -764,7 +868,7 @@

    Method List

  • -
  • +
  • #element_names Idl::BitfieldDefinitionAst @@ -772,7 +876,7 @@

    Method List

  • -
  • +
  • #element_names Idl::EnumerationType @@ -780,7 +884,7 @@

    Method List

  • -
  • +
  • #element_nodes Idl::ArrayLiteralAst @@ -788,7 +892,7 @@

    Method List

  • -
  • +
  • #element_ranges Idl::BitfieldDefinitionAst @@ -796,7 +900,7 @@

    Method List

  • -
  • +
  • #element_values Idl::EnumDefinitionAst @@ -804,7 +908,7 @@

    Method List

  • -
  • +
  • #element_values Idl::EnumerationType @@ -812,6 +916,14 @@

    Method List

  • +
  • +
    + #elseifs + Idl::IfAst +
    +
  • + +
  • #enclosing_function @@ -829,6 +941,14 @@

    Method List

  • +
    + #encoding_width + Instruction +
    +
  • + + +
  • #enum_class Idl::Type @@ -836,7 +956,7 @@

    Method List

  • -
  • +
  • #enums Idl::IsaAst @@ -844,7 +964,7 @@

    Method List

  • -
  • +
  • #eql? EncodingField @@ -852,7 +972,7 @@

    Method List

  • -
  • +
  • #eql? DecodeVariable @@ -860,7 +980,7 @@

    Method List

  • -
  • +
  • #eql? DecodeField @@ -868,7 +988,7 @@

    Method List

  • -
  • +
  • #equal_to? Idl::Type @@ -876,7 +996,7 @@

    Method List

  • -
  • +
  • #exception_codes ArchGen @@ -884,6 +1004,14 @@

    Method List

  • +
  • +
    + #excluded_by? + Instruction +
    +
  • + +
  • #execute @@ -934,72 +1062,72 @@

    Method List

  • - #execute - Idl::MultiVariableDeclarationAst + #execute + Idl::VariableDeclarationWithInitializationAst
  • - #execute - Idl::VariableDeclarationAst + #execute + Idl::PostDecrementExpressionAst
  • - #execute - Idl::VariableDeclarationWithInitializationAst + #execute + Idl::PostIncrementExpressionAst
  • - #execute - Idl::PostDecrementExpressionAst + #execute + Idl::NoopAst
  • - #execute - Idl::PostIncrementExpressionAst + #execute + Idl::StatementAst
  • - #execute - Idl::StatementAst + #execute + Idl::ConditionalStatementAst
  • - #execute - Idl::ConditionalStatementAst + #execute + Idl::InstructionOperationAst
  • - #execute - Idl::FunctionStatementAst + #execute + Idl::IfBodyAst
  • - #execute - Idl::InstructionOperationAst + #execute + Idl::CsrSoftwareWriteAst
  • @@ -1013,6 +1141,14 @@

    Method List

  • +
    + #exists_in_cfg? + Instruction +
    +
  • + + +
  • #exp Idl::UnaryOperatorExpressionAst @@ -1020,7 +1156,7 @@

    Method List

  • -
  • +
  • #expected_return_type Idl::ReturnStatementAst @@ -1028,34 +1164,42 @@

    Method List

  • +
  • +
    + #expression + Idl::SignCastAst +
    +
  • + +
  • - #ext? - ArchDef + #expression + Idl::ParenExpressionAst
  • - #extension - Instruction + #ext? + ArchDef
  • - #extension - ExtensionVersion + #extension + ArchDef
  • - #extension - ArchDef + #extension_exclusions + Instruction
  • @@ -1069,6 +1213,14 @@

    Method List

  • +
    + #extension_requirements + Instruction +
    +
  • + + +
  • #extensions ArchDef @@ -1076,6 +1228,14 @@

    Method List

  • +
  • +
    + #extensions + MockArchDef +
    +
  • + +
  • #extract @@ -1196,6 +1356,22 @@

    Method List

  • +
  • +
    + #final_else_body + Idl::IfAst +
    +
  • + + +
  • +
    + #find_all + Idl::SymbolTable +
    +
  • + +
  • #find_ancestor @@ -1238,375 +1414,375 @@

    Method List

  • - #gen_adoc - Treetop::Runtime::SyntaxNode + #gen_adoc + Idl::AstNode
  • - #gen_adoc - Idl::AryRangeAccessAst + #gen_adoc + Idl::EnumRefAst
  • - #gen_adoc - Idl::FunctionCallExpressionAst + #gen_adoc + Idl::ParenExpressionAst
  • - #gen_dir - ArchGen + #gen_adoc + Idl::IntLiteralAst
  • - #generate - ArchGen + #gen_adoc + Idl::IdAst
  • - #get - Idl::SymbolTable + #gen_adoc + Idl::SignCastAst
  • - #globals - Idl::IsaAst + #gen_adoc + Idl::AryRangeAccessAst
  • - #grouped_encoding_fields - DecodeVariable + #gen_adoc + Idl::VariableDeclarationAst
  • - #grouped_encoding_fields - DecodeField + #gen_adoc + Idl::TernaryOperatorExpressionAst
  • - #has_custom_sw_read? - Csr + #gen_adoc + Idl::BuiltinTypeNameAst
  • - #has_custom_write? - CsrField + #gen_adoc + Idl::ForLoopAst
  • - #has_template_ancestor? - Treetop::Runtime::SyntaxNode + #gen_adoc + Idl::BuiltinVariableAst
  • - #hash - EncodingField + #gen_adoc + Idl::VariableDeclarationWithInitializationAst
  • - #hash - DecodeVariable + #gen_adoc + Idl::AryElementAccessAst
  • - #hash - DecodeField + #gen_adoc + Idl::BinaryExpressionAst
  • - #idl_compiler - ArchDef + #gen_adoc + Idl::VariableAssignmentAst
  • - #implemented_csr - ArchDef + #gen_adoc + Idl::AryElementAssignmentAst
  • - #implemented_csr_hash - ArchDef + #gen_adoc + Idl::StatementAst
  • - #implemented_csrs - ArchDef + #gen_adoc + Idl::UnaryOperatorExpressionAst
  • - #implemented_csrs - ArchGen + #gen_adoc + Idl::ReturnStatementAst
  • - #implemented_extensions - ArchDef + #gen_adoc + Idl::ReplicationExpressionAst
  • - #implemented_extensions - ArchGen + #gen_adoc + Idl::ConditionalStatementAst
  • - #implemented_fields - Csr + #gen_adoc + Idl::FunctionCallExpressionAst
  • - #implemented_fields_for - Csr + #gen_adoc + Idl::FunctionBodyAst
  • - #implemented_instructions - ArchDef + #gen_adoc + Idl::CsrFieldReadExpressionAst
  • - #implemented_instructions - ArchGen + #gen_adoc + Idl::CsrReadExpressionAst
  • - #implies - Extension + #gen_adoc + Idl::IfAst
  • - #index - Idl::AryElementAccessAst + #gen_dir + ArchGen
  • - #initialize - Idl::Compiler + #generate + ArchGen
  • - #initialize - Idl::AstNode::TypeError + #get + Idl::SymbolTable
  • - #initialize - Idl::AstNode::InternalError + #get_from + Idl::SymbolTable
  • - #initialize - Idl::AstNode::ValueError + #get_global + Idl::SymbolTable
  • - #initialize - Idl::AryElementAccessAst + #global_ast + ArchDef
  • - #initialize - Idl::AryRangeAccessAst + #globals + Idl::IsaAst
  • - #initialize - Idl::BinaryExpressionAst + #grouped_encoding_fields + DecodeVariable
  • - #initialize - EncodingField + #grouped_encoding_fields + DecodeField
  • - #initialize - DecodeVariable + #has_custom_sw_read? + Csr
  • - #initialize - DecodeField + #has_custom_write? + CsrField
  • - #initialize - ArchDefObject + #has_template_ancestor? + Treetop::Runtime::SyntaxNode
  • - #initialize - CsrField + #hash + EncodingField
  • - #initialize - Csr + #hash + DecodeVariable
  • - #initialize - Instruction::Encoding::Field + #hash + DecodeField
  • - #initialize - Instruction::Encoding + #idl_compiler + ArchDef
  • - #initialize - Instruction + #idx + Idl::AryElementAssignmentAst
  • - #initialize - Extension + #if_body + Idl::IfAst
  • - #initialize - ExtensionVersion + #if_cond + Idl::IfAst
  • @@ -1614,591 +1790,591 @@

    Method List

  • - #initialize - ArchGen + #implemented_csr_hash + ArchDef
  • - #initialize - Idl::Type + #implemented_csrs + ArchDef
  • - #initialize - Idl::EnumerationType + #implemented_csrs + ArchGen
  • - #initialize - Idl::BitfieldType + #implemented_extensions + ArchDef
  • - #initialize - Idl::CsrType + #implemented_extensions + ArchGen
  • - #initialize - Idl::FunctionType + #implemented_fields + Csr
  • - #initialize - Idl::TemplateFunctionType + #implemented_fields_for + Csr
  • - #initialize - Idl::XregType + #implemented_instructions + ArchDef
  • - #initialize - Validator::SchemaError + #implemented_instructions + ArchGen
  • - #initialize - Validator::ValidationError + #implies + Extension
  • - #initialize - Validator + #index + Idl::AryElementAccessAst
  • - #initialize - Idl::Var + #init + Idl::ForLoopAst
  • - #initialize - Idl::SymbolTable + #initialize + Idl::Compiler
  • - #input_file - Treetop::Runtime::CompiledParser + #initialize + Idl::AstNode::TypeError
  • - #input_file - Treetop::Runtime::SyntaxNode + #initialize + Idl::AstNode::InternalError
  • - insn_table - Opcodes + #initialize + Idl::AstNode::ValueError
  • - #inspect - ArchDefObject + #initialize + Idl::IdAst
  • - #inst - ArchDef + #initialize + Idl::AryElementAccessAst
  • - #inst_pos_to_var_pos - DecodeVariable + #initialize + Idl::AryRangeAccessAst
  • - #instantiate_node - Treetop::Runtime::CompiledParser + #initialize + Idl::VariableAssignmentAst
  • - #instruction_hash - ArchDef + #initialize + Idl::AryElementAssignmentAst
  • - #instructions - Idl::IsaAst + #initialize + Idl::VariableDeclarationWithInitializationAst
  • - #instructions - ArchDef + #initialize + Idl::SignCastAst
  • - #integral? - Idl::Type + #initialize + Idl::BinaryExpressionAst
  • - #internal_error - Idl::AstNodeFuncs + #initialize + Idl::ParenExpressionAst
  • - #interrupt_codes - ArchGen + #initialize + Idl::ReplicationExpressionAst
  • - #invert - Idl::BinaryExpressionAst + #initialize + Idl::BuiltinVariableAst
  • - #invert - Idl::ParenExpressionAst + #initialize + Idl::EnumRefAst
  • - #is_function_name? - Treetop::Runtime::SyntaxNode + #initialize + Idl::TernaryOperatorExpressionAst
  • - #key? - Idl::SymbolTable + #initialize + Idl::NoopAst
  • - #keys - ArchDefObject + #initialize + Idl::StatementAst
  • - #kind - Idl::FieldAssignmentAst + #initialize + Idl::ConditionalStatementAst
  • - #kind - Idl::BitfieldAccessExpressionAst + #initialize + Idl::DontCareReturnAst
  • - #kind - Idl::Type + #initialize + Idl::BuiltinTypeNameAst
  • - #left_shift - DecodeVariable + #initialize + Idl::IntLiteralAst
  • - #length - Csr + #initialize + Idl::FunctionCallExpressionAst
  • - #length_cond32 - Csr + #initialize + Idl::FunctionBodyAst
  • - #length_cond64 - Csr + #initialize + Idl::ForLoopAst
  • - #length_pretty - Csr + #initialize + Idl::IfBodyAst
  • - #levels - Idl::SymbolTable + #initialize + Idl::ElseIfAst
  • - #lhs - Idl::AssignmentAst + #initialize + Idl::IfAst
  • - #lhs - Idl::VariableAssignmentAst + #initialize + EncodingField
  • - #lhs - Idl::AryElementAssignmentAst + #initialize + DecodeVariable
  • - #lhs - Idl::AryRangeAssignmentAst + #initialize + DecodeField
  • - #lhs - Idl::VariableDeclarationWithInitializationAst + #initialize + ArchDefObject
  • - #lhs - Idl::BinaryExpressionAst + #initialize + CsrField
  • - #lhs_type - Idl::VariableDeclarationWithInitializationAst + #initialize + Csr
  • - #lineno - Treetop::Runtime::SyntaxNode + #initialize + Instruction::Encoding::Field
  • - #lineno - Idl::AstNode::ValueError + #initialize + Instruction::Encoding
  • - #location - CsrField + #initialize + Extension
  • - #location_pretty - CsrField + #initialize + ExtensionVersion
  • - #lsb - Idl::AryRangeAccessAst + #initialize + ExtensionRequirement
  • - #make_const - Idl::Type + #initialize + ArchDef
  • - #make_left - Treetop::Runtime::SyntaxNode + #initialize + ArchGen
  • - #make_left - Idl::AryAccess + #initialize + Idl::Type
  • - #make_left - Idl::BinaryExpressionRightAst + #initialize + Idl::EnumerationType
  • - #make_signed - Idl::Type + #initialize + Idl::BitfieldType
  • - #method_missing - ArchDefObject + #initialize + Idl::CsrType
  • - #msb - Idl::AryRangeAccessAst + #initialize + Idl::FunctionType
  • - #multi_encoding? - Instruction + #initialize + Idl::XregType
  • - #multi_xlen? - ArchDef + #initialize + Validator::SchemaError
  • - #mutable? - Idl::Type + #initialize + Validator::ValidationError
  • - #name - Idl::IdAst + #initialize + Validator
  • - #name - Idl::EnumDefinitionAst + #initialize + Idl::Var
  • - #name - Idl::BitfieldDefinitionAst + #initialize + Idl::SymbolTable
  • - #name - Idl::FunctionCallExpressionAst + #initialize + MockExtension
  • - #name - Idl::FunctionDefAst + #input_file + Treetop::Runtime::CompiledParser
  • - #name - Idl::CsrWriteAst + #input_file + Treetop::Runtime::SyntaxNode
  • - #name - EncodingField + insn_table + Opcodes
  • - #name - DecodeVariable + #inspect + ArchDefObject
  • - #name - DecodeField + #inst + ArchDef
  • - #name - Instruction::Encoding::Field + #inst_pos_to_var_pos + DecodeVariable
  • - #name - ExtensionVersion + #instantiate_node + Treetop::Runtime::CompiledParser
  • - #name + #instruction_hash ArchDef
  • @@ -2206,151 +2382,983 @@

    Method List

  • - #name - ArchGen + #instructions + Idl::IsaAst
  • - #name - Idl::Type + #instructions + Extension
  • - #name - Idl::Var + #instructions + ArchDef
  • - #nodes - Idl::AstNodeFuncs + #integral? + Idl::Type
  • - #num_args - Idl::FunctionDefAst -
    + #internal_error + Idl::AstNodeFuncs + +
  • + + +
  • +
    + #interrupt_codes + ArchGen +
    +
  • + + +
  • +
    + #invert + Idl::BinaryExpressionAst +
    +
  • + + +
  • +
    + #invert + Idl::ParenExpressionAst +
    +
  • + + +
  • +
    + #is_function_name? + Treetop::Runtime::SyntaxNode +
    +
  • + + +
  • +
    + #key? + Idl::SymbolTable +
    +
  • + + +
  • +
    + #keys + ArchDefObject +
    +
  • + + +
  • +
    + #keys_pretty + Idl::SymbolTable +
    +
  • + + +
  • +
    + #kind + Idl::FieldAssignmentAst +
    +
  • + + +
  • +
    + #kind + Idl::BitfieldAccessExpressionAst +
    +
  • + + +
  • +
    + #kind + Idl::Type +
    +
  • + + +
  • +
    + #left_shift + DecodeVariable +
    +
  • + + +
  • +
    + #length + Csr +
    +
  • + + +
  • +
    + #length_cond32 + Csr +
    +
  • + + +
  • +
    + #length_cond64 + Csr +
    +
  • + + +
  • +
    + #length_pretty + Csr +
    +
  • + + +
  • +
    + #levels + Idl::SymbolTable +
    +
  • + + +
  • +
    + #lhs + Idl::AssignmentAst +
    +
  • + + +
  • +
    + #lhs + Idl::VariableAssignmentAst +
    +
  • + + +
  • +
    + #lhs + Idl::AryElementAssignmentAst +
    +
  • + + +
  • +
    + #lhs + Idl::AryRangeAssignmentAst +
    +
  • + + +
  • +
    + #lhs + Idl::VariableDeclarationWithInitializationAst +
    +
  • + + +
  • +
    + #lhs + Idl::BinaryExpressionAst +
    +
  • + + +
  • +
    + #lhs_type + Idl::VariableDeclarationWithInitializationAst +
    +
  • + + +
  • +
    + #lineno + Treetop::Runtime::SyntaxNode +
    +
  • + + +
  • +
    + #lineno + Idl::AstNode::ValueError +
    +
  • + + +
  • +
    + #location + CsrField +
    +
  • + + +
  • +
    + #location_pretty + CsrField +
    +
  • + + +
  • +
    + #lsb + Idl::AryRangeAccessAst +
    +
  • + + +
  • +
    + #make_const + Idl::Type +
    +
  • + + +
  • +
    + #make_signed + Idl::Type +
    +
  • + + +
  • +
    + #member_name + Idl::EnumRefAst +
    +
  • + + +
  • +
    + #method_missing + ArchDefObject +
    +
  • + + +
  • +
    + #msb + Idl::AryRangeAccessAst +
    +
  • + + +
  • +
    + #multi_encoding? + Instruction +
    +
  • + + +
  • +
    + #multi_xlen? + ArchDef +
    +
  • + + +
  • +
    + #mutable? + Idl::Type +
    +
  • + + +
  • +
    + #n + Idl::ReplicationExpressionAst +
    +
  • + + +
  • +
    + #name + Idl::IdAst +
    +
  • + + +
  • +
    + #name + Idl::EnumDefinitionAst +
    +
  • + + +
  • +
    + #name + Idl::BitfieldDefinitionAst +
    +
  • + + +
  • +
    + #name + Idl::BuiltinVariableAst +
    +
  • + + +
  • +
    + #name + Idl::FunctionCallExpressionAst +
    +
  • + + +
  • +
    + #name + Idl::FunctionDefAst +
    +
  • + + +
  • +
    + #name + Idl::CsrWriteAst +
    +
  • + + +
  • +
    + #name + EncodingField +
    +
  • + + +
  • +
    + #name + DecodeVariable +
    +
  • + + +
  • +
    + #name + DecodeField +
    +
  • + + +
  • +
    + #name + Instruction::Encoding::Field +
    +
  • + + +
  • +
    + #name + ExtensionVersion +
    +
  • + + +
  • +
    + #name + ExtensionRequirement +
    +
  • + + +
  • +
    + #name + ArchDef +
    +
  • + + +
  • +
    + #name + ArchGen +
    +
  • + + +
  • +
    + #name + Idl::Type +
    +
  • + + +
  • +
    + #name + Idl::Var +
    +
  • + + +
  • +
    + #name + MockExtension +
    +
  • + + +
  • +
    + #nodes + Idl::AstNodeFuncs +
    +
  • + + +
  • +
    + #num_args + Idl::FunctionDefAst +
    +
  • + + +
  • +
    + #num_args + Idl::FunctionType +
    +
  • + + +
  • +
    + #op + Idl::BinaryExpressionAst +
    +
  • + + +
  • +
    + #op + Idl::UnaryOperatorExpressionAst +
    +
  • + + +
  • +
    + #opcode? + EncodingField +
    +
  • + + +
  • +
    + #opcode? + Instruction::Encoding::Field +
    +
  • + + +
  • +
    + #opcode_fields + Instruction::Encoding +
    +
  • + + +
  • +
    + #operation_ast + Instruction +
    +
  • + + +
  • +
    + #orig_instantiate_node + Treetop::Runtime::CompiledParser +
    +
  • + + +
  • +
    + #params + ArchGen +
    +
  • + + +
  • +
    + #parent + CsrField +
    +
  • + + +
  • +
    + #pass_find_return_values + Treetop::Runtime::SyntaxNode +
    +
  • + + +
  • +
    + #pass_find_return_values + Idl::ReturnStatementAst +
    +
  • + + +
  • +
    + #pass_find_return_values + Idl::IfAst +
    +
  • + + +
  • +
    + #pass_find_return_values + Idl::FunctionBodyAst +
    +
  • + + +
  • +
    + #pop + Idl::SymbolTable +
    +
  • + + +
  • +
    + #pretty_to_s + EncodingField +
    +
  • + + +
  • +
    + #print + Idl::SymbolTable +
    +
  • + + +
  • +
    + #print_ast + Idl::AstNodeFuncs +
    +
  • + + +
  • +
    + #prune + Treetop::Runtime::SyntaxNode +
    +
  • + + +
  • +
    + #prune + Idl::AstNode +
    +
  • + + +
  • +
    + #prune + Idl::FunctionCallExpressionAst +
    +
  • + + +
  • +
    + #prune + Idl::FunctionBodyAst +
    +
  • + + +
  • +
    + #prune + Idl::StatementAst +
    +
  • + + +
  • +
    + #prune + Idl::AryElementAccessAst +
    +
  • + + +
  • +
    + #prune + Idl::AryRangeAccessAst +
    +
  • + + +
  • +
    + #prune + Idl::BinaryExpressionAst +
    +
  • + + +
  • +
    + #prune + Idl::IfBodyAst +
    +
  • + + +
  • +
    + #prune + Idl::ElseIfAst +
    +
  • + + +
  • +
    + #prune + Idl::IfAst +
    +
  • + + +
  • +
    + #prune + Idl::ConditionalStatementAst +
    +
  • + + +
  • +
    + #pruned_operation_ast + Instruction +
    +
  • + + +
  • +
    + #push + Idl::SymbolTable +
    +
  • + + +
  • +
    + #qualifiers + Idl::Type +
    +
  • + + +
  • +
    + #qualify + Idl::Type +
    +
  • + + +
  • +
    + #range + EncodingField +
    +
  • + + +
  • +
    + #range + CsrField::Alias +
    +
  • + + +
  • +
    + #range + Instruction::Encoding::Field +
    +
  • + + +
  • +
    + #range + Idl::BitfieldType +
    +
  • + + +
  • +
    + #reset_value + CsrField +
  • - #num_args + #reset_value_func + CsrField +
    +
  • + + +
  • +
    + #respond_to_missing? + ArchDefObject +
    +
  • + + +
  • +
    + #result + Validator::SchemaError +
    +
  • + + +
  • +
    + #result + Validator::ValidationError +
    +
  • + + +
  • +
    + #return_type + Idl::ReturnStatementAst +
    +
  • + + +
  • +
    + #return_type + Idl::FunctionDefAst +
    +
  • + + +
  • +
    + #return_type + Idl::Type +
    +
  • + + +
  • +
    + #return_type Idl::FunctionType
  • +
  • +
    + #return_type_list_str + Idl::FunctionDefAst +
    +
  • + +
  • - #op - Idl::BinaryExpressionAst + #return_types + Idl::ReturnStatementAst
  • - #op - Idl::UnaryOperatorExpressionAst + #return_types + Idl::FunctionType
  • - #opcode? - EncodingField + #return_value + Idl::Returns
  • - #opcode? - Instruction::Encoding::Field + #return_value + Idl::ReturnStatementAst
  • - #opcode_fields - Instruction::Encoding + #return_value + Idl::ConditionalReturnStatementAst
  • - #operation_ast - Instruction + #return_value + Idl::FunctionBodyAst
  • - #operation_source - Instruction + #return_value + Idl::ForLoopAst
  • - #orig_instantiate_node - Treetop::Runtime::CompiledParser + #return_value + Idl::IfBodyAst
  • - #params - ArchGen + #return_value + Idl::IfAst
  • - #parent - CsrField + #return_value + Idl::FunctionType
  • - #parsing_in_template? - Treetop::Runtime::SyntaxNode + #return_value_nodes + Idl::ReturnStatementAst
  • - #pass_find_return_values - Treetop::Runtime::SyntaxNode + #return_values + Idl::Returns
  • - #pass_find_return_values + #return_values Idl::ReturnStatementAst
  • @@ -2358,15 +3366,15 @@

    Method List

  • - #pass_find_return_values - Idl::IfAst + #return_values + Idl::ConditionalReturnStatementAst
  • - #pass_find_return_values + #return_values Idl::FunctionBodyAst
  • @@ -2374,565 +3382,621 @@

    Method List

  • - #pop - Idl::SymbolTable + #return_values + Idl::ForLoopAst
  • - #pretty_to_s - EncodingField + #return_values + Idl::IfBodyAst
  • - #print - Idl::SymbolTable + #return_values + Idl::ElseIfAst
  • - #print_ast - Idl::AstNodeFuncs + #return_values + Idl::IfAst
  • - #push - Idl::SymbolTable + #rhs + Idl::AssignmentAst
  • - #qualifiers - Idl::Type + #rhs + Idl::VariableAssignmentAst
  • - #qualify - Idl::Type + #rhs + Idl::AryElementAssignmentAst
  • - #range - EncodingField + #rhs + Idl::AryRangeAssignmentAst
  • - #range - CsrField::Alias + #rhs + Idl::MultiVariableAssignmentAst
  • - #range - Instruction::Encoding::Field + #rhs + Idl::VariableDeclarationWithInitializationAst
  • - #range - Idl::BitfieldType + #rhs + Idl::BinaryExpressionAst
  • - #reset_value - CsrField + #rv32? + Instruction
  • - #reset_value_func - CsrField + #rv64? + Instruction
  • - #respond_to_missing? - ArchDefObject + #satisfied_by? + ExtensionRequirement
  • - #result - Validator::SchemaError + #satisfies? + ExtensionVersion
  • - #result - Validator::ValidationError + #set_expected_type + Idl::DontCareReturnAst
  • - #return_type - Idl::ReturnStatementAst + #set_input_file + Treetop::Runtime::CompiledParser
  • - #return_type - Idl::FunctionDefAst + #set_input_file + Treetop::Runtime::SyntaxNode
  • - #return_type - Idl::Type + #setup + TestMixin
  • - #return_type - Idl::FunctionType + #sext? + DecodeVariable
  • - #return_type_list_str - Idl::FunctionDefAst + #sext? + DecodeField
  • - #return_types - Idl::ReturnStatementAst + #signed? + Idl::Type
  • - #return_types - Idl::FunctionDefAst + #size + EncodingField
  • - #return_types - Idl::FunctionType + #size + DecodeVariable
  • - #return_value - Idl::Returns + #size + DecodeField
  • - #return_value - Idl::ReturnStatementAst + #size + Instruction::Encoding
  • - #return_value - Idl::ConditionalReturnStatementAst + #size_in_encoding + DecodeVariable
  • - #return_value + #size_in_encoding + DecodeField +
    +
  • + + +
  • +
    + #split? + DecodeVariable +
    +
  • + + +
  • +
    + #split? + DecodeField +
    +
  • + + +
  • +
    + #statements Idl::FunctionBodyAst
  • +
  • +
    + #stmts + Idl::ForLoopAst +
    +
  • + + +
  • +
    + #stmts + Idl::IfBodyAst +
    +
  • + + +
  • +
    + #sub_type + Idl::Type +
    +
  • + +
  • - #return_value - Idl::ForLoopAst + #sym_table + Csr
  • - #return_value - Idl::IfAst + #sym_table + ArchDef
  • - #return_value_nodes - Idl::ReturnStatementAst + #taken_body + Idl::IfAst
  • - #return_values - Idl::FunctionBodyAst + #template? + Idl::FunctionCallExpressionAst
  • - #return_values - Idl::IfAst + #template_arg_nodes + Idl::FunctionCallExpressionAst
  • - #rhs - Idl::AssignmentAst + #template_index + Idl::Var
  • - #rhs - Idl::VariableAssignmentAst + #template_names + Idl::FunctionDefAst
  • - #rhs - Idl::AryElementAssignmentAst + #template_names + Idl::FunctionType
  • - #rhs - Idl::AryRangeAssignmentAst + #template_types + Idl::FunctionDefAst
  • - #rhs - Idl::MultiVariableAssignmentAst + #template_types + Idl::FunctionType
  • - #rhs - Idl::VariableDeclarationWithInitializationAst + #template_val? + Idl::Var
  • - #rhs - Idl::BinaryExpressionAst + #template_value_for? + Idl::Var
  • - #satisfies? - ExtensionVersion + #template_values + Idl::FunctionCallExpressionAst
  • - #set_expected_type - Idl::DontCareReturnAst + #templated? + Idl::FunctionDefAst
  • - #set_input_file - Treetop::Runtime::CompiledParser + #templated? + Idl::FunctionType
  • - #set_input_file - Treetop::Runtime::SyntaxNode + #test_that_constants_are_read_only + TestVariables
  • - #sext? - DecodeVariable + #test_that_integer_literals_give_correct_values + TestExpressions
  • - #signed? - Idl::Type + #test_that_operators_are_left_recusrive + TestExpressions
  • - #size - EncodingField + #test_that_values_are_tuncated + TestExpressions
  • - #size - DecodeVariable + #to_ast + Treetop::Runtime::SyntaxNode
  • - #size - DecodeField + #to_ast + Idl::IdSyntaxNode
  • - #size - Instruction::Encoding + #to_ast + Idl::AryAccessSyntaxNode
  • - #size_in_encoding - DecodeVariable + #to_ast + Idl::VariableAssignmentSyntaxNode
  • - #size_in_encoding - DecodeField + #to_ast + Idl::AryElementAssignmentSyntaxNode
  • - #split? - DecodeVariable + #to_ast + Idl::VariableDeclarationWithInitializationSyntaxNode
  • - #split? - DecodeField + #to_ast + Idl::BinaryExpressionRightSyntaxNode
  • - #statements - Idl::FunctionBodyAst + #to_ast + Idl::SignCastSyntaxNode
  • - #sub_type - Idl::Type + #to_ast + Idl::ParenExpressionSyntaxNode
  • - #sym_table - Csr + #to_ast + Idl::ReplicationExpressionSyntaxNode
  • - #sym_table - ArchDef + #to_ast + Idl::BuiltinVariableSyntaxNode
  • - #taken_body - Idl::IfAst + #to_ast + Idl::EnumRefSyntaxNode
  • - #template? - Idl::FunctionCallExpressionAst + #to_ast + Idl::TernaryOperatorExpressionSyntaxNode
  • - #template_arg_nodes - Idl::FunctionCallExpressionAst + #to_ast + Idl::StatementSyntaxNode
  • - #template_names - Idl::FunctionDefAst + #to_ast + Idl::ConditionalStatementSyntaxNode
  • - #template_names - Idl::FunctionType + #to_ast + Idl::DontCareReturnSyntaxNode
  • - #template_types - Idl::FunctionDefAst + #to_ast + Idl::BuiltinTypeNameSyntaxNode
  • - #template_types - Idl::FunctionType + #to_ast + Idl::IntLiteralSyntaxNode
  • - #template_types - Idl::TemplateFunctionType + #to_ast + Idl::FunctionCallExpressionSyntaxNode
  • - #template_values - Idl::FunctionCallExpressionAst + #to_ast + Idl::InstructionOperationSyntaxNode
  • - #templated? - Idl::FunctionDefAst + #to_ast + Idl::FunctionBodySyntaxNode
  • - #templated? - Idl::FunctionType + #to_ast + Idl::ForLoopSyntaxNode
  • +
    + #to_ast + Idl::IfSyntaxNode +
    +
  • + + +
  • #to_cxx Idl::Type @@ -2940,7 +4004,7 @@

    Method List

  • -
  • +
  • #to_cxx Idl::XregType @@ -2948,7 +4012,7 @@

    Method List

  • -
  • +
  • #to_cxx Idl::Var @@ -2956,7 +4020,7 @@

    Method List

  • -
  • +
  • #to_cxx_no_qualifiers Idl::Type @@ -2964,7 +4028,7 @@

    Method List

  • -
  • +
  • #to_idl Idl::AstNodeFuncs @@ -2972,7 +4036,7 @@

    Method List

  • -
  • +
  • #to_idl Idl::IdAst @@ -2980,7 +4044,7 @@

    Method List

  • -
  • +
  • #to_idl Idl::GlobalWithInitializationAst @@ -2988,7 +4052,7 @@

    Method List

  • -
  • +
  • #to_idl Idl::EnumDefinitionAst @@ -2996,7 +4060,7 @@

    Method List

  • -
  • +
  • #to_idl Idl::BuiltinEnumDefinitionAst @@ -3004,7 +4068,7 @@

    Method List

  • -
  • +
  • #to_idl Idl::BitfieldDefinitionAst @@ -3012,15 +4076,31 @@

    Method List

  • +
  • +
    + #to_idl + Idl::AryAccessSyntaxNode +
    +
  • + +
  • - #to_idl - Idl::AryAccess + #to_idl + Idl::AryElementAccessAst
  • +
    + #to_idl + Idl::AryRangeAccessAst +
    +
  • + + +
  • #to_idl Idl::VariableAssignmentAst @@ -3028,7 +4108,7 @@

    Method List

  • -
  • +
  • #to_idl Idl::AryElementAssignmentAst @@ -3036,7 +4116,7 @@

    Method List

  • -
  • +
  • #to_idl Idl::AryRangeAssignmentAst @@ -3044,7 +4124,7 @@

    Method List

  • -
  • +
  • #to_idl Idl::FieldAssignmentAst @@ -3052,7 +4132,7 @@

    Method List

  • -
  • +
  • #to_idl Idl::MultiVariableAssignmentAst @@ -3060,7 +4140,7 @@

    Method List

  • -
  • +
  • #to_idl Idl::MultiVariableDeclarationAst @@ -3068,7 +4148,7 @@

    Method List

  • -
  • +
  • #to_idl Idl::VariableDeclarationAst @@ -3076,6 +4156,14 @@

    Method List

  • +
  • +
    + #to_idl + Idl::VariableDeclarationWithInitializationAst +
    +
  • + +
  • #to_idl @@ -3182,8 +4270,8 @@

    Method List

  • - #to_idl - Idl::VarReadExpressionAst + #to_idl + Idl::NoopAst
  • @@ -3197,6 +4285,14 @@

    Method List

  • +
    + #to_idl + Idl::ConditionalStatementAst +
    +
  • + + +
  • #to_idl Idl::DontCareReturnAst @@ -3204,7 +4300,7 @@

    Method List

  • -
  • +
  • #to_idl Idl::DontCareLvalueAst @@ -3212,7 +4308,7 @@

    Method List

  • -
  • +
  • #to_idl Idl::ReturnStatementAst @@ -3220,42 +4316,130 @@

    Method List

  • +
  • +
    + #to_idl + Idl::BuiltinTypeNameAst +
    +
  • + + +
  • +
    + #to_idl + Idl::IntLiteralAst +
    +
  • + + +
  • +
    + #to_idl + Idl::FunctionCallExpressionAst +
    +
  • + + +
  • +
    + #to_idl + Idl::UserTypeNameAst +
    +
  • + + +
  • +
    + #to_idl + Idl::FieldNameAst +
    +
  • + + +
  • +
    + #to_idl + Idl::InstructionOperationAst +
    +
  • + + +
  • +
    + #to_idl + Idl::FunctionBodyAst +
    +
  • + + +
  • +
    + #to_idl + Idl::ForLoopAst +
    +
  • + + +
  • +
    + #to_idl + Idl::IfBodyAst +
    +
  • + + +
  • +
    + #to_idl + Idl::ElseIfAst +
    +
  • + + +
  • +
    + #to_idl + Idl::IfAst +
    +
  • + +
  • - #to_idl - Idl::IntAst + #to_idl + Idl::CsrFieldReadExpressionAst
  • - #to_idl - Idl::UserTypeNameAst + #to_idl + Idl::CsrReadExpressionAst
  • - #to_idl - Idl::FunctionBodyAst + #to_idl + Idl::CsrSoftwareWriteAst
  • - #to_idl - Idl::IfAst + #to_idl + Idl::CsrSoftwareReadAst
  • - #to_idl - Idl::CsrFieldReadExpressionAst + #to_idl + Idl::CsrWriteAst
  • @@ -3438,48 +4622,48 @@

    Method List

  • - #type - Idl::PostIncrementExpressionAst + #type + Idl::BuiltinVariableAst
  • - #type - Idl::BitfieldAccessExpressionAst + #type + Idl::PostIncrementExpressionAst
  • - #type - Idl::EnumRefAst + #type + Idl::BitfieldAccessExpressionAst
  • - #type - Idl::UnaryOperatorExpressionAst + #type + Idl::EnumRefAst
  • - #type - Idl::TernaryOperatorExpressionAst + #type + Idl::UnaryOperatorExpressionAst
  • - #type - Idl::VarReadExpressionAst + #type + Idl::TernaryOperatorExpressionAst
  • @@ -3501,14 +4685,6 @@

    Method List

  • -
    - #type - Idl::BitsTypeAst -
    -
  • - - -
  • #type Idl::BuiltinTypeNameAst @@ -3516,15 +4692,15 @@

    Method List

  • -
  • +
  • - #type - Idl::IntAst + #type + Idl::IntLiteralAst
  • -
  • +
  • #type Idl::FunctionCallExpressionAst @@ -3532,7 +4708,7 @@

    Method List

  • -
  • +
  • #type Idl::UserTypeNameAst @@ -3540,7 +4716,7 @@

    Method List

  • -
  • +
  • #type Idl::CsrFieldReadExpressionAst @@ -3548,7 +4724,7 @@

    Method List

  • -
  • +
  • #type Idl::CsrReadExpressionAst @@ -3556,7 +4732,7 @@

    Method List

  • -
  • +
  • #type Idl::CsrSoftwareReadAst @@ -3564,7 +4740,7 @@

    Method List

  • -
  • +
  • #type Idl::CsrWriteAst @@ -3572,7 +4748,7 @@

    Method List

  • -
  • +
  • #type CsrField @@ -3580,7 +4756,7 @@

    Method List

  • -
  • +
  • #type Idl::Var @@ -3588,6 +4764,14 @@

    Method List

  • +
  • +
    + #type_check + Idl::Compiler +
    +
  • + +
  • #type_check @@ -3734,8 +4918,8 @@

    Method List

  • - #type_check - Idl::BinaryExpressionRightAst + #type_check + Idl::BinaryExpressionRightSyntaxNode
  • @@ -3805,6 +4989,14 @@

    Method List

  • +
    + #type_check + Idl::BuiltinVariableAst +
    +
  • + + +
  • #type_check Idl::PostIncrementExpressionAst @@ -3812,7 +5004,7 @@

    Method List

  • -
  • +
  • #type_check Idl::BitfieldAccessExpressionAst @@ -3820,7 +5012,7 @@

    Method List

  • -
  • +
  • #type_check Idl::EnumRefAst @@ -3828,7 +5020,7 @@

    Method List

  • -
  • +
  • #type_check Idl::UnaryOperatorExpressionAst @@ -3836,7 +5028,7 @@

    Method List

  • -
  • +
  • #type_check Idl::TernaryOperatorExpressionAst @@ -3844,15 +5036,15 @@

    Method List

  • -
  • +
  • - #type_check - Idl::VarReadExpressionAst + #type_check + Idl::NoopAst
  • -
  • +
  • #type_check Idl::StatementAst @@ -3860,7 +5052,7 @@

    Method List

  • -
  • +
  • #type_check Idl::ConditionalStatementAst @@ -3868,7 +5060,7 @@

    Method List

  • -
  • +
  • #type_check Idl::DontCareReturnAst @@ -3876,7 +5068,7 @@

    Method List

  • -
  • +
  • #type_check Idl::DontCareLvalueAst @@ -3884,7 +5076,7 @@

    Method List

  • -
  • +
  • #type_check Idl::ReturnStatementAst @@ -3892,7 +5084,7 @@

    Method List

  • -
  • +
  • #type_check Idl::ExecutionCommentAst @@ -3900,14 +5092,6 @@

    Method List

  • -
  • -
    - #type_check - Idl::BitsTypeAst -
    -
  • - -
  • #type_check @@ -3918,8 +5102,8 @@

    Method List

  • - #type_check - Idl::IntAst + #type_check + Idl::IntLiteralAst
  • @@ -3980,6 +5164,22 @@

    Method List

    +
  • +
    + #type_check + Idl::IfBodyAst +
    +
  • + + +
  • +
    + #type_check + Idl::ElseIfAst +
    +
  • + +
  • #type_check @@ -4061,6 +5261,14 @@

    Method List

  • +
    + #type_check_operation + Instruction +
    +
  • + + +
  • #type_check_return Idl::FunctionDefAst @@ -4068,7 +5276,7 @@

    Method List

  • -
  • +
  • #type_check_targs Idl::FunctionDefAst @@ -4076,7 +5284,7 @@

    Method List

  • -
  • +
  • #type_check_template_instance Idl::FunctionDefAst @@ -4084,7 +5292,7 @@

    Method List

  • -
  • +
  • #type_desc CsrField @@ -4092,7 +5300,7 @@

    Method List

  • -
  • +
  • #type_error Idl::AstNodeFuncs @@ -4100,6 +5308,14 @@

    Method List

  • +
  • +
    + #type_name + Idl::VariableDeclarationWithInitializationAst +
    +
  • + +
  • #unindent @@ -4109,6 +5325,30 @@

    Method List

  • +
    + #unsigned_value + Idl::IntLiteralAst +
    +
  • + + +
  • +
    + #update + Idl::ForLoopAst +
    +
  • + + +
  • +
    + #v + Idl::ReplicationExpressionAst +
    +
  • + + +
  • #validate Validator @@ -4116,7 +5356,7 @@

    Method List

  • -
  • +
  • #validate_config ArchGen @@ -4124,7 +5364,7 @@

    Method List

  • -
  • +
  • #validate_str Validator @@ -4132,7 +5372,7 @@

    Method List

  • -
  • +
  • #value Idl::Rvalue @@ -4140,7 +5380,7 @@

    Method List

  • -
  • +
  • #value Idl::IdAst @@ -4148,7 +5388,7 @@

    Method List

  • -
  • +
  • #value Idl::GlobalWithInitializationAst @@ -4156,7 +5396,7 @@

    Method List

  • -
  • +
  • #value Idl::EnumDefinitionAst @@ -4164,7 +5404,7 @@

    Method List

  • -
  • +
  • #value Idl::BitfieldDefinitionAst @@ -4172,7 +5412,7 @@

    Method List

  • -
  • +
  • #value Idl::AryElementAccessAst @@ -4180,7 +5420,7 @@

    Method List

  • -
  • +
  • #value Idl::AryRangeAccessAst @@ -4188,7 +5428,7 @@

    Method List

  • -
  • +
  • #value Idl::SignCastAst @@ -4196,7 +5436,7 @@

    Method List

  • -
  • +
  • #value Idl::BitsCastAst @@ -4204,7 +5444,7 @@

    Method List

  • -
  • +
  • #value Idl::BinaryExpressionAst @@ -4212,7 +5452,7 @@

    Method List

  • -
  • +
  • #value Idl::ParenExpressionAst @@ -4220,7 +5460,7 @@

    Method List

  • -
  • +
  • #value Idl::ArrayLiteralAst @@ -4228,7 +5468,7 @@

    Method List

  • -
  • +
  • #value Idl::ConcatenationExpressionAst @@ -4236,7 +5476,7 @@

    Method List

  • -
  • +
  • #value Idl::ReplicationExpressionAst @@ -4244,6 +5484,14 @@

    Method List

  • +
  • +
    + #value + Idl::BuiltinVariableAst +
    +
  • + +
  • #value @@ -4277,14 +5525,6 @@

    Method List

  • -
    - #value - Idl::VarReadExpressionAst -
    -
  • - - -
  • #value Idl::DontCareReturnAst @@ -4292,7 +5532,7 @@

    Method List

  • -
  • +
  • #value Idl::DontCareLvalueAst @@ -4300,15 +5540,15 @@

    Method List

  • -
  • +
  • - #value - Idl::IntAst + #value + Idl::IntLiteralAst
  • -
  • +
  • #value Idl::FunctionCallExpressionAst @@ -4316,7 +5556,7 @@

    Method List

  • -
  • +
  • #value Idl::CsrFieldReadExpressionAst @@ -4324,7 +5564,7 @@

    Method List

  • -
  • +
  • #value Idl::CsrReadExpressionAst @@ -4332,7 +5572,7 @@

    Method List

  • -
  • +
  • #value Idl::CsrSoftwareWriteAst @@ -4340,7 +5580,7 @@

    Method List

  • -
  • +
  • #value Idl::CsrSoftwareReadAst @@ -4348,7 +5588,7 @@

    Method List

  • -
  • +
  • #value Idl::EnumerationType @@ -4356,7 +5596,7 @@

    Method List

  • -
  • +
  • #value Idl::Var @@ -4364,7 +5604,7 @@

    Method List

  • -
  • +
  • #value_error Idl::AstNodeFuncs @@ -4372,7 +5612,23 @@

    Method List

  • +
  • +
    + #values + Idl::Rvalue +
    +
  • + +
  • +
    + #values + Idl::TernaryOperatorExpressionAst +
    +
  • + + +
  • #var Idl::AryElementAccessAst @@ -4380,7 +5636,7 @@

    Method List

  • -
  • +
  • #var Idl::AryRangeAccessAst @@ -4388,7 +5644,7 @@

    Method List

  • -
  • +
  • #var_names Idl::MultiVariableDeclarationAst @@ -4396,7 +5652,7 @@

    Method List

  • -
  • +
  • #vars Idl::MultiVariableAssignmentAst @@ -4404,7 +5660,7 @@

    Method List

  • -
  • +
  • #version ExtensionVersion @@ -4412,6 +5668,14 @@

    Method List

  • +
  • +
    + #version_requirement + ExtensionRequirement +
    +
  • + +
  • #wavedrom_desc @@ -4445,6 +5709,14 @@

    Method List

  • +
    + #width + Idl::IntLiteralAst +
    +
  • + + +
  • #width CsrField @@ -4452,7 +5724,7 @@

    Method List

  • -
  • +
  • #width Idl::Type @@ -4460,7 +5732,7 @@

    Method List

  • -
  • +
  • #width Idl::EnumerationType diff --git a/docs/ruby/top-level-namespace.html b/docs/ruby/top-level-namespace.html index 73b4ebc40..8d51e8a1d 100644 --- a/docs/ruby/top-level-namespace.html +++ b/docs/ruby/top-level-namespace.html @@ -82,11 +82,11 @@

    Defined Under Namespace

    - Modules: Idl, Opcodes, RiscvOpcodes, Treetop + Modules: Idl, Opcodes, RiscvOpcodes, TestMixin, Treetop - Classes: ArchDef, ArchDefObject, ArchGen, Csr, CsrField, DecodeField, DecodeVariable, EncodingField, Extension, ExtensionVersion, Instruction, Validator + Classes: ArchDef, ArchDefObject, ArchGen, Csr, CsrField, DecodeField, DecodeVariable, EncodingField, Extension, ExtensionRequirement, ExtensionVersion, Instruction, MockArchDef, MockExtension, TestExpressions, TestVariables, Validator

    @@ -102,7 +102,7 @@

    Defined Under Namespace

    diff --git a/docs/schema/arch_schema.html b/docs/schema/arch_schema.html deleted file mode 100644 index d4950ae7e..000000000 --- a/docs/schema/arch_schema.html +++ /dev/null @@ -1 +0,0 @@ - Unified Architecture Specification

    Unified Architecture Specification

    Type: object
    No Additional Properties

    Type: object

    Type: enum (of integer)

    Base instruction set datapath width

    Must be one of:

    • 32
    • 64

    Type: string

    Name of the configuration

    Type: number

    Number of implemented ASID bits

    Value must be lesser or equal to 16

    Type: number

    Number of implemented PMP entries

    Value must be greater or equal to 0 and lesser or equal to 64

    Type: number

    Vendor-specific architecture ID presented in marchid

    Value must be greater or equal to 0 and lesser or equal to 18446744073709551615

    Type: number

    Vendor-specific implementation ID present in mimpid

    Value must be greater or equal to 0 and lesser or equal to 18446744073709551615

    Type: boolean

    whether or not the implementation supports misaligned loads and stores in main memory (not including atomics). Must be true when extension Zicclsm is implemented.

    Type: boolean Default: false

    whether or not the implementation supports misaligned atomics.

    Type: number

    Number of implemented programmable hardware counters (not including cycle, time, and instret)

    Value must be greater or equal to 0 and lesser or equal to 29

    Type: boolean Default: true

    When true, writing an illegal value to a WLRL CSR field raises an Illegal Instruction exception.
    When false, writing an illegal value to a WLRL CSR field is ignored.

    Type: boolean

    when true, *tval is written with the virtual PC of the EBREAK instruction (same information as *epc).
    when false, *tval is written with 0 on an EBREAK instruction

    regardless, *tval is always written with a virtual PC when an external breakpoint is generated.

    Type: number

    Physical address of the unified discovery configuration data structure (reported in mconfigptr).

    Value must be greater or equal to 0 and lesser or equal to 18446744073709551615

    Type: number

    log2 of the smallest supported PMP region.

    Value must be greater or equal to 2 and lesser or equal to 66

    Type: number

    log2 of the smallest supported PMA region.

    Value must be greater or equal to 2 and lesser or equal to 66

    Type: number

    Number of bits in the physical address space

    Value must be greater or equal to 1 and lesser or equal to 36028797018963968

    Type: boolean Default: "false"

    When C extension is supported, wether or not it can be dynamically disabled by writing the misa.C bit.

    Type: number

    Size, in bytes of a cache block (as seen by cache maintence operations)

    Value must be greater or equal to 1 and lesser or equal to 65536

    Type: number

    Number of supported virtualized guest external interrupts.
    Corresponds to the GEILEN parameter in RISC-V specifications.

    Value must be greater or equal to 1 and lesser or equal to 63

    Type: object

    Type: array of object

    Extensions implemented by this architecture

    No Additional Items

    Each item of this array must be:

    Type: object
    No Additional Properties

    Type: string

    Extension name

    Must match regular expression: ^([A-WY]|([SXZ][a-z0-9]+))$

    Type: object

    All properties whose name matches the following regular expression must respect the following conditions

    Property name regular expression: .*
    Type: object
    No Additional Properties

    Type: string

    Type: string

    Type: enum (of string)

    Must be one of:

    • "unprivileged"
    • "privileged"


    Extension(s) required by this extension

    Type: string
    Type: array of string
    No Additional Items

    Each item of this array must be:

    Type: array of object
    No Additional Items

    Each item of this array must be:

    Type: object
    No Additional Properties


    Type: string
    Must match regular expression: ^[0-9]+(\.[0-9]+(\.[0-9]+(-[a-fA-F0-9]+)?)?)?$


    Type: string
    Must match regular expression: ^20[0-9][0-9]-[0-9][0-9]$
    Type: string
    Must match regular expression: ^unknown$

    Type: string

    Changes since last version

    Type: stringFormat: uri

    Link to ratified document

    Type: array of object
    No Additional Items

    Each item of this array must be:

    Type: object

    Exceptions defined by this extension

    No Additional Properties

    Type: array of object
    No Additional Items

    Each item of this array must be:

    Type: object

    Interrupts defined by this extension

    No Additional Properties

    Type: object

    All properties whose name matches the following regular expression must respect the following conditions

    Property name regular expression: .*
    Type: object
    No Additional Properties

    If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

    Type: object

    Type: const
    Specific value: "VS"
    Type: object

    Type: number

    Address of the CSR viewed from VS-mode

    Type: string

    Optional name (name is extracted from object key of parent), so information is redundant

    Type: enum (of integer)

    When a CSR is only defined in RV32, or RV64, the base that defines it. When defined in both, this field should be absent.

    Must be one of:

    • 32
    • 64

    Type: string

    Type: string

    Type: string
    Must match regular expression: ^([A-WY]|([SXZ][a-z]+))$

    Type: integer

    CSR address

    Type: object

    Type: object

    Type: enum (of string)

    Must be one of:

    • "M"
    • "S"
    • "U"
    • "VS"

    Type: enum (of integer or string)

    Length, in bits, of the CSR. Can either be a 32, 64, or XLEN

    Must be one of:

    • 32
    • 64
    • "XLEN"

    Type: string

    Extension that must be implemented for this CSR to exist

    Type: object
    No Additional Properties

    All properties whose name matches the following regular expression must respect the following conditions

    Property name regular expression: ^[a-zA-Z].*$
    Type: object

    Field in a CSR register

    No Additional Properties

    Type: object

    If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

    Type: object

    Type: const
    Specific value: "RO"
    Type: object


    Type: string
    Must match regular expression: ^<%=.*%>$
    Type: object

    If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

    Type: object

    Type: const
    Specific value: "RO-H"
    Type: object

    Type: object

    If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

    Type: object

    Type: const
    Specific value: "RW"
    Type: object

    Type: object

    If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

    Type: object

    Type: const
    Specific value: "RW-H"
    Type: object

    Type: object

    If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

    Type: object

    Type: const
    Specific value: "RW-R"
    Type: object

    Type: string

    Function implementing custom write behavior for the CSR. Given a 'value', return either the value to be written in the field or false if the write would be illegal. 'value' is the value of the entire CSR, which is sometimes needed to detect illegal writes

    Type: object

    If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

    Type: object

    Type: const
    Specific value: "RW-RH"
    Type: object

    Type: string

    Function implementing custom write behavior for the CSR. Given a 'value', return either the value to be written in the field or false if the write would be illegal. 'value' is the value of the entire CSR, which is sometimes needed to detect illegal writes

    Same definition as write(value)


    Location of the field within the CSR register

    Type: number

    Location of a single bit

    Type: string

    Location range of a multibit field

    Must match regular expression: ^[0-9]+-[0-9]+$

    Type: string

    Function of the field

    Type: enum (of string)

    Type of the field. One of:
    * RO: Read-only immutable
    * RO-H: Read-only, updated by hardware
    * RW: Read-write, not updated by hardware
    * RW-R: Read-write, but values are restricted. write(value) must be provided
    * RW-H: Read-write, with hardware updates
    * RW-RH: Read-write, with hardware updates, but values are restricted. write(value) must be provded

    Must be one of:

    • "RO"
    • "RO-H"
    • "RW"
    • "RW-R"
    • "RW-H"
    • "RW-RH"


    Other CSR fields that alias with this field

    Type: string
    Must match regular expression: ^[a-z]+\.[A-Z0-9]+$
    Type: array of string
    No Additional Items

    Each item of this array must be:

    Type: string
    Must match regular expression: ^[a-z]+\.[A-Z0-9]+$


    Where this field is defined: indicates that the field is only present if the extension(s) are implemented. If definedBy is not given, defaults to the definedBy field of the parent CSR

    Type: string

    An extension name

    Must match regular expression: ^([A-WY]|([SXZ][a-z]+))$
    Type: array of string
    No Additional Items

    Each item of this array must be:

    Type: string

    An extension name

    Must match regular expression: ^([A-WY]|([SXZ][a-z]+))$


    Extension(s) that affect the definition of the field beyond the extension (or base) the field is originally defined in

    Type: string
    Must match regular expression: ^(RV64)|([A-WY]|(Z[a-z]+)|(S[a-z]+))$
    Type: array of string
    No Additional Items

    Each item of this array must be:

    Type: string
    Must match regular expression: ^(RV64)|([A-WY]|(Z[a-z]+)|(S[a-z]+))$

    Type: object

    Type: string

    Optional function called to handle special-case checks for access permission.

    Type: string

    Function that returns the value of the CSR when read by software (i.e., a Zicsr instruction). If not specified, the value last written (through hw_write) is returned.

    Type: array of string

    CSRs implemented by this architecture

    No Additional Items

    Each item of this array must be:

    Type: string

    CSR name

    Must match regular expression: ^[a-z][a-zA-Z0-9]+$

    Type: object

    All properties whose name matches the following regular expression must respect the following conditions

    Property name regular expression: .*
    Type: object
    No Additional Properties

    Type: string
    Must match regular expression: ^[a-z0-9.]+$

    Type: string

    Short descrption of the instruction

    Type: string

    Detailed description of the instruction


    Extension(s) that defines the instruction

    Type: string

    RISC-V Extension

    Must match regular expression: ^[A-W,Y]|([XZ][a-z]+)$
    Type: array
    No Additional Items

    Each item of this array must be:

    Type: enum (of integer)

    When present, instruction is only defined for RV32 or RV64 base

    Must be one of:

    • 32
    • 64

    Type: object

    Type: enum (of string) Default: "always"

    Must be one of:

    • "always"
    • "sometimes"
    • "never"

    Type: enum (of string) Default: "always"

    Must be one of:

    • "always"
    • "sometimes"
    • "never"

    Type: enum (of string) Default: "always"

    Must be one of:

    • "always"
    • "sometimes"
    • "never"

    Type: enum (of string) Default: "always"

    Must be one of:

    • "always"
    • "sometimes"
    • "never"

    Type: enum (of string) Default: "always"

    Must be one of:

    • "always"
    • "sometimes"
    • "never"

    Type: string

    Extra detail about access when at least one mode is 'sometimes'

    Type: array of enum (of string) Default: []

    Types of exceptions that can be raised by this instruction (excluding Instruction Page/Access Fault)

    No Additional Items

    Each item of this array must be:

    Type: enum (of string)

    Must be one of:

    • "Store/AMO Page Fault"
    • "Store/AMO Guest-Page Fault"
    • "Store Access Fault"
    • "Illegal Instruction"
    • "Virtual Instruction"
    • "MisalignedAddress"

    Type: string

    Functional description of the instruction using ISA language

    Type: string

    Assembly format of the instruction. Can use decode variables

    All properties whose name matches the following regular expression must respect the following conditions

    Property name regular expression: additionalProperties
    Type: object

    Type: array of string

    Instructions implemented by this architecture

    No Additional Items

    Each item of this array must be:

    Type: string

    Instruction name

    Must match regular expression: ^[a-z][a-zA-Z0-9.]+$
    \ No newline at end of file diff --git a/docs/schema/arch_schema.md b/docs/schema/arch_schema.md deleted file mode 100644 index a084350e3..000000000 --- a/docs/schema/arch_schema.md +++ /dev/null @@ -1,1908 +0,0 @@ -# Unified Architecture Specification - -- [1. Property `Unified Architecture Specification > params`](#params) - - [1.1. Property `Unified Architecture Specification > params > XLEN`](#params_XLEN) - - [1.2. Property `Unified Architecture Specification > params > NAME`](#params_NAME) - - [1.3. Property `Unified Architecture Specification > params > ASID_WIDTH`](#params_ASID_WIDTH) - - [1.4. Property `Unified Architecture Specification > params > NUM_PMP_ENTRIES`](#params_NUM_PMP_ENTRIES) - - [1.5. Property `Unified Architecture Specification > params > ARCH_ID`](#params_ARCH_ID) - - [1.6. Property `Unified Architecture Specification > params > IMP_ID`](#params_IMP_ID) - - [1.7. Property `Unified Architecture Specification > params > MISALIGNED_LDST`](#params_MISALIGNED_LDST) - - [1.8. Property `Unified Architecture Specification > params > MISALIGNED_AMO`](#params_MISALIGNED_AMO) - - [1.9. Property `Unified Architecture Specification > params > NUM_HPM_COUNTERS`](#params_NUM_HPM_COUNTERS) - - [1.10. Property `Unified Architecture Specification > params > TRAP_ON_ILLEGAL_WLRL`](#params_TRAP_ON_ILLEGAL_WLRL) - - [1.11. Property `Unified Architecture Specification > params > REPORT_EBREAK_PC_IN_TVAL`](#params_REPORT_EBREAK_PC_IN_TVAL) - - [1.12. Property `Unified Architecture Specification > params > CONFIG_PTR_ADDRESS`](#params_CONFIG_PTR_ADDRESS) - - [1.13. Property `Unified Architecture Specification > params > PMP_GRANULARITY`](#params_PMP_GRANULARITY) - - [1.14. Property `Unified Architecture Specification > params > PMA_GRANULARITY`](#params_PMA_GRANULARITY) - - [1.15. Property `Unified Architecture Specification > params > PHYS_ADDR_WIDTH`](#params_PHYS_ADDR_WIDTH) - - [1.16. Property `Unified Architecture Specification > params > MUTABLE_MISA_C`](#params_MUTABLE_MISA_C) - - [1.17. Property `Unified Architecture Specification > params > CACHE_BLOCK_SIZE`](#params_CACHE_BLOCK_SIZE) - - [1.18. Property `Unified Architecture Specification > params > NUM_EXTERNAL_GUEST_INTERRUPTS`](#params_NUM_EXTERNAL_GUEST_INTERRUPTS) -- [2. Property `Unified Architecture Specification > exception_codes`](#exception_codes) -- [3. Property `Unified Architecture Specification > implemented_extensions`](#implemented_extensions) - - [3.1. Unified Architecture Specification > implemented_extensions > implemented_extensions items](#autogenerated_heading_2) - - [3.1.1. Property `Unified Architecture Specification > implemented_extensions > implemented_extensions items > name`](#implemented_extensions_items_name) - - [3.1.2. Property `Unified Architecture Specification > implemented_extensions > implemented_extensions items > version`](#implemented_extensions_items_version) - - [3.1.2.1. Property `Unified Architecture Specification > implemented_extensions > implemented_extensions items > version > oneOf > item 0`](#implemented_extensions_items_version_oneOf_i0) - - [3.1.2.2. Property `Unified Architecture Specification > implemented_extensions > implemented_extensions items > version > oneOf > item 1`](#implemented_extensions_items_version_oneOf_i1) -- [4. Property `Unified Architecture Specification > extensions`](#extensions) - - [4.1. Pattern Property `Unified Architecture Specification > extensions > ext_data`](#extensions_pattern1) - - [4.1.1. Property `Unified Architecture Specification > extensions > .* > name`](#extensions_pattern1_name) - - [4.1.2. Property `Unified Architecture Specification > extensions > .* > description`](#extensions_pattern1_description) - - [4.1.3. Property `Unified Architecture Specification > extensions > .* > type`](#extensions_pattern1_type) - - [4.1.4. Property `Unified Architecture Specification > extensions > .* > requires`](#extensions_pattern1_requires) - - [4.1.4.1. Property `Unified Architecture Specification > extensions > .* > requires > oneOf > item 0`](#extensions_pattern1_requires_oneOf_i0) - - [4.1.4.2. Property `Unified Architecture Specification > extensions > .* > requires > oneOf > item 1`](#extensions_pattern1_requires_oneOf_i1) - - [4.1.4.2.1. Unified Architecture Specification > extensions > .* > requires > oneOf > item 1 > item 1 items](#autogenerated_heading_3) - - [4.1.5. Property `Unified Architecture Specification > extensions > .* > versions`](#extensions_pattern1_versions) - - [4.1.5.1. Unified Architecture Specification > extensions > .* > versions > versions items](#autogenerated_heading_4) - - [4.1.5.1.1. Property `Unified Architecture Specification > extensions > .* > versions > versions items > version`](#extensions_pattern1_versions_items_version) - - [4.1.5.1.1.1. Property `Unified Architecture Specification > extensions > .* > versions > versions items > version > oneOf > item 0`](#extensions_pattern1_versions_items_version_oneOf_i0) - - [4.1.5.1.1.2. Property `Unified Architecture Specification > extensions > .* > versions > versions items > version > oneOf > item 1`](#extensions_pattern1_versions_items_version_oneOf_i1) - - [4.1.5.1.2. Property `Unified Architecture Specification > extensions > .* > versions > versions items > ratification_date`](#extensions_pattern1_versions_items_ratification_date) - - [4.1.5.1.2.1. Property `Unified Architecture Specification > extensions > .* > versions > versions items > ratification_date > oneOf > item 0`](#extensions_pattern1_versions_items_ratification_date_oneOf_i0) - - [4.1.5.1.2.2. Property `Unified Architecture Specification > extensions > .* > versions > versions items > ratification_date > oneOf > item 1`](#extensions_pattern1_versions_items_ratification_date_oneOf_i1) - - [4.1.5.1.2.3. Property `Unified Architecture Specification > extensions > .* > versions > versions items > ratification_date > oneOf > item 2`](#extensions_pattern1_versions_items_ratification_date_oneOf_i2) - - [4.1.5.1.3. Property `Unified Architecture Specification > extensions > .* > versions > versions items > changes`](#extensions_pattern1_versions_items_changes) - - [4.1.5.1.4. Property `Unified Architecture Specification > extensions > .* > versions > versions items > url`](#extensions_pattern1_versions_items_url) - - [4.1.6. Property `Unified Architecture Specification > extensions > .* > exception_codes`](#extensions_pattern1_exception_codes) - - [4.1.6.1. Unified Architecture Specification > extensions > .* > exception_codes > exception_codes items](#autogenerated_heading_5) - - [4.1.6.1.1. Property `Unified Architecture Specification > extensions > .* > exception_codes > exception_codes items > num`](#extensions_pattern1_exception_codes_items_num) - - [4.1.6.1.2. Property `Unified Architecture Specification > extensions > .* > exception_codes > exception_codes items > name`](#extensions_pattern1_exception_codes_items_name) - - [4.1.7. Property `Unified Architecture Specification > extensions > .* > interrupt_codes`](#extensions_pattern1_interrupt_codes) - - [4.1.7.1. Unified Architecture Specification > extensions > .* > interrupt_codes > interrupt_codes items](#autogenerated_heading_6) - - [4.1.7.1.1. Property `Unified Architecture Specification > extensions > .* > interrupt_codes > interrupt_codes items > num`](#extensions_pattern1_interrupt_codes_items_num) - - [4.1.7.1.2. Property `Unified Architecture Specification > extensions > .* > interrupt_codes > interrupt_codes items > name`](#extensions_pattern1_interrupt_codes_items_name) -- [5. Property `Unified Architecture Specification > csrs`](#csrs) - - [5.1. Pattern Property `Unified Architecture Specification > csrs > csr_register`](#csrs_pattern1) - - [5.1.1. If (priv_mode = "VS")](#autogenerated_heading_7) - - [5.1.1.1. Property `Unified Architecture Specification > csrs > .* > then > virtual_address`](#csrs_pattern1_pattern5_virtual_address) - - [5.1.2. Property `Unified Architecture Specification > csrs > .* > name`](#csrs_pattern1_name) - - [5.1.3. Property `Unified Architecture Specification > csrs > .* > base`](#csrs_pattern1_base) - - [5.1.4. Property `Unified Architecture Specification > csrs > .* > long_name`](#csrs_pattern1_long_name) - - [5.1.5. Property `Unified Architecture Specification > csrs > .* > description`](#csrs_pattern1_description) - - [5.1.6. Property `Unified Architecture Specification > csrs > .* > definedBy`](#csrs_pattern1_definedBy) - - [5.1.7. Property `Unified Architecture Specification > csrs > .* > address`](#csrs_pattern1_address) - - [5.1.8. Property `Unified Architecture Specification > csrs > .* > virtual_address`](#csrs_pattern1_virtual_address) - - [5.1.9. Property `Unified Architecture Specification > csrs > .* > $comment`](#csrs_pattern1_comment) - - [5.1.10. Property `Unified Architecture Specification > csrs > .* > priv_mode`](#csrs_pattern1_priv_mode) - - [5.1.11. Property `Unified Architecture Specification > csrs > .* > length`](#csrs_pattern1_length) - - [5.1.12. Property `Unified Architecture Specification > csrs > .* > requires`](#csrs_pattern1_requires) - - [5.1.13. Property `Unified Architecture Specification > csrs > .* > fields`](#csrs_pattern1_fields) - - [5.1.13.1. Pattern Property `Unified Architecture Specification > csrs > .* > fields > csr_field`](#csrs_pattern1_fields_pattern1) - - [5.1.13.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 0`](#csrs_pattern1_fields_pattern1_pattern4_i0) - - [5.1.13.1.1.1. If (type = "RO")](#autogenerated_heading_8) - - [5.1.13.1.1.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 0 > then > value`](#csrs_pattern1_fields_pattern1_pattern4_i0_then_value) - - [5.1.13.1.1.1.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 0 > then > value > oneOf > item 0`](#csrs_pattern1_fields_pattern1_pattern4_i0_then_value_oneOf_i0) - - [5.1.13.1.1.1.1.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 0 > then > value > oneOf > item 1`](#csrs_pattern1_fields_pattern1_pattern4_i0_then_value_oneOf_i1) - - [5.1.13.1.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 1`](#csrs_pattern1_fields_pattern1_pattern4_i1) - - [5.1.13.1.2.1. If (type = "RO-H")](#autogenerated_heading_9) - - [5.1.13.1.2.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 1 > then > reset_value`](#csrs_pattern1_fields_pattern1_pattern4_i1_then_reset_value) - - [5.1.13.1.3. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 2`](#csrs_pattern1_fields_pattern1_pattern4_i2) - - [5.1.13.1.3.1. If (type = "RW")](#autogenerated_heading_10) - - [5.1.13.1.3.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 2 > then > reset_value`](#csrs_pattern1_fields_pattern1_pattern4_i2_then_reset_value) - - [5.1.13.1.4. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 3`](#csrs_pattern1_fields_pattern1_pattern4_i3) - - [5.1.13.1.4.1. If (type = "RW-H")](#autogenerated_heading_11) - - [5.1.13.1.4.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 3 > then > reset_value`](#csrs_pattern1_fields_pattern1_pattern4_i3_then_reset_value) - - [5.1.13.1.5. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 4`](#csrs_pattern1_fields_pattern1_pattern4_i4) - - [5.1.13.1.5.1. If (type = "RW-R")](#autogenerated_heading_12) - - [5.1.13.1.5.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 4 > then > write(value)`](#csrs_pattern1_fields_pattern1_pattern4_i4_then_write(value)) - - [5.1.13.1.5.1.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 4 > then > reset_value`](#csrs_pattern1_fields_pattern1_pattern4_i4_then_reset_value) - - [5.1.13.1.6. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 5`](#csrs_pattern1_fields_pattern1_pattern4_i5) - - [5.1.13.1.6.1. If (type = "RW-RH")](#autogenerated_heading_13) - - [5.1.13.1.6.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 5 > then > write(value)`](#csrs_pattern1_fields_pattern1_pattern4_i5_then_write(value)) - - [5.1.13.1.6.1.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 5 > then > reset_value`](#csrs_pattern1_fields_pattern1_pattern4_i5_then_reset_value) - - [5.1.13.1.7. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > location`](#csrs_pattern1_fields_pattern1_location) - - [5.1.13.1.7.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > location > oneOf > item 0`](#csrs_pattern1_fields_pattern1_location_oneOf_i0) - - [5.1.13.1.7.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > location > oneOf > item 1`](#csrs_pattern1_fields_pattern1_location_oneOf_i1) - - [5.1.13.1.8. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > description`](#csrs_pattern1_fields_pattern1_description) - - [5.1.13.1.9. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > type`](#csrs_pattern1_fields_pattern1_type) - - [5.1.13.1.10. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > alias`](#csrs_pattern1_fields_pattern1_alias) - - [5.1.13.1.10.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > alias > oneOf > item 0`](#csrs_pattern1_fields_pattern1_alias_oneOf_i0) - - [5.1.13.1.10.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > alias > oneOf > item 1`](#csrs_pattern1_fields_pattern1_alias_oneOf_i1) - - [5.1.13.1.10.2.1. Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > alias > oneOf > item 1 > item 1 items](#autogenerated_heading_14) - - [5.1.13.1.11. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > definedBy`](#csrs_pattern1_fields_pattern1_definedBy) - - [5.1.13.1.11.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > definedBy > oneOf > item 0`](#csrs_pattern1_fields_pattern1_definedBy_oneOf_i0) - - [5.1.13.1.11.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > definedBy > oneOf > item 1`](#csrs_pattern1_fields_pattern1_definedBy_oneOf_i1) - - [5.1.13.1.11.2.1. Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > definedBy > oneOf > item 1 > item 1 items](#autogenerated_heading_15) - - [5.1.13.1.12. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > affectedBy`](#csrs_pattern1_fields_pattern1_affectedBy) - - [5.1.13.1.12.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > affectedBy > oneOf > item 0`](#csrs_pattern1_fields_pattern1_affectedBy_oneOf_i0) - - [5.1.13.1.12.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > affectedBy > oneOf > item 1`](#csrs_pattern1_fields_pattern1_affectedBy_oneOf_i1) - - [5.1.13.1.12.2.1. Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > affectedBy > oneOf > item 1 > item 1 items](#autogenerated_heading_16) - - [5.1.13.1.13. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > reset_value`](#csrs_pattern1_fields_pattern1_reset_value) - - [5.1.13.1.14. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > value`](#csrs_pattern1_fields_pattern1_value) - - [5.1.13.1.15. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > write(value)`](#csrs_pattern1_fields_pattern1_write(value)) - - [5.1.14. Property `Unified Architecture Specification > csrs > .* > access_check`](#csrs_pattern1_access_check) - - [5.1.15. Property `Unified Architecture Specification > csrs > .* > sw_read`](#csrs_pattern1_sw_read) -- [6. Property `Unified Architecture Specification > implemented_csrs`](#implemented_csrs) - - [6.1. Unified Architecture Specification > implemented_csrs > implemented_csrs items](#autogenerated_heading_17) -- [7. Property `Unified Architecture Specification > instructions`](#instructions) - - [7.1. Pattern Property `Unified Architecture Specification > instructions > inst_data`](#instructions_pattern1) - - [7.1.1. Property `Unified Architecture Specification > instructions > .* > name`](#instructions_pattern1_name) - - [7.1.2. Property `Unified Architecture Specification > instructions > .* > long_name`](#instructions_pattern1_long_name) - - [7.1.3. Property `Unified Architecture Specification > instructions > .* > description`](#instructions_pattern1_description) - - [7.1.4. Property `Unified Architecture Specification > instructions > .* > definedBy`](#instructions_pattern1_definedBy) - - [7.1.4.1. Property `Unified Architecture Specification > instructions > .* > definedBy > oneOf > extension`](#instructions_pattern1_definedBy_oneOf_i0) - - [7.1.4.2. Property `Unified Architecture Specification > instructions > .* > definedBy > oneOf > item 1`](#instructions_pattern1_definedBy_oneOf_i1) - - [7.1.4.2.1. Unified Architecture Specification > instructions > .* > definedBy > oneOf > item 1 > extension](#autogenerated_heading_18) - - [7.1.5. Property `Unified Architecture Specification > instructions > .* > base`](#instructions_pattern1_base) - - [7.1.6. Property `Unified Architecture Specification > instructions > .* > access`](#instructions_pattern1_access) - - [7.1.6.1. Property `Unified Architecture Specification > instructions > .* > access > m`](#instructions_pattern1_access_m) - - [7.1.6.2. Property `Unified Architecture Specification > instructions > .* > access > s`](#instructions_pattern1_access_s) - - [7.1.6.3. Property `Unified Architecture Specification > instructions > .* > access > u`](#instructions_pattern1_access_u) - - [7.1.6.4. Property `Unified Architecture Specification > instructions > .* > access > vs`](#instructions_pattern1_access_vs) - - [7.1.6.5. Property `Unified Architecture Specification > instructions > .* > access > vu`](#instructions_pattern1_access_vu) - - [7.1.7. Property `Unified Architecture Specification > instructions > .* > access_detail`](#instructions_pattern1_access_detail) - - [7.1.8. Property `Unified Architecture Specification > instructions > .* > raises`](#instructions_pattern1_raises) - - [7.1.8.1. Unified Architecture Specification > instructions > .* > raises > raises items](#autogenerated_heading_19) - - [7.1.9. Property `Unified Architecture Specification > instructions > .* > operation`](#instructions_pattern1_operation) - - [7.1.10. Property `Unified Architecture Specification > instructions > .* > assembly`](#instructions_pattern1_assembly) - - [7.2. Pattern Property `Unified Architecture Specification > instructions > additionalProperties`](#instructions_pattern2) -- [8. Property `Unified Architecture Specification > implemented_instructions`](#implemented_instructions) - - [8.1. Unified Architecture Specification > implemented_instructions > implemented_instructions items](#autogenerated_heading_20) - -**Title:** Unified Architecture Specification - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| -------------------------------------------------------- | ------- | --------------- | ---------- | ------------------------------------------- | --------------------------------------------- | -| + [params](#params ) | No | object | No | In ../cfgs/config_schema.json#/$defs/params | - | -| - [exception_codes](#exception_codes ) | No | object | No | In misc/exception_code_schema.json | - | -| + [implemented_extensions](#implemented_extensions ) | No | array of object | No | - | Extensions implemented by this architecture | -| + [extensions](#extensions ) | No | object | No | - | - | -| + [csrs](#csrs ) | No | object | No | - | - | -| + [implemented_csrs](#implemented_csrs ) | No | array of string | No | - | CSRs implemented by this architecture | -| + [instructions](#instructions ) | No | object | No | - | - | -| + [implemented_instructions](#implemented_instructions ) | No | array of string | No | - | Instructions implemented by this architecture | - -## 1. Property `Unified Architecture Specification > params` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | -| **Defined in** | ../cfgs/config_schema.json#/$defs/params | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ------------------------------------------------------------------------- | ------- | ----------------- | ---------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| + [XLEN](#params_XLEN ) | No | enum (of integer) | No | - | Base instruction set datapath width | -| + [NAME](#params_NAME ) | No | string | No | - | Name of the configuration | -| - [ASID_WIDTH](#params_ASID_WIDTH ) | No | number | No | - | Number of implemented ASID bits | -| - [NUM_PMP_ENTRIES](#params_NUM_PMP_ENTRIES ) | No | number | No | - | Number of implemented PMP entries | -| - [ARCH_ID](#params_ARCH_ID ) | No | number | No | - | Vendor-specific architecture ID presented in \`marchid\` | -| - [IMP_ID](#params_IMP_ID ) | No | number | No | - | Vendor-specific implementation ID present in \`mimpid\` | -| - [MISALIGNED_LDST](#params_MISALIGNED_LDST ) | No | boolean | No | - | whether or not the implementation supports misaligned loads and stores in main memory (not including atomics). Must be true when extension Zicclsm is implemented. | -| - [MISALIGNED_AMO](#params_MISALIGNED_AMO ) | No | boolean | No | - | whether or not the implementation supports misaligned atomics. | -| - [NUM_HPM_COUNTERS](#params_NUM_HPM_COUNTERS ) | No | number | No | - | Number of implemented programmable hardware counters (not including cycle, time, and instret) | -| - [TRAP_ON_ILLEGAL_WLRL](#params_TRAP_ON_ILLEGAL_WLRL ) | No | boolean | No | - | When true, writing an illegal value to a WLRL CSR field raises an Illegal Instruction exception.
    When false, writing an illegal value to a WLRL CSR field is ignored. | -| - [REPORT_EBREAK_PC_IN_TVAL](#params_REPORT_EBREAK_PC_IN_TVAL ) | No | boolean | No | - | when true, *tval is written with the virtual PC of the EBREAK instruction (same information as *epc).
    when false, *tval is written with 0 on an EBREAK instruction

    regardless, *tval is always written with a virtual PC when an external breakpoint is generated. | -| - [CONFIG_PTR_ADDRESS](#params_CONFIG_PTR_ADDRESS ) | No | number | No | - | Physical address of the unified discovery configuration data structure (reported in \`mconfigptr\`). | -| - [PMP_GRANULARITY](#params_PMP_GRANULARITY ) | No | number | No | - | log2 of the smallest supported PMP region. | -| - [PMA_GRANULARITY](#params_PMA_GRANULARITY ) | No | number | No | - | log2 of the smallest supported PMA region. | -| - [PHYS_ADDR_WIDTH](#params_PHYS_ADDR_WIDTH ) | No | number | No | - | Number of bits in the physical address space | -| - [MUTABLE_MISA_C](#params_MUTABLE_MISA_C ) | No | boolean | No | - | When C extension is supported, wether or not it can be dynamically disabled by writing the \`misa.C\` bit. | -| - [CACHE_BLOCK_SIZE](#params_CACHE_BLOCK_SIZE ) | No | number | No | - | Size, in bytes of a cache block (as seen by cache maintence operations) | -| - [NUM_EXTERNAL_GUEST_INTERRUPTS](#params_NUM_EXTERNAL_GUEST_INTERRUPTS ) | No | number | No | - | Number of supported virtualized guest external interrupts.
    Corresponds to the GEILEN parameter in RISC-V specifications. | - -### 1.1. Property `Unified Architecture Specification > params > XLEN` - -| | | -| ------------ | ------------------- | -| **Type** | `enum (of integer)` | -| **Required** | Yes | - -**Description:** Base instruction set datapath width - -Must be one of: -* 32 -* 64 - -### 1.2. Property `Unified Architecture Specification > params > NAME` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -**Description:** Name of the configuration - -### 1.3. Property `Unified Architecture Specification > params > ASID_WIDTH` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -**Description:** Number of implemented ASID bits - -| Restrictions | | -| ------------ | ------- | -| **Maximum** | ≤ 16 | - -### 1.4. Property `Unified Architecture Specification > params > NUM_PMP_ENTRIES` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -**Description:** Number of implemented PMP entries - -| Restrictions | | -| ------------ | ------- | -| **Minimum** | ≥ 0 | -| **Maximum** | ≤ 64 | - -### 1.5. Property `Unified Architecture Specification > params > ARCH_ID` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -**Description:** Vendor-specific architecture ID presented in `marchid` - -| Restrictions | | -| ------------ | ------------------------- | -| **Minimum** | ≥ 0 | -| **Maximum** | ≤ 18446744073709551615 | - -### 1.6. Property `Unified Architecture Specification > params > IMP_ID` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -**Description:** Vendor-specific implementation ID present in `mimpid` - -| Restrictions | | -| ------------ | ------------------------- | -| **Minimum** | ≥ 0 | -| **Maximum** | ≤ 18446744073709551615 | - -### 1.7. Property `Unified Architecture Specification > params > MISALIGNED_LDST` - -| | | -| ------------ | --------- | -| **Type** | `boolean` | -| **Required** | No | - -**Description:** whether or not the implementation supports misaligned loads and stores in main memory (not including atomics). Must be true when extension Zicclsm is implemented. - -### 1.8. Property `Unified Architecture Specification > params > MISALIGNED_AMO` - -| | | -| ------------ | --------- | -| **Type** | `boolean` | -| **Required** | No | -| **Default** | `false` | - -**Description:** whether or not the implementation supports misaligned atomics. - -### 1.9. Property `Unified Architecture Specification > params > NUM_HPM_COUNTERS` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -**Description:** Number of implemented programmable hardware counters (not including cycle, time, and instret) - -| Restrictions | | -| ------------ | ------- | -| **Minimum** | ≥ 0 | -| **Maximum** | ≤ 29 | - -### 1.10. Property `Unified Architecture Specification > params > TRAP_ON_ILLEGAL_WLRL` - -| | | -| ------------ | --------- | -| **Type** | `boolean` | -| **Required** | No | -| **Default** | `true` | - -**Description:** When true, writing an illegal value to a WLRL CSR field raises an Illegal Instruction exception. -When false, writing an illegal value to a WLRL CSR field is ignored. - -### 1.11. Property `Unified Architecture Specification > params > REPORT_EBREAK_PC_IN_TVAL` - -| | | -| ------------ | --------- | -| **Type** | `boolean` | -| **Required** | No | - -**Description:** when true, *tval is written with the virtual PC of the EBREAK instruction (same information as *epc). -when false, *tval is written with 0 on an EBREAK instruction - -regardless, *tval is always written with a virtual PC when an external breakpoint is generated. - -### 1.12. Property `Unified Architecture Specification > params > CONFIG_PTR_ADDRESS` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -**Description:** Physical address of the unified discovery configuration data structure (reported in `mconfigptr`). - -| Restrictions | | -| ------------ | ------------------------- | -| **Minimum** | ≥ 0 | -| **Maximum** | ≤ 18446744073709551615 | - -### 1.13. Property `Unified Architecture Specification > params > PMP_GRANULARITY` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -**Description:** log2 of the smallest supported PMP region. - -| Restrictions | | -| ------------ | ------- | -| **Minimum** | ≥ 2 | -| **Maximum** | ≤ 66 | - -### 1.14. Property `Unified Architecture Specification > params > PMA_GRANULARITY` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -**Description:** log2 of the smallest supported PMA region. - -| Restrictions | | -| ------------ | ------- | -| **Minimum** | ≥ 2 | -| **Maximum** | ≤ 66 | - -### 1.15. Property `Unified Architecture Specification > params > PHYS_ADDR_WIDTH` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -**Description:** Number of bits in the physical address space - -| Restrictions | | -| ------------ | ---------------------- | -| **Minimum** | ≥ 1 | -| **Maximum** | ≤ 36028797018963968 | - -### 1.16. Property `Unified Architecture Specification > params > MUTABLE_MISA_C` - -| | | -| ------------ | --------- | -| **Type** | `boolean` | -| **Required** | No | -| **Default** | `"false"` | - -**Description:** When C extension is supported, wether or not it can be dynamically disabled by writing the `misa.C` bit. - -### 1.17. Property `Unified Architecture Specification > params > CACHE_BLOCK_SIZE` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -**Description:** Size, in bytes of a cache block (as seen by cache maintence operations) - -| Restrictions | | -| ------------ | ---------- | -| **Minimum** | ≥ 1 | -| **Maximum** | ≤ 65536 | - -### 1.18. Property `Unified Architecture Specification > params > NUM_EXTERNAL_GUEST_INTERRUPTS` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -**Description:** Number of supported virtualized guest external interrupts. -Corresponds to the GEILEN parameter in RISC-V specifications. - -| Restrictions | | -| ------------ | ------- | -| **Minimum** | ≥ 1 | -| **Maximum** | ≤ 63 | - -## 2. Property `Unified Architecture Specification > exception_codes` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | -| **Defined in** | misc/exception_code_schema.json | - -## 3. Property `Unified Architecture Specification > implemented_extensions` - -| | | -| ------------ | ----------------- | -| **Type** | `array of object` | -| **Required** | Yes | - -**Description:** Extensions implemented by this architecture - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------------------------- | ----------- | -| [implemented_extensions items](#implemented_extensions_items) | - | - -### 3.1. Unified Architecture Specification > implemented_extensions > implemented_extensions items - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| --------------------------------------------------- | ------- | ----------- | ---------- | ---------- | ----------------- | -| + [name](#implemented_extensions_items_name ) | No | string | No | - | Extension name | -| + [version](#implemented_extensions_items_version ) | No | Combination | No | - | - | - -#### 3.1.1. Property `Unified Architecture Specification > implemented_extensions > implemented_extensions items > name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -**Description:** Extension name - -| Restrictions | | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | -| **Must match regular expression** | ```^([A-WY]\|([SXZ][a-z0-9]+))$``` [Test](https://regex101.com/?regex=%5E%28%5BA-WY%5D%7C%28%5BSXZ%5D%5Ba-z0-9%5D%2B%29%29%24) | - -#### 3.1.2. Property `Unified Architecture Specification > implemented_extensions > implemented_extensions items > version` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| One of(Option) | -| -------------------------------------------------------- | -| [item 0](#implemented_extensions_items_version_oneOf_i0) | -| [item 1](#implemented_extensions_items_version_oneOf_i1) | - -##### 3.1.2.1. Property `Unified Architecture Specification > implemented_extensions > implemented_extensions items > version > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Extension version - -##### 3.1.2.2. Property `Unified Architecture Specification > implemented_extensions > implemented_extensions items > version > oneOf > item 1` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -## 4. Property `Unified Architecture Specification > extensions` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ----------------------------- | ------- | ------ | ---------- | -------------------------------------------- | ----------------- | -| - [.*](#extensions_pattern1 ) | Yes | object | No | In ext/extension_schema.json#/$defs/ext_data | - | - -### 4.1. Pattern Property `Unified Architecture Specification > extensions > ext_data` -> All properties whose name matches the regular expression -```.*``` ([Test](https://regex101.com/?regex=.%2A)) -must respect the following conditions - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | -| **Defined in** | ext/extension_schema.json#/$defs/ext_data | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ---------------------------------------------------------- | ------- | ---------------- | ---------- | ---------- | --------------------------------------- | -| - [name](#extensions_pattern1_name ) | No | string | No | - | - | -| + [description](#extensions_pattern1_description ) | No | string | No | - | - | -| - [type](#extensions_pattern1_type ) | No | enum (of string) | No | - | - | -| - [requires](#extensions_pattern1_requires ) | No | Combination | No | - | Extension(s) required by this extension | -| + [versions](#extensions_pattern1_versions ) | No | array of object | No | - | - | -| - [exception_codes](#extensions_pattern1_exception_codes ) | No | array of object | No | - | - | -| - [interrupt_codes](#extensions_pattern1_interrupt_codes ) | No | array of object | No | - | - | - -#### 4.1.1. Property `Unified Architecture Specification > extensions > .* > name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -#### 4.1.2. Property `Unified Architecture Specification > extensions > .* > description` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -#### 4.1.3. Property `Unified Architecture Specification > extensions > .* > type` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | No | - -Must be one of: -* "unprivileged" -* "privileged" - -#### 4.1.4. Property `Unified Architecture Specification > extensions > .* > requires` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -**Description:** Extension(s) required by this extension - -| One of(Option) | -| ------------------------------------------------ | -| [item 0](#extensions_pattern1_requires_oneOf_i0) | -| [item 1](#extensions_pattern1_requires_oneOf_i1) | - -##### 4.1.4.1. Property `Unified Architecture Specification > extensions > .* > requires > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -##### 4.1.4.2. Property `Unified Architecture Specification > extensions > .* > requires > oneOf > item 1` - -| | | -| ------------ | ----------------- | -| **Type** | `array of string` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------------------------ | ----------- | -| [item 1 items](#extensions_pattern1_requires_oneOf_i1_items) | - | - -###### 4.1.4.2.1. Unified Architecture Specification > extensions > .* > requires > oneOf > item 1 > item 1 items - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -#### 4.1.5. Property `Unified Architecture Specification > extensions > .* > versions` - -| | | -| ------------ | ----------------- | -| **Type** | `array of object` | -| **Required** | Yes | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ----------------------------------------------------- | ----------- | -| [versions items](#extensions_pattern1_versions_items) | - | - -##### 4.1.5.1. Unified Architecture Specification > extensions > .* > versions > versions items - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ----------------------------------------------------------------------------- | ------- | ----------- | ---------- | ---------- | -------------------------- | -| + [version](#extensions_pattern1_versions_items_version ) | No | Combination | No | - | - | -| + [ratification_date](#extensions_pattern1_versions_items_ratification_date ) | No | Combination | No | - | - | -| - [changes](#extensions_pattern1_versions_items_changes ) | No | string | No | - | Changes since last version | -| - [url](#extensions_pattern1_versions_items_url ) | No | string | No | - | Link to ratified document | - -###### 4.1.5.1.1. Property `Unified Architecture Specification > extensions > .* > versions > versions items > version` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| One of(Option) | -| -------------------------------------------------------------- | -| [item 0](#extensions_pattern1_versions_items_version_oneOf_i0) | -| [item 1](#extensions_pattern1_versions_items_version_oneOf_i1) | - -###### 4.1.5.1.1.1. Property `Unified Architecture Specification > extensions > .* > versions > versions items > version > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -###### 4.1.5.1.1.2. Property `Unified Architecture Specification > extensions > .* > versions > versions items > version > oneOf > item 1` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^[0-9]+(\.[0-9]+(\.[0-9]+(-[a-fA-F0-9]+)?)?)?$``` [Test](https://regex101.com/?regex=%5E%5B0-9%5D%2B%28%5C.%5B0-9%5D%2B%28%5C.%5B0-9%5D%2B%28-%5Ba-fA-F0-9%5D%2B%29%3F%29%3F%29%3F%24) | - -###### 4.1.5.1.2. Property `Unified Architecture Specification > extensions > .* > versions > versions items > ratification_date` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| One of(Option) | -| ------------------------------------------------------------------------ | -| [item 0](#extensions_pattern1_versions_items_ratification_date_oneOf_i0) | -| [item 1](#extensions_pattern1_versions_items_ratification_date_oneOf_i1) | -| [item 2](#extensions_pattern1_versions_items_ratification_date_oneOf_i2) | - -###### 4.1.5.1.2.1. Property `Unified Architecture Specification > extensions > .* > versions > versions items > ratification_date > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | ----------------------------------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^20[0-9][0-9]-[0-9][0-9]$``` [Test](https://regex101.com/?regex=%5E20%5B0-9%5D%5B0-9%5D-%5B0-9%5D%5B0-9%5D%24) | - -###### 4.1.5.1.2.2. Property `Unified Architecture Specification > extensions > .* > versions > versions items > ratification_date > oneOf > item 1` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | ----------------------------------------------------------------- | -| **Must match regular expression** | ```^unknown$``` [Test](https://regex101.com/?regex=%5Eunknown%24) | - -###### 4.1.5.1.2.3. Property `Unified Architecture Specification > extensions > .* > versions > versions items > ratification_date > oneOf > item 2` - -| | | -| ------------ | ------ | -| **Type** | `null` | -| **Required** | No | - -###### 4.1.5.1.3. Property `Unified Architecture Specification > extensions > .* > versions > versions items > changes` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Changes since last version - -###### 4.1.5.1.4. Property `Unified Architecture Specification > extensions > .* > versions > versions items > url` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | -| **Format** | `uri` | - -**Description:** Link to ratified document - -#### 4.1.6. Property `Unified Architecture Specification > extensions > .* > exception_codes` - -| | | -| ------------ | ----------------- | -| **Type** | `array of object` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------------------------------- | ------------------------------------ | -| [exception_codes items](#extensions_pattern1_exception_codes_items) | Exceptions defined by this extension | - -##### 4.1.6.1. Unified Architecture Specification > extensions > .* > exception_codes > exception_codes items - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -**Description:** Exceptions defined by this extension - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ---------------------------------------------------------- | ------- | ------- | ---------- | ---------- | ----------------- | -| - [num](#extensions_pattern1_exception_codes_items_num ) | No | integer | No | - | - | -| - [name](#extensions_pattern1_exception_codes_items_name ) | No | string | No | - | - | - -###### 4.1.6.1.1. Property `Unified Architecture Specification > extensions > .* > exception_codes > exception_codes items > num` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | No | - -###### 4.1.6.1.2. Property `Unified Architecture Specification > extensions > .* > exception_codes > exception_codes items > name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -#### 4.1.7. Property `Unified Architecture Specification > extensions > .* > interrupt_codes` - -| | | -| ------------ | ----------------- | -| **Type** | `array of object` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------------------------------- | ------------------------------------ | -| [interrupt_codes items](#extensions_pattern1_interrupt_codes_items) | Interrupts defined by this extension | - -##### 4.1.7.1. Unified Architecture Specification > extensions > .* > interrupt_codes > interrupt_codes items - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -**Description:** Interrupts defined by this extension - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ---------------------------------------------------------- | ------- | ------- | ---------- | ---------- | ----------------- | -| - [num](#extensions_pattern1_interrupt_codes_items_num ) | No | integer | No | - | - | -| - [name](#extensions_pattern1_interrupt_codes_items_name ) | No | string | No | - | - | - -###### 4.1.7.1.1. Property `Unified Architecture Specification > extensions > .* > interrupt_codes > interrupt_codes items > num` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | No | - -###### 4.1.7.1.2. Property `Unified Architecture Specification > extensions > .* > interrupt_codes > interrupt_codes items > name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -## 5. Property `Unified Architecture Specification > csrs` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ----------------------- | ------- | ------ | ---------- | ------------------------------------------ | ----------------- | -| - [.*](#csrs_pattern1 ) | Yes | object | No | In csr/csr_schema.json#/$defs/csr_register | - | - -### 5.1. Pattern Property `Unified Architecture Specification > csrs > csr_register` -> All properties whose name matches the regular expression -```.*``` ([Test](https://regex101.com/?regex=.%2A)) -must respect the following conditions - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | -| **Defined in** | csr/csr_schema.json#/$defs/csr_register | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ---------------------------------------------------- | ------- | --------------------------- | ---------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| - [name](#csrs_pattern1_name ) | No | string | No | - | Optional name (name is extracted from object key of parent), so information is redundant | -| - [base](#csrs_pattern1_base ) | No | enum (of integer) | No | - | When a CSR is only defined in RV32, or RV64, the base that defines it. When defined in both, this field should be absent. | -| + [long_name](#csrs_pattern1_long_name ) | No | string | No | - | - | -| + [description](#csrs_pattern1_description ) | No | string | No | - | - | -| + [definedBy](#csrs_pattern1_definedBy ) | No | string | No | - | - | -| + [address](#csrs_pattern1_address ) | No | integer | No | - | CSR address | -| - [virtual_address](#csrs_pattern1_virtual_address ) | No | object | No | - | - | -| - [$comment](#csrs_pattern1_comment ) | No | object | No | - | - | -| + [priv_mode](#csrs_pattern1_priv_mode ) | No | enum (of string) | No | - | - | -| + [length](#csrs_pattern1_length ) | No | enum (of integer or string) | No | - | Length, in bits, of the CSR. Can either be a 32, 64, or XLEN | -| - [requires](#csrs_pattern1_requires ) | No | string | No | - | Extension that must be implemented for this CSR to exist | -| - [fields](#csrs_pattern1_fields ) | No | object | No | - | - | -| - [access_check](#csrs_pattern1_access_check ) | No | string | No | - | Optional function called to handle special-case checks for access permission. | -| - [sw_read](#csrs_pattern1_sw_read ) | No | string | No | - | Function that returns the value of the CSR when read by software (i.e., a Zicsr instruction). If not specified, the value last written (through hw_write) is returned. | - -#### 5.1.1. If (priv_mode = "VS") - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ------------------------------------------------------------- | ------- | ------ | ---------- | ---------- | -------------------------------------- | -| + [virtual_address](#csrs_pattern1_pattern5_virtual_address ) | No | number | No | - | Address of the CSR viewed from VS-mode | - -##### 5.1.1.1. Property `Unified Architecture Specification > csrs > .* > then > virtual_address` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | Yes | - -**Description:** Address of the CSR viewed from VS-mode - -#### 5.1.2. Property `Unified Architecture Specification > csrs > .* > name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Optional name (name is extracted from object key of parent), so information is redundant - -#### 5.1.3. Property `Unified Architecture Specification > csrs > .* > base` - -| | | -| ------------ | ------------------- | -| **Type** | `enum (of integer)` | -| **Required** | No | - -**Description:** When a CSR is only defined in RV32, or RV64, the base that defines it. When defined in both, this field should be absent. - -Must be one of: -* 32 -* 64 - -#### 5.1.4. Property `Unified Architecture Specification > csrs > .* > long_name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -#### 5.1.5. Property `Unified Architecture Specification > csrs > .* > description` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -#### 5.1.6. Property `Unified Architecture Specification > csrs > .* > definedBy` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -| Restrictions | | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | -| **Must match regular expression** | ```^([A-WY]\|([SXZ][a-z]+))$``` [Test](https://regex101.com/?regex=%5E%28%5BA-WY%5D%7C%28%5BSXZ%5D%5Ba-z%5D%2B%29%29%24) | - -#### 5.1.7. Property `Unified Architecture Specification > csrs > .* > address` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | Yes | - -**Description:** CSR address - -#### 5.1.8. Property `Unified Architecture Specification > csrs > .* > virtual_address` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -#### 5.1.9. Property `Unified Architecture Specification > csrs > .* > $comment` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -#### 5.1.10. Property `Unified Architecture Specification > csrs > .* > priv_mode` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | Yes | - -Must be one of: -* "M" -* "S" -* "U" -* "VS" - -#### 5.1.11. Property `Unified Architecture Specification > csrs > .* > length` - -| | | -| ------------ | ----------------------------- | -| **Type** | `enum (of integer or string)` | -| **Required** | Yes | - -**Description:** Length, in bits, of the CSR. Can either be a 32, 64, or XLEN - -Must be one of: -* 32 -* 64 -* "XLEN" - -#### 5.1.12. Property `Unified Architecture Specification > csrs > .* > requires` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Extension that must be implemented for this CSR to exist - -#### 5.1.13. Property `Unified Architecture Specification > csrs > .* > fields` - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ------------------------------------------------- | ------- | ------ | ---------- | -------------------- | ----------------------- | -| - [^[a-zA-Z].*$](#csrs_pattern1_fields_pattern1 ) | Yes | object | No | In #/$defs/csr_field | Field in a CSR register | - -##### 5.1.13.1. Pattern Property `Unified Architecture Specification > csrs > .* > fields > csr_field` -> All properties whose name matches the regular expression -```^[a-zA-Z].*$``` ([Test](https://regex101.com/?regex=%5E%5Ba-zA-Z%5D.%2A%24)) -must respect the following conditions - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | -| **Defined in** | #/$defs/csr_field | - -**Description:** Field in a CSR register - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| -------------------------------------------------------------- | ------- | ---------------- | ---------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| + [location](#csrs_pattern1_fields_pattern1_location ) | No | Combination | No | - | Location of the field within the CSR register | -| + [description](#csrs_pattern1_fields_pattern1_description ) | No | string | No | - | Function of the field | -| + [type](#csrs_pattern1_fields_pattern1_type ) | No | enum (of string) | No | - | Type of the field. One of:
    * RO: Read-only immutable
    * RO-H: Read-only, updated by hardware
    * RW: Read-write, not updated by hardware
    * RW-R: Read-write, but values are restricted. write(value) must be provided
    * RW-H: Read-write, with hardware updates
    * RW-RH: Read-write, with hardware updates, but values are restricted. write(value) must be provded | -| - [alias](#csrs_pattern1_fields_pattern1_alias ) | No | Combination | No | - | Other CSR fields that alias with this field | -| - [definedBy](#csrs_pattern1_fields_pattern1_definedBy ) | No | Combination | No | - | Where this field is defined: indicates that the field is only present if the extension(s) are implemented. If definedBy is not given, defaults to the definedBy field of the parent CSR | -| - [affectedBy](#csrs_pattern1_fields_pattern1_affectedBy ) | No | Combination | No | - | Extension(s) that affect the definition of the field beyond the extension (or base) the field is originally defined in | -| - [reset_value](#csrs_pattern1_fields_pattern1_reset_value ) | No | object | No | - | - | -| - [value](#csrs_pattern1_fields_pattern1_value ) | No | object | No | - | - | -| - [write(value)](#csrs_pattern1_fields_pattern1_write(value) ) | No | object | No | - | - | - -| All of(Requirement) | -| ---------------------------------------------------- | -| [item 0](#csrs_pattern1_fields_pattern1_pattern4_i0) | -| [item 1](#csrs_pattern1_fields_pattern1_pattern4_i1) | -| [item 2](#csrs_pattern1_fields_pattern1_pattern4_i2) | -| [item 3](#csrs_pattern1_fields_pattern1_pattern4_i3) | -| [item 4](#csrs_pattern1_fields_pattern1_pattern4_i4) | -| [item 5](#csrs_pattern1_fields_pattern1_pattern4_i5) | - -###### 5.1.13.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 0` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -###### 5.1.13.1.1.1. If (type = "RO") - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ----------------------------------------------------------------- | ------- | ----------- | ---------- | ---------- | ----------------- | -| + [value](#csrs_pattern1_fields_pattern1_pattern4_i0_then_value ) | No | Combination | No | - | - | - -###### 5.1.13.1.1.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 0 > then > value` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| One of(Option) | -| ------------------------------------------------------------------------ | -| [item 0](#csrs_pattern1_fields_pattern1_pattern4_i0_then_value_oneOf_i0) | -| [item 1](#csrs_pattern1_fields_pattern1_pattern4_i0_then_value_oneOf_i1) | - -###### 5.1.13.1.1.1.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 0 > then > value > oneOf > item 0` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | No | - -###### 5.1.13.1.1.1.1.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 0 > then > value > oneOf > item 1` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | ----------------------------------------------------------------------------- | -| **Must match regular expression** | ```^<%=.*%>$``` [Test](https://regex101.com/?regex=%5E%3C%25%3D.%2A%25%3E%24) | - -###### 5.1.13.1.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 1` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -###### 5.1.13.1.2.1. If (type = "RO-H") - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ----------------------------------------------------------------------------- | ------- | ------- | ---------- | ---------- | ----------------- | -| + [reset_value](#csrs_pattern1_fields_pattern1_pattern4_i1_then_reset_value ) | No | integer | No | - | - | - -###### 5.1.13.1.2.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 1 > then > reset_value` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | Yes | - -###### 5.1.13.1.3. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 2` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -###### 5.1.13.1.3.1. If (type = "RW") - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ----------------------------------------------------------------------------- | ------- | ------- | ---------- | ---------- | ----------------- | -| + [reset_value](#csrs_pattern1_fields_pattern1_pattern4_i2_then_reset_value ) | No | integer | No | - | - | - -###### 5.1.13.1.3.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 2 > then > reset_value` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | Yes | - -###### 5.1.13.1.4. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 3` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -###### 5.1.13.1.4.1. If (type = "RW-H") - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ----------------------------------------------------------------------------- | ------- | ------- | ---------- | ---------- | ----------------- | -| + [reset_value](#csrs_pattern1_fields_pattern1_pattern4_i3_then_reset_value ) | No | integer | No | - | - | - -###### 5.1.13.1.4.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 3 > then > reset_value` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | Yes | - -###### 5.1.13.1.5. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 4` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -###### 5.1.13.1.5.1. If (type = "RW-R") - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ------------------------------------------------------------------------------- | ------- | ------- | ---------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| + [write(value)](#csrs_pattern1_fields_pattern1_pattern4_i4_then_write(value) ) | No | string | No | In #/$defs/write(value) | Function implementing custom write behavior for the CSR. Given a 'value', return either the value to be written in the field or false if the write would be illegal. 'value' is the value of the entire CSR, which is sometimes needed to detect illegal writes | -| + [reset_value](#csrs_pattern1_fields_pattern1_pattern4_i4_then_reset_value ) | No | integer | No | - | - | - -###### 5.1.13.1.5.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 4 > then > write(value)` - -| | | -| -------------- | -------------------- | -| **Type** | `string` | -| **Required** | Yes | -| **Defined in** | #/$defs/write(value) | - -**Description:** Function implementing custom write behavior for the CSR. Given a 'value', return either the value to be written in the field or false if the write would be illegal. 'value' is the value of the entire CSR, which is sometimes needed to detect illegal writes - -###### 5.1.13.1.5.1.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 4 > then > reset_value` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | Yes | - -###### 5.1.13.1.6. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 5` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -###### 5.1.13.1.6.1. If (type = "RW-RH") - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ------------------------------------------------------------------------------- | ------- | ------- | ---------- | ------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| + [write(value)](#csrs_pattern1_fields_pattern1_pattern4_i5_then_write(value) ) | No | string | No | Same as [write(value)](#csrs_pattern1_fields_pattern1_pattern4_i4_then_write(value) ) | Function implementing custom write behavior for the CSR. Given a 'value', return either the value to be written in the field or false if the write would be illegal. 'value' is the value of the entire CSR, which is sometimes needed to detect illegal writes | -| + [reset_value](#csrs_pattern1_fields_pattern1_pattern4_i5_then_reset_value ) | No | integer | No | - | - | - -###### 5.1.13.1.6.1.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 5 > then > write(value)` - -| | | -| ---------------------- | ---------------------------------------------------------------------------- | -| **Type** | `string` | -| **Required** | Yes | -| **Same definition as** | [write(value)](#csrs_pattern1_fields_pattern1_pattern4_i4_then_write(value)) | - -**Description:** Function implementing custom write behavior for the CSR. Given a 'value', return either the value to be written in the field or false if the write would be illegal. 'value' is the value of the entire CSR, which is sometimes needed to detect illegal writes - -###### 5.1.13.1.6.1.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > allOf > item 5 > then > reset_value` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | Yes | - -###### 5.1.13.1.7. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > location` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -**Description:** Location of the field within the CSR register - -| One of(Option) | -| ---------------------------------------------------------- | -| [item 0](#csrs_pattern1_fields_pattern1_location_oneOf_i0) | -| [item 1](#csrs_pattern1_fields_pattern1_location_oneOf_i1) | - -###### 5.1.13.1.7.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > location > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -**Description:** Location of a single bit - -###### 5.1.13.1.7.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > location > oneOf > item 1` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Location range of a multibit field - -| Restrictions | | -| --------------------------------- | ----------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^[0-9]+-[0-9]+$``` [Test](https://regex101.com/?regex=%5E%5B0-9%5D%2B-%5B0-9%5D%2B%24) | - -###### 5.1.13.1.8. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > description` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -**Description:** Function of the field - -###### 5.1.13.1.9. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > type` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | Yes | - -**Description:** Type of the field. One of: - * RO: Read-only immutable - * RO-H: Read-only, updated by hardware - * RW: Read-write, not updated by hardware - * RW-R: Read-write, but values are restricted. write(value) must be provided - * RW-H: Read-write, with hardware updates - * RW-RH: Read-write, with hardware updates, but values are restricted. write(value) must be provded - -Must be one of: -* "RO" -* "RO-H" -* "RW" -* "RW-R" -* "RW-H" -* "RW-RH" - -###### 5.1.13.1.10. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > alias` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -**Description:** Other CSR fields that alias with this field - -| One of(Option) | -| ------------------------------------------------------- | -| [item 0](#csrs_pattern1_fields_pattern1_alias_oneOf_i0) | -| [item 1](#csrs_pattern1_fields_pattern1_alias_oneOf_i1) | - -###### 5.1.13.1.10.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > alias > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | --------------------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^[a-z]+\.[A-Z0-9]+$``` [Test](https://regex101.com/?regex=%5E%5Ba-z%5D%2B%5C.%5BA-Z0-9%5D%2B%24) | - -###### 5.1.13.1.10.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > alias > oneOf > item 1` - -| | | -| ------------ | ----------------- | -| **Type** | `array of string` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------------------------------- | ----------- | -| [item 1 items](#csrs_pattern1_fields_pattern1_alias_oneOf_i1_items) | - | - -###### 5.1.13.1.10.2.1. Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > alias > oneOf > item 1 > item 1 items - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | --------------------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^[a-z]+\.[A-Z0-9]+$``` [Test](https://regex101.com/?regex=%5E%5Ba-z%5D%2B%5C.%5BA-Z0-9%5D%2B%24) | - -###### 5.1.13.1.11. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > definedBy` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -**Description:** Where this field is defined: indicates that the field is only present if the extension(s) are implemented. If definedBy is not given, defaults to the definedBy field of the parent CSR - -| One of(Option) | -| ----------------------------------------------------------- | -| [item 0](#csrs_pattern1_fields_pattern1_definedBy_oneOf_i0) | -| [item 1](#csrs_pattern1_fields_pattern1_definedBy_oneOf_i1) | - -###### 5.1.13.1.11.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > definedBy > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** An extension name - -| Restrictions | | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | -| **Must match regular expression** | ```^([A-WY]\|([SXZ][a-z]+))$``` [Test](https://regex101.com/?regex=%5E%28%5BA-WY%5D%7C%28%5BSXZ%5D%5Ba-z%5D%2B%29%29%24) | - -###### 5.1.13.1.11.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > definedBy > oneOf > item 1` - -| | | -| ------------ | ----------------- | -| **Type** | `array of string` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ----------------------------------------------------------------------- | ----------------- | -| [item 1 items](#csrs_pattern1_fields_pattern1_definedBy_oneOf_i1_items) | An extension name | - -###### 5.1.13.1.11.2.1. Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > definedBy > oneOf > item 1 > item 1 items - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** An extension name - -| Restrictions | | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | -| **Must match regular expression** | ```^([A-WY]\|([SXZ][a-z]+))$``` [Test](https://regex101.com/?regex=%5E%28%5BA-WY%5D%7C%28%5BSXZ%5D%5Ba-z%5D%2B%29%29%24) | - -###### 5.1.13.1.12. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > affectedBy` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -**Description:** Extension(s) that affect the definition of the field beyond the extension (or base) the field is originally defined in - -| One of(Option) | -| ------------------------------------------------------------ | -| [item 0](#csrs_pattern1_fields_pattern1_affectedBy_oneOf_i0) | -| [item 1](#csrs_pattern1_fields_pattern1_affectedBy_oneOf_i1) | - -###### 5.1.13.1.12.1. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > affectedBy > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| **Must match regular expression** | ```^(RV64)\|([A-WY]\|(Z[a-z]+)\|(S[a-z]+))$``` [Test](https://regex101.com/?regex=%5E%28RV64%29%7C%28%5BA-WY%5D%7C%28Z%5Ba-z%5D%2B%29%7C%28S%5Ba-z%5D%2B%29%29%24) | - -###### 5.1.13.1.12.2. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > affectedBy > oneOf > item 1` - -| | | -| ------------ | ----------------- | -| **Type** | `array of string` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------------------------------------ | ----------- | -| [item 1 items](#csrs_pattern1_fields_pattern1_affectedBy_oneOf_i1_items) | - | - -###### 5.1.13.1.12.2.1. Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > affectedBy > oneOf > item 1 > item 1 items - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| **Must match regular expression** | ```^(RV64)\|([A-WY]\|(Z[a-z]+)\|(S[a-z]+))$``` [Test](https://regex101.com/?regex=%5E%28RV64%29%7C%28%5BA-WY%5D%7C%28Z%5Ba-z%5D%2B%29%7C%28S%5Ba-z%5D%2B%29%29%24) | - -###### 5.1.13.1.13. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > reset_value` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -###### 5.1.13.1.14. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > value` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -###### 5.1.13.1.15. Property `Unified Architecture Specification > csrs > .* > fields > ^[a-zA-Z].*$ > write(value)` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -#### 5.1.14. Property `Unified Architecture Specification > csrs > .* > access_check` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Optional function called to handle special-case checks for access permission. - -#### 5.1.15. Property `Unified Architecture Specification > csrs > .* > sw_read` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Function that returns the value of the CSR when read by software (i.e., a Zicsr instruction). If not specified, the value last written (through hw_write) is returned. - -## 6. Property `Unified Architecture Specification > implemented_csrs` - -| | | -| ------------ | ----------------- | -| **Type** | `array of string` | -| **Required** | Yes | - -**Description:** CSRs implemented by this architecture - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------------- | ----------- | -| [implemented_csrs items](#implemented_csrs_items) | CSR name | - -### 6.1. Unified Architecture Specification > implemented_csrs > implemented_csrs items - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** CSR name - -| Restrictions | | -| --------------------------------- | ----------------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^[a-z][a-zA-Z0-9]+$``` [Test](https://regex101.com/?regex=%5E%5Ba-z%5D%5Ba-zA-Z0-9%5D%2B%24) | - -## 7. Property `Unified Architecture Specification > instructions` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ------------------------------------------------- | ------- | ------ | ---------- | ----------------------------------------- | ----------------- | -| - [.*](#instructions_pattern1 ) | Yes | object | No | In inst/inst_schema.json#/$defs/inst_data | - | -| - [additionalProperties](#instructions_pattern2 ) | Yes | object | No | - | - | - -### 7.1. Pattern Property `Unified Architecture Specification > instructions > inst_data` -> All properties whose name matches the regular expression -```.*``` ([Test](https://regex101.com/?regex=.%2A)) -must respect the following conditions - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | -| **Defined in** | inst/inst_schema.json#/$defs/inst_data | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| -------------------------------------------------------- | ------- | ------------------------- | ---------- | ---------- | ---------------------------------------------------------------------------------------------------- | -| - [name](#instructions_pattern1_name ) | No | string | No | - | - | -| + [long_name](#instructions_pattern1_long_name ) | No | string | No | - | Short descrption of the instruction | -| + [description](#instructions_pattern1_description ) | No | string | No | - | Detailed description of the instruction | -| + [definedBy](#instructions_pattern1_definedBy ) | No | Combination | No | - | Extension(s) that defines the instruction | -| - [base](#instructions_pattern1_base ) | No | enum (of integer) | No | - | When present, instruction is only defined for RV32 or RV64 base | -| + [access](#instructions_pattern1_access ) | No | object | No | - | - | -| - [access_detail](#instructions_pattern1_access_detail ) | No | string | No | - | Extra detail about access when at least one mode is 'sometimes' | -| - [raises](#instructions_pattern1_raises ) | No | array of enum (of string) | No | - | Types of exceptions that can be raised by this instruction (excluding Instruction Page/Access Fault) | -| - [operation](#instructions_pattern1_operation ) | No | string | No | - | Functional description of the instruction using ISA language | -| + [assembly](#instructions_pattern1_assembly ) | No | string | No | - | Assembly format of the instruction. Can use decode variables | - -#### 7.1.1. Property `Unified Architecture Specification > instructions > .* > name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | ----------------------------------------------------------------------------- | -| **Must match regular expression** | ```^[a-z0-9.]+$``` [Test](https://regex101.com/?regex=%5E%5Ba-z0-9.%5D%2B%24) | - -#### 7.1.2. Property `Unified Architecture Specification > instructions > .* > long_name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -**Description:** Short descrption of the instruction - -#### 7.1.3. Property `Unified Architecture Specification > instructions > .* > description` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -**Description:** Detailed description of the instruction - -#### 7.1.4. Property `Unified Architecture Specification > instructions > .* > definedBy` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -**Description:** Extension(s) that defines the instruction - -| One of(Option) | -| ------------------------------------------------------ | -| [extension](#instructions_pattern1_definedBy_oneOf_i0) | -| [item 1](#instructions_pattern1_definedBy_oneOf_i1) | - -##### 7.1.4.1. Property `Unified Architecture Specification > instructions > .* > definedBy > oneOf > extension` - -| | | -| -------------- | ----------------- | -| **Type** | `string` | -| **Required** | No | -| **Defined in** | #/$defs/extension | - -**Description:** RISC-V Extension - -| Restrictions | | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------ | -| **Must match regular expression** | ```^[A-W,Y]\|([XZ][a-z]+)$``` [Test](https://regex101.com/?regex=%5E%5BA-W%2CY%5D%7C%28%5BXZ%5D%5Ba-z%5D%2B%29%24) | - -##### 7.1.4.2. Property `Unified Architecture Specification > instructions > .* > definedBy > oneOf > item 1` - -| | | -| ------------ | ------- | -| **Type** | `array` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------------------------ | ---------------- | -| [extension](#instructions_pattern1_definedBy_oneOf_i1_items) | RISC-V Extension | - -###### 7.1.4.2.1. Unified Architecture Specification > instructions > .* > definedBy > oneOf > item 1 > extension - -| | | -| ---------------------- | ------------------------------------------------------------------------------------- | -| **Type** | `string` | -| **Required** | No | -| **Same definition as** | [instructions_pattern1_definedBy_oneOf_i0](#instructions_pattern1_definedBy_oneOf_i0) | - -**Description:** RISC-V Extension - -#### 7.1.5. Property `Unified Architecture Specification > instructions > .* > base` - -| | | -| ------------ | ------------------- | -| **Type** | `enum (of integer)` | -| **Required** | No | - -**Description:** When present, instruction is only defined for RV32 or RV64 base - -Must be one of: -* 32 -* 64 - -#### 7.1.6. Property `Unified Architecture Specification > instructions > .* > access` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ----------------------------------------- | ------- | ---------------- | ---------- | ---------- | ----------------- | -| - [m](#instructions_pattern1_access_m ) | No | enum (of string) | No | - | - | -| + [s](#instructions_pattern1_access_s ) | No | enum (of string) | No | - | - | -| + [u](#instructions_pattern1_access_u ) | No | enum (of string) | No | - | - | -| + [vs](#instructions_pattern1_access_vs ) | No | enum (of string) | No | - | - | -| + [vu](#instructions_pattern1_access_vu ) | No | enum (of string) | No | - | - | - -##### 7.1.6.1. Property `Unified Architecture Specification > instructions > .* > access > m` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | No | -| **Default** | `"always"` | - -Must be one of: -* "always" -* "sometimes" -* "never" - -##### 7.1.6.2. Property `Unified Architecture Specification > instructions > .* > access > s` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | Yes | -| **Default** | `"always"` | - -Must be one of: -* "always" -* "sometimes" -* "never" - -##### 7.1.6.3. Property `Unified Architecture Specification > instructions > .* > access > u` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | Yes | -| **Default** | `"always"` | - -Must be one of: -* "always" -* "sometimes" -* "never" - -##### 7.1.6.4. Property `Unified Architecture Specification > instructions > .* > access > vs` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | Yes | -| **Default** | `"always"` | - -Must be one of: -* "always" -* "sometimes" -* "never" - -##### 7.1.6.5. Property `Unified Architecture Specification > instructions > .* > access > vu` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | Yes | -| **Default** | `"always"` | - -Must be one of: -* "always" -* "sometimes" -* "never" - -#### 7.1.7. Property `Unified Architecture Specification > instructions > .* > access_detail` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Extra detail about access when at least one mode is 'sometimes' - -#### 7.1.8. Property `Unified Architecture Specification > instructions > .* > raises` - -| | | -| ------------ | --------------------------- | -| **Type** | `array of enum (of string)` | -| **Required** | No | -| **Default** | `[]` | - -**Description:** Types of exceptions that can be raised by this instruction (excluding Instruction Page/Access Fault) - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| --------------------------------------------------- | ----------- | -| [raises items](#instructions_pattern1_raises_items) | - | - -##### 7.1.8.1. Unified Architecture Specification > instructions > .* > raises > raises items - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | No | - -Must be one of: -* "Store/AMO Page Fault" -* "Store/AMO Guest-Page Fault" -* "Store Access Fault" -* "Illegal Instruction" -* "Virtual Instruction" -* "MisalignedAddress" - -#### 7.1.9. Property `Unified Architecture Specification > instructions > .* > operation` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Functional description of the instruction using ISA language - -#### 7.1.10. Property `Unified Architecture Specification > instructions > .* > assembly` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -**Description:** Assembly format of the instruction. Can use decode variables - -### 7.2. Pattern Property `Unified Architecture Specification > instructions > additionalProperties` -> All properties whose name matches the regular expression -```additionalProperties``` ([Test](https://regex101.com/?regex=additionalProperties)) -must respect the following conditions - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -## 8. Property `Unified Architecture Specification > implemented_instructions` - -| | | -| ------------ | ----------------- | -| **Type** | `array of string` | -| **Required** | Yes | - -**Description:** Instructions implemented by this architecture - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ----------------------------------------------------------------- | ---------------- | -| [implemented_instructions items](#implemented_instructions_items) | Instruction name | - -### 8.1. Unified Architecture Specification > implemented_instructions > implemented_instructions items - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Instruction name - -| Restrictions | | -| --------------------------------- | ------------------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^[a-z][a-zA-Z0-9.]+$``` [Test](https://regex101.com/?regex=%5E%5Ba-z%5D%5Ba-zA-Z0-9.%5D%2B%24) | - ----------------------------------------------------------------------------------------------------------------------------- -Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2024-06-12 at 20:18:06 -0700 diff --git a/docs/schema/csr_schema.html b/docs/schema/csr_schema.html deleted file mode 100644 index 9c07ce019..000000000 --- a/docs/schema/csr_schema.html +++ /dev/null @@ -1,2 +0,0 @@ - CSR description

    CSR description

    Type: object

    A CSR register specification

    No Additional Properties
    Example:

    "misa:\\n  long_name: Machine ISA Control\\n  address: 0x301\\n  priv_mode: M\\n  length: 64\\n  description: Reports the XLEN and 'major' extensions supported by the ISA.\\n  definedBy: I\\n  fields:\\n    MXL:\\n      location: 63-62\\n      description: XLEN in M-mode.\\n      type: RO\\n      value: 2\\n    Extensions:      location: 25-0\\n      description: |\\n        Indicates support for major (single letter) ISA extensions.\\n\\n        Value corresponds to A, D, F, H, I, M, S, U\\n      type: RO\\n      value: 0x1411A9"
    -

    All properties whose name matches the following regular expression must respect the following conditions

    Property name regular expression: ^[a-z][a-z0-9A-Z]+$
    Type: object

    CSR name

    No Additional Properties

    If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

    Type: object

    Type: const
    Specific value: "VS"
    Type: object

    Type: number

    Address of the CSR viewed from VS-mode

    Type: string

    Optional name (name is extracted from object key of parent), so information is redundant

    Type: enum (of integer)

    When a CSR is only defined in RV32, or RV64, the base that defines it. When defined in both, this field should be absent.

    Must be one of:

    • 32
    • 64

    Type: string

    Type: string

    Type: string
    Must match regular expression: ^([A-WY]|([SXZ][a-z]+))$

    Type: integer

    CSR address

    Type: object

    Type: enum (of string)

    Must be one of:

    • "M"
    • "S"
    • "U"
    • "VS"

    Type: enum (of integer or string)

    Length, in bits, of the CSR. Can either be a 32, 64, or XLEN

    Must be one of:

    • 32
    • 64
    • "XLEN"

    Type: string

    Extension that must be implemented for this CSR to exist

    Type: object
    No Additional Properties

    All properties whose name matches the following regular expression must respect the following conditions

    Property name regular expression: ^[a-zA-Z].*$
    Type: object

    Field in a CSR register

    No Additional Properties

    Type: object

    If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

    Type: object

    If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

    Type: object

    Type: const
    Specific value: "RO-H"
    Type: object

    If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

    Type: object

    Type: const
    Specific value: "RW"
    Type: object

    If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

    Type: object

    Type: const
    Specific value: "RW-H"
    Type: object

    If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

    Type: object

    Type: const
    Specific value: "RW-R"
    Type: object

    Type: string

    Function implementing custom write behavior for the CSR. Given a 'value', return either the value to be written in the field or false if the write would be illegal. 'value' is the value of the entire CSR, which is sometimes needed to detect illegal writes

    Type: object

    If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

    Type: object

    Type: const
    Specific value: "RW-RH"
    Type: object

    Type: string

    Function implementing custom write behavior for the CSR. Given a 'value', return either the value to be written in the field or false if the write would be illegal. 'value' is the value of the entire CSR, which is sometimes needed to detect illegal writes

    Same definition as write(value)


    Location of the field within the CSR register

    Type: number

    Location of a single bit

    Type: string

    Location range of a multibit field

    Must match regular expression: ^[0-9]+-[0-9]+$

    Type: string

    Function of the field

    Type: enum (of string)

    Type of the field. One of:
    * RO: Read-only immutable
    * RO-H: Read-only, updated by hardware
    * RW: Read-write, not updated by hardware
    * RW-R: Read-write, but values are restricted. write(value) must be provided
    * RW-H: Read-write, with hardware updates
    * RW-RH: Read-write, with hardware updates, but values are restricted. write(value) must be provded

    Must be one of:

    • "RO"
    • "RO-H"
    • "RW"
    • "RW-R"
    • "RW-H"
    • "RW-RH"


    Other CSR fields that alias with this field

    Type: string
    Must match regular expression: ^[a-z]+\.[A-Z0-9]+$
    Type: array of string
    No Additional Items

    Each item of this array must be:

    Type: string
    Must match regular expression: ^[a-z]+\.[A-Z0-9]+$


    Where this field is defined: indicates that the field is only present if the extension(s) are implemented. If definedBy is not given, defaults to the definedBy field of the parent CSR

    Type: string

    An extension name

    Must match regular expression: ^([A-WY]|([SXZ][a-z]+))$
    Type: array of string
    No Additional Items

    Each item of this array must be:

    Type: string

    An extension name

    Must match regular expression: ^([A-WY]|([SXZ][a-z]+))$


    Extension(s) that affect the definition of the field beyond the extension (or base) the field is originally defined in

    Type: string
    Must match regular expression: ^(RV64)|([A-WY]|(Z[a-z]+)|(S[a-z]+))$
    Type: array of string
    No Additional Items

    Each item of this array must be:

    Type: string
    Must match regular expression: ^(RV64)|([A-WY]|(Z[a-z]+)|(S[a-z]+))$

    Type: string

    Optional function called to handle special-case checks for access permission.

    Type: string

    Function that returns the value of the CSR when read by software (i.e., a Zicsr instruction). If not specified, the value last written (through hw_write) is returned.

    \ No newline at end of file diff --git a/docs/schema/csr_schema.md b/docs/schema/csr_schema.md deleted file mode 100644 index 58a264b32..000000000 --- a/docs/schema/csr_schema.md +++ /dev/null @@ -1,783 +0,0 @@ -# CSR description - -- [1. Pattern Property `CSR description > csr_register`](#pattern1) - - [1.1. If (priv_mode = "VS")](#autogenerated_heading_2) - - [1.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > then > virtual_address`](#pattern1_pattern5_virtual_address) - - [1.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > name`](#pattern1_name) - - [1.3. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > base`](#pattern1_base) - - [1.4. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > long_name`](#pattern1_long_name) - - [1.5. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > description`](#pattern1_description) - - [1.6. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > definedBy`](#pattern1_definedBy) - - [1.7. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > address`](#pattern1_address) - - [1.8. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > virtual_address`](#pattern1_virtual_address) - - [1.9. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > $comment`](#pattern1_comment) - - [1.10. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > priv_mode`](#pattern1_priv_mode) - - [1.11. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > length`](#pattern1_length) - - [1.12. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > requires`](#pattern1_requires) - - [1.13. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields`](#pattern1_fields) - - [1.13.1. Pattern Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > csr_field`](#pattern1_fields_pattern1) - - [1.13.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 0`](#pattern1_fields_pattern1_pattern4_i0) - - [1.13.1.1.1. If (type = "RO")](#autogenerated_heading_3) - - [1.13.1.1.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 0 > then > value`](#pattern1_fields_pattern1_pattern4_i0_then_value) - - [1.13.1.1.1.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 0 > then > value > oneOf > item 0`](#pattern1_fields_pattern1_pattern4_i0_then_value_oneOf_i0) - - [1.13.1.1.1.1.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 0 > then > value > oneOf > item 1`](#pattern1_fields_pattern1_pattern4_i0_then_value_oneOf_i1) - - [1.13.1.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 1`](#pattern1_fields_pattern1_pattern4_i1) - - [1.13.1.2.1. If (type = "RO-H")](#autogenerated_heading_4) - - [1.13.1.2.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 1 > then > reset_value`](#pattern1_fields_pattern1_pattern4_i1_then_reset_value) - - [1.13.1.3. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 2`](#pattern1_fields_pattern1_pattern4_i2) - - [1.13.1.3.1. If (type = "RW")](#autogenerated_heading_5) - - [1.13.1.3.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 2 > then > reset_value`](#pattern1_fields_pattern1_pattern4_i2_then_reset_value) - - [1.13.1.4. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 3`](#pattern1_fields_pattern1_pattern4_i3) - - [1.13.1.4.1. If (type = "RW-H")](#autogenerated_heading_6) - - [1.13.1.4.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 3 > then > reset_value`](#pattern1_fields_pattern1_pattern4_i3_then_reset_value) - - [1.13.1.5. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 4`](#pattern1_fields_pattern1_pattern4_i4) - - [1.13.1.5.1. If (type = "RW-R")](#autogenerated_heading_7) - - [1.13.1.5.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 4 > then > write(value)`](#pattern1_fields_pattern1_pattern4_i4_then_write(value)) - - [1.13.1.5.1.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 4 > then > reset_value`](#pattern1_fields_pattern1_pattern4_i4_then_reset_value) - - [1.13.1.6. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 5`](#pattern1_fields_pattern1_pattern4_i5) - - [1.13.1.6.1. If (type = "RW-RH")](#autogenerated_heading_8) - - [1.13.1.6.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 5 > then > write(value)`](#pattern1_fields_pattern1_pattern4_i5_then_write(value)) - - [1.13.1.6.1.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 5 > then > reset_value`](#pattern1_fields_pattern1_pattern4_i5_then_reset_value) - - [1.13.1.7. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > location`](#pattern1_fields_pattern1_location) - - [1.13.1.7.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > location > oneOf > item 0`](#pattern1_fields_pattern1_location_oneOf_i0) - - [1.13.1.7.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > location > oneOf > item 1`](#pattern1_fields_pattern1_location_oneOf_i1) - - [1.13.1.8. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > description`](#pattern1_fields_pattern1_description) - - [1.13.1.9. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > type`](#pattern1_fields_pattern1_type) - - [1.13.1.10. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > alias`](#pattern1_fields_pattern1_alias) - - [1.13.1.10.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > alias > oneOf > item 0`](#pattern1_fields_pattern1_alias_oneOf_i0) - - [1.13.1.10.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > alias > oneOf > item 1`](#pattern1_fields_pattern1_alias_oneOf_i1) - - [1.13.1.10.2.1. CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > alias > oneOf > item 1 > item 1 items](#autogenerated_heading_9) - - [1.13.1.11. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > definedBy`](#pattern1_fields_pattern1_definedBy) - - [1.13.1.11.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > definedBy > oneOf > item 0`](#pattern1_fields_pattern1_definedBy_oneOf_i0) - - [1.13.1.11.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > definedBy > oneOf > item 1`](#pattern1_fields_pattern1_definedBy_oneOf_i1) - - [1.13.1.11.2.1. CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > definedBy > oneOf > item 1 > item 1 items](#autogenerated_heading_10) - - [1.13.1.12. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > affectedBy`](#pattern1_fields_pattern1_affectedBy) - - [1.13.1.12.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > affectedBy > oneOf > item 0`](#pattern1_fields_pattern1_affectedBy_oneOf_i0) - - [1.13.1.12.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > affectedBy > oneOf > item 1`](#pattern1_fields_pattern1_affectedBy_oneOf_i1) - - [1.13.1.12.2.1. CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > affectedBy > oneOf > item 1 > item 1 items](#autogenerated_heading_11) - - [1.13.1.13. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > reset_value`](#pattern1_fields_pattern1_reset_value) - - [1.13.1.14. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > value`](#pattern1_fields_pattern1_value) - - [1.13.1.15. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > write(value)`](#pattern1_fields_pattern1_write(value)) - - [1.14. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > access_check`](#pattern1_access_check) - - [1.15. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > sw_read`](#pattern1_sw_read) - -**Title:** CSR description - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -**Description:** A CSR register specification - -**Example:** - -```json -"misa:\\n long_name: Machine ISA Control\\n address: 0x301\\n priv_mode: M\\n length: 64\\n description: Reports the XLEN and 'major' extensions supported by the ISA.\\n definedBy: I\\n fields:\\n MXL:\\n location: 63-62\\n description: XLEN in M-mode.\\n type: RO\\n value: 2\\n Extensions: location: 25-0\\n description: |\\n Indicates support for major (single letter) ISA extensions.\\n\\n Value corresponds to A, D, F, H, I, M, S, U\\n type: RO\\n value: 0x1411A9" -``` - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ----------------------------------- | ------- | ------ | ---------- | ----------------------- | ----------------- | -| - [^[a-z][a-z0-9A-Z]+$](#pattern1 ) | Yes | object | No | In #/$defs/csr_register | CSR name | - -## 1. Pattern Property `CSR description > csr_register` -> All properties whose name matches the regular expression -```^[a-z][a-z0-9A-Z]+$``` ([Test](https://regex101.com/?regex=%5E%5Ba-z%5D%5Ba-z0-9A-Z%5D%2B%24)) -must respect the following conditions - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | -| **Defined in** | #/$defs/csr_register | - -**Description:** CSR name - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ----------------------------------------------- | ------- | --------------------------- | ---------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| - [name](#pattern1_name ) | No | string | No | - | Optional name (name is extracted from object key of parent), so information is redundant | -| - [base](#pattern1_base ) | No | enum (of integer) | No | - | When a CSR is only defined in RV32, or RV64, the base that defines it. When defined in both, this field should be absent. | -| + [long_name](#pattern1_long_name ) | No | string | No | - | - | -| + [description](#pattern1_description ) | No | string | No | - | - | -| + [definedBy](#pattern1_definedBy ) | No | string | No | - | - | -| + [address](#pattern1_address ) | No | integer | No | - | CSR address | -| - [virtual_address](#pattern1_virtual_address ) | No | object | No | - | - | -| - [$comment](#pattern1_comment ) | No | object | No | - | - | -| + [priv_mode](#pattern1_priv_mode ) | No | enum (of string) | No | - | - | -| + [length](#pattern1_length ) | No | enum (of integer or string) | No | - | Length, in bits, of the CSR. Can either be a 32, 64, or XLEN | -| - [requires](#pattern1_requires ) | No | string | No | - | Extension that must be implemented for this CSR to exist | -| - [fields](#pattern1_fields ) | No | object | No | - | - | -| - [access_check](#pattern1_access_check ) | No | string | No | - | Optional function called to handle special-case checks for access permission. | -| - [sw_read](#pattern1_sw_read ) | No | string | No | - | Function that returns the value of the CSR when read by software (i.e., a Zicsr instruction). If not specified, the value last written (through hw_write) is returned. | - -### 1.1. If (priv_mode = "VS") - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| -------------------------------------------------------- | ------- | ------ | ---------- | ---------- | -------------------------------------- | -| + [virtual_address](#pattern1_pattern5_virtual_address ) | No | number | No | - | Address of the CSR viewed from VS-mode | - -#### 1.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > then > virtual_address` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | Yes | - -**Description:** Address of the CSR viewed from VS-mode - -### 1.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Optional name (name is extracted from object key of parent), so information is redundant - -### 1.3. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > base` - -| | | -| ------------ | ------------------- | -| **Type** | `enum (of integer)` | -| **Required** | No | - -**Description:** When a CSR is only defined in RV32, or RV64, the base that defines it. When defined in both, this field should be absent. - -Must be one of: -* 32 -* 64 - -### 1.4. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > long_name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -### 1.5. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > description` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -### 1.6. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > definedBy` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -| Restrictions | | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | -| **Must match regular expression** | ```^([A-WY]\|([SXZ][a-z]+))$``` [Test](https://regex101.com/?regex=%5E%28%5BA-WY%5D%7C%28%5BSXZ%5D%5Ba-z%5D%2B%29%29%24) | - -### 1.7. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > address` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | Yes | - -**Description:** CSR address - -### 1.8. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > virtual_address` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -### 1.9. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > $comment` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -### 1.10. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > priv_mode` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | Yes | - -Must be one of: -* "M" -* "S" -* "U" -* "VS" - -### 1.11. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > length` - -| | | -| ------------ | ----------------------------- | -| **Type** | `enum (of integer or string)` | -| **Required** | Yes | - -**Description:** Length, in bits, of the CSR. Can either be a 32, 64, or XLEN - -Must be one of: -* 32 -* 64 -* "XLEN" - -### 1.12. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > requires` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Extension that must be implemented for this CSR to exist - -### 1.13. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields` - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| -------------------------------------------- | ------- | ------ | ---------- | -------------------- | ----------------------- | -| - [^[a-zA-Z].*$](#pattern1_fields_pattern1 ) | Yes | object | No | In #/$defs/csr_field | Field in a CSR register | - -#### 1.13.1. Pattern Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > csr_field` -> All properties whose name matches the regular expression -```^[a-zA-Z].*$``` ([Test](https://regex101.com/?regex=%5E%5Ba-zA-Z%5D.%2A%24)) -must respect the following conditions - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | -| **Defined in** | #/$defs/csr_field | - -**Description:** Field in a CSR register - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| --------------------------------------------------------- | ------- | ---------------- | ---------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| + [location](#pattern1_fields_pattern1_location ) | No | Combination | No | - | Location of the field within the CSR register | -| + [description](#pattern1_fields_pattern1_description ) | No | string | No | - | Function of the field | -| + [type](#pattern1_fields_pattern1_type ) | No | enum (of string) | No | - | Type of the field. One of:
    * RO: Read-only immutable
    * RO-H: Read-only, updated by hardware
    * RW: Read-write, not updated by hardware
    * RW-R: Read-write, but values are restricted. write(value) must be provided
    * RW-H: Read-write, with hardware updates
    * RW-RH: Read-write, with hardware updates, but values are restricted. write(value) must be provded | -| - [alias](#pattern1_fields_pattern1_alias ) | No | Combination | No | - | Other CSR fields that alias with this field | -| - [definedBy](#pattern1_fields_pattern1_definedBy ) | No | Combination | No | - | Where this field is defined: indicates that the field is only present if the extension(s) are implemented. If definedBy is not given, defaults to the definedBy field of the parent CSR | -| - [affectedBy](#pattern1_fields_pattern1_affectedBy ) | No | Combination | No | - | Extension(s) that affect the definition of the field beyond the extension (or base) the field is originally defined in | -| - [reset_value](#pattern1_fields_pattern1_reset_value ) | No | object | No | - | - | -| - [value](#pattern1_fields_pattern1_value ) | No | object | No | - | - | -| - [write(value)](#pattern1_fields_pattern1_write(value) ) | No | object | No | - | - | - -| All of(Requirement) | -| ----------------------------------------------- | -| [item 0](#pattern1_fields_pattern1_pattern4_i0) | -| [item 1](#pattern1_fields_pattern1_pattern4_i1) | -| [item 2](#pattern1_fields_pattern1_pattern4_i2) | -| [item 3](#pattern1_fields_pattern1_pattern4_i3) | -| [item 4](#pattern1_fields_pattern1_pattern4_i4) | -| [item 5](#pattern1_fields_pattern1_pattern4_i5) | - -##### 1.13.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 0` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -###### 1.13.1.1.1. If (type = "RO") - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ------------------------------------------------------------ | ------- | ----------- | ---------- | ---------- | ----------------- | -| + [value](#pattern1_fields_pattern1_pattern4_i0_then_value ) | No | Combination | No | - | - | - -###### 1.13.1.1.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 0 > then > value` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| One of(Option) | -| ------------------------------------------------------------------- | -| [item 0](#pattern1_fields_pattern1_pattern4_i0_then_value_oneOf_i0) | -| [item 1](#pattern1_fields_pattern1_pattern4_i0_then_value_oneOf_i1) | - -###### 1.13.1.1.1.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 0 > then > value > oneOf > item 0` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | No | - -###### 1.13.1.1.1.1.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 0 > then > value > oneOf > item 1` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | ----------------------------------------------------------------------------- | -| **Must match regular expression** | ```^<%=.*%>$``` [Test](https://regex101.com/?regex=%5E%3C%25%3D.%2A%25%3E%24) | - -##### 1.13.1.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 1` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -###### 1.13.1.2.1. If (type = "RO-H") - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ------------------------------------------------------------------------ | ------- | ------- | ---------- | ---------- | ----------------- | -| + [reset_value](#pattern1_fields_pattern1_pattern4_i1_then_reset_value ) | No | integer | No | - | - | - -###### 1.13.1.2.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 1 > then > reset_value` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | Yes | - -##### 1.13.1.3. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 2` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -###### 1.13.1.3.1. If (type = "RW") - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ------------------------------------------------------------------------ | ------- | ------- | ---------- | ---------- | ----------------- | -| + [reset_value](#pattern1_fields_pattern1_pattern4_i2_then_reset_value ) | No | integer | No | - | - | - -###### 1.13.1.3.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 2 > then > reset_value` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | Yes | - -##### 1.13.1.4. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 3` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -###### 1.13.1.4.1. If (type = "RW-H") - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ------------------------------------------------------------------------ | ------- | ------- | ---------- | ---------- | ----------------- | -| + [reset_value](#pattern1_fields_pattern1_pattern4_i3_then_reset_value ) | No | integer | No | - | - | - -###### 1.13.1.4.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 3 > then > reset_value` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | Yes | - -##### 1.13.1.5. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 4` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -###### 1.13.1.5.1. If (type = "RW-R") - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| -------------------------------------------------------------------------- | ------- | ------- | ---------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| + [write(value)](#pattern1_fields_pattern1_pattern4_i4_then_write(value) ) | No | string | No | In #/$defs/write(value) | Function implementing custom write behavior for the CSR. Given a 'value', return either the value to be written in the field or false if the write would be illegal. 'value' is the value of the entire CSR, which is sometimes needed to detect illegal writes | -| + [reset_value](#pattern1_fields_pattern1_pattern4_i4_then_reset_value ) | No | integer | No | - | - | - -###### 1.13.1.5.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 4 > then > write(value)` - -| | | -| -------------- | -------------------- | -| **Type** | `string` | -| **Required** | Yes | -| **Defined in** | #/$defs/write(value) | - -**Description:** Function implementing custom write behavior for the CSR. Given a 'value', return either the value to be written in the field or false if the write would be illegal. 'value' is the value of the entire CSR, which is sometimes needed to detect illegal writes - -###### 1.13.1.5.1.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 4 > then > reset_value` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | Yes | - -##### 1.13.1.6. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 5` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -###### 1.13.1.6.1. If (type = "RW-RH") - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| -------------------------------------------------------------------------- | ------- | ------- | ---------- | -------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| + [write(value)](#pattern1_fields_pattern1_pattern4_i5_then_write(value) ) | No | string | No | Same as [write(value)](#pattern1_fields_pattern1_pattern4_i4_then_write(value) ) | Function implementing custom write behavior for the CSR. Given a 'value', return either the value to be written in the field or false if the write would be illegal. 'value' is the value of the entire CSR, which is sometimes needed to detect illegal writes | -| + [reset_value](#pattern1_fields_pattern1_pattern4_i5_then_reset_value ) | No | integer | No | - | - | - -###### 1.13.1.6.1.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 5 > then > write(value)` - -| | | -| ---------------------- | ----------------------------------------------------------------------- | -| **Type** | `string` | -| **Required** | Yes | -| **Same definition as** | [write(value)](#pattern1_fields_pattern1_pattern4_i4_then_write(value)) | - -**Description:** Function implementing custom write behavior for the CSR. Given a 'value', return either the value to be written in the field or false if the write would be illegal. 'value' is the value of the entire CSR, which is sometimes needed to detect illegal writes - -###### 1.13.1.6.1.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > allOf > item 5 > then > reset_value` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | Yes | - -##### 1.13.1.7. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > location` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -**Description:** Location of the field within the CSR register - -| One of(Option) | -| ----------------------------------------------------- | -| [item 0](#pattern1_fields_pattern1_location_oneOf_i0) | -| [item 1](#pattern1_fields_pattern1_location_oneOf_i1) | - -###### 1.13.1.7.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > location > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -**Description:** Location of a single bit - -###### 1.13.1.7.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > location > oneOf > item 1` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Location range of a multibit field - -| Restrictions | | -| --------------------------------- | ----------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^[0-9]+-[0-9]+$``` [Test](https://regex101.com/?regex=%5E%5B0-9%5D%2B-%5B0-9%5D%2B%24) | - -##### 1.13.1.8. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > description` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -**Description:** Function of the field - -##### 1.13.1.9. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > type` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | Yes | - -**Description:** Type of the field. One of: - * RO: Read-only immutable - * RO-H: Read-only, updated by hardware - * RW: Read-write, not updated by hardware - * RW-R: Read-write, but values are restricted. write(value) must be provided - * RW-H: Read-write, with hardware updates - * RW-RH: Read-write, with hardware updates, but values are restricted. write(value) must be provded - -Must be one of: -* "RO" -* "RO-H" -* "RW" -* "RW-R" -* "RW-H" -* "RW-RH" - -##### 1.13.1.10. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > alias` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -**Description:** Other CSR fields that alias with this field - -| One of(Option) | -| -------------------------------------------------- | -| [item 0](#pattern1_fields_pattern1_alias_oneOf_i0) | -| [item 1](#pattern1_fields_pattern1_alias_oneOf_i1) | - -###### 1.13.1.10.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > alias > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | --------------------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^[a-z]+\.[A-Z0-9]+$``` [Test](https://regex101.com/?regex=%5E%5Ba-z%5D%2B%5C.%5BA-Z0-9%5D%2B%24) | - -###### 1.13.1.10.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > alias > oneOf > item 1` - -| | | -| ------------ | ----------------- | -| **Type** | `array of string` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| -------------------------------------------------------------- | ----------- | -| [item 1 items](#pattern1_fields_pattern1_alias_oneOf_i1_items) | - | - -###### 1.13.1.10.2.1. CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > alias > oneOf > item 1 > item 1 items - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | --------------------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^[a-z]+\.[A-Z0-9]+$``` [Test](https://regex101.com/?regex=%5E%5Ba-z%5D%2B%5C.%5BA-Z0-9%5D%2B%24) | - -##### 1.13.1.11. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > definedBy` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -**Description:** Where this field is defined: indicates that the field is only present if the extension(s) are implemented. If definedBy is not given, defaults to the definedBy field of the parent CSR - -| One of(Option) | -| ------------------------------------------------------ | -| [item 0](#pattern1_fields_pattern1_definedBy_oneOf_i0) | -| [item 1](#pattern1_fields_pattern1_definedBy_oneOf_i1) | - -###### 1.13.1.11.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > definedBy > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** An extension name - -| Restrictions | | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | -| **Must match regular expression** | ```^([A-WY]\|([SXZ][a-z]+))$``` [Test](https://regex101.com/?regex=%5E%28%5BA-WY%5D%7C%28%5BSXZ%5D%5Ba-z%5D%2B%29%29%24) | - -###### 1.13.1.11.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > definedBy > oneOf > item 1` - -| | | -| ------------ | ----------------- | -| **Type** | `array of string` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------------------------------ | ----------------- | -| [item 1 items](#pattern1_fields_pattern1_definedBy_oneOf_i1_items) | An extension name | - -###### 1.13.1.11.2.1. CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > definedBy > oneOf > item 1 > item 1 items - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** An extension name - -| Restrictions | | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | -| **Must match regular expression** | ```^([A-WY]\|([SXZ][a-z]+))$``` [Test](https://regex101.com/?regex=%5E%28%5BA-WY%5D%7C%28%5BSXZ%5D%5Ba-z%5D%2B%29%29%24) | - -##### 1.13.1.12. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > affectedBy` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -**Description:** Extension(s) that affect the definition of the field beyond the extension (or base) the field is originally defined in - -| One of(Option) | -| ------------------------------------------------------- | -| [item 0](#pattern1_fields_pattern1_affectedBy_oneOf_i0) | -| [item 1](#pattern1_fields_pattern1_affectedBy_oneOf_i1) | - -###### 1.13.1.12.1. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > affectedBy > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| **Must match regular expression** | ```^(RV64)\|([A-WY]\|(Z[a-z]+)\|(S[a-z]+))$``` [Test](https://regex101.com/?regex=%5E%28RV64%29%7C%28%5BA-WY%5D%7C%28Z%5Ba-z%5D%2B%29%7C%28S%5Ba-z%5D%2B%29%29%24) | - -###### 1.13.1.12.2. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > affectedBy > oneOf > item 1` - -| | | -| ------------ | ----------------- | -| **Type** | `array of string` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------------------------------- | ----------- | -| [item 1 items](#pattern1_fields_pattern1_affectedBy_oneOf_i1_items) | - | - -###### 1.13.1.12.2.1. CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > affectedBy > oneOf > item 1 > item 1 items - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| **Must match regular expression** | ```^(RV64)\|([A-WY]\|(Z[a-z]+)\|(S[a-z]+))$``` [Test](https://regex101.com/?regex=%5E%28RV64%29%7C%28%5BA-WY%5D%7C%28Z%5Ba-z%5D%2B%29%7C%28S%5Ba-z%5D%2B%29%29%24) | - -##### 1.13.1.13. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > reset_value` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -##### 1.13.1.14. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > value` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -##### 1.13.1.15. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > fields > ^[a-zA-Z].*$ > write(value)` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -### 1.14. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > access_check` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Optional function called to handle special-case checks for access permission. - -### 1.15. Property `CSR description > ^[a-z][a-z0-9A-Z]+$ > sw_read` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Function that returns the value of the CSR when read by software (i.e., a Zicsr instruction). If not specified, the value last written (through hw_write) is returned. - ----------------------------------------------------------------------------------------------------------------------------- -Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2024-06-12 at 20:18:06 -0700 diff --git a/docs/schema/exception_code_schema.html b/docs/schema/exception_code_schema.html deleted file mode 100644 index 10b748f79..000000000 --- a/docs/schema/exception_code_schema.html +++ /dev/null @@ -1 +0,0 @@ - Schema Docs Type: object
    \ No newline at end of file diff --git a/docs/schema/exception_code_schema.md b/docs/schema/exception_code_schema.md deleted file mode 100644 index c11833b17..000000000 --- a/docs/schema/exception_code_schema.md +++ /dev/null @@ -1,10 +0,0 @@ -# Schema Docs - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - ----------------------------------------------------------------------------------------------------------------------------- -Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2024-06-12 at 20:18:06 -0700 diff --git a/docs/schema/extension_schema.html b/docs/schema/extension_schema.html deleted file mode 100644 index 2df430c51..000000000 --- a/docs/schema/extension_schema.html +++ /dev/null @@ -1 +0,0 @@ - Schema Docs Type: object
    No Additional Properties

    All properties whose name matches the following regular expression must respect the following conditions

    Property name regular expression: [A-W,Y]|([X,Z].*)
    Type: object
    No Additional Properties

    Type: string

    Type: string

    Type: enum (of string)

    Must be one of:

    • "unprivileged"
    • "privileged"


    Extension(s) required by this extension

    Type: array of string
    No Additional Items

    Each item of this array must be:

    Type: array of object
    No Additional Items

    Each item of this array must be:

    Type: object
    No Additional Properties


    Type: string
    Must match regular expression: ^[0-9]+(\.[0-9]+(\.[0-9]+(-[a-fA-F0-9]+)?)?)?$

    Type: string

    Changes since last version

    Type: stringFormat: uri

    Link to ratified document

    Type: array of object
    No Additional Items

    Each item of this array must be:

    Type: object

    Exceptions defined by this extension

    No Additional Properties

    Type: array of object
    No Additional Items

    Each item of this array must be:

    Type: object

    Interrupts defined by this extension

    No Additional Properties
    \ No newline at end of file diff --git a/docs/schema/extension_schema.md b/docs/schema/extension_schema.md deleted file mode 100644 index dd0433720..000000000 --- a/docs/schema/extension_schema.md +++ /dev/null @@ -1,360 +0,0 @@ -# Schema Docs - -- [1. Pattern Property `root > ext_data`](#pattern1) - - [1.1. Property `root > [A-W,Y]\|([X,Z].*) > name`](#pattern1_name) - - [1.2. Property `root > [A-W,Y]\|([X,Z].*) > description`](#pattern1_description) - - [1.3. Property `root > [A-W,Y]\|([X,Z].*) > type`](#pattern1_type) - - [1.4. Property `root > [A-W,Y]\|([X,Z].*) > requires`](#pattern1_requires) - - [1.4.1. Property `root > [A-W,Y]\|([X,Z].*) > requires > oneOf > item 0`](#pattern1_requires_oneOf_i0) - - [1.4.2. Property `root > [A-W,Y]\|([X,Z].*) > requires > oneOf > item 1`](#pattern1_requires_oneOf_i1) - - [1.4.2.1. root > [A-W,Y]\|([X,Z].*) > requires > oneOf > item 1 > item 1 items](#autogenerated_heading_2) - - [1.5. Property `root > [A-W,Y]\|([X,Z].*) > versions`](#pattern1_versions) - - [1.5.1. root > [A-W,Y]\|([X,Z].*) > versions > versions items](#autogenerated_heading_3) - - [1.5.1.1. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > version`](#pattern1_versions_items_version) - - [1.5.1.1.1. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > version > oneOf > item 0`](#pattern1_versions_items_version_oneOf_i0) - - [1.5.1.1.2. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > version > oneOf > item 1`](#pattern1_versions_items_version_oneOf_i1) - - [1.5.1.2. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > ratification_date`](#pattern1_versions_items_ratification_date) - - [1.5.1.2.1. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > ratification_date > oneOf > item 0`](#pattern1_versions_items_ratification_date_oneOf_i0) - - [1.5.1.2.2. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > ratification_date > oneOf > item 1`](#pattern1_versions_items_ratification_date_oneOf_i1) - - [1.5.1.2.3. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > ratification_date > oneOf > item 2`](#pattern1_versions_items_ratification_date_oneOf_i2) - - [1.5.1.3. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > changes`](#pattern1_versions_items_changes) - - [1.5.1.4. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > url`](#pattern1_versions_items_url) - - [1.6. Property `root > [A-W,Y]\|([X,Z].*) > exception_codes`](#pattern1_exception_codes) - - [1.6.1. root > [A-W,Y]\|([X,Z].*) > exception_codes > exception_codes items](#autogenerated_heading_4) - - [1.6.1.1. Property `root > [A-W,Y]\|([X,Z].*) > exception_codes > exception_codes items > num`](#pattern1_exception_codes_items_num) - - [1.6.1.2. Property `root > [A-W,Y]\|([X,Z].*) > exception_codes > exception_codes items > name`](#pattern1_exception_codes_items_name) - - [1.7. Property `root > [A-W,Y]\|([X,Z].*) > interrupt_codes`](#pattern1_interrupt_codes) - - [1.7.1. root > [A-W,Y]\|([X,Z].*) > interrupt_codes > interrupt_codes items](#autogenerated_heading_5) - - [1.7.1.1. Property `root > [A-W,Y]\|([X,Z].*) > interrupt_codes > interrupt_codes items > num`](#pattern1_interrupt_codes_items_num) - - [1.7.1.2. Property `root > [A-W,Y]\|([X,Z].*) > interrupt_codes > interrupt_codes items > name`](#pattern1_interrupt_codes_items_name) - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ---------------------------------- | ------- | ------ | ---------- | ------------------- | ----------------- | -| - [[A-W,Y]\|([X,Z].*)](#pattern1 ) | Yes | object | No | In #/$defs/ext_data | - | - -## 1. Pattern Property `root > ext_data` -> All properties whose name matches the regular expression -```[A-W,Y]|([X,Z].*)``` ([Test](https://regex101.com/?regex=%5BA-W%2CY%5D%7C%28%5BX%2CZ%5D.%2A%29)) -must respect the following conditions - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | -| **Defined in** | #/$defs/ext_data | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ----------------------------------------------- | ------- | ---------------- | ---------- | ---------- | --------------------------------------- | -| - [name](#pattern1_name ) | No | string | No | - | - | -| + [description](#pattern1_description ) | No | string | No | - | - | -| - [type](#pattern1_type ) | No | enum (of string) | No | - | - | -| - [requires](#pattern1_requires ) | No | Combination | No | - | Extension(s) required by this extension | -| + [versions](#pattern1_versions ) | No | array of object | No | - | - | -| - [exception_codes](#pattern1_exception_codes ) | No | array of object | No | - | - | -| - [interrupt_codes](#pattern1_interrupt_codes ) | No | array of object | No | - | - | - -### 1.1. Property `root > [A-W,Y]\|([X,Z].*) > name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -### 1.2. Property `root > [A-W,Y]\|([X,Z].*) > description` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -### 1.3. Property `root > [A-W,Y]\|([X,Z].*) > type` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | No | - -Must be one of: -* "unprivileged" -* "privileged" - -### 1.4. Property `root > [A-W,Y]\|([X,Z].*) > requires` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -**Description:** Extension(s) required by this extension - -| One of(Option) | -| ------------------------------------- | -| [item 0](#pattern1_requires_oneOf_i0) | -| [item 1](#pattern1_requires_oneOf_i1) | - -#### 1.4.1. Property `root > [A-W,Y]\|([X,Z].*) > requires > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -#### 1.4.2. Property `root > [A-W,Y]\|([X,Z].*) > requires > oneOf > item 1` - -| | | -| ------------ | ----------------- | -| **Type** | `array of string` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------------- | ----------- | -| [item 1 items](#pattern1_requires_oneOf_i1_items) | - | - -##### 1.4.2.1. root > [A-W,Y]\|([X,Z].*) > requires > oneOf > item 1 > item 1 items - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -### 1.5. Property `root > [A-W,Y]\|([X,Z].*) > versions` - -| | | -| ------------ | ----------------- | -| **Type** | `array of object` | -| **Required** | Yes | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------ | ----------- | -| [versions items](#pattern1_versions_items) | - | - -#### 1.5.1. root > [A-W,Y]\|([X,Z].*) > versions > versions items - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ------------------------------------------------------------------ | ------- | ----------- | ---------- | ---------- | -------------------------- | -| + [version](#pattern1_versions_items_version ) | No | Combination | No | - | - | -| + [ratification_date](#pattern1_versions_items_ratification_date ) | No | Combination | No | - | - | -| - [changes](#pattern1_versions_items_changes ) | No | string | No | - | Changes since last version | -| - [url](#pattern1_versions_items_url ) | No | string | No | - | Link to ratified document | - -##### 1.5.1.1. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > version` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| One of(Option) | -| --------------------------------------------------- | -| [item 0](#pattern1_versions_items_version_oneOf_i0) | -| [item 1](#pattern1_versions_items_version_oneOf_i1) | - -###### 1.5.1.1.1. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > version > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -###### 1.5.1.1.2. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > version > oneOf > item 1` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^[0-9]+(\.[0-9]+(\.[0-9]+(-[a-fA-F0-9]+)?)?)?$``` [Test](https://regex101.com/?regex=%5E%5B0-9%5D%2B%28%5C.%5B0-9%5D%2B%28%5C.%5B0-9%5D%2B%28-%5Ba-fA-F0-9%5D%2B%29%3F%29%3F%29%3F%24) | - -##### 1.5.1.2. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > ratification_date` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| One of(Option) | -| ------------------------------------------------------------- | -| [item 0](#pattern1_versions_items_ratification_date_oneOf_i0) | -| [item 1](#pattern1_versions_items_ratification_date_oneOf_i1) | -| [item 2](#pattern1_versions_items_ratification_date_oneOf_i2) | - -###### 1.5.1.2.1. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > ratification_date > oneOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | ----------------------------------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^20[0-9][0-9]-[0-9][0-9]$``` [Test](https://regex101.com/?regex=%5E20%5B0-9%5D%5B0-9%5D-%5B0-9%5D%5B0-9%5D%24) | - -###### 1.5.1.2.2. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > ratification_date > oneOf > item 1` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | ----------------------------------------------------------------- | -| **Must match regular expression** | ```^unknown$``` [Test](https://regex101.com/?regex=%5Eunknown%24) | - -###### 1.5.1.2.3. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > ratification_date > oneOf > item 2` - -| | | -| ------------ | ------ | -| **Type** | `null` | -| **Required** | No | - -##### 1.5.1.3. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > changes` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Changes since last version - -##### 1.5.1.4. Property `root > [A-W,Y]\|([X,Z].*) > versions > versions items > url` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | -| **Format** | `uri` | - -**Description:** Link to ratified document - -### 1.6. Property `root > [A-W,Y]\|([X,Z].*) > exception_codes` - -| | | -| ------------ | ----------------- | -| **Type** | `array of object` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| -------------------------------------------------------- | ------------------------------------ | -| [exception_codes items](#pattern1_exception_codes_items) | Exceptions defined by this extension | - -#### 1.6.1. root > [A-W,Y]\|([X,Z].*) > exception_codes > exception_codes items - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -**Description:** Exceptions defined by this extension - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ----------------------------------------------- | ------- | ------- | ---------- | ---------- | ----------------- | -| - [num](#pattern1_exception_codes_items_num ) | No | integer | No | - | - | -| - [name](#pattern1_exception_codes_items_name ) | No | string | No | - | - | - -##### 1.6.1.1. Property `root > [A-W,Y]\|([X,Z].*) > exception_codes > exception_codes items > num` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | No | - -##### 1.6.1.2. Property `root > [A-W,Y]\|([X,Z].*) > exception_codes > exception_codes items > name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -### 1.7. Property `root > [A-W,Y]\|([X,Z].*) > interrupt_codes` - -| | | -| ------------ | ----------------- | -| **Type** | `array of object` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| -------------------------------------------------------- | ------------------------------------ | -| [interrupt_codes items](#pattern1_interrupt_codes_items) | Interrupts defined by this extension | - -#### 1.7.1. root > [A-W,Y]\|([X,Z].*) > interrupt_codes > interrupt_codes items - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -**Description:** Interrupts defined by this extension - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ----------------------------------------------- | ------- | ------- | ---------- | ---------- | ----------------- | -| - [num](#pattern1_interrupt_codes_items_num ) | No | integer | No | - | - | -| - [name](#pattern1_interrupt_codes_items_name ) | No | string | No | - | - | - -##### 1.7.1.1. Property `root > [A-W,Y]\|([X,Z].*) > interrupt_codes > interrupt_codes items > num` - -| | | -| ------------ | --------- | -| **Type** | `integer` | -| **Required** | No | - -##### 1.7.1.2. Property `root > [A-W,Y]\|([X,Z].*) > interrupt_codes > interrupt_codes items > name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - ----------------------------------------------------------------------------------------------------------------------------- -Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2024-06-12 at 20:18:06 -0700 diff --git a/docs/schema/extensions.schema.html b/docs/schema/extensions.schema.html deleted file mode 100644 index 041b03843..000000000 --- a/docs/schema/extensions.schema.html +++ /dev/null @@ -1 +0,0 @@ - Schema Docs Type: object

    RISC-V standard extensions

    No Additional Properties

    All properties whose name matches the following regular expression must respect the following conditions

    Property name regular expression: ^[A-FH-WY]|([XZ][a-z]+)$
    Type: object
    No Additional Properties

    Type: string

    Type: enum (of string)

    Must be one of:

    • "Ratified"
    • "Proposed"

    Type: array of object
    No Additional Items

    Each item of this array must be:

    Type: array of string
    No Additional Items

    Each item of this array must be:

    Type: string
    Must match regular expression: ^[A-FH-WY]|([XZ][a-z]+)$

    Type: array of string
    No Additional Items

    Each item of this array must be:

    Type: string
    Must match regular expression: ^[A-FH-WY]|([XZ][a-z]+)$

    \ No newline at end of file diff --git a/docs/schema/extensions.schema.md b/docs/schema/extensions.schema.md deleted file mode 100644 index 7e11bfe51..000000000 --- a/docs/schema/extensions.schema.md +++ /dev/null @@ -1,249 +0,0 @@ -# Schema Docs - -- [1. Pattern Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$`](#pattern1) - - [1.1. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > name`](#pattern1_name) - - [1.2. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > status`](#pattern1_status) - - [1.3. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions`](#pattern1_versions) - - [1.3.1. root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items](#autogenerated_heading_2) - - [1.3.1.1. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > id`](#pattern1_versions_items_id) - - [1.3.1.2. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > ratification_date`](#pattern1_versions_items_ratification_date) - - [1.3.1.2.1. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > ratification_date > anyOf > item 0`](#pattern1_versions_items_ratification_date_anyOf_i0) - - [1.3.1.2.2. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > ratification_date > anyOf > item 1`](#pattern1_versions_items_ratification_date_anyOf_i1) - - [1.3.1.3. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > ratified_document`](#pattern1_versions_items_ratified_document) - - [1.3.1.3.1. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > ratified_document > anyOf > item 0`](#pattern1_versions_items_ratified_document_anyOf_i0) - - [1.3.1.3.2. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > ratified_document > anyOf > item 1`](#pattern1_versions_items_ratified_document_anyOf_i1) - - [1.3.1.4. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > additionalProperties`](#pattern1_versions_items_additionalProperties) - - [1.4. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > subsumes`](#pattern1_subsumes) - - [1.4.1. root > ^[A-FH-WY]\|([XZ][a-z]+)$ > subsumes > subsumes items](#autogenerated_heading_3) - - [1.5. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > requires`](#pattern1_requires) - - [1.5.1. root > ^[A-FH-WY]\|([XZ][a-z]+)$ > requires > requires items](#autogenerated_heading_4) - - [1.6. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > description`](#pattern1_description) - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -**Description:** RISC-V standard extensions - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ----------------------------------------- | ------- | ------ | ---------- | ---------- | ----------------- | -| - [^[A-FH-WY]\|([XZ][a-z]+)$](#pattern1 ) | Yes | object | No | - | - | - -## 1. Pattern Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$` -> All properties whose name matches the regular expression -```^[A-FH-WY]|([XZ][a-z]+)$``` ([Test](https://regex101.com/?regex=%5E%5BA-FH-WY%5D%7C%28%5BXZ%5D%5Ba-z%5D%2B%29%24)) -must respect the following conditions - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| --------------------------------------- | ------- | ---------------- | ---------- | ---------- | ----------------- | -| + [name](#pattern1_name ) | No | string | No | - | - | -| + [status](#pattern1_status ) | No | enum (of string) | No | - | - | -| - [versions](#pattern1_versions ) | No | array of object | No | - | - | -| - [subsumes](#pattern1_subsumes ) | No | array of string | No | - | - | -| - [requires](#pattern1_requires ) | No | array of string | No | - | - | -| + [description](#pattern1_description ) | No | string | No | - | - | - -### 1.1. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -### 1.2. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > status` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | Yes | - -Must be one of: -* "Ratified" -* "Proposed" - -### 1.3. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions` - -| | | -| ------------ | ----------------- | -| **Type** | `array of object` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------ | ----------- | -| [versions items](#pattern1_versions_items) | - | - -#### 1.3.1. root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ------------------------------------------------------------------------ | ------- | ----------- | ---------- | ---------- | ----------------- | -| - [id](#pattern1_versions_items_id ) | No | number | No | - | - | -| - [ratification_date](#pattern1_versions_items_ratification_date ) | No | Combination | No | - | - | -| - [ratified_document](#pattern1_versions_items_ratified_document ) | No | Combination | No | - | - | -| - [additionalProperties](#pattern1_versions_items_additionalProperties ) | No | object | No | - | - | - -##### 1.3.1.1. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > id` - -| | | -| ------------ | -------- | -| **Type** | `number` | -| **Required** | No | - -##### 1.3.1.2. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > ratification_date` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Any of(Option) | -| ------------------------------------------------------------- | -| [item 0](#pattern1_versions_items_ratification_date_anyOf_i0) | -| [item 1](#pattern1_versions_items_ratification_date_anyOf_i1) | - -###### 1.3.1.2.1. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > ratification_date > anyOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | -| **Format** | `date` | - -| Restrictions | | -| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^2[0-9]{3}-(10\|11\|12\|(0?[1-9]))-(31\|30\|[12][0-9]\|0?[0-9])$``` [Test](https://regex101.com/?regex=%5E2%5B0-9%5D%7B3%7D-%2810%7C11%7C12%7C%280%3F%5B1-9%5D%29%29-%2831%7C30%7C%5B12%5D%5B0-9%5D%7C0%3F%5B0-9%5D%29%24) | - -###### 1.3.1.2.2. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > ratification_date > anyOf > item 1` - -| | | -| ------------ | ------ | -| **Type** | `null` | -| **Required** | No | - -##### 1.3.1.3. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > ratified_document` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Any of(Option) | -| ------------------------------------------------------------- | -| [item 0](#pattern1_versions_items_ratified_document_anyOf_i0) | -| [item 1](#pattern1_versions_items_ratified_document_anyOf_i1) | - -###### 1.3.1.3.1. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > ratified_document > anyOf > item 0` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | -| **Format** | `uri` | - -###### 1.3.1.3.2. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > ratified_document > anyOf > item 1` - -| | | -| ------------ | ------ | -| **Type** | `null` | -| **Required** | No | - -##### 1.3.1.4. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > versions > versions items > additionalProperties` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -### 1.4. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > subsumes` - -| | | -| ------------ | ----------------- | -| **Type** | `array of string` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------ | ----------- | -| [subsumes items](#pattern1_subsumes_items) | - | - -#### 1.4.1. root > ^[A-FH-WY]\|([XZ][a-z]+)$ > subsumes > subsumes items - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^[A-FH-WY]\|([XZ][a-z]+)$``` [Test](https://regex101.com/?regex=%5E%5BA-FH-WY%5D%7C%28%5BXZ%5D%5Ba-z%5D%2B%29%24) | - -### 1.5. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > requires` - -| | | -| ------------ | ----------------- | -| **Type** | `array of string` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ------------------------------------------ | ----------- | -| [requires items](#pattern1_requires_items) | - | - -#### 1.5.1. root > ^[A-FH-WY]\|([XZ][a-z]+)$ > requires > requires items - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -| **Must match regular expression** | ```^[A-FH-WY]\|([XZ][a-z]+)$``` [Test](https://regex101.com/?regex=%5E%5BA-FH-WY%5D%7C%28%5BXZ%5D%5Ba-z%5D%2B%29%24) | - -### 1.6. Property `root > ^[A-FH-WY]\|([XZ][a-z]+)$ > description` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - ----------------------------------------------------------------------------------------------------------------------------- -Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2024-06-12 at 20:18:06 -0700 diff --git a/docs/schema/inst_schema.html b/docs/schema/inst_schema.html deleted file mode 100644 index 2bc258022..000000000 --- a/docs/schema/inst_schema.html +++ /dev/null @@ -1 +0,0 @@ - Instruction description

    Instruction description

    Type: object
    No Additional Properties

    All properties whose name matches the following regular expression must respect the following conditions

    Property name regular expression: .*
    Type: object
    No Additional Properties

    Type: string
    Must match regular expression: ^[a-z0-9.]+$

    Type: string

    Short descrption of the instruction

    Type: string

    Detailed description of the instruction


    Extension(s) that defines the instruction

    Type: string

    RISC-V Extension

    Must match regular expression: ^[A-W,Y]|([XZ][a-z]+)$
    Type: array
    No Additional Items

    Each item of this array must be:

    Type: enum (of integer)

    When present, instruction is only defined for RV32 or RV64 base

    Must be one of:

    • 32
    • 64

    Type: object

    Type: enum (of string) Default: "always"

    Must be one of:

    • "always"
    • "sometimes"
    • "never"

    Type: enum (of string) Default: "always"

    Must be one of:

    • "always"
    • "sometimes"
    • "never"

    Type: enum (of string) Default: "always"

    Must be one of:

    • "always"
    • "sometimes"
    • "never"

    Type: enum (of string) Default: "always"

    Must be one of:

    • "always"
    • "sometimes"
    • "never"

    Type: enum (of string) Default: "always"

    Must be one of:

    • "always"
    • "sometimes"
    • "never"

    Type: string

    Extra detail about access when at least one mode is 'sometimes'

    Type: array of enum (of string) Default: []

    Types of exceptions that can be raised by this instruction (excluding Instruction Page/Access Fault)

    No Additional Items

    Each item of this array must be:

    Type: enum (of string)

    Must be one of:

    • "Store/AMO Page Fault"
    • "Store/AMO Guest-Page Fault"
    • "Store Access Fault"
    • "Illegal Instruction"
    • "Virtual Instruction"
    • "MisalignedAddress"

    Type: string

    Functional description of the instruction using ISA language

    Type: string

    Assembly format of the instruction. Can use decode variables

    \ No newline at end of file diff --git a/docs/schema/inst_schema.md b/docs/schema/inst_schema.md deleted file mode 100644 index caf1a285b..000000000 --- a/docs/schema/inst_schema.md +++ /dev/null @@ -1,307 +0,0 @@ -# Instruction description - -- [1. Pattern Property `Instruction description > inst_data`](#pattern1) - - [1.1. Property `Instruction description > .* > name`](#pattern1_name) - - [1.2. Property `Instruction description > .* > long_name`](#pattern1_long_name) - - [1.3. Property `Instruction description > .* > description`](#pattern1_description) - - [1.4. Property `Instruction description > .* > definedBy`](#pattern1_definedBy) - - [1.4.1. Property `Instruction description > .* > definedBy > oneOf > extension`](#pattern1_definedBy_oneOf_i0) - - [1.4.2. Property `Instruction description > .* > definedBy > oneOf > item 1`](#pattern1_definedBy_oneOf_i1) - - [1.4.2.1. Instruction description > .* > definedBy > oneOf > item 1 > extension](#autogenerated_heading_2) - - [1.5. Property `Instruction description > .* > base`](#pattern1_base) - - [1.6. Property `Instruction description > .* > access`](#pattern1_access) - - [1.6.1. Property `Instruction description > .* > access > m`](#pattern1_access_m) - - [1.6.2. Property `Instruction description > .* > access > s`](#pattern1_access_s) - - [1.6.3. Property `Instruction description > .* > access > u`](#pattern1_access_u) - - [1.6.4. Property `Instruction description > .* > access > vs`](#pattern1_access_vs) - - [1.6.5. Property `Instruction description > .* > access > vu`](#pattern1_access_vu) - - [1.7. Property `Instruction description > .* > access_detail`](#pattern1_access_detail) - - [1.8. Property `Instruction description > .* > raises`](#pattern1_raises) - - [1.8.1. Instruction description > .* > raises > raises items](#autogenerated_heading_3) - - [1.9. Property `Instruction description > .* > operation`](#pattern1_operation) - - [1.10. Property `Instruction description > .* > assembly`](#pattern1_assembly) - -**Title:** Instruction description - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ------------------ | ------- | ------ | ---------- | -------------------- | ----------------- | -| - [.*](#pattern1 ) | Yes | object | No | In #/$defs/inst_data | - | - -## 1. Pattern Property `Instruction description > inst_data` -> All properties whose name matches the regular expression -```.*``` ([Test](https://regex101.com/?regex=.%2A)) -must respect the following conditions - -| | | -| ------------------------- | ------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Not allowed]](# "Additional Properties not allowed.") | -| **Defined in** | #/$defs/inst_data | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ------------------------------------------- | ------- | ------------------------- | ---------- | ---------- | ---------------------------------------------------------------------------------------------------- | -| - [name](#pattern1_name ) | No | string | No | - | - | -| + [long_name](#pattern1_long_name ) | No | string | No | - | Short descrption of the instruction | -| + [description](#pattern1_description ) | No | string | No | - | Detailed description of the instruction | -| + [definedBy](#pattern1_definedBy ) | No | Combination | No | - | Extension(s) that defines the instruction | -| - [base](#pattern1_base ) | No | enum (of integer) | No | - | When present, instruction is only defined for RV32 or RV64 base | -| + [access](#pattern1_access ) | No | object | No | - | - | -| - [access_detail](#pattern1_access_detail ) | No | string | No | - | Extra detail about access when at least one mode is 'sometimes' | -| - [raises](#pattern1_raises ) | No | array of enum (of string) | No | - | Types of exceptions that can be raised by this instruction (excluding Instruction Page/Access Fault) | -| - [operation](#pattern1_operation ) | No | string | No | - | Functional description of the instruction using ISA language | -| + [assembly](#pattern1_assembly ) | No | string | No | - | Assembly format of the instruction. Can use decode variables | - -### 1.1. Property `Instruction description > .* > name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -| Restrictions | | -| --------------------------------- | ----------------------------------------------------------------------------- | -| **Must match regular expression** | ```^[a-z0-9.]+$``` [Test](https://regex101.com/?regex=%5E%5Ba-z0-9.%5D%2B%24) | - -### 1.2. Property `Instruction description > .* > long_name` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -**Description:** Short descrption of the instruction - -### 1.3. Property `Instruction description > .* > description` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -**Description:** Detailed description of the instruction - -### 1.4. Property `Instruction description > .* > definedBy` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `combining` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -**Description:** Extension(s) that defines the instruction - -| One of(Option) | -| ----------------------------------------- | -| [extension](#pattern1_definedBy_oneOf_i0) | -| [item 1](#pattern1_definedBy_oneOf_i1) | - -#### 1.4.1. Property `Instruction description > .* > definedBy > oneOf > extension` - -| | | -| -------------- | ----------------- | -| **Type** | `string` | -| **Required** | No | -| **Defined in** | #/$defs/extension | - -**Description:** RISC-V Extension - -| Restrictions | | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------ | -| **Must match regular expression** | ```^[A-W,Y]\|([XZ][a-z]+)$``` [Test](https://regex101.com/?regex=%5E%5BA-W%2CY%5D%7C%28%5BXZ%5D%5Ba-z%5D%2B%29%24) | - -#### 1.4.2. Property `Instruction description > .* > definedBy > oneOf > item 1` - -| | | -| ------------ | ------- | -| **Type** | `array` | -| **Required** | No | - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| ----------------------------------------------- | ---------------- | -| [extension](#pattern1_definedBy_oneOf_i1_items) | RISC-V Extension | - -##### 1.4.2.1. Instruction description > .* > definedBy > oneOf > item 1 > extension - -| | | -| ---------------------- | ----------------------------------------------------------- | -| **Type** | `string` | -| **Required** | No | -| **Same definition as** | [pattern1_definedBy_oneOf_i0](#pattern1_definedBy_oneOf_i0) | - -**Description:** RISC-V Extension - -### 1.5. Property `Instruction description > .* > base` - -| | | -| ------------ | ------------------- | -| **Type** | `enum (of integer)` | -| **Required** | No | - -**Description:** When present, instruction is only defined for RV32 or RV64 base - -Must be one of: -* 32 -* 64 - -### 1.6. Property `Instruction description > .* > access` - -| | | -| ------------------------- | ------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | Yes | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ---------------------------- | ------- | ---------------- | ---------- | ---------- | ----------------- | -| - [m](#pattern1_access_m ) | No | enum (of string) | No | - | - | -| + [s](#pattern1_access_s ) | No | enum (of string) | No | - | - | -| + [u](#pattern1_access_u ) | No | enum (of string) | No | - | - | -| + [vs](#pattern1_access_vs ) | No | enum (of string) | No | - | - | -| + [vu](#pattern1_access_vu ) | No | enum (of string) | No | - | - | - -#### 1.6.1. Property `Instruction description > .* > access > m` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | No | -| **Default** | `"always"` | - -Must be one of: -* "always" -* "sometimes" -* "never" - -#### 1.6.2. Property `Instruction description > .* > access > s` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | Yes | -| **Default** | `"always"` | - -Must be one of: -* "always" -* "sometimes" -* "never" - -#### 1.6.3. Property `Instruction description > .* > access > u` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | Yes | -| **Default** | `"always"` | - -Must be one of: -* "always" -* "sometimes" -* "never" - -#### 1.6.4. Property `Instruction description > .* > access > vs` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | Yes | -| **Default** | `"always"` | - -Must be one of: -* "always" -* "sometimes" -* "never" - -#### 1.6.5. Property `Instruction description > .* > access > vu` - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | Yes | -| **Default** | `"always"` | - -Must be one of: -* "always" -* "sometimes" -* "never" - -### 1.7. Property `Instruction description > .* > access_detail` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Extra detail about access when at least one mode is 'sometimes' - -### 1.8. Property `Instruction description > .* > raises` - -| | | -| ------------ | --------------------------- | -| **Type** | `array of enum (of string)` | -| **Required** | No | -| **Default** | `[]` | - -**Description:** Types of exceptions that can be raised by this instruction (excluding Instruction Page/Access Fault) - -| | Array restrictions | -| -------------------- | ------------------ | -| **Min items** | N/A | -| **Max items** | N/A | -| **Items unicity** | False | -| **Additional items** | False | -| **Tuple validation** | See below | - -| Each item of this array must be | Description | -| -------------------------------------- | ----------- | -| [raises items](#pattern1_raises_items) | - | - -#### 1.8.1. Instruction description > .* > raises > raises items - -| | | -| ------------ | ------------------ | -| **Type** | `enum (of string)` | -| **Required** | No | - -Must be one of: -* "Store/AMO Page Fault" -* "Store/AMO Guest-Page Fault" -* "Store Access Fault" -* "Illegal Instruction" -* "Virtual Instruction" -* "MisalignedAddress" - -### 1.9. Property `Instruction description > .* > operation` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | No | - -**Description:** Functional description of the instruction using ISA language - -### 1.10. Property `Instruction description > .* > assembly` - -| | | -| ------------ | -------- | -| **Type** | `string` | -| **Required** | Yes | - -**Description:** Assembly format of the instruction. Can use decode variables - ----------------------------------------------------------------------------------------------------------------------------- -Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2024-06-12 at 20:18:06 -0700 diff --git a/docs/schema/schema_doc.css b/docs/schema/schema_doc.css deleted file mode 100644 index e1f3a5112..000000000 --- a/docs/schema/schema_doc.css +++ /dev/null @@ -1,181 +0,0 @@ -body { - font: 16px/1.5em "Overpass", "Open Sans", Helvetica, sans-serif; - color: #333; - font-weight: 300; - padding: 40px; -} - -.btn.btn-link { - font-size: 18px; - user-select: text; -} - -.jsfh-animated-property { - animation: eclair; - animation-iteration-count: 1; - animation-fill-mode: forwards; - animation-duration: .75s; - -} - -@keyframes eclair { - 0%,100% { - transform: scale(1); - } - 50% { - transform: scale(1.03); - } -} - -.btn.btn-primary { - margin: 10px; -} - -.btn.example-show.collapsed:before { - content: "show" -} - -.btn.example-show:before { - content: "hide" -} - -.description.collapse:not(.show) { - max-height: 100px !important; - overflow: hidden; - - display: -webkit-box; - -webkit-line-clamp: 2; - -webkit-box-orient: vertical; -} - -.description.collapsing { - min-height: 100px !important; -} - -.collapse-description-link.collapsed:after { - content: '+ Read More'; -} - -.collapse-description-link:not(.collapsed):after { - content: '- Read Less'; -} - -.badge { - font-size: 100%; - margin-bottom: 0.5rem; - margin-top: 0.5rem; -} - -.badge.value-type { - font-size: 120%; - margin-right: 5px; - margin-bottom: 10px; -} - - -.badge.default-value { - font-size: 120%; - margin-left: 5px; - margin-bottom: 10px; -} - -.badge.restriction { - display: inline-block; -} - -.badge.required-property,.badge.deprecated-property,.badge.pattern-property,.badge.no-additional { - font-size: 100%; - margin-left: 10px; -} - -.accordion div.card:only-child { - border-bottom: 1px solid rgba(0, 0, 0, 0.125); -} - -.examples { - padding: 1rem !important; -} - -.examples pre { - margin-bottom: 0; -} - -.highlight.jumbotron { - padding: 1rem !important; -} - -.generated-by-footer { - margin-top: 1em; - text-align: right; -} - -/* From https://github.com/richleland/pygments-css/blob/master/friendly.css, see https://github.com/trentm/python-markdown2/wiki/fenced-code-blocks */ -.highlight { background: #e9ecef; } /* Changed from #f0f0f0 in the original style to be the same as bootstrap's jumbotron */ -.highlight .hll { background-color: #ffffcc } -.highlight .c { color: #60a0b0; font-style: italic } /* Comment */ -.highlight .err { border: 1px solid #FF0000 } /* Error */ -.highlight .k { color: #007020; font-weight: bold } /* Keyword */ -.highlight .o { color: #666666 } /* Operator */ -.highlight .ch { color: #60a0b0; font-style: italic } /* Comment.Hashbang */ -.highlight .cm { color: #60a0b0; font-style: italic } /* Comment.Multiline */ -.highlight .cp { color: #007020 } /* Comment.Preproc */ -.highlight .cpf { color: #60a0b0; font-style: italic } /* Comment.PreprocFile */ -.highlight .c1 { color: #60a0b0; font-style: italic } /* Comment.Single */ -.highlight .cs { color: #60a0b0; background-color: #fff0f0 } /* Comment.Special */ -.highlight .gd { color: #A00000 } /* Generic.Deleted */ -.highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gr { color: #FF0000 } /* Generic.Error */ -.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ -.highlight .gi { color: #00A000 } /* Generic.Inserted */ -.highlight .go { color: #888888 } /* Generic.Output */ -.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ -.highlight .gs { font-weight: bold } /* Generic.Strong */ -.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -.highlight .gt { color: #0044DD } /* Generic.Traceback */ -.highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ -.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ -.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */ -.highlight .kp { color: #007020 } /* Keyword.Pseudo */ -.highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ -.highlight .kt { color: #902000 } /* Keyword.Type */ -.highlight .m { color: #40a070 } /* Literal.Number */ -.highlight .s { color: #4070a0 } /* Literal.String */ -.highlight .na { color: #4070a0 } /* Name.Attribute */ -.highlight .nb { color: #007020 } /* Name.Builtin */ -.highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ -.highlight .no { color: #60add5 } /* Name.Constant */ -.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */ -.highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */ -.highlight .ne { color: #007020 } /* Name.Exception */ -.highlight .nf { color: #06287e } /* Name.Function */ -.highlight .nl { color: #002070; font-weight: bold } /* Name.Label */ -.highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ -.highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */ -.highlight .nv { color: #bb60d5 } /* Name.Variable */ -.highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */ -.highlight .w { color: #bbbbbb } /* Text.Whitespace */ -.highlight .mb { color: #40a070 } /* Literal.Number.Bin */ -.highlight .mf { color: #40a070 } /* Literal.Number.Float */ -.highlight .mh { color: #40a070 } /* Literal.Number.Hex */ -.highlight .mi { color: #40a070 } /* Literal.Number.Integer */ -.highlight .mo { color: #40a070 } /* Literal.Number.Oct */ -.highlight .sa { color: #4070a0 } /* Literal.String.Affix */ -.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */ -.highlight .sc { color: #4070a0 } /* Literal.String.Char */ -.highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */ -.highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ -.highlight .s2 { color: #4070a0 } /* Literal.String.Double */ -.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ -.highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */ -.highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ -.highlight .sx { color: #c65d09 } /* Literal.String.Other */ -.highlight .sr { color: #235388 } /* Literal.String.Regex */ -.highlight .s1 { color: #4070a0 } /* Literal.String.Single */ -.highlight .ss { color: #517918 } /* Literal.String.Symbol */ -.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */ -.highlight .fm { color: #06287e } /* Name.Function.Magic */ -.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */ -.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */ -.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */ -.highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */ -.highlight .il { color: #40a070 } /* Literal.Number.Integer.Long */ diff --git a/docs/schema/schema_doc.min.js b/docs/schema/schema_doc.min.js deleted file mode 100644 index 17eceaf59..000000000 --- a/docs/schema/schema_doc.min.js +++ /dev/null @@ -1 +0,0 @@ -$(document).on("click",'a[href^="#"]',function(event){event.preventDefault();history.pushState({},"",this.href)});function flashElement(elementId){myElement=document.getElementById(elementId);myElement.classList.add("jsfh-animated-property");setTimeout(function(){myElement.classList.remove("jsfh-animated-property")},1e3)}function setAnchor(anchorLinkDestination){history.pushState({},"",anchorLinkDestination)}function anchorOnLoad(){let linkTarget=decodeURIComponent(window.location.hash.split("?")[0].split("&")[0]);if(linkTarget[0]==="#"){linkTarget=linkTarget.substr(1)}if(linkTarget.length>0){anchorLink(linkTarget)}}function anchorLink(linkTarget){const target=$("#"+linkTarget);target.parents().addBack().filter(".collapse:not(.show), .tab-pane, [role='tab']").each(function(index){if($(this).hasClass("collapse")){$(this).collapse("show")}else if($(this).hasClass("tab-pane")){const tabToShow=$("a[href='#"+$(this).attr("id")+"']");if(tabToShow){tabToShow.tab("show")}}else if($(this).attr("role")==="tab"){$(this).tab("show")}});setTimeout(function(){let targetElement=document.getElementById(linkTarget);if(targetElement){targetElement.scrollIntoView({block:"center",behavior:"smooth"});setTimeout(function(){flashElement(linkTarget)},500)}},1e3)} \ No newline at end of file diff --git a/lib/arch_def.rb b/lib/arch_def.rb index 4c002f698..5a60fa018 100644 --- a/lib/arch_def.rb +++ b/lib/arch_def.rb @@ -1,16 +1,13 @@ # frozen_string_literal: true require "forwardable" -# require "treetop" -require_relative "opcodes" + require_relative "validate" require_relative "idl" require_relative "idl/passes/find_return_values" require_relative "idl/passes/gen_adoc" -# require_relative "ast/ast" -# require_relative "ast/gen_adoc" +require_relative "idl/passes/prune" -# Treetop.load("arch/isa/isa") # base for any object representation of the Architecture Definition # does two things: @@ -862,11 +859,44 @@ module RiscvOpcodes # model of a specific instruction in a specific base (RV32/RV64) class Instruction < ArchDefObject - # @return [Idl::AstNode] Abstract syntax tree of the instruction operation() - def operation_ast - parse_operation(@sym_table) if @operation_ast.nil? + def fill_symtab(global_symtab) + symtab = global_symtab.deep_clone(clone_values: true) + symtab.push + symtab.add( + "__instruction_encoding_size", + Idl::Var.new("__instruction_encoding_size", Idl::Type.new(:bits, width:encoding_width.bit_length), encoding_width) + ) + @encodings[symtab.archdef.config_params["XLEN"]].decode_variables.each do |d| + qualifiers = [] + qualifiers << :signed if d.sext? + width = d.size - @operation_ast + var = Idl::Var.new(d.name, Idl::Type.new(:bits, qualifiers:, width:), decode_var: true) + symtab.add(d.name, var) + end + + symtab + end + private :fill_symtab + + # type check the instruction operation in the context of symtab + # + # @param global_symtab [Idl::SymbolTable] A symbol table with global scope populated + # @raise Idl::AstNode::TypeError if there is a type problem + def type_check_operation(global_symtab) + global_symtab.archdef.idl_compiler.type_check( + operation_ast(global_symtab.archdef.idl_compiler), + fill_symtab(global_symtab), + "#{name}.operation()" + ) + end + + # @param global_symtab [Idl::SymbolTable] Symbol table with global scope populated and a configuration loaded + # @return [Idl::FunctionBodyAst] A pruned abstract syntax tree + def pruned_operation_ast(global_symtab) + type_check_operation(global_symtab) + puts "PRUNING #{name}" + operation_ast(global_symtab.archdef.idl_compiler).prune(fill_symtab(global_symtab)) end # @return [ArchDef] The architecture definition @@ -929,7 +959,7 @@ def initialize(format, decode_vars) end @decode_variables = [] - decode_vars.each do |var| + decode_vars&.each do |var| @decode_variables << DecodeVariable.new(self, var) end end @@ -944,158 +974,57 @@ def load_encoding @encodings = {} if @data["encoding"].key?("RV32") # there are different encodings for RV32/RV64 - @encodings[32] = Encoding.new(@data["encoding"]["RV32"]["mask"], @data["encoding"]["RV32"]["fields"]) - @encodings[64] = Encoding.new(@data["encoding"]["RV64"]["mask"], @data["encoding"]["RV64"]["fields"]) + @encodings[32] = Encoding.new(@data["encoding"]["RV32"]["match"], @data["encoding"]["RV32"]["variables"]) + @encodings[64] = Encoding.new(@data["encoding"]["RV64"]["match"], @data["encoding"]["RV64"]["variables"]) elsif @data.key("base") - @encodings[@data["base"]] = Encoding.new(@data["encoding"]["mask"], @data["encoding"]["fields"]) + @encodings[@data["base"]] = Encoding.new(@data["encoding"]["match"], @data["encoding"]["variables"]) else - @encodings[32] = Encoding.new(@data["encoding"]["mask"], @data["encoding"]["fields"]) - @encodings[64] = Encoding.new(@data["encoding"]["mask"], @data["encoding"]["fields"]) + @encodings[32] = Encoding.new(@data["encoding"]["match"], @data["encoding"]["variables"]) + @encodings[64] = Encoding.new(@data["encoding"]["match"], @data["encoding"]["variables"]) end end private :load_encoding - # @params inst_data [Hash] Instruction data from the architecture spec - # @params full_opcode_data [Hash] Opcode data to interpret riscv-opcodes -- this will be deprecated - # @params sym_table [Idl::SymbolTable] Symbol table with global names - # @params arch_def [ArchDef] The architecture definition - def initialize(inst_data, full_opcode_data, sym_table, arch_def) - @arch_def = arch_def - @sym_table = sym_table.deep_clone - - super(inst_data) - - if inst_data.key?("encoding") - load_encoding - else - opcode_data_key = name.downcase.gsub(".", "_") - raise "opcode data not found for #{name}" unless full_opcode_data.key?(opcode_data_key) - - opcode_data = full_opcode_data[opcode_data_key] - encoding_mask = opcode_data["encoding"] - - opcode_fields = [] - msb = encoding_mask.size - encoding_mask.split("-").each do |e| - if e.empty? - msb -= 1 - else - opcode_fields << Encoding::Field.new(e, (msb - e.size + 1)..msb) - msb -= e.size - end - end - - - decode_variables = [] - opcode_data["variable_fields"].to_a.each do |f| - decode_field_data = RiscvOpcodes::VARIABLE_FIELDS.to_a.select do |d| - d[0] == f || (d[0].is_a?(Array) && d[0].any?(f)) - end - raise "didn't find '#{f}' in DECODER_RING" if decode_field_data.empty? - - raise "Found multiple matches for '#{f}' in DECODER_RING" if decode_field_data.size > 1 - - data = decode_field_data[0][1] - names = [] - if data.key?(:decode_variable) - if data[:decode_variable].is_a?(String) - names << data[:decode_variable] - else - raise "unexpected" unless data[:decode_variable].is_a?(Array) - - names = data[:decode_variable] - end - else - raise "?" unless decode_field_data[0][0].is_a?(String) - - names = [decode_field_data[0][0]] - end - - names.each do |name| - decode_variables << DecodeField.new(self, name, decode_field_data[0][0], decode_field_data[0][1]) - end - end - decode_variables.uniq! - - @encodings ||= {} - klass = Struct.new(:opcode_fields, :decode_variables) - @encodings[32] = klass.new(opcode_fields, decode_variables) - @encodings[64] = klass.new(opcode_fields, decode_variables) - end - end - # @return [Boolean] whether or not this instruction has different encodings depending on XLEN def multi_encoding? @data.key?("encoding") && @data["encoding"].key?("RV32") end - # @return [String] The operation() IDL code - def operation_source - return "" if @data["operation()"].nil? - - operation_ast.gen_adoc.gsub("{{", '\((') - # @data['operation'] - end + # @return [FunctionBodyAst] The abstract syntax tree of the instruction operation + def operation_ast(idl_compiler) + return @operation_ast unless @operation_ast.nil? + return nil if @data["operation()"].nil? - def parse_operation(sym_table) # now, parse the operation - return if @data["operation()"].nil? || !@operation_ast.nil? - - cloned_symtab = sym_table.deep_clone - - cloned_symtab.push - @encodings[@arch_def.config_params["XLEN"]].decode_variables.each do |d| - qualifiers = [] - qualifiers << :signed if d.sext? - width = d.size - var = Idl::Var.new(d.name, Idl::Type.new(:bits, qualifiers:, width:), decode_var: true) - cloned_symtab.add(d.name, var) - end - - m = arch_def.idl_compiler.compile_inst_operation( - @data["operation()"], - symtab: cloned_symtab, - name:, - parent: nil, + @operation_ast = idl_compiler.compile_inst_operation( + self, input_file: "Instruction #{name}" ) - cloned_symtab.pop + raise "unexpected #{@operation_ast.class}" unless @operation_ast.is_a?(Idl::FunctionBodyAst) - raise "unexpected #{m.class}" unless m.is_a?(Idl::InstructionOperationAst) + @operation_ast + end - m.make_left # fix up right recursion + # @param base [Integer] 32 or 64 + # @return [Encoding] the encoding + def encoding(base) + load_encoding if @encodings.nil? - @operation_ast = m + @encodings[base] end - private :parse_operation - # @return [String] the encoding as, e.g.,: - # 0000101----------001-----0110011 - def encoding(base) - @encodings[base].format + # @return [Integer] the width of the encoding + def encoding_width + raise "unexpected: encodings are different sizes" unless encoding(32).size == encoding(64).size + + encoding(64).size end # @return [Array] The decode variables def decode_variables(base) - @encodings[base].decode_variables - end - - # def encoding_variable_fields - # @decode_variables.map(&:decode_variable).flatten - # end - - # @return [String] the extension that defines this instruction - # @return [Array] the extensions that define this instruction - def extension - @data["definedBy"] - # parts = @data["extension"][0].split("_") - # if @data["definedBy"].is_a?(String) - # parts[1].capitalize - # else - # parts[1..].map(&:capitalize) - # end + encoding(base).decode_variables end # @return [Boolean] true if the instruction has an 'access_detail' field @@ -1112,8 +1041,8 @@ def wavedrom_desc(base) "reg" => [] } - display_fields = @encodings[base].opcode_fields - display_fields += @encodings[base].decode_variables.map(&:grouped_encoding_fields).flatten + display_fields = encoding(base).opcode_fields + display_fields += encoding(base).decode_variables.map(&:grouped_encoding_fields).flatten display_fields.sort { |a, b| b.range.last <=> a.range.last }.reverse.each do |e| desc["reg"] << { "bits" => e.range.size, "name" => e.name, "type" => (e.opcode? ? 2 : 4) } @@ -1121,6 +1050,136 @@ def wavedrom_desc(base) desc end + + # @return [Boolean] whether or not this instruction is defined for RV32 + def rv32? + !@data.key?("base") || base == 32 + end + + # @return [Boolean] whether or not this instruction is defined for RV64 + def rv64? + !@data.key?("base") || base == 64 + end + + def extension_requirement?(obj) + obj.is_a?(String) && obj =~ /^([A-WY])|([SXZ][a-z]+)$/ || + obj.is_a?(Array) && obj[0] =~ /^([A-WY])|([SXZ][a-z]+)$/ + end + private :extension_requirement? + + def to_extension_requirement(obj) + if obj.is_a?(String) + ExtensionRequirement.new(obj, ">= 0") + else + ExtensionRequirement.new(*obj) + end + end + private :to_extension_requirement + + # @return [Array] Extension requirements for the instruction. If *any* requirement is met, the instruction is defined + def extension_requirements + return @extension_requirements unless @extension_requirements.nil? + + @extension_requirements = [] + if @data["definedBy"].is_a?(Array) + # could be either a single extension with requirement, or a list of requirements + if extension_requirement?(@data["definedBy"][0]) + @extension_requirements << to_extension_requirement(@data["definedBy"][0]) + else + # this is a list + @data["definedBy"].each do |r| + @extension_requirements << to_extension_requirement(r) + end + end + else + @extension_requirements << to_extension_requirement(@data["definedBy"]) + end + + raise "empty requirements" if @extension_requirements.empty? + + @extension_requirements + end + + # @return [Array] Extension exclusions for the instruction. If *any* exclusion is met, the instruction is not defined + def extension_exclusions + return @extension_exclusions unless @extension_excludions.nil? + + @extension_exclusions = [] + if @data.key?("excludedBy") + if @data["exludedBy"].is_a?(Array) + # could be either a single extension with exclusion, or a list of exclusions + if extension_exclusion?(@data["definedBy"][0]) + @extension_exclusions << to_extension_requirement(@data["excludedBy"][0]) + else + # this is a list + @data["excludeddBy"].each do |r| + @extension_exclusions << to_extension_exclusion(r) + end + end + else + @extension_exclusions << to_extension_requirement(@data["excludedBy"]) + end + end + + @extension_exclusions + end + + # @overload defined_by?(ext_name, ext_version) + # @param ext_name [#to_s] An extension name + # @param ext_version [#to_s] A specific extension version + # @return [Boolean] Whether or not the instruction is defined by extesion `ext`, version `version` + # @overload defined_by?(ext_version) + # @param ext_version [ExtensionVersion] An extension version + # @return [Boolean] Whether or not the instruction is defined by ext_version + def defined_by?(*args) + if args.size == 1 + raise ArgumentError, "Parameter must be an ExtensionVersion" unless args[0].is_a?(ExtensionVersion) + + extension_requirements.any? do |r| + r.satisfied_by?(args[0]) + end + elsif args.size == 2 + raise ArgumentError, "First parameter must be an extension name" unless args[0].respond_to?(:to_s) + raise ArgumentError, "Second parameter must be an extension version" unless args[0].respond_to?(:to_s) + + extension_requirements.any? do |r| + r.satisfied_by?(args[0].to_s, args[1].to_s) + end + end + end + + # @overload excluded_by?(ext_name, ext_version) + # @param ext_name [#to_s] An extension name + # @param ext_version [#to_s] A specific extension version + # @return [Boolean] Whether or not the instruction is excluded by extesion `ext`, version `version` + # @overload excluded_by?(ext_version) + # @param ext_version [ExtensionVersion] An extension version + # @return [Boolean] Whether or not the instruction is excluded by ext_version + def excluded_by?(*args) + if args.size == 1 + raise ArgumentError, "Parameter must be an ExtensionVersion" unless args[0].is_a?(ExtensionVersion) + + extension_exclusions.any? do |r| + r.satisfied_by?(args[0]) + end + elsif args.size == 2 + raise ArgumentError, "First parameter must be an extension name" unless args[0].respond_to?(:to_s) + raise ArgumentError, "Second parameter must be an extension version" unless args[0].respond_to?(:to_s) + + extension_exclusions.any? do |r| + r.satisfied_by?(args[0].to_s, args[1].to_s) + end + end + end + + # @param possible_xlens [Array] List of xlens that be used in any implemented mode + # @param extensions [Array] List of extensions implemented + # @return [Boolean] whether or not the instruction is implemented given the supplies config options + def exists_in_cfg?(possible_xlens, extensions) + (@data["base"].nil? || (possible_xlens.include?(@data["base"]))) && + extensions.any? { |e| defined_by?(e) } && + extensions.none? { |e| excluded_by?(e) } + end end # Extension definition @@ -1135,16 +1194,30 @@ def initialize(ext_data, arch_def) @arch_def = arch_def end - # @return [Array] Array of extensions implied by this one - def implies - case @data["implies"] - when nil - [] - when Array - @data["implies"] - else - [@data["implies"]] + # @param version_requirement [String] Version requirement + # @return [Array] Array of extensions implied by any version of this extension meeting version_requirement + def implies(version_requirement = ">= 0") + implications = [] + @data["versions"].each do |v| + next unless Gem::Requirement.new(version_requirement).satisfied_by?(Gem::Version.new(v["version"])) + + case v["implies"] + when nil + next + when Array + if v["implies"][0].is_a?(Array) + implications += v["implies"].map { |e| ExtensionVersion.new(e[0], e[1])} + else + implications << ExtensionVersion.new(v["implies"][0], v["implies"][1]) + end + end end + implications + end + + # returns the list of instructions implemented by this extension + def instructions + arch_def.instructions.select { |i| i.definedBy == name || (i.definedBy.is_a?(Array) && i.definedBy.include?(name)) } end end @@ -1156,20 +1229,13 @@ class ExtensionVersion # @return [Gem::Version] Version of the extension attr_reader :version - # @return [ArchDef] Owning ArchDef - attr_reader :arch_def - - # @return [Extension] The full definition of the extension (all versions) - attr_reader :extension # @param name [#to_s] The extension name # @param version [Integer,String] The version specifier # @param arch_def [ArchDef] The architecture definition - def initialize(name, version, arch_def) + def initialize(name, version) @name = name.to_s @version = Gem::Version.new(version) - @arch_def = arch_def - @extension = @arch_def.extension(@name) end # @override ==(other) @@ -1209,6 +1275,52 @@ def <=>(other) end end +# represents an extension requirement, that is an extension name paired with version requirement(s) +class ExtensionRequirement + # @return [String] Extension name + attr_reader :name + + # @return [Gem::Requirement] Version requirement + def version_requirement + @requirement + end + + def initialize(name, *requirements) + @name = name + requirements = + if requirements.empty? + [">= 0"] + else + requirements + end + @requirement = Gem::Requirement.new(requirements) + end + + # @overload + # @param extension_version [ExtensionVersion] A specific extension version + # @return [Boolean] whether or not the extension_version meets this requirement + # @overload + # @param extension_name [#to_s] An extension name + # @param extension_name [#to_s] An extension version + # @return [Boolean] whether or not the extension_version meets this requirement + def satisfied_by?(*args) + if args.size == 1 + raise ArgumentError, "Single argument must be an ExtensionVersion" unless args[0].is_a?(ExtensionVersion) + + args[0].name == @name && + @requirement.satisfied_by?(Gem::Version.new(args[0].version)) + elsif args.size == 2 + raise ArgumentError, "First parameter must be an extension name" unless args[0].respond_to?(:to_s) + raise ArgumentError, "First parameter must be an extension version" unless args[1].respond_to?(:to_s) + + args[0] == @name && + @requirement.satisfied_by?(Gem::Version.new(args[1])) + else + raise ArgumentError, "Wrong number of args (expecting 1 or 2)" + end + end +end + # Object model for a configured architecture definition class ArchDef # @return [String] Name of the architecture configuration @@ -1268,8 +1380,8 @@ def implemented_extensions @implemented_extensions = [] @arch_def["implemented_extensions"].each do |e| - @implemented_extensions << ExtensionVersion.new(e["name"], e["version"], self) - end + @implemented_extensions << ExtensionVersion.new(e["name"], e["version"]) +2 end @implemented_extensions end @@ -1395,10 +1507,8 @@ def csr(csr_name) def instructions return @instructions unless @instructions.nil? - opcode_data = YAML.load_file("#{$root}/ext/riscv-opcodes/instr_dict.yaml") - @instructions = @arch_def["instructions"].map do |_inst_name, inst_data| - Instruction.new(inst_data, opcode_data, @sym_table, self) + Instruction.new(inst_data) end @instructions @@ -1445,13 +1555,13 @@ def find_replace_links(adoc) csr_name, field_name = name.split(".") csr = csr(csr_name) if !field_name.nil? && !csr.nil? && csr.field?(field_name) - "%%LINK[csr_field;#{csr_name}.#{field_name};#{csr_name}.#{field_name}]%%" + "%%LINK%csr_field;#{csr_name}.#{field_name};#{csr_name}.#{field_name}%%" elsif !csr.nil? - "%%LINK[csr;#{csr_name};#{csr_name}]%%" + "%%LINK%csr;#{csr_name};#{csr_name}%%" elsif inst(name.downcase) - "%%LINK[inst;#{name};#{name}]%%" + "%%LINK%inst;#{name};#{name}%%" elsif extension(name) - "%%LINK[ext;#{name};#{name}]%%" + "%%LINK%ext;#{name};#{name}%%" else match end diff --git a/lib/arch_gen.rb b/lib/arch_gen.rb index 91367cb09..5e61b9be2 100644 --- a/lib/arch_gen.rb +++ b/lib/arch_gen.rb @@ -9,6 +9,7 @@ require "yaml" require_relative "validate" +require_relative "arch_def" $root = Pathname.new(__FILE__).dirname.dirname.realpath if $root.nil? @@ -281,7 +282,7 @@ def ext?(ext_name, ext_version = nil) # @params type [Symbol] Type (:section, :csr, :inst, :ext) # @params name [#to_s] Name of the object def link_to(type, name) - "%%LINK[#{type};#{name}]%%" + "%%LINK%#{type};#{name}%%" end # info on interrupt and exception codes @@ -717,48 +718,47 @@ def maybe_add_inst(inst_name, extra_env = {}) merged_path = gen_merged_def(:inst, arch_path, arch_overlay_path) # get the inst data (not including the name key), which is redundant at this point - inst_obj = YAML.load_file(merged_path)[inst_name] - inst_obj["name"] = inst_name + inst_data = YAML.load_file(merged_path)[inst_name] + inst_data["name"] = inst_name - defined_in = inst_obj["definedBy"] - defined_in = [defined_in] unless defined_in.is_a?(Array) - - excluded_by = inst_obj.key?("excluded_by") ? inst_obj["excluded_by"] : [] - excluded_by = [excluded_by] unless excluded_by.is_a?(Array) - - - unless inst_obj.key?("encoding") - raise "no riscv-opcode data for #{inst_obj['name']}" unless @opcode_data.key?(inst_obj["name"].tr(".", "_")) - - opcode_str = @opcode_data[inst_obj["name"].tr(".", "_")]["extension"][0] - - raise "Bad opcode string" unless opcode_str =~ /rv((32)|(64))?_([a-zA-Z0-9]+)/ - - base = ::Regexp.last_match(1) - riscv_opcodes_extension = ::Regexp.last_match(4) - warn "Found #{inst_obj['name']} in unexpected extension (#{riscv_opcodes_extension})" unless defined_in.include?(riscv_opcodes_extension.capitalize) + inst_yaml = YAML.dump({ inst_name => inst_data}) + begin + inst_data = @validator.validate_str(inst_yaml, type: :inst) + rescue Validator::ValidationError => e + warn "Instruction definition in #{gen_inst_path} did not validate" + raise e end - inst_obj["base"] = base.to_i unless base.nil? - - # add the instruction, unless it is from an extension not supported in this config + inst_obj = Instruction.new(inst_data[inst_name]) + possible_xlens = [@params["XLEN"]] + if @cfg["extensions"].any? { |e| e[0] == "S" } + possible_xlens << 32 if [32, 3264].include?(@params["SXLEN"]) + possible_xlens << 64 if [64, 3264].include?(@params["SXLEN"]) + end + if @cfg["extensions"].any? { |e| e[0] == "U" } + possible_xlens << 32 if [32, 3264].include?(@params["UXLEN"]) + possible_xlens << 64 if [64, 3264].include?(@params["UXLEN"]) + end + if @cfg["extensions"].any? { |e| e[0] == "H" } + possible_xlens << 32 if [32, 3264].include?(@params["VSXLEN"]) + possible_xlens << 32 if [32, 3264].include?(@params["VUXLEN"]) + possible_xlens << 64 if [64, 3264].include?(@params["VSXLEN"]) + possible_xlens << 64 if [64, 3264].include?(@params["VUXLEN"]) + end belongs = - (base.nil? || (base.to_i == @params["XLEN"])) && - @cfg["extensions"].any? { |e| defined_in.map(&:downcase).include?(e[0].downcase) } && - @cfg["extensions"].none? { |e| excluded_by.map(&:downcase).include?(e[0].downcase) } + inst_obj.exists_in_cfg?( + possible_xlens.uniq, + @cfg["extensions"].map { |e| ExtensionVersion.new(e[0], e[1]) } + ) + @implemented_instructions ||= [] @implemented_instructions << inst_name if belongs - gen_inst_path = @gen_dir / "arch" / "inst" / defined_in[0] / "#{inst_name}.yaml" + raise "?" if inst_obj.extension_requirements[0].name.nil? + gen_inst_path = @gen_dir / "arch" / "inst" / inst_obj.extension_requirements[0].name / "#{inst_name}.yaml" FileUtils.mkdir_p gen_inst_path.dirname - gen_inst_path.write YAML.dump({ inst_name => inst_obj }) + gen_inst_path.write inst_yaml - begin - @validator.validate_str(File.read(gen_inst_path), type: :inst) - rescue Validator::ValidationError => e - warn "Instruction definition in #{gen_inst_path} did not validate" - raise e - end # @instructions << inst_def # @inst_hash ||= {} diff --git a/lib/idl.rb b/lib/idl.rb index b41beb414..c8e28bb41 100644 --- a/lib/idl.rb +++ b/lib/idl.rb @@ -56,17 +56,17 @@ def compile_file(path, symtab) raise "unexpected type #{m.class.name}" unless m.is_a?(IsaAst) - m.make_left + ast = m.to_ast - m.set_input_file(path.to_s) + ast.set_input_file(path.to_s) begin - m.type_check(symtab) + ast.type_check(symtab) rescue AstNode::TypeError, AstNode::InternalError => e warn e.what warn e.bt exit 1 end - m + ast end # compile a function body, and return the abstract syntax tree @@ -88,8 +88,8 @@ def compile_func_body(body, return_type: nil, symtab: SymbolTable.new, name: nil cloned_symtab.pop end - ast = @parser.parse(body, root: :function_body) - if ast.nil? + m = @parser.parse(body, root: :function_body) + if m.nil? raise SyntaxError, <<~MSG While parsing #{parent}::#{name} #{@parser.failure_line}:#{@parser.failure_column} @@ -98,15 +98,15 @@ def compile_func_body(body, return_type: nil, symtab: SymbolTable.new, name: nil end # fix up left recursion - ast.make_left + ast = m.to_ast # type check cloned_symtab.push cloned_symtab.add("__expected_return_type", return_type) unless return_type.nil? begin - ast.func_stmt_list.elements.each do |e| - e.choice.type_check(cloned_symtab) + ast.statements.each do |s| + s.type_check(cloned_symtab) end rescue AstNode::TypeError => e raise e if no_rescue @@ -138,18 +138,17 @@ def compile_func_body(body, return_type: nil, symtab: SymbolTable.new, name: nil # compile an instruction operation, and return the abstract syntax tree # - # @param operation [String] Instruction operation source code + # @param inst [Instruction] Instruction object # @param symtab [SymbolTable] Symbol table to use for type checking - # @param name [String] Function name, used for error messages - # @param parent [String] Parent class of the function, used for error messages # @param input_file [Pathname] Path to the input file this source comes from # @param input_line [Integer] Starting line in the input file that this source comes from # @return [Ast] The root of the abstract syntax tree - def compile_inst_operation(operation, symtab: SymbolTable.new, name: nil, parent: nil, input_file: nil, input_line: 0) + def compile_inst_operation(inst, input_file: nil, input_line: 0) + operation = inst["operation()"] @parser.set_input_file(input_file, input_line) - ast = @parser.parse(operation, root: :instruction_operation) - if ast.nil? + m = @parser.parse(operation, root: :instruction_operation) + if m.nil? raise SyntaxError, <<~MSG While parsing #{input_file}:#{@parser.failure_line}:#{@parser.failure_column} @@ -158,33 +157,63 @@ def compile_inst_operation(operation, symtab: SymbolTable.new, name: nil, parent end # fix up left recursion - ast.make_left + ast = m.to_ast + ast.set_input_file("Inst #{inst.name} (#{input_file})", input_line) + ast + end + # Type check an abstract syntax tree + # + # @param ast [AstNode] An abstract syntax tree + # @param symtab [SymbolTable] The compilation context + # @param what [String] A description of what you are type checking (for error messages) + # @raise AstNode::TypeError if a type error is found + def type_check(ast, symtab, what) # type check - symtab.push + begin + ast.type_check(symtab) + rescue AstNode::TypeError => e + warn "While type checking #{what}:" + warn e.what + exit 1 + rescue AstNode::InternalError => e + warn "While type checking #{what}:" + warn e.what + warn e.backtrace + exit 1 + end + ast + end + + def compile_expression(expression, symtab, pass_error: false) + m = @parser.parse(expression, root: :expression) + if m.nil? + raise SyntaxError, <<~MSG + While parsing #{expression}:#{@parser.failure_line}:#{@parser.failure_column} + + #{@parser.failure_reason} + MSG + end + + ast = m.to_ast begin ast.type_check(symtab) rescue AstNode::TypeError => e - if name && parent - warn "In function #{name} of #{parent}:" - elsif name && parent.nil? - warn "In function #{name}:" - end + raise e if pass_error + + warn "Compiling #{expression}" warn e.what warn e.backtrace exit 1 rescue AstNode::InternalError => e - if name && parent - warn "In function #{name} of #{parent}:" - elsif name && parent.nil? - warn "In function #{name}:" - end + raise e if pass_error + + warn "Compiling #{expression}" warn e.what warn e.backtrace exit 1 end - symtab.pop ast end diff --git a/lib/idl/ast.rb b/lib/idl/ast.rb index f8f1cec91..a06b5cca3 100644 --- a/lib/idl/ast.rb +++ b/lib/idl/ast.rb @@ -27,18 +27,20 @@ def has_template_ancestor? # @return [Boolean] whether or not this SyntaxNode represents a function name (overriden in the parser) def is_function_name? = false - # Fix up left recursion for the PEG + # convert SyntaxNode into an AstNode # - # This is the default for anything that isn't a left-recursive binary op + # Mostly, there is a 1:1 correspondence between SyntaxNode and AstNode. A few exceptions: # - # Only left-recursive binary ops need to override this + # * Left recusrion needs fixed up, so BinaryExpreesions are converted + # * If statements are converted to a more friendly format # # @note This may alter the SyntaxTree. You shouldn't use pointers within the - # tree from before a call to make_left + # tree from before a call to to_ast # @return [SyntaxNode] A fixed syntax tree - def make_left + def to_ast elements.nil? || elements.length.times do |i| - elements[i] = elements[i].make_left + elements[i] = elements[i].to_ast + elements[i].parent = self end self end @@ -50,6 +52,9 @@ def make_left def set_input_file(filename, starting_line = 0) @input_file = filename @starting_line = starting_line + elements.nil? || elements.length.times do |i| + elements[i].set_input_file(filename, starting_line) + end raise "?" if @starting_line.nil? end @@ -283,7 +288,7 @@ def print_ast(indent = 0, indent_size: 2, io: $stdout) # @!macro type_check # @abstract - def type_check(symtab) = raise NotImplementedError, "Subclass of AstNode must implement type_check" + def type_check(symtab) = raise NotImplementedError, "#{self.class.name} must implement type_check" # @!macro [new] to_idl # Return valid IDL representation of the node (and its subtree) @@ -310,22 +315,37 @@ module Executable # @return [void] # @!macro execute - def execute(symtab) = raise NotImplementedError, "#{self.class.name} must implement update_value" + def execute(symtab) = raise NotImplementedError, "#{self.class.name} must implement execute" end # interface for nodes that *might* return a value in a function body module Returns # @!macro [new] retrun_value # Evaluate the compile-time return value of this node, or, if the node does not return - # (e.g., because it is an IfAst and the return in the not-taken path), execute the node + # (e.g., because it is an IfAst but there is no return on the taken path), execute the node # and update the symtab # # @param symtab [SymbolTable] The symbol table for the context # @raise ValueError if, during evaulation, a node without a compile-time value is found - # @return [Integer, nil] The return value, or nil if the node doesn't return + # @return [Integer] The return value, if it is integral + # @return [Boolean] The return value, if it is boolean + # @return [nil] if the return value is not compile-time-known # @!macro return_value def return_value(symtab) = raise NotImplementedError, "#{self.class.name} must implement return_value" + + # @!macro [new] retrun_values + # Evaluate all possible compile-time return values of this node, or, if the node does not return + # (e.g., because it is an IfAst but there is no return on a possible path), execute the node + # and update the symtab + # + # @param symtab [SymbolTable] The symbol table for the context + # @raise ValueError if, during evaulation, a node without a compile-time value is found + # @return [Array] The possible return values. Will be an empty array if there are no return values + # @return [Array] The possible return values. Will be an empty array if there are no return values + + # @!macro return_values + def return_values(symtab) = raise NotImplementedError, "#{self.class.name} must implement return_values" end # interface for R-values (e.g., expressions that have a value) @@ -355,7 +375,7 @@ def type(symtab) = raise NotImplementedError, "#{self.class.name} has no type" # Should not be called until {#type_check} is called with the same arguments # # @param symtab [SymbolTable] Symbol table for lookup - # @return [Integer] if the compile-time-known value is an integer + # @return [Integer] if the compile-time-known value is integral # @return [Boolean] if the compile-time-known value is a boolean # @raise [AstNode::ValueError] if the value is not knowable at compile time # @raise [AstNode::InternalError] if the value is dependent on symtab, and type_check was not called first @@ -371,6 +391,33 @@ def type(symtab) = raise NotImplementedError, "#{self.class.name} has no type" # @!macro value # @abstract def value(symtab) = raise NotImplementedError, "#{self.class.name} must implement value(symtab)" + + # @!macro [new] values + # Return a complete list of possible compile-time-known values of the node, or raise a ValueError if + # the full list cannot be determined + # + # For most AstNodes, this will just be a single-entry array + # + # @param symtab [SymbolTable] The context for the evaulation + # @return [Array] The complete list of compile-time-known values, when they are integral + # @return [Array] The complete list of compile-time-known values, when they are booleans + # @return [AstNode::ValueError] if the list of values is not knowable at compile time + + # @!macro values + def values(symtab) = [value(symtab)] + end + + # interface for any AstNode that introduces a new symbol into scope + module Declaration + # @!macro [new] add_symbol + # Add symbol(s) at the outermost scope of the symbol table + # + # @param symtab [SymbolTable] Symbol table at the scope that the symbol(s) will be inserted + def add_symbol(symtab) = raise NotImplementedError, "#{self.class.name} must implment add_symbol" + end + + class IdSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast = IdAst.new(input, interval, text_value) end # an identifier @@ -379,34 +426,39 @@ def value(symtab) = raise NotImplementedError, "#{self.class.name} must implemen class IdAst < AstNode include Rvalue + def initialize(input, interval, id_name) + super(input, interval, []) + @name = id_name + end + # @!macro type_check def type_check(symtab) - type_error "no symbol named '#{text_value}' on line #{lineno}" if symtab.get(text_value).nil? + type_error "no symbol named '#{@name}' on line #{lineno}" if symtab.get(@name).nil? end # @return [String] The ID name - def name = text_value + def name = @name # @!macro type_no_archdef def type(symtab) - internal_error "Symbol not found (should have called type_check)" if symtab.get(text_value).nil? + internal_error "Symbol '#{@name}' not found (should have called type_check)" if symtab.get(@name).nil? - symtab.get(text_value).type + symtab.get(@name).type end # @!macro value_no_archdef def value(symtab) - var = symtab.get(text_value) + var = symtab.get(@name) - internal_error "Var was not found, call type_check first!" if var.nil? + type_error "Variable '#{@name}' was not found" if var.nil? - value_error "Value of '#{text_value}' not known" if var.value.nil? + value_error "Value of '#{@name}' not known" if var.value.nil? var.value end # @!macro to_idl - def to_idl = text_value + def to_idl = @name end # global variable declared with an initializer, @@ -569,6 +621,11 @@ def type_check(symtab) end end + add_symbol(symtab) + end + + # @!macro add_symbol + def add_symbol(symtab) et = EnumerationType.new(user_type_name.text_value, element_names, element_values) symtab.add!(et.name, et) end @@ -673,6 +730,11 @@ def type_check(symtab) type_error "Field position (#{b}) is larger than the bitfield width (#{bf_size})" if b >= bf_size end + add_symbol(symtab) + end + + # @!macro add_symbol + def add_symbol(symtab) t = type(symtab) symtab.add!(name, t) end @@ -723,19 +785,19 @@ def to_idl # # For example, it helps us represent # X[rs1][31:0] - class AryAccess < Treetop::Runtime::SyntaxNode + class AryAccessSyntaxNode < Treetop::Runtime::SyntaxNode # fix up left recursion # # @return [AstNode] New tree rooted at the array access - def make_left - var = a.make_left + def to_ast + var = a.to_ast interval_start = interval.begin brackets.elements.each do |bracket| var = if bracket.msb.empty? - AryElementAccessAst.new(input, interval_start...bracket.interval.end, var, bracket.lsb.make_left) + AryElementAccessAst.new(input, interval_start...bracket.interval.end, var, bracket.lsb.to_ast) else AryRangeAccessAst.new(input, interval_start...bracket.interval.end, var, - bracket.msb.expression.make_left, bracket.lsb.make_left) + bracket.msb.expression.to_ast, bracket.lsb.to_ast) end interval_start = bracket.interval.end end @@ -824,6 +886,9 @@ def value(symtab) ary.value[idx].value end end + + # @!macro to_idl + def to_idl = "#{@var.to_idl}[#{@index.to_idl}]" end class AryRangeAccessAst < AstNode @@ -838,6 +903,7 @@ def initialize(input, interval, var, msb, lsb) @lsb = lsb end + # @!macro type_check def type_check(symtab) @var.type_check(symtab) @msb.type_check(symtab) @@ -863,6 +929,7 @@ def type_check(symtab) end end + # @!macro type def type(symtab) begin msb_value = @msb.value(symtab) @@ -875,10 +942,15 @@ def type(symtab) end end + # @!macro value def value(symtab) mask = (1 << (@msb.value(symtab) - @lsb.value(symtab) + 1)) - 1 (@var.value(symtab) >> @lsb.value(symtab)) & mask end + + # @!macro to_idl + def to_idl = "#{@var.to_idl}[#{@msb.to_idl}:#{@lsb.to_idl}]" + end # base class for all nodes representing an assignment @@ -897,76 +969,99 @@ def rhs end end + class VariableAssignmentSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + VariableAssignmentAst.new(input, interval, var.to_ast, rval.to_ast) + end + end + # represents a variable assignment statement # # for example, these will result in a VariableAssignmentAst # X[rs1] = XLEN'b0 # CSR[mepc] = PC + 4 - class VariableAssignmentAst < AssignmentAst - # @!macro type_check - def type_check(symtab) - var.type_check(symtab) - rval.type_check(symtab) - unless rval.type(symtab).convertable_to?(var.type(symtab)) - type_error "Incompatible type in assignment (#{var.type(symtab)}, #{rval.type(symtab)}) on line #{lineno}" - end - end + class VariableAssignmentAst < AstNode + attr_reader :lhs, :rhs - def lhs - var + def initialize(input, interval, lhs_ast, rhs_ast) + super(input, interval, [lhs_ast, rhs_ast]) + @lhs = lhs_ast + @rhs = rhs_ast end - def rhs - rval + # @!macro type_check + def type_check(symtab) + @lhs.type_check(symtab) + @rhs.type_check(symtab) + unless @rhs.type(symtab).convertable_to?(@lhs.type(symtab)) + type_error "Incompatible type in assignment (#{@lhs.type(symtab)}, #{@rhs.type(symtab)})" + end end def execute(symtab) - if var.is_a?(CsrWriteAst) + if @lhs.is_a?(CsrWriteAst) value_error "CSR writes are never compile-time-known" else - variable = symtab.get(var.text_value) + variable = symtab.get(@lhs.text_value) - internal_error "No variable #{var.text_value}" if variable.nil? + internal_error "No variable #{@lhs.text_value}" if variable.nil? - variable.value = rval.value(symtab) + variable.value = @rhs.value(symtab) end end # @!macro to_idl - def to_idl = "#{var.to_idl} = #{rval.to_idl}" + def to_idl = "#{@lhs.to_idl} = #{@rhs.to_idl}" + end + + class AryElementAssignmentSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + AryElementAssignmentAst.new(input, interval, var.to_ast, idx.to_ast, rval.to_ast) + end end # represents an array element assignement # # for example: # X[rs1] = XLEN'd0 - class AryElementAssignmentAst < AssignmentAst - # @!macro type_check + class AryElementAssignmentAst < AstNode + attr_reader :lhs, :idx, :rhs + + def initialize(input, interval, lhs, idx, rhs) + super(input, interval, [lhs, idx, rhs]) + @lhs = lhs + @idx = idx + @rhs = rhs + end + + # @!macro type_check def type_check(symtab) - var.type_check(symtab) - type_error "#{var.text_value} must be an array or an integral type" unless [:array, :bits].include?(var.type(symtab).kind) - type_errpr "Assigning to a constant" if var.type(symtab).const? + @lhs.type_check(symtab) + unless [:array, :bits].include?(@lhs.type(symtab).kind) + type_error "#{@lhs.text_value} must be an array or an integral type" + end + type_errpr "Assigning to a constant" if @lhs.type(symtab).const? - idx.type_check(symtab) + @idx.type_check(symtab) - type_error "Index must be integral" unless idx.type(symtab).integral? + type_error "Index must be integral" unless @idx.type(symtab).integral? begin - idx_value = idx.value(symtab) - type_error "Array index out of range" if idx_value(symtab) >= var.type(symtab).width + idx_value = @idx.value(symtab) + type_error "Array index (#{@idx.text_value} = #{idx_value}) out of range (< #{var.type(symtab).width})" if idx_value >= @lhs.type(symtab).width rescue ValueError # OK, doesn't need to be known end - rval.type_check(symtab) + @rhs.type_check(symtab) - case var.type(symtab).kind + case @lhs.type(symtab).kind when :array - unless rval.type(symtab).convertable_to?(var.type(symtab).sub_type) + unless @rhs.type(symtab).convertable_to?(@lhs.type(symtab).sub_type) type_error "Incompatible type in array assignment" end when :bits - unless rval.type(symtab).convertable_to?(Type.new(:bits, width: 1)) + unless @rhs.type(symtab).convertable_to?(Type.new(:bits, width: 1)) type_error "Incompatible type in integer slice assignement" end else @@ -974,30 +1069,21 @@ def type_check(symtab) end end - def lhs - internal_error "What's this used for?" - end - - def rhs - rval - end - def execute(symtab) - case var.type(symtab).kind + case @lhs.type(symtab).kind when :array - value_error "TODO: array element assignement execution" + @lhs.value(symtab)[@idx.value(symtab)] = @rhs.value(symtab) when :bits - v = rhs.value(symtab) - var = symtab.get(var.text_value) - mask = 1 << idx.value(symtab) - var.value = (var.value & ~0) | ((v & 1) << idx.value(symtab)) + v = @rhs.value(symtab) + var = symtab.get(@lhs.text_value) + var.value = (@lhs.value & ~0) | ((v & 1) << @idx.value(symtab)) else internal_error "unexpected type for array element assignment" end end # @!macro to_idl - def to_idl = "#{var.to_idl}[#{idx.to_idl}] = #{rval.to_idl}" + def to_idl = "#{@lhs.to_idl}[#{@idx.to_idl}] = #{@rhs.to_idl}" end # represents an array range assignement @@ -1048,7 +1134,7 @@ def execute(symtab) msb_val = msb.value(symtab) lsb_val = lsb.value(symtab) - type_error "MSB is <= LSB" if msb_val <= lsb_val + type_error "MSB (#{msb_val}) is <= LSB (#{lsb_val})" if msb_val <= lsb_val rval_val = rval.value(symtab) @@ -1233,7 +1319,9 @@ def to_idl = "(#{vars.map(&:to_idl).join(', ')}) = #{function_call.to_idl}" # for example: # Bits<64> a, b; # Bits<64> a, b, c, d; - class MultiVariableDeclarationAst < AssignmentAst + class MultiVariableDeclarationAst < AstNode + include Declaration + # @return [Array] Variables being declared def var_names return @var_names unless @var_names.nil? @@ -1252,14 +1340,13 @@ def type_check(symtab) type_error "Attempt to write read-only/constant variable #{text_value}" if type.const? - var_names.each do |vname| - symtab.add(vname, Var.new(vname, type.clone)) - end + add_symbol(symtab) end - def execute(symtab) - var_names.each do |name| - symtab.add(name, Var.new(name, type.clone)) + # @!macro add_symbol + def add_symbol(symtab) + var_names.each do |vname| + symtab.add(vname, Var.new(vname, type.clone, type.default)) end end @@ -1273,19 +1360,26 @@ def to_idl = "#{type.to_idl} #{var_names.map(&:to_idl).join(', ')}" # Bits<64> doubleword # Boolean has_property class VariableDeclarationAst < AstNode - include Executable + include Declaration def decl_type(symtab) dtype = type_name.type(symtab) return nil if dtype.nil? - dtype = Type.new(:enum_ref, enum_class: dtype) if dtype.kind == :enum + qualifiers = + if var_write.text_value[0].upcase == var_write.text_value[0] + [:const] + else + [] + end + + dtype = Type.new(:enum_ref, enum_class: dtype, qualifiers:) if dtype.kind == :enum dtype = dtype.clone.qualify(q.text_value.to_sym) unless q.empty? unless ary_size.empty? - dtype = Type.new(:array, width: ary_size.expression.value(symtab), sub_type: dtype.clone) + dtype = Type.new(:array, width: ary_size.expression.value(symtab), sub_type: dtype.clone, qualifiers:) end dtype @@ -1303,39 +1397,64 @@ def type_check(symtab) unless ary_size.empty? ary_size.expression.type_check(symtab) begin - ary_size_value = ary_size.expression.value(symtab) + ary_size.expression.value(symtab) rescue ValueError type_error "Array size must be known at compile time" end end - symtab.add(var_write.text_value, Var.new(var_write.text_value, decl_type(symtab))) + add_symbol(symtab) var_write.type_check(symtab) end - def execute(symtab) - value_error "TODO: array declration execution" unless ary_size.empty? - symtab.add(var_write.text_value, Var.new(var_write.text_value, decl_type(symtab))) + # @!macro add_symbol + def add_symbol(symtab) + symtab.add(var_write.text_value, Var.new(var_write.text_value, decl_type(symtab), decl_type(symtab).default)) end # @!macro to_idl def to_idl if ary_size.empty? - "#{type.to_idl} #{var_write.to_idl}" + "#{type_name.to_idl} #{var_write.to_idl}" else - "#{type.to_idl} #{var_write.to_idl}[#{ary_size.expression.to_idl}]" + "#{type_name.to_idl} #{var_write.to_idl}[#{ary_size.expression.to_idl}]" end end end + class VariableDeclarationWithInitializationSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + ary_size_ast = ary_size.empty? ? nil : ary_size.expression.to_ast + VariableDeclarationWithInitializationAst.new( + input, interval, + type_name.to_ast, var_write.to_ast, ary_size_ast, rval.to_ast + ) + end + end + # reprents a single variable declaration with initialization # # for example: # Bits<64> doubleword = 64'hdeadbeef # Boolean has_property = true - class VariableDeclarationWithInitializationAst < AssignmentAst + class VariableDeclarationWithInitializationAst < AstNode include Executable + include Declaration + + attr_reader :type_name, :lhs, :rhs + + def initialize(input, interval, type_name_ast, var_write_ast, ary_size, rval_ast) + if ary_size.nil? + super(input, interval, [type_name_ast, var_write_ast, rval_ast]) + else + super(input, interval, [type_name_ast, var_write_ast, ary_size, rval_ast]) + end + @type_name = type_name_ast + @lhs = var_write_ast + @ary_size = ary_size + @rhs = rval_ast + end def lhs_type(symtab) decl_type = type_name.type(symtab).clone @@ -1343,97 +1462,121 @@ def lhs_type(symtab) decl_type = Type.new(:enum_ref, enum_class: decl_type) if decl_type.kind == :enum - decl_type = decl_type.clone.qualify(q.text_value.to_sym) unless q.empty? + # decl_type = decl_type.clone.qualify(q.text_value.to_sym) unless q.empty? + + if @lhs.text_value[0].upcase == @lhs.text_value[0] + decl_type.make_const + end + + unless @ary_size.nil? + begin + decl_type = Type.new(:array, sub_type: decl_type, width: @ary_size.value(symtab)) + rescue ValueError + type_error "Array size must be known at compile time" + end + if @lhs.text_value[0].upcase == @lhs.text_value[0] + decl_type.make_const + end + end decl_type end + # @!macro type_check def type_check(symtab) - rval.type_check(symtab) + @rhs.type_check(symtab) - type_name.type_check(symtab) + @type_name.type_check(symtab) - decl_type = lhs_type(symtab) + @ary_size&.type_check(symtab) - unless ary_size.empty? - ary_size.expression.type_check(symtab) - begin - ary_size_value = ary_size.expression.value(symtab) - rescue ValueError - type_error "Array size must be known at compile time" - end + decl_type = lhs_type(symtab) - decl_type = Type.new(:array, width: ary_size_value, sub_type: decl_type) - end - if (var_write.text_value == var_write.text_value.upcase) && ary_size.empty? + if decl_type.const? # this is a constant; ensure we are assigning a constant value begin - symtab.add(var_write.text_value, Var.new(var_write.text_value, decl_type.clone.make_const, rval.value(symtab))) + symtab.add(@lhs.text_value, Var.new(@lhs.text_value, decl_type.clone, @rhs.value(symtab))) rescue ValueError => e type_error "Declaring constant with a non-constant value (#{e})" end else - symtab.add(var_write.text_value, Var.new(var_write.text_value, decl_type.clone)) + symtab.add(@lhs.text_value, Var.new(@lhs.text_value, decl_type.clone)) end - var_write.type_check(symtab) + @lhs.type_check(symtab) # now check that the assignment is compatible - return if rval.type(symtab).convertable_to?(decl_type) - - type_error "Incompatible type (#{decl_type}, #{rval.type(symtab)}) in assignment" - end + return if @rhs.type(symtab).convertable_to?(decl_type) - def lhs - var_write + type_error "Incompatible type (#{decl_type}, #{@rhs.type(symtab)}) in assignment" end - def rhs - # if rhs is nil, this is the non-initializing variant - return nil unless respond_to?(:rval) - - return rval if rval.is_a?(Rvalue) - - internal_error "unexpected #{rval.inspect}" unless rval.is_a?(MemoryRValAst) - - rval + # @!macro add_symbol + def add_symbol(symtab) + symtab.add(lhs.text_value, Var.new(lhs.text_value, lhs_type(symtab), rhs.value(symtab))) + rescue ValueError + symtab.add(lhs.text_value, Var.new(lhs.text_value, lhs_type(symtab))) end + # @!macro execute def execute(symtab) - value_error "TODO: Array declaration" unless ary_size.empty? + value_error "TODO: Array declaration" unless @ary_size.nil? symtab.add(lhs.text_value, Var.new(lhs.text_value, lhs_type(symtab), rhs.value(symtab))) end + + # @!macro to_idl + def to_idl + if @ary_size.nil? + "#{type_name.to_idl} #{lhs.to_idl} = #{rhs.to_idl}" + else + "#{type_name.to_idl} #{lhs.to_idl}[#{@ary_size.to_idl}] = #{rhs.to_idl}" + end + end end - class BinaryExpressionRightAst < AstNode + class BinaryExpressionRightSyntaxNode < Treetop::Runtime::SyntaxNode - def make_left + # fix up left recursion + # i.e., xlen() - 1 - i => (xlen() - 1) - i + def to_ast first = BinaryExpressionAst.new( input, (interval.begin...r.elements[0].r.interval.end), - l.make_left, r.elements[0].op, r.elements[0].r.make_left + l.to_ast, r.elements[0].op.text_value, r.elements[0].r.to_ast ) if r.elements.size == 1 first else - r.elements[1, -1].inject(first) do |lhs, r| - BinaryExpressionAst.new(input, (r.interval.begin...r.r.interval.end), - lhs, r.op, r.r.make_left) + r.elements[1..].inject(first) do |lhs, el| + BinaryExpressionAst.new(input, (lhs.interval.begin...el.r.interval.end), + lhs, el.op.text_value, el.r.to_ast) end end - first end - def type_check(_symtab, _archdef) - raise "you must have forgotten the make_left pass" + def type_check(_symtab) + raise "you must have forgotten the to_ast pass" + end + end + + class SignCastSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + SignCastAst.new(input, interval, expression.to_ast) end end class SignCastAst < AstNode include Rvalue + attr_reader :expression + + def initialize(input, interval, expression) + super(input, interval, [expression]) + @expression = expression + end + # @!macro type_check def type_check(symtab) expression.type_check(symtab) @@ -1523,9 +1666,9 @@ class BinaryExpressionAst < AstNode # create a new, left-recursion-fixed, binary expression def initialize(input, interval, lhs, op, rhs) - super(input, interval, [lhs, op, rhs]) + super(input, interval, [lhs, rhs]) @lhs = lhs - @op = op.text_value + @op = op.to_s type_error "Bad op '#{@op}'" unless OPS.include?(@op) @rhs = rhs end @@ -1560,7 +1703,7 @@ def invert(symtab) # @!macro to_idl def to_idl - "#{lhs.to_idl} #{op} #{rhs.to_idl}" + "(#{lhs.to_idl} #{op} #{rhs.to_idl})" end # @!macro type @@ -1670,8 +1813,87 @@ def value(symtab) else eval "lhs_value #{op} rhs.value(symtab)", binding, __FILE__, __LINE__ end + elsif op == "==" + begin + @lhs.value(symtab) == @rhs.value(symtab) + rescue ValueError + # even if we don't know the exact value of @lhs and @rhs, we can still + # know that == is false if the possible values of each do not overlap + if @lhs.values(symtab).intersection(@rhs.value(symtab)).empty? + false + else + value_error "There is overlap in the lhs/rhs return values" + end + end + elsif op == "!=" + begin + @lhs.value(symtab) != @rhs.value(symtab) + rescue ValueError + # even if we don't know the exact value of @lhs and @rhs, we can still + # know that != is true if the possible values of each do not overlap + if @lhs.values(symtab).intersection(@rhs.value(symtab)).empty? + true + else + value_error "There is overlap in the lhs/rhs return values" + end + end + elsif op == "<=" + begin + @lhs.value(symtab) <= @rhs.value(symtab) + rescue ValueError + # even if we don't know the exact value of @lhs and @rhs, we can still + # know that != is true if the possible values of lhs are all <= the possible values of rhs + rhs_values = @rhs.values(symtab) + if @lhs.values(symtab).all? { |lhs_value| rhs_values.all? { |rhs_value| lhs_value <= rhs_value} } + true + else + value_error "Some value of lhs is not <= some value of rhs" + end + end + elsif op == ">=" + begin + @lhs.value(symtab) >= @rhs.value(symtab) + rescue ValueError + # even if we don't know the exact value of @lhs and @rhs, we can still + # know that != is true if the possible values of lhs are all >= the possible values of rhs + rhs_values = @rhs.values(symtab) + if @lhs.values(symtab).all? { |lhs_value| rhs_values.all? { |rhs_value| lhs_value >= rhs_value} } + true + else + value_error "Some value of lhs is not >= some value of rhs" + end + end + elsif op == "<" + begin + @lhs.value(symtab) < @rhs.value(symtab) + rescue ValueError + # even if we don't know the exact value of @lhs and @rhs, we can still + # know that != is true if the possible values of lhs are all < the possible values of rhs + rhs_values = @rhs.values(symtab) + if @lhs.values(symtab).all? { |lhs_value| rhs_values.all? { |rhs_value| lhs_value < rhs_value} } + true + else + value_error "Some value of lhs is not < some value of rhs" + end + end + elsif op == ">" + begin + @lhs.value(symtab) > @rhs.value(symtab) + rescue ValueError + # even if we don't know the exact value of @lhs and @rhs, we can still + # know that != is true if the possible values of lhs are all > the possible values of rhs + rhs_values = @rhs.values(symtab) + if @lhs.values(symtab).all? { |lhs_value| rhs_values.all? { |rhs_value| lhs_value > rhs_value} } + true + else + value_error "Some value of lhs is not > some value of rhs" + end + end else - eval "lhs.value(symtab) #{op} rhs.value(symtab)", binding, __FILE__, __LINE__ + v = eval "lhs.value(symtab) #{op} rhs.value(symtab)", binding, __FILE__, __LINE__ + v_trunc = v & ((1 << type(symtab).width) - 1) + warn "WARNING: The value of '#{text_value}' is truncated from #{v} to #{v_trunc} because the result is only #{type(symtab).width} bits" if v != v_trunc + v_trunc end end @@ -1685,6 +1907,12 @@ def value(symtab) attr_reader :op end + class ParenExpressionSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + ParenExpressionAst.new(input, interval, e.to_ast) + end + end + # represents a parenthesized expression # # for example: @@ -1692,16 +1920,23 @@ def value(symtab) class ParenExpressionAst < AstNode include Rvalue - def invert(symtab) = e.invert(symtab) + attr_reader :expression + + def initialize(input, interval, expression) + super(input, interval, [expression]) + @expression = expression + end + + def invert(symtab) = expression.invert(symtab) # @!macro type_check - def type_check(symtab) = e.type_check(symtab) + def type_check(symtab) = expression.type_check(symtab) # @!macro type - def type(symtab) = e.type(symtab) + def type(symtab) = expression.type(symtab) # @!macro value - def value(symtab) = e.value(symtab) + def value(symtab) = expression.value(symtab) # @!macro to_idl def to_idl = "(#{e.to_idl})" @@ -1771,12 +2006,13 @@ def type(symtab) # @!macro value def value(symtab) - result = first.value(symtab) - total_width = first.type(symtab).width - rest.elements.each do |e| + result = 0 + total_width = 0 + rest.elements.reverse_each do |e| result |= (e.expression.value(symtab) << total_width) total_width += e.expression.type(symtab).width end + result |= first.value(symtab) << total_width result end @@ -1784,6 +2020,12 @@ def value(symtab) def to_idl = "{#{first.to_idl},#{rest.elements.map { |e| e.expression.to_idl }.join(',')}}" end + class ReplicationExpressionSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + ReplicationExpressionAst.new(input, interval, n.to_ast, v.to_ast) + end + end + # represents a replication expression # # for example: @@ -1791,6 +2033,14 @@ def to_idl = "{#{first.to_idl},#{rest.elements.map { |e| e.expression.to_idl }.j class ReplicationExpressionAst < AstNode include Rvalue + attr_reader :n, :v + + def initialize(input, interval, n, v) + super(input, interval, [n, v]) + @n = n + @v = v + end + # @!macro type_check def type_check(symtab) n.type_check(symtab) @@ -1844,12 +2094,48 @@ def execute(symtab) var = symtab.get(rval.text_value) internal_error "No symbol #{rval.text_value}" if var.nil? + value_error "value of variable '#{rval.text_value}' not know" if var.value.nil? + var.value = var.value - 1 end def to_idl = "#{rval.to_idl}--" end + class BuiltinVariableSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + BuiltinVariableAst.new(input, interval, text_value) + end + end + + class BuiltinVariableAst < AstNode + attr_reader :name + + def initialize(input, interval, name) + super(input, interval, []) + @name = name + end + + def type_check(symtab) + type_error "Not a builtin variable" unless ["$pc", "$encoding"].include?(@name) + end + + def type(symtab) + case @name + when "$encoding" + sz = symtab.get("__instruction_encoding_size") + internal_error "Forgot to set __instruction_encoding_size" if sz.nil? + Type.new(:bits, width: sz.value, qualifiers: [:const]) + when "$pc" + Type.new(:bits, width: symtab.archdef.config_params["XLEN"]) + end + end + + def value(symtab) + value_error "Cannot know the value of pc or encoding" + end + end + # represents a post-increment expression # # for example: @@ -1861,6 +2147,7 @@ class PostIncrementExpressionAst < AstNode def type_check(symtab) rval.type_check(symtab) var = symtab.get(rval.text_value) + type_error "Post increment variable must be integral" unless var.type.integral? end # @!macro type @@ -1870,8 +2157,8 @@ def type(symtab) # @!macro execute def execute(symtab) - var = symtab.get(rval) - internal_error "Call type check first" if var.nil? + var = symtab.get(rval.text_value) + internal_error "No symbol named '#{rval.text_value}'" if var.nil? var.value = var.value + 1 end @@ -1951,6 +2238,12 @@ def value(symtab) def to_idl = "#{rval.to_idl}.#{field_name.to_idl}" end + class EnumRefSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + EnumRefAst.new(input, interval, enum_class.text_value, member.text_value) + end + end + # represents an enum reference # # for example: @@ -1959,30 +2252,41 @@ def to_idl = "#{rval.to_idl}.#{field_name.to_idl}" class EnumRefAst < AstNode include Rvalue + def class_name = @enum_class_name + def member_name = @member_name + + def initialize(input, interval, class_name, member_name) + super(input, interval, []) + + @enum_class_name = class_name + @member_name = member_name + end + # @!macro type_check def type_check(symtab) - enum_def_type = symtab.get(enum_class.text_value) - type_error "No symbol #{enum_class.text_value} has been defined" if enum_def_type.nil? + enum_def_type = symtab.get(@enum_class_name) + type_error "No symbol #{@enum_class_name} has been defined" if enum_def_type.nil? - type_error "#{enum_class.text_value} is not an enum type" unless enum_def_type.is_a?(EnumerationType) + type_error "#{@enum_class_name} is not an enum type" unless enum_def_type.is_a?(EnumerationType) + type_error "#{@enum_class_name} has no member '#{@member_name}'" if enum_def_type.value(@member_name).nil? end # @!macro type_no_archdef def type(symtab) - internal_error "Must call type_check first" if symtab.get(enum_class.text_value).nil? + internal_error "Must call type_check first" if symtab.get(@enum_class_name).nil? - Type.new(:enum_ref, enum_class: symtab.get(enum_class.text_value)) + Type.new(:enum_ref, enum_class: symtab.get(@enum_class_name)) end # @!macro value_no_archdef def value(symtab) - internal_error "Must call type_check first" if symtab.get(enum_class.text_value).nil? + internal_error "Must call type_check first" if symtab.get(@enum_class_name).nil? - symtab.get(enum_class.text_value).value(member.text_value) + symtab.get(@enum_class_name).value(@member_name) end # @!macro to_idl - def to_idl = "#{enum_class.to_idl}::#{member.to_idl}" + def to_idl = "#{@enum_class_name}::#{@member_name}" end # represents a unary operator @@ -2016,7 +2320,7 @@ def type_check(symtab) type_error "#{exp.type(symtab)} does not support unary #{op} operator" end - type_error "Unary minus only works on signed values" unless exp.type(symtab).signed? + # type_error "Unary minus only works on signed values" unless exp.type(symtab).signed? when "~" unless [:bits, :bitfield].include?(exp.type(symtab).kind) type_error "#{exp.type(symtab)} does not support unary #{op} operator" @@ -2032,18 +2336,19 @@ def type_check(symtab) # @!macro value def value(symtab) - val = eval("#{op}#{exp.value(symtab)}", binding, __FILE__, __LINE__) - if type(symtab).integral? && type(symtab).width > val.bit_length - # need to truncate - val &= ((1 << type(symtab).width) - 1) - if type(symtab).signed? && ((((val >> (type(symtab).width - 1))) & 1) == 1) + val = val_trunc = eval("#{op}#{exp.value(symtab)}", binding, __FILE__, __LINE__) + if type(symtab).integral? + val_trunc = val & ((1 << type(symtab).width) - 1) + if type(symtab).signed? && ((((val_trunc >> (type(symtab).width - 1))) & 1) == 1) # need to make this negative! # take the twos compliment - val = -((1 << type(symtab).width) - val) + val_trunc = -((1 << type(symtab).width) - val_trunc) end end - val + warn "#{text_value} is truncated due to insufficient bit width (from #{val} to #{val_trunc})" if val_trunc != val + + val_trunc end # return the operated-on expression @@ -2060,6 +2365,12 @@ def op def to_idl = "#{op}#{e.to_idl}" end + class TernaryOperatorExpressionSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + TernaryOperatorExpressionAst.new(input, interval, p9_binary_expression.to_ast, t.to_ast, f.to_ast) + end + end + # Represents a ternary operator # # for example: @@ -2068,157 +2379,214 @@ def to_idl = "#{op}#{e.to_idl}" class TernaryOperatorExpressionAst < AstNode include Rvalue + attr_reader :condition, :true_expression, :false_expression + + def initialize(input, interval, condition, true_expression, false_expression) + super(input, interval, [condition, true_expression, false_expression]) + + @condition = condition + @true_expression = true_expression + @false_expression = false_expression + end + # @!macro type_check def type_check(symtab) - p9_binary_expression.type_check(symtab) + @condition.type_check(symtab) + type_error "ternary selector must be bool" unless @condition.type(symtab).kind == :boolean + begin - cond = p9_binary_expression.value(symtab) + cond = @condition.value(symtab) # if the condition is compile-time-known, only check the used field if (cond) - t.type_check(symtab) + @true_expression.type_check(symtab) else - f.type_check(symtab) + @false_expression.type_check(symtab) end rescue ValueError - t.type_check(symtab) - f.type_check(symtab) + @true_expression.type_check(symtab) + @false_expression.type_check(symtab) - unless t.type(symtab).equal_to?(f.type(symtab)) + unless @true_expression.type(symtab).equal_to?(@false_expression.type(symtab)) # we'll allow dissimilar if they are both bits type - unless t.type(symtab).kind == :bits && f.type(symtab).kind == :bits - type_error "True and false options must be same type (have #{t.type(symtab)} and #{f.type(symtab)})" + unless @true_expression.type(symtab).kind == :bits && @false_expression.type(symtab).kind == :bits + type_error "True and false options must be same type (have #{@true_expression.type(symtab)} and #{@false_expression.type(symtab)})" end end end - - type_error "ternary selector must be bool" unless p9_binary_expression.type(symtab).kind == :boolean - - end # @!macro type def type(symtab) - p9_binary_expression.type_check(symtab) + @condition.type_check(symtab) begin - cond = p9_binary_expression.value(symtab) + cond = @condition.value(symtab) # if the condition is compile-time-known, only check the used field if (cond) - t.type(symtab) + @true_expression.type(symtab) else - f.type(symtab) + @false_expression.type(symtab) end rescue ValueError - if t.type(symtab).kind == :bits && f.type(symtab).kind == :bits - Type.new(:bits, width: [t.type(symtab).width, f.type(symtab).width].max) + if @true_expression.type(symtab).kind == :bits && @false_expression.type(symtab).kind == :bits + Type.new(:bits, width: [@true_expression.type(symtab).width, @false_expression.type(symtab).width].max) else - t.type(symtab) + @true_expression.type(symtab) end end end - def condition - p9_binary_expression - end - - def true_expression - t - end - - def false_expression - f - end - # @!macro value def value(symtab) - condition.value(symtab) ? t.value(symtab) : f.value(symtab) + @condition.value(symtab) ? @true_expression.value(symtab) : @false_expression.value(symtab) + end + + # @!macro values + def values(symtab) + @condition.value(symtab) ? @true_expression.values(symtab) : @false_expression.values(symtab) + rescue ValueError + (@true_expression.values(symtab) + @false_expression.values(symtab)).uniq end # @!macro to_idl - def to_idl = "#{condition.to_idl} ? #{true_expression.to_idl} : #{false_expression.to_idl}" + def to_idl = "#{@condition.to_idl} ? #{@true_expression.to_idl} : #{@false_expression.to_idl}" end - module VarReadExpressionAst - include Rvalue + # module VarReadExpressionAst + # include Rvalue - # @!macro type_check - def type_check(symtab) - var = symtab.get(text_value) + # # @!macro type_check + # def type_check(symtab) + # var = symtab.get(text_value) - type_error "No symbol named '#{text_value}'" if var.nil? + # type_error "No symbol named '#{text_value}'" if var.nil? - type_error "'#{text_value}' is not a variable" unless var.is_a?(Var) - end + # type_error "'#{text_value}' is not a variable" unless var.is_a?(Var) + # end - # @!macro type_no_archdef - def type(symtab) - internal_error "While checking VarRead type, no symbol '#{text_value}' found" if symtab.get(text_value).nil? + # # @!macro type_no_archdef + # def type(symtab) + # internal_error "While checking VarRead type, no symbol '#{text_value}' found" if symtab.get(text_value).nil? - symtab.get(text_value).type - end + # symtab.get(text_value).type + # end - # @!macro value_no_archdef - def value(symtab) - var = symtab.get(text_value) + # # @!macro value_no_archdef + # def value(symtab) + # var = symtab.get(text_value) - internal_error "Call type_check first" if var.nil? + # internal_error "Cannot find variable #{text_value}" if var.nil? - value_error "The value of '#{text_value}' is not known" if var.value.nil? + # value_error "The value of '#{text_value}' is not known" if var.value.nil? - var.value - end + # var.value + # end - # @!macro to_idl - def to_idl = text_value + # # @!macro to_idl + # def to_idl = text_value + # end + + + class StatementSyntaxNode < AstNode + def to_ast + StatementAst.new(a.to_ast) + end end - # represents a simple, one-line statement - # - # for example: - # Bits<64> new_variable; - # new_variable = 4; + class NoopAst < AstNode + def initialize + super("", 0...0, []) + end + + # @!macro type_check + def type_check(symtab); end + + # @!macro execute + def execute(symtab); end + + # @1macro to_idl + def to_idl = "" + end + + # represents a simple, one-line statement + # + # for example: + # Bits<64> new_variable; + # new_variable = 4; # func(); class StatementAst < AstNode include Executable - def action = a + attr_reader :action + + def initialize(action) + super(action.input, action.interval, [action]) + @action = action + end # @!macro type_check def type_check(symtab) - a.type_check(symtab) + @action.type_check(symtab) end + # @!macro execute def execute(symtab) - a.execute(symtab) + if @action.is_a?(Declaration) + @action.add_symbol(symtab) + end + if @action.is_a?(Executable) + @action.execute(symtab) + end end - def to_idl = "#{action.to_idl};" + # @!macro to_idl + def to_idl = "#{@action.to_idl};" + end + + class ConditionalStatementSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + ConditionalStatementAst.new(a.to_ast, expression.to_ast) + end end # represents a predicated simple statement # # for example: # a = 2 if condition; - class ConditionalStatementAst < StatementAst - # @!macro type_check - def type_check(symtab) - action.type_check(symtab) - condition.type_check(symtab) - type_error "condition is not boolean" unless condition.type(symtab).convertable_to?(:boolean) - end + class ConditionalStatementAst < AstNode + attr_reader :action, :condition - def action = a + def initialize(action, condition) + super(action.input, action.interval.first..action.interval.end, [action, condition]) + @action = action + @condition = condition + end - def condition - expression + # @!macro type_check + def type_check(symtab) + @action.type_check(symtab) + @condition.type_check(symtab) + type_error "condition is not boolean" unless @condition.type(symtab).convertable_to?(:boolean) end + # @!macro execute def execute(symtab) - cond = condition.value(symtab) + cond = @condition.value(symtab) if (cond) - action.execute(symtab) + @action.execute(symtab) end end + + # @!macro to_idl + def to_idl + "#{@action.to_idl} if (#{@condition.to_idl});" + end + end + + class DontCareReturnSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + DontCareReturnAst.new(input, interval) + end end # represents a don't care return value @@ -2228,6 +2596,10 @@ def execute(symtab) class DontCareReturnAst < AstNode include Rvalue + def initialize(input, interval) + super(input, interval, []) + end + # @!macro type_check_no_args def type_check(_symtab) # nothing to do! @@ -2347,7 +2719,6 @@ def type_check(symtab) types = [] if first.type(symtab).kind == :tuple type_error("Can't combine tuple types in return") unless rest.elements.empty? - num_values = first.type(symtab).tuple_types.size types = first.type(symtab).tuple_types else types = [first.type(symtab)] @@ -2362,7 +2733,7 @@ def type_check(symtab) end end - # list of return value nodes + # @return [Array] List of return value nodes def return_value_nodes v = [first] unless rest.empty? @@ -2377,6 +2748,7 @@ def enclosing_function find_ancestor(FunctionDefAst) end + # @!macro return_value def return_value(symtab) if return_value_nodes.size == 1 return_value_nodes[0].value(symtab) @@ -2385,6 +2757,15 @@ def return_value(symtab) end end + # @!macro return_values + def return_values(symtab) + if return_value_nodes.size == 1 + return_value_nodes[0].values(symtab) + else + return_value_nodes.map { |v| v.values(symtab) }.flatten.uniq + end + end + def to_idl = "return #{return_value_nodes.map(&:to_idl).join(',')};" end @@ -2395,6 +2776,7 @@ def condition expression end + # @!macro return_value def return_value(symtab) cond = condition.value(symtab) @@ -2406,42 +2788,60 @@ def return_value(symtab) nil end end + + # @!macro return_values + def return_values(symtab) + cond = condition.value(symtab) + + cond ? return_value_nodes.map { |n| n.values(symtab) }.flatten.uniq : [] + + rescue ValueError + # condition isn't known, so the return value is always possible + return_value_nodes.map { |n| n.values(symtab) }.flatten + end end class ExecutionCommentAst < AstNode def type_check(_symtab, _global); end end - class BitsTypeAst < AstNode - # @!macro type_check - def type_check(symtab) - i.type_check(symtab) - - begin - i.value(symtab) - rescue ValueError - type_error "Bit width is not compile-time known" + class BuiltinTypeNameSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + if !respond_to?(:i) + BuiltinTypeNameAst.new(input, interval, elements[0].text_value, nil) + else + BuiltinTypeNameAst.new(input, interval, elements[0].text_value, i.to_ast) end - type_error "Bit widht must be integral" unless i.type(symtab).integral? - end - - # @!macro type - def type(symtab) - Type.new(:bits, width: i.value(symtab).to_i) end - end class BuiltinTypeNameAst < AstNode + + def initialize(input, interval, type_name, bits_expression) + if bits_expression.nil? + super(input, interval, []) + else + super(input, interval, [bits_expression]) + end + @type_name = type_name + @bits_expression = bits_expression + end + # @!macro type_check def type_check(symtab) - type_error "Unimplemented builtin type #{text_value}" unless ["XReg", "Boolean", "U32", "U64"].include?(text_value) + if @type_name == "Bits" + @bits_expression.type_check(symtab) + type_error "Bits width (#{@bits_expression.value(symtab)}) must be positive" unless @bits_expression.value(symtab).positive? + end + unless ["Bits", "XReg", "Boolean", "U32", "U64"].include?(@type_name) + type_error "Unimplemented builtin type #{text_value}" + end end # @!macro type def type(symtab) archdef = symtab.archdef - case text_value + case @type_name when "XReg" Type.new(:bits, width: archdef.config_params["XLEN"]) when "Boolean" @@ -2450,116 +2850,248 @@ def type(symtab) Type.new(:bits, width: 32) when "U64" Type.new(:bits, width: 64) + when "Bits" + Type.new(:bits, width: @bits_expression.value(symtab)) else internal_error "TODO: #{text_value}" end end + + # @!macro to_idl + def to_idl + if @type_name == "Bits" + "Bits<#{@bits_expression.to_idl}>" + else + @type_name + end + end end - module IntAst + module IntLiteralSyntaxNode + def to_ast + IntLiteralAst.new(input, interval) + end + end + + class IntLiteralAst < AstNode include AstNodeFuncs include Rvalue + def initialize(input, interval) + super(input, interval, []) + end + # @!macro type_check def type_check(symtab) - archdef = symtab.archdef - text_value_no_underscores = text_value.delete("_") - if text_value_no_underscores =~ /([0-9]+)?'(s?)([bodh]?)(.*)/ + if text_value.delete("_") =~ /([0-9]+)?'(s?)([bodh]?)(.*)/ + # verilog-style literal width = ::Regexp.last_match(1) - signed = ::Regexp.last_match(2) - radix_id = ::Regexp.last_match(3) - value = ::Regexp.last_match(4) + value_text = ::Regexp.last_match(4) - width = archdef.config_params["XLEN"] if width.nil? - radix_id = "d" if radix_id.empty? + if width.nil? + width = symtab.archdef.config_params["XLEN"] + memoize = false + end # ensure we actually have enough bits to represent the value - case radix_id - when "b" - @value = value.to_i(2) - type_error("#{value} cannot be represented in #{width} bits") if @value.bit_length > width.to_i - when "o" - @value = value.to_i(8) - type_error("#{value} cannot be represented in #{width} bits") if @value.bit_length > width.to_i - when "d" - @value = value.to_i(10) - type_error("#{value} cannot be represented in #{width} bits") if @value.bit_length > width.to_i - when "h" - @value = value.to_i(16) - type_error("#{value} cannot be represented in #{width} bits") if @value.bit_length > width.to_i - end + type_error("#{value_text} cannot be represented in #{width} bits") if unsigned_value.bit_length > width.to_i + end + end - qualifiers = signed == "s" ? [:signed, :const] : [:const] - @type = Type.new(:bits, width: width.to_i, qualifiers:) - elsif text_value_no_underscores =~ /0([bdx]?)([0-9a-fA-F]*)(s?)/ - radix_id = ::Regexp.last_match(1) - value = ::Regexp.last_match(2) - signed = ::Regexp.last_match(3) + # @!macro type + def type(symtab) + return @type unless @type.nil? - radix_id = "o" if radix_id.empty? + case text_value.delete("_") + when /([0-9]+)?'(s?)([bodh]?)(.*)/ + # verilog-style literal + width = ::Regexp.last_match(1) + signed = ::Regexp.last_match(2) - case radix_id - when "b" - @value = value.to_i(2) - when "o" - @value = value.to_i(8) - when "d" - @value = value.to_i(10) - when "x" - @value = value.to_i(16) + memoize = true + if width.nil? + width = symtab.archdef.config_params["XLEN"] + memoize = false end qualifiers = signed == "s" ? [:signed, :const] : [:const] - width = signed == "s" ? @value.bit_length + 1 : @value.bit_length - width = 1 if width.zero? # happens when the literal is '0' - @type = Type.new(:bits, width:, qualifiers:) - elsif text_value_no_underscores =~ /([0-9]*)(s?)/ - value = ::Regexp.last_match(1) - signed = ::Regexp.last_match(2) + t = Type.new(:bits, width: width.to_i, qualifiers:) + @type = t if memoize + t + when /0([bdx]?)([0-9a-fA-F]*)(s?)/ + # C++-style literal + signed = ::Regexp.last_match(3) - @value = value.to_i(10) + qualifiers = signed == "s" ? [:signed, :const] : [:const] + @type = Type.new(:bits, width: width(symtab), qualifiers:) + when /([0-9]*)(s?)/ + # basic decimal + signed = ::Regexp.last_match(2) qualifiers = signed == "s" ? [:signed, :const] : [:const] - width = signed == "s" ? @value.bit_length + 1 : @value.bit_length - width = 1 if width.zero? # happens when the literal is '0' - @type = Type.new(:bits, width:, qualifiers:) + @type = Type.new(:bits, width: width(symtab), qualifiers:) else internal_error "Unhandled int value" end - type_error(text_value) if @value.nil? end - # @!macro type - def type(symtab) - @type + def width(symtab) + return @width unless @width.nil? + + text_value_no_underscores = text_value.delete("_") + + case text_value_no_underscores + when /([0-9]+)?'(s?)([bodh]?)(.*)/ + # verilog-style literal + width = ::Regexp.last_match(1) + memoize = true + if width.nil? + width = archdef.config_params["XLEN"] + memoize = false + end + @width = width if memoize + width + when /0([bdx]?)([0-9a-fA-F]*)(s?)/ + signed = ::Regexp.last_match(3) + + @width = signed == "s" ? value(symtab).bit_length + 1 : value(symtab).bit_length + @width = 1 if @width.zero? # happens when the literal is '0' + + @width + when /([0-9]*)(s?)/ + signed = ::Regexp.last_match(3) + + @width = signed == "s" ? value(symtab).bit_length + 1 : value(symtab).bit_length + @width = 1 if @width.zero? # happens when the literal is '0' + + @width + else + internal_error "No match on int literal" + end end # @!macro value def value(symtab) - internal_error("Did not type check #{text_value}") if @value.nil? + return @value unless @value.nil? + + if text_value.delete("_") =~ /([0-9]+)?'(s?)([bodh]?)(.*)/ + # verilog-style literal + width = ::Regexp.last_match(1) + signed = ::Regexp.last_match(2) - @value + memoize = true + if width.nil? + width = symtab.archdef.config_params["XLEN"] + memoize = false + end + + v = + if !signed.empty? && ((unsigned_value >> (width.to_i - 1)) == 1) + -(2**width.to_i - unsigned_value) + else + unsigned_value + end + + @value = v if memoize + v + else + @value = unsigned_value + end + end + + + # @return [Integer] the unsigned value of this literal (i.e., treating it as unsigned even if the signed specifier is present) + def unsigned_value + return @unsigned_value unless @unsigned_value.nil? + + case text_value.delete("_") + when /([0-9]+)?'(s?)([bodh]?)(.*)/ + # verilog-style literal + radix_id = ::Regexp.last_match(3) + value = ::Regexp.last_match(4) + + radix_id = "d" if radix_id.empty? + + # ensure we actually have enough bits to represent the value + @unsigned_value = + case radix_id + when "b" + value.to_i(2) + when "o" + value.to_i(8) + when "d" + value.to_i(10) + when "h" + value.to_i(16) + end + when /0([bdx]?)([0-9a-fA-F]*)(s?)/ + # C++-style literal + radix_id = ::Regexp.last_match(1) + value = ::Regexp.last_match(2) + signed = ::Regexp.last_match(3) + + radix_id = "o" if radix_id.empty? + + @unsigned_value = + case radix_id + when "b" + value.to_i(2) + when "o" + value.to_i(8) + when "d" + value.to_i(10) + when "x" + value.to_i(16) + end + when /([0-9]*)(s?)/ + # basic decimal + value = ::Regexp.last_match(1) + signed = ::Regexp.last_match(2) + + @unsigned_value = value.to_i(10) + else + internal_error "Unhandled int value" + end end # @!macro to_idl def to_idl = text_value end + class FunctionCallExpressionSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + targs = t.empty? ? [] : [t.targs.first.to_ast] + t.targs.rest.elements.map { |e| e.arg.to_ast } + args = [] + args << function_arg_list.first.to_ast unless function_arg_list.first.empty? + args += function_arg_list.rest.elements.map { |e| e.expression.to_ast } + FunctionCallExpressionAst.new(input, interval, function_name.text_value, targs, args) + end + end + class FunctionCallExpressionAst < AstNode # a function call can be both Lvalue (when void or return is ignored) and Rvalue include Rvalue include Executable + def initialize(input, interval, function_name, targs, args) + raise ArgumentError, "targs shoudl be an array" unless targs.is_a?(Array) + raise ArgumentError, "args shoudl be an array" unless args.is_a?(Array) + + super(input, interval, targs + args) + + @name = function_name + @targs = targs + @args = args + end + # @return [Boolean] whether or not the function call has a template argument def template? - !t.empty? + !@targs.empty? end # @return [Array] Template argument nodes def template_arg_nodes - return [] unless template? - - [t.targs.first] + t.targs.rest.elements.map(&:arg) + @targs end def template_values(symtab) @@ -2570,25 +3102,23 @@ def template_values(symtab) # @return [Array] Function argument nodes def arg_nodes - nodes = [] - nodes << function_arg_list.first unless function_arg_list.first.empty? - nodes + function_arg_list.rest.elements.map(&:expression) + @args end # @!macro type_check def type_check(symtab) level = symtab.levels - func_def_type = symtab.get(name) - type_error "No symbol #{name}" if func_def_type.nil? + func_def_type = symtab.get(@name) + type_error "No symbol #{@name}" if func_def_type.nil? unless func_def_type.is_a?(FunctionType) - type_error "#{name} is not a function (it's a #{func_def_type.class.name})" + type_error "#{@name} is not a function (it's a #{func_def_type.class.name})" end - type_error "Missing template arguments in call to #{name}" if template? && func_def_type.template_names.empty? + type_error "Missing template arguments in call to #{@name}" if template? && func_def_type.template_names.empty? - type_error "Template arguments provided in call to non-template function #{name}" if !template? && !func_def_type.template_names.empty? + type_error "Template arguments provided in call to non-template function #{@name}" if !template? && !func_def_type.template_names.empty? if template? num_targs = template_arg_nodes.size @@ -2598,7 +3128,7 @@ def type_check(symtab) template_arg_nodes.each_with_index do |t, idx| t.type_check(symtab) - unless t.type(symtab).convertable_to?(func_def_type.template_types[idx]) + unless t.type(symtab).convertable_to?(func_def_type.template_types(symtab)[idx]) type_error "Template argument #{idx + 1} has wrong type" end end @@ -2612,7 +3142,7 @@ def type_check(symtab) if func_def_type.num_args != num_args type_error "Wrong number of arguments to '#{name}' function call. Expecting #{func_def_type.num_args}, got #{num_args}" end - arg_nodes.each_with_index do |a, idx| + arg_nodes.each do |a| a.type_check(symtab) end arg_nodes.each_with_index do |a, idx| @@ -2640,17 +3170,17 @@ def value(symtab) type_error "not a function" unless func_def_type.is_a?(FunctionType) if func_def_type.builtin? if name == "implemented?" - extname = arg_nodes[0].text_value - return symtab.archdef.ext?(extname) + extname_ref = arg_nodes[0] + type_error "First argument should be a ExtensionName" unless extname_ref.type(symtab).kind == :enum_ref && extname_ref.class_name == "ExtensionName" + + return symtab.archdef.ext?(arg_nodes[0].member_name) else value_error "value of builtin function cannot be known" end end template_values = [] - template_arg_nodes.each_with_index do |targ, idx| - # targ_name = func_def_type.template_names[idx] - # targ_type = func_def_type.template_types[idx] + template_arg_nodes.each do |targ| template_values << targ.value(symtab) end @@ -2659,7 +3189,16 @@ def value(symtab) alias execute value def name - function_name.text_value + @name + end + + # @!macro to_idl + def to_idl + if template? + "#{name}<#{template_arg_nodes.map(&:to_idl).join(',')}>(#{arg_nodes.map(&:to_idl).join(',')})" + else + "#{name}(#{arg_nodes.map(&:to_idl).join(',')})" + end end end @@ -2691,14 +3230,24 @@ class FieldNameAst < AstNode def type_check(_symtab, _archdef) # nothing to do end + + + # @!macro to_idl + def to_idl = text_value end - module FunctionStatementAst - include Executable - include AstNodeFuncs + # module FunctionStatementAst + # include Executable + # include AstNodeFuncs - def execute(symtab) - raise "WHere is this AST?" + # def execute(symtab) + # raise "WHere is this AST?" + # end + # end + + class InstructionOperationSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + FunctionBodyAst.new(input, interval, op_stmt_list.elements.map(&:choice).map(&:to_ast) ) end end @@ -2717,23 +3266,37 @@ def execute(symtab) e.choice.execute(symtab) end end + + def to_idl = op_stmt_list.elements.map { |e| e.choice.to_idl }.join("") + end + + class FunctionBodySyntaxNode < Treetop::Runtime::SyntaxNode + # @!macro to_ast + def to_ast + FunctionBodyAst.new(input, interval, func_stmt_list.elements.map(&:choice).map(&:to_ast)) + end end class FunctionBodyAst < AstNode include Executable include Returns + def initialize(input, interval, stmts) + super(input, interval, stmts) + @stmts = stmts + end + def statements - func_stmt_list.elements.map(&:choice) + @stmts end # @!macro type_check def type_check(symtab) - internal_error "Function bodies should be at global + 1 scope" unless symtab.levels == 2 + internal_error "Function bodies should be at global + 1 scope (at #{symtab.levels})" unless symtab.levels == 2 return_value_might_be_known = true - statements.each do |s| + @stmts.each do |s| s.type_check(symtab) next unless return_value_might_be_known @@ -2741,7 +3304,7 @@ def type_check(symtab) if s.is_a?(Returns) s.return_value(symtab) # if we reach here, the return value is known, so we don't have to go futher - return + break else s.execute(symtab) end @@ -2758,7 +3321,7 @@ def return_value(symtab) internal_error "Function bodies should be at global + 1 scope" unless symtab.levels == 2 # go through the statements, and return the first one that has a return value - statements.each do |s| + @stmts.each do |s| if s.is_a?(Returns) v = s.return_value(symtab) return v unless v.nil? @@ -2771,10 +3334,38 @@ def return_value(symtab) end alias execute return_value + # @!macro return_values + def return_values(symtab) + internal_error "Function bodies should be at global + 1 scope" unless symtab.levels == 2 + + values = [] + begin + # if there is a definate return value, then just return that + return [return_value(symtab)] + rescue ValueError + # go through the statements, and collect return values + # we can stop if we encounter a statement with a known return value + @stmts.each do |s| + if s.is_a?(Returns) + begin + v = s.return_value(symtab) + return values.push(v).uniq unless v.nil? + rescue ValueError + values += s.return_values(symtab) + end + else + s.execute(symtab) + end + end + end + + values.uniq + end + def to_idl result = "" # go through the statements, and return the first one that has a return value - statements.each do |s| + @stmts.each do |s| result << s.to_idl end result @@ -2796,7 +3387,7 @@ def num_args 1 + args.rest.elements.size end - # @return [Array] containing the argument types, in order + # @return [Array] containing the argument types, in order def arguments(symtab) if templated? template_names.each do |tname| @@ -2925,19 +3516,50 @@ def type_check(symtab) type_check_targs(symtab) + # recursion isn't supported (doesn't map well to hardware), so we can add the function after type checking the body + add_symbol(symtab) + end + + # @!macro add_symbol + def add_symbol(symtab) # now add the function in global scope def_type = FunctionType.new( - name, - self, - symtab - ) + name, + self, + symtab + ) - # recursion isn't supported (doesn't map well to hardware), so we can add the function after type checking the body symtab.add!(name, def_type) end - attr_reader :template_names - attr_reader :template_types + # @return [Array] Template arugment names, in order + def template_names + return [] unless templated? + + tnames = [targs.first.id.text_value] + targs.rest.elements.each do |a| + tnames << a.function_argument_definition.id.text_value + end + tnames + end + + # @param symtab [SymbolTable] The context for evaluation + # @return [Array] Template argument types, in order + def template_types(symtab) + return [] unless templated? + + ttype = targs.first.type_name.type(symtab) + ttype = Type.new(:enum_ref, enum_class: ttype) if ttype.kind == :enum + + ttypes = [ttype.clone] + targs.rest.elements.each do |a| + ttype = a.function_argument_definition.type_name.type(symtab) + ttype = Type.new(:enum_ref, enum_class: ttype) if ttype.kind == :enum + ttypes << ttype + end + ttypes + end + def type_check_targs(symtab) @template_names = [] @template_types = [] @@ -3039,42 +3661,66 @@ def builtin? end + class ForLoopSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + ForLoopAst.new( + input, interval, + single_declaration_with_initialization.to_ast, + condition.to_ast, + action.to_ast, + stmts.elements.map(&:s).map(&:to_ast) + ) + end + end + class ForLoopAst < AstNode include Executable include Returns # a return statement in a for loop can make it return a value + attr_reader :init, :condition, :update, :stmts + + def initialize(input, interval, init, condition, update, stmts) + super(input, interval, [init, condition] + stmts) + + @init = init + @condition = condition + @update = update + @stmts = stmts + end + # @!macro type_check def type_check(symtab) symtab.push - single_declaration_with_initialization.type_check(symtab) - condition.type_check(symtab) - action.type_check(symtab) + @init.type_check(symtab) + @condition.type_check(symtab) + @update.type_check(symtab) - stmts.elements.each do |s| - s.s.type_check(symtab) + @stmts.each do |s| + s.type_check(symtab) end symtab.pop end + # @!macro return_value def return_value(symtab) symtab.push begin - single_declaration_with_initialization.execute(symtab) + @init.execute(symtab) - while condition.value(symtab) - stmts.elements.each do |s| - if s.s.is_a?(Returns) - v = s.s.return_value(symtab) + while @condition.value(symtab) + @stmts.each do |s| + if s.is_a?(Returns) + v = s.return_value(symtab) unless v.nil? symtab.pop return v end else - s.s.execute(symtab) + s.execute(symtab) end end - action.execute(symtab) + @update.execute(symtab) end rescue ValueError => e symtab.pop @@ -3084,150 +3730,365 @@ def return_value(symtab) symtab.pop nil end + + # @!macro return_values + def return_values(symtab) + # if there is a known return value, then we are done + [return_value(symtab)] + rescue ValueError + # see if we can collect a list + values = [] + symtab.push + + begin + @init.execute(symtab) + + while @condition.value(symtab) + @stmts.each do |s| + if s.is_a?(Returns) + begin + v = s.return_value(symtab) + return values.push(v).uniq unless v.nil? + rescue ValueError + values += s.return_values(symtab) + end + else + s.execute(symtab) + end + end + @update.execute(symtab) + end + ensure + symtab.pop + end + + values.uniq + end + + # @!macro execute alias execute return_value + + # @!macro to_idl + def to_idl + idl = "for (#{@init.to_idl}; #{@condition.to_idl}; #{@update.to_idl}) {" + @stmts.each do |s| + idl << s.to_idl + end + idl << "}" + idl + end end - class IfAst < AstNode + class IfBodyAst < AstNode include Executable include Returns + attr_reader :stmts + + def initialize(body_stmts) + if body_stmts.empty? + super("", 0...0, []) + else + super(body_stmts[0].input, body_stmts.first.interval.first..body_stmts.last.interval.end, body_stmts) + end + @stmts = body_stmts + end + # @!macro type_check def type_check(symtab) - level = symtab.levels - if_cond.type_check(symtab) + symtab.push - type_error "'#{if_cond.text_value}' is not boolean" unless if_cond.type(symtab).convertable_to?(:boolean) + @stmts.each do |s| + s.type_check(symtab) + end - symtab.push + symtab.pop + end + # @!macro return_value + def return_value(symtab) + symtab.push begin - # only type check the body if it is reachable - if if_cond.value(symtab) == true - if_body.elements.each do |e| - e.e.type_check(symtab) + @stmts.each do |s| + if s.is_a?(Returns) + v = s.return_value(symtab) + unless v.nil? + return v + end + else + s.execute(symtab) end - return # don't bother with the rest - end - rescue ValueError - # we don't know if the body is reachable; type check it - if_body.elements.each do |e| - e.e.type_check(symtab) end ensure symtab.pop end - internal_error "not at same level #{level} #{symtab.levels}" unless level == symtab.levels - - unless elseifs.empty? - elseifs.elements.each do |eif| - eif.expression.type_check(symtab) - unless eif.expression.type(symtab).convertable_to?(:boolean) - type_error "'#{eif.expression.text_value}' is not boolean" - end + nil + end - symtab.push - begin - # only type check the body if it is reachable - if eif.expression.value(symtab) == true - eif.body.elements.each do |e| - e.e.type_check(symtab) - end - return # don't bother with the rest - end - rescue ValueError - # condition isn't compile-time-known; have to check the body - eif.body.elements.each do |e| - e.e.type_check(symtab) + # @!macro return_values + def return_values(symtab) + values = [] + symtab.push + begin + @stmts.each do |s| + if s.is_a?(Returns) + begin + v = s.return_value(symtab) + return values.push(v).uniq unless v.nil? + rescue ValueError + values += s.return_values(symtab) end - ensure - symtab.pop + else + s.execute(symtab) end end + ensure + symtab.pop end - return if final_else.empty? + values.uniq + end - internal_error "not at same level #{level} #{symtab.levels}" unless level == symtab.levels + # @!macro execute + def execute(symtab) + stmts.each do |s| + s.execute(symtab) + end + end - symtab.push - final_else.body.elements.each do |e| - e.e.type_check(symtab) + # @!macro to_idl + def to_idl + stmts.map(&:to_idl).join("") + end + + end + + class ElseIfAst < AstNode + include Returns + + attr_reader :cond, :body + + def initialize(cond, body_stmts) + @body = IfBodyAst.new(body_stmts) + super(cond.input, cond.interval.first..body_stmts.last.interval.end, [cond, @body]) + @cond = cond + end + + def type_check(symtab) + @cond.type_check(symtab) + unless @cond.type(symtab).convertable_to?(:boolean) + type_error "'#{@cond.text_value}' is not boolean" end - symtab.pop - internal_error "not at same level #{level} #{symtab.levels}" unless level == symtab.levels + begin + # only type check the body if it is reachable + if @cond.value(symtab) == true + @body.type_check(symtab) + return # don't bother with the rest + end + rescue ValueError + # condition isn't compile-time-known; have to check the body + @body.type_check(symtab) + end end - # @return [Boolean] true if the taken path is knowable at compile-time - # @raise ValueError if the take path is not known at compile time - def taken_body(symtab) - return if_body if if_cond.value(symtab) + # @!macro return_values + def return_values(symtab) + if @cond.value(symtab) + @body.return_values(symtab) + else + [] + end + rescue ValueError + # might be taken, so add the possible return values + @body.return_values(symtab) + end + # @!macro to_idl + def to_idl + " else if (#{@cond.to_idl}) { #{@body.to_idl} }" + end + end + + class IfSyntaxNode < Treetop::Runtime::SyntaxNode + def to_ast + if_body_stmts = [] + if_body.elements.each do |e| + if_body_stmts << e.e.to_ast + end + eifs = [] unless elseifs.empty? elseifs.elements.each do |eif| - return eif.body if eif.expression.value(symtab) + stmts = [] + eif.body.elements.each do |e| + stmts << e.e.to_ast + end + eifs << ElseIfAst.new(eif.expression.to_ast, stmts) end end - - final_else.empty? ? nil : final_else.body + final_else_stmts = [] + unless final_else.empty? + final_else.body.elements.each do |e| + final_else_stmts << e.e.to_ast + end + end + if_body_ast = IfBodyAst.new(if_body_stmts) + final_else_ast = IfBodyAst.new(final_else_stmts) + ast = IfAst.new(if_cond.to_ast, if_body_ast, eifs, final_else_ast) + ast.parent = parent + if_body_ast.parent = ast + eifs.each { |eif| eif.parent = ast } + final_else_ast.parent = ast + ast end + end - def return_values(symtab) - begin - # the if condition is known - if if_cond.value(symtab) + class IfAst < AstNode + include Executable + include Returns + + attr_reader :if_cond, :if_body, :elseifs, :final_else_body + + def initialize(if_cond, if_body, elseifs, final_else_body) + children_nodes = [if_cond, if_body] + children_nodes += elseifs + children_nodes << final_else_body + interval_end = + if !final_else_body.stmts.empty? + final_else_body.stmts.last.interval.end + elsif !elseifs.empty? + elseifs.last.body.stmts.last.interval.end else + if_body.stmts.last.interval.end + end + + super(if_cond.input, if_cond.interval.first..interval_end, children_nodes) + + @if_cond = if_cond + @if_body = if_body + @elseifs = elseifs + @final_else_body = final_else_body + end + + # @!macro type_check + def type_check(symtab) + level = symtab.levels + if_cond.type_check(symtab) + + type_error "'#{if_cond.text_value}' is not boolean" unless if_cond.type(symtab).convertable_to?(:boolean) + + begin + # only type check the body if it is reachable + if @if_cond.value(symtab) == true + @if_body.type_check(symtab) + return # don't bother with the rest end rescue ValueError + # we don't know if the body is reachable; type check it + @if_body.type_check(symtab) + end + + internal_error "not at same level #{level} #{symtab.levels}" unless level == symtab.levels + + unless @elseifs.empty? + @elseifs.each do |eif| + eif.type_check(symtab) + end end + + internal_error "not at same level #{level} #{symtab.levels}" unless level == symtab.levels + + @final_else_body.type_check(symtab) + + internal_error "not at same level #{level} #{symtab.levels}" unless level == symtab.levels end + # @return [Boolean] true if the taken path is knowable at compile-time + # @raise ValueError if the take path is not known at compile time + def taken_body(symtab) + return @if_body if @if_cond.value(symtab) + + unless @elseifs.empty? + @elseifs.each do |eif| + return eif.body if eif.cond.value(symtab) + end + end + + @final_else_body.stmts.empty? ? nil : @final_else_body + end + + # @!macro return_value def return_value(symtab) body = taken_body(symtab) return nil if body.nil? - symtab.push - begin - body.elements.each do |e| - if e.e.is_a?(Returns) - v = e.e.return_value(symtab) - unless v.nil? - return v + body.return_value(symtab) + end + alias execute return_value + + # return values starting at the first else if + def return_values_after_if(symtab) + values = [] + + unless @elsifs.empty? + @elsifs.each do |eif| + values += eif.return_values(symtab) + begin + elseif_cond_value = eif.value(symtab) + if elseif_cond_value + # this else if is defintately taken, so we are done + return (values + eif.return_values(symtab)).uniq + else + next # we know the else if isn't taken, so we can just go to the next end - else - e.e.execute(symtab) + rescue ValueError + # else if path not known; body return paths are possible + values += eif.return_values(symtab) end end - ensure - symtab.pop end - nil + # now add the returns from the final else + (values + @final_else_body.return_values(symtab)).uniq end + private :return_values_after_if - def to_idl - result = "if (#{if_cond.to_idl}) { " - if_body.elements.each do |e| - result << e.e.to_idl + # Returns a list of all possible return values, if known. Otherwise, raises a ValueError + # + # @param symtab [SymbolTable] Context for the evaluation + # @return [Array] List of all possible return values + # @raise ValueError if it is not possible to determine all return values at compile time + def return_values(symtab) + if_cond_value = @if_cond.value(symtab) + if if_cond_value + # if is taken, so the only possible return values are those in the if body + @if_body.return_values(symtab) + else + # if cond not taken; check else ifs and possibly final else + return_values_after_if(symtab) end + rescue ValueError + # if condition not known; both paths are possible + (@if_body.return_values(symtab) + return_values_after_if(symtab)).uniq + end + + # @!macro to_idl + def to_idl + result = "if (#{@if_cond.to_idl}) { " + result << @if_body.to_idl result << "} " - elseifs.elements.each do |eif| - result << " else if (#{eif.expression.to_idl}) { " - eif.body.elements.each do |e| - result << e.e.to_idl - end - result << "} " + @elseifs.each do |eif| + result << eif.to_idl end - unless final_else.empty? + unless @final_else_body.stmts.empty? result << " else { " - final_else.body.elements.each do |e| - result << e.e.to_idl - end + result << @final_else_body.to_idl result << "} " end + result end end @@ -3236,11 +4097,7 @@ class CsrFieldReadExpressionAst < AstNode # @!macro type_check def type_check(symtab) - archdef = symtab.archdef - - - - if idx.is_a?(IntAst) + if idx.is_a?(IntLiteralAst) type_error "No CSR at address #{idx.text_value}" if csr_def(symtab).nil? else # idx is a csr name @@ -3253,7 +4110,7 @@ def type_check(symtab) def csr_def(symtab) archdef = symtab.archdef - if idx.is_a?(IntAst) + if idx.is_a?(IntLiteralAst) archdef.implemented_csrs.find { |c| c.address == idx.value(symtab) } else archdef.implemented_csrs.find { |c| c.name == idx.text_value } @@ -3274,7 +4131,7 @@ def field_name(symtab) # @!macro to_idl def to_idl - if idx.is_a?(IntAst) + if idx.is_a?(IntLiteralAst) "CSR[#{idx.to_idl}].#{csr_field_name.text_value}" else "CSR[#{idx.text_value}].#{csr_field_name.text_value}" @@ -3373,6 +4230,7 @@ def csr_name(symtab) csr_def(symtab).name end + # @!macro value def value(symtab) cd = csr_def(symtab) value_error "CSR number not knowable" if cd.nil? @@ -3381,6 +4239,9 @@ def value(symtab) csr_def(symtab).fields.reduce(0) { |val, f| val | (f.value << f.location.begin) } end + + # @!macro to_idl + def to_idl = "CSR[#{idx.text_value}]" end class CsrSoftwareWriteAst < AstNode @@ -3405,10 +4266,16 @@ def csr_name(symtab) csr.csr_name(symtab) end + # @!macro value def value(_symtab) value_error "CSR writes are global" end + # @!macro execute + def execute(_symtab) = value_error "CSR writes are global" + + # @!macro to_idl + def to_idl = "CSR[#{csr.to_idl}].sw_write(#{expression.to_idl})" end class CsrSoftwareReadAst < AstNode @@ -3442,19 +4309,23 @@ def csr_def(symtab) # @todo check the sw_read function body def value(symtab) - value_error "CSR not knowable" unless csr_known? + value_error "CSR not knowable" unless csr_known?(symtab) cd = csr_def(symtab) cd.fields.each { |f| value_error "#{csr_name}.#{f.name} not RO" unless f.type == "RO" } value_error "TODO: CSRs with sw_read function" end + + # @!macro to_idl + def to_idl = "CSR[#{csr.to_idl}].sw_read()" end class CsrWriteAst < AstNode include Executable + # @!macro type_check def type_check(symtab) - if idx.is_a?(IntAst) + if idx.is_a?(IntLiteralAst) # make sure this value is a defined CSR index = symtab.archdef.csrs.index { |csr| csr.address == idx.value(symtab) } type_error "No csr number '#{idx.value(symtab)}' was found" if index.nil? @@ -3468,7 +4339,7 @@ def type_check(symtab) def csr_def(symtab) index = - if idx.is_a?(IntAst) + if idx.is_a?(IntLiteralAst) # make sure this value is a defined CSR symtab.archdef.csrs.index { |csr| csr.address == idx.text_value.to_i } else @@ -3478,6 +4349,7 @@ def csr_def(symtab) symtab.archdef.csrs[index] end + # @!macro type def type(symtab) CsrType.new(csr_def(symtab)) end @@ -3486,8 +4358,12 @@ def name(symtab) csr_def(symtab).name end + # @!macro execute def execute(symtab) value_error "CSR write" end + + # @!macro to_idl + def to_idl = "CSR[#{idx.text_value}]" end end diff --git a/lib/idl/idl.treetop b/lib/idl/idl.treetop index 4fcbf87ae..2c495fff8 100644 --- a/lib/idl/idl.treetop +++ b/lib/idl/idl.treetop @@ -32,7 +32,7 @@ grammar Idl end rule enum_ref - enum_class:user_type_name space* '::' space* member:user_type_name + enum_class:user_type_name space* '::' space* member:user_type_name end rule bitfield_definition @@ -47,31 +47,31 @@ grammar Idl rule int # verilog style: explicit bit width - ([0-9]+)? "'" 'b' [0-1] [0-1_]* / - ([0-9]+)? "'" 'o' [0-7] [0-7_]* / - ([0-9]+)? "'" 'd'? [0-9] [0-9]* / - ([0-9]+)? "'" 'h' [0-9a-fA-F] [0-9a-fA-F]* / + ([0-9]+)? "'" 'b' [0-1] [0-1_]* / + ([0-9]+)? "'" 'o' [0-7] [0-7_]* / + ([0-9]+)? "'" 'd'? [0-9] [0-9_]* / + ([0-9]+)? "'" 'h' [0-9a-fA-F] [0-9a-fA-F_]* / # verilog style: explicit bit width, signed - ([0-9]+)? "'" 'sb' [0-1] [0-1_]* / - ([0-9]+)? "'" 'so' [0-7] [0-7_]* / - ([0-9]+)? "'" 'sd' [0-9] [0-9]* / - ([0-9]+)? "'" 'sh' [0-9a-fA-F] [0-9a-fA-F]* / + ([0-9]+)? "'" 'sb' [0-1] [0-1_]* / + ([0-9]+)? "'" 'so' [0-7] [0-7_]* / + ([0-9]+)? "'" 's' 'd'? [0-9] [0-9_]* / + ([0-9]+)? "'" 'sh' [0-9a-fA-F] [0-9a-fA-F_]* / # c++ style: signed - '0b' [0-1] [0-1_]* 's' / - '0' [0-7] [0-7_]* 's' / - [1-9] [0-9]* 's' / - '0x' [0-9a-fA-F] [0-9a-fA-F]* 's' / + '0b' [0-1] [0-1_]* 's' / + '0' [0-7] [0-7_]* 's' / + [1-9] [0-9]* 's' / + '0x' [0-9a-fA-F] [0-9a-fA-F]* 's' / # c++ style: unsigned - '0b' [0-1] [0-1_]* / - '0' [0-7] [0-7_]* / - [1-9] [0-9]* / - '0x' [0-9a-fA-F] [0-9a-fA-F]* / + '0b' [0-1] [0-1_]* / + '0' [0-7] [0-7_]* / + [1-9] [0-9]* / + '0x' [0-9a-fA-F] [0-9a-fA-F]* / # special case: just a single 0 - '0' 's'? + '0' 's'? end rule bits @@ -140,114 +140,114 @@ grammar Idl end rule p0_binary_expression - l:unary_expression r:(space* op:p0_binary_operator space* r:p0_binary_expression)+ + l:unary_expression r:(space* op:p0_binary_operator space* r:unary_expression)+ / unary_expression end rule p1_binary_expression - l:p0_binary_expression r:(space* op:p1_binary_operator space* r:p1_binary_expression)+ + l:p0_binary_expression r:(space* op:p1_binary_operator space* r:p0_binary_expression)+ / p0_binary_expression end rule p2_binary_expression - l:p1_binary_expression r:(space* op:p2_binary_operator space* r:p2_binary_expression)+ + l:p1_binary_expression r:(space* op:p2_binary_operator space* r:p1_binary_expression)+ / p1_binary_expression end rule p3_binary_expression - l:p2_binary_expression r:(space* op:p3_binary_operator space* r:p3_binary_expression)+ + l:p2_binary_expression r:(space* op:p3_binary_operator space* r:p2_binary_expression)+ / p2_binary_expression end rule template_safe_p3_binary_expression - l:p2_binary_expression r:(space* op:p3_template_binary_operator space* r:p3_binary_expression)+ + l:p2_binary_expression r:(space* op:p3_template_binary_operator space* r:p2_binary_expression)+ / p2_binary_expression end rule p4_binary_expression - l:p3_binary_expression r:(space* op:p4_binary_operator space* r:p4_binary_expression)+ + l:p3_binary_expression r:(space* op:p4_binary_operator space* r:p3_binary_expression)+ / p3_binary_expression end rule template_safe_p4_binary_expression - l:template_safe_p3_binary_expression r:(space* op:p4_binary_operator space* r:p4_binary_expression)+ + l:template_safe_p3_binary_expression r:(space* op:p4_binary_operator space* r:p3_binary_expression)+ / template_safe_p3_binary_expression end rule p5_binary_expression - l:p4_binary_expression r:(space* op:p5_binary_operator space* r:p5_binary_expression)+ + l:p4_binary_expression r:(space* op:p5_binary_operator space* r:p4_binary_expression)+ / p4_binary_expression end rule template_safe_p5_binary_expression - l:template_safe_p4_binary_expression r:(space* op:p5_binary_operator space* r:p5_binary_expression)+ + l:template_safe_p4_binary_expression r:(space* op:p5_binary_operator space* r:p4_binary_expression)+ / template_safe_p4_binary_expression end rule p6_binary_expression - l:p5_binary_expression r:(space* op:p6_binary_operator space* r:p6_binary_expression)+ + l:p5_binary_expression r:(space* op:p6_binary_operator space* r:p5_binary_expression)+ / p5_binary_expression end rule template_safe_p6_binary_expression - l:template_safe_p5_binary_expression r:(space* op:p6_binary_operator space* r:p6_binary_expression)+ + l:template_safe_p5_binary_expression r:(space* op:p6_binary_operator space* r:p5_binary_expression)+ / template_safe_p5_binary_expression end rule p7_binary_expression - l:p6_binary_expression r:(space* op:p7_binary_operator space* r:p7_binary_expression)+ + l:p6_binary_expression r:(space* op:p7_binary_operator space* r:p6_binary_expression)+ / p6_binary_expression end rule template_safe_p7_binary_expression - l:template_safe_p6_binary_expression r:(space* op:p7_binary_operator space* r:p7_binary_expression)+ + l:template_safe_p6_binary_expression r:(space* op:p7_binary_operator space* r:p6_binary_expression)+ / template_safe_p6_binary_expression end rule p8_binary_expression - l:p7_binary_expression r:(space* op:p8_binary_operator space* r:p8_binary_expression)+ + l:p7_binary_expression r:(space* op:p8_binary_operator space* r:p7_binary_expression)+ / p7_binary_expression end rule template_safe_p8_binary_expression - l:template_safe_p7_binary_expression r:(space* op:p8_binary_operator space* r:p8_binary_expression)+ + l:template_safe_p7_binary_expression r:(space* op:p8_binary_operator space* r:p7_binary_expression)+ / template_safe_p7_binary_expression end rule p9_binary_expression - l:p8_binary_expression r:(space* op:p9_binary_operator space* r:p9_binary_expression)+ + l:p8_binary_expression r:(space* op:p9_binary_operator space* r:p8_binary_expression)+ / p8_binary_expression end rule template_safe_p9_binary_expression - l:template_safe_p8_binary_expression r:(space* op:p9_binary_operator space* r:p9_binary_expression)+ + l:template_safe_p8_binary_expression r:(space* op:p9_binary_operator space* r:p8_binary_expression)+ / template_safe_p8_binary_expression end rule paren_expression - '(' space* e:expression space* ')' + '(' space* e:expression space* ')' end rule replication_expression # verilog-style replication - '{' space* n:expression space* '{' space* v:expression space* '}' space* '}' + '{' space* n:expression space* '{' space* v:expression space* '}' space* '}' end rule concatenation_expression @@ -288,7 +288,7 @@ grammar Idl end rule ary_access - a:ary_eligible_expression space* brackets:('[' space* msb:(expression space* ':' space*)? lsb:expression space* ']' space*)+ + a:ary_eligible_expression space* brackets:('[' space* msb:(expression space* ':' space*)? lsb:expression space* ']' space*)+ end rule post_dec @@ -304,7 +304,7 @@ grammar Idl / ary_access / - '$signed' space* '(' space* expression space* ')' + '$signed' space* '(' space* expression space* ')' / '$bits' space* '(' space* expression space* ')' / @@ -334,7 +334,7 @@ grammar Idl end rule ternary_expression - p9_binary_expression space* '?' space* t:expression space* ':' space* f:expression + p9_binary_expression space* '?' space* t:expression space* ':' space* f:expression end rule template_safe_ternary_expression @@ -367,7 +367,7 @@ grammar Idl / csr:csr_register_access_expression space* '.' space* 'sw_read' space* '(' space* ')' / - function_name t:(space* '<' space* targs:function_call_template_arguments space* '>')? space* '(' space* function_arg_list space* ')' + function_name t:(space* '<' space* targs:function_call_template_arguments space* '>')? space* '(' space* function_arg_list space* ')' end rule function_name @@ -425,21 +425,17 @@ grammar Idl type_name space+ id end - rule exception_name - 'AddressMisalignedException' - end - rule rval - (var_read / int) + (id / int / builtin_read_only_var / builtin_read_write_var) end rule assignment '(' first:(var_write / dontcare_lvalue) space* rest:(',' space* var:(var_write / dontcare_lvalue) space*)+ ')' space* '=' space* function_call / single_declaration_with_initialization / - var:var_write space* '=' space* rval:expression / + var:var_write space* '=' space* rval:expression / var:var_write '.' field_name space* '=' space* rval:expression / var:var_write space* '[' space* msb:expression space* ':' space* lsb:expression space* ']' space* '=' space* rval:expression / - var:var_write space* '[' space* idx:expression space* ']' space* '=' space* rval:expression + var:var_write space* '[' space* idx:expression space* ']' space* '=' space* rval:expression end rule ary_size_decl @@ -447,7 +443,7 @@ grammar Idl end rule single_declaration_with_initialization - q:type_qualifier? space* type_name space+ var_write space* ary_size:ary_size_decl? space* '=' space* rval:expression + q:type_qualifier? space* type_name space+ var_write space* ary_size:ary_size_decl? space* '=' space* rval:expression end rule declaration @@ -461,9 +457,9 @@ grammar Idl end rule statement - a:(function_call / assignment) space* 'if' space* expression space* ';' + a:(function_call / assignment) space* 'if' space* expression space* ';' / - a:(function_call / assignment / declaration) space* ';' + a:(function_call / assignment / declaration) space* ';' end rule dontcare_lvalue @@ -471,7 +467,7 @@ grammar Idl end rule dontcare_return - '-' + '-' end rule return_statement @@ -493,7 +489,7 @@ grammar Idl space* 'else' space* '{' space* body:(e:(statement / return_statement / function_if_block / for_loop) space*)+ '}' - )? + )? end rule execute_if_block @@ -509,13 +505,13 @@ grammar Idl space* 'else' space* '{' space* body:(e:(statement / execute_if_block / for_loop) space*)+ '}' - )? + )? end rule for_loop 'for' space* '(' space* single_declaration_with_initialization space* ';' space* condition:expression space* ';' space* action:(assignment / post_inc / post_dec) space* ')' space* '{' space* stmts:(s:(statement / return_statement / function_if_block / for_loop) space*)+ - '}' + '}' end rule type_qualifier @@ -524,17 +520,17 @@ grammar Idl rule builtin_type_name # alias for Bits - 'XReg' ![A-Za-z0-9] / + 'XReg' ![A-Za-z0-9] / - 'Bits' space* '<' space* i:template_safe_expression space* '>' ![A-Za-z0-9] / + 'Bits' space* '<' space* i:template_safe_expression space* '>' ![A-Za-z0-9] / - 'Boolean' ![A-Za-z0-9] / + 'Boolean' ![A-Za-z0-9] / # 64-bit unsigned integer - 'U64' ![A-Za-z0-9] / + 'U64' ![A-Za-z0-9] / # 32-bit unsigned integer - 'U32' ![A-Za-z0-9] + 'U32' ![A-Za-z0-9] end rule keyword @@ -577,17 +573,25 @@ grammar Idl end rule function_body - space* func_stmt_list:(choice:function_statement space*)* + space* func_stmt_list:(choice:function_statement space*)* end rule instruction_operation - space* op_stmt_list:(choice:(statement/execute_if_block/for_loop) space*)* + space* op_stmt_list:(choice:(statement/execute_if_block/for_loop) space*)* end rule id # we purposely omit _ from the starting character so that tools can safely use such names # without worrying about name collisions - !reserved [A-Za-z] [A-Za-z_0-9]* + !reserved [A-Za-z] [A-Za-z_0-9]* + end + + rule builtin_read_only_var + "$encoding" + end + + rule builtin_read_write_var + "$pc" end rule csr_name @@ -598,10 +602,6 @@ grammar Idl [a-zA-Z] ([a-zA-Z0-9])* end - rule var_read - id - end - rule var_write 'CSR' space* '[' space* idx:(csr_name / int) space* ']' / diff --git a/lib/idl/passes/gen_adoc.rb b/lib/idl/passes/gen_adoc.rb index ef5355c6a..3145a4b8e 100644 --- a/lib/idl/passes/gen_adoc.rb +++ b/lib/idl/passes/gen_adoc.rb @@ -1,51 +1,237 @@ require_relative "../ast" -class Treetop::Runtime::SyntaxNode +class Idl::AstNode def gen_adoc(indent = 0, indent_spaces: 2) - if terminal? - text_value - else - adoc = '' - next_pos = interval.begin - elements.each do |e| - if e.interval.size > 0 && e.interval.begin != next_pos - adoc << input[next_pos..(e.interval.begin - 1)] - end - adoc << e.gen_adoc(indent+2, indent_spaces: 2) - next_pos = e.interval.exclude_end? ? e.interval.end : (e.interval.end + 1) - end - if next_pos != (interval.exclude_end? ? interval.end : (interval.end + 1)) - end_pos = interval.exclude_end? ? interval.end - 1 : interval.end - adoc << input[next_pos..end_pos] - end - if adoc != text_value && !text_value.index('xref').nil? - raise - end - adoc + adoc = [] + puts self.class.name if elements.nil? + elements.each do |e| + next unless e.is_a?(Idl::AstNode) + + adoc << e.gen_adoc(indent, indent_spaces:) end + adoc.map{ |a| "#{' '*indent}#{a}" }.join('') end + # def gen_adoc(indent = 0, indent_spaces: 2) + # if terminal? + # text_value + # else + # adoc = '' + # next_pos = interval.begin + # elements.each do |e| + # if e.interval.size > 0 && e.interval.begin != next_pos + # adoc << input[next_pos..(e.interval.begin - 1)] + # end + # adoc << e.gen_adoc(indent+2, indent_spaces: 2) + # next_pos = e.interval.exclude_end? ? e.interval.end : (e.interval.end + 1) + # end + # if next_pos != (interval.exclude_end? ? interval.end : (interval.end + 1)) + # end_pos = interval.exclude_end? ? interval.end - 1 : interval.end + # adoc << input[next_pos..end_pos] + # end + # if adoc != text_value && !text_value.index('xref').nil? + # raise + # end + # adoc + # end + # end end module Idl + class EnumRefAst + def gen_adoc(indent, indent_spaces: 2) + "#{class_name}::#{member_name}" + end + end + class ParenExpressionAst + def gen_adoc(indent = 0, indent_spaces: 2) + "(#{expression.gen_adoc(indent, indent_spaces:)})" + end + end + class IntLiteralAst + def gen_adoc(indent = 0, indent_spaces: 2) + raise "?" if text_value.empty? + text_value + end + end + class IdAst + def gen_adoc(indent = 0, indent_spaces: 2) + text_value + end + end + class SignCastAst + def gen_adoc(indent = 0, indent_spaces: 2) + "$signed(#{expression.gen_adoc(0, indent_spaces:)})" + end + end class AryRangeAccessAst def gen_adoc(indent = 0, indent_spaces: 2) - adoc = '' - unless var.is_a?(AryRangeAccessAst) || var.is_a?(AryElementAccessAst) - adoc << input[interval.begin...var.interval.begin] - adoc << var.gen_adoc(indent + indent_spaces, indent_spaces: indent_spaces) + "#{var.gen_adoc(indent, indent_spaces:)}[#{msb.gen_adoc(0, indent_spaces:)}:#{lsb.gen_adoc(0, indent_spaces:)}]" + end + end + + class VariableDeclarationAst + def gen_adoc(indent = 0, indent_spaces: 2) + "#{' ' * indent}#{type_name.gen_adoc(0, indent_spaces:)} #{var_write.gen_adoc(0, indent_spaces:)};" + end + end + + class TernaryOperatorExpressionAst + def gen_adoc(indent = 0, indent_spaces: 2) + "#{' ' * indent}#{condition.gen_adoc(0, indent_spaces:)} ? #{true_expression.gen_adoc(0, indent_spaces:)} : #{false_expression.gen_adoc(0, indent_spaces:)}" + end + end + + class BuiltinTypeNameAst + def gen_adoc(indent = 0, indent_spaces: 2) + if @type_name == "Bits" + "Bits<#{@bits_expression.gen_adoc(0, indent_spaces:)}>" + else + to_idl end - adoc << input[var.interval.end...msb.interval.begin] - adoc << msb.gen_adoc(indent + indent_spaces, indent_spaces: indent_spaces) - adoc << input[msb.interval.end...lsb.interval.begin] - adoc << lsb.gen_adoc(indent + indent_spaces, indent_spaces: indent_spaces) - adoc << input[lsb.interval.end...interval.end] - adoc + end + end + + class ForLoopAst + def gen_adoc(indent = 0, indent_spaces: 2) + lines = ["#{' '*indent}for (#{init.gen_adoc(0, indent_spaces:)}; #{condition.gen_adoc(0, indent_spaces:)}; #{update.gen_adoc(0, indent_spaces:)}) {"] + stmts.each do |s| + lines << s.gen_adoc(indent + indent_spaces, indent_spaces:) + end + lines << "#{' '*indent}}" + lines.join("\n") + end + end + + class BuiltinVariableAst + def gen_adoc(indent = 0, indent_spaces: 2) + name + end + end + + class VariableDeclarationWithInitializationAst + def gen_adoc(indent = 0, indent_spaces: 2) + if @ary_size.nil? + "#{' ' * indent}#{type_name.gen_adoc(0, indent_spaces:)} #{lhs.gen_adoc(0, indent_spaces:)} = #{rhs.gen_adoc(0, indent_spaces:)};" + else + "#{' ' * indent}#{type_name.gen_adoc(0, indent_spaces:)} #{lhs.gen_adoc(0, indent_spaces:)}[#{@ary_size.gen_adoc(0, indent_spaces:)}] = #{rhs.gen_adoc(0, indent_spaces:)};" + end + end + end + + class AryElementAccessAst + def gen_adoc(indent = 0, indent_spaces: 2) + "#{var.gen_adoc(indent, indent_spaces:)}[#{index.gen_adoc(0, indent_spaces:)}]" + end + end + + class BinaryExpressionAst + def gen_adoc(indent = 0, indent_spaces: 2) + "#{lhs.gen_adoc(0, indent_spaces:)} #{op} #{rhs.gen_adoc(0, indent_spaces:)}" + end + end + + class VariableAssignmentAst + def gen_adoc(indent = 0, indent_spaces: 2) + "#{lhs.gen_adoc(0, indent_spaces:)} = #{rhs.gen_adoc(0, indent_spaces:)}" + end + end + + class AryElementAssignmentAst + def gen_adoc(indent = 0, indent_spaces: 2) + "#{lhs.gen_adoc(0, indent_spaces:)}[#{@idx.gen_adoc(0, indent_spaces:)}] = #{@rhs.gen_adoc(0, indent_spaces:)}" + end + end + + class StatementAst + def gen_adoc(indent = 0, indent_spaces: 2) + "#{' ' * indent}#{action.gen_adoc(0, indent_spaces:)};" + end + end + + class UnaryOperatorExpressionAst + def gen_adoc(indent = 0, indent_spaces: 2) + "#{op}#{exp.gen_adoc(0, indent_spaces:)}" + end + end + + class ReturnStatementAst + def gen_adoc(indent = 0, indent_spaces: 2) + values = [first.gen_adoc(0, indent_spaces:)] + rest.elements.each { |e| e.e.gen_adoc(0, indent_spaces: )} + "#{' ' * indent}return #{values.join(', ')};" + end + end + + class ReplicationExpressionAst + def gen_adoc(indent = 0, indent_spaces: 2) + puts v.class.name + "{#{n.gen_adoc(indent, indent_spaces:)}{#{v.gen_adoc(indent, indent_spaces:)}}}" + end + end + + class ConditionalStatementAst + def gen_adoc(indent = 0, indent_spaces: 2) + "#{action.gen_adoc(indent, indent_spaces:)} if (#{condition.gen_adoc(0, indent_spaces:)});" end end class FunctionCallExpressionAst def gen_adoc(indent = 0, indent_spaces: 2) - "xref:funcs:funcs.adoc##{name}-func-def[#{name}]" << t.gen_adoc << "(#{function_arg_list.gen_adoc})" + after_name = [] + after_name << "<#{template_arg_nodes.map { |t| t.gen_adoc(0, indent_spaces:)}.join(', ')}>" unless template_arg_nodes.empty? + after_name << "(#{arg_nodes.map { |a| a.gen_adoc(0, indent_spaces: ) }.join(', ')})" + "%%LINK%func;#{name};#{name}%%#{after_name.join ''}" + end + end + + class FunctionBodyAst + def gen_adoc(indent = 0, indent_spaces: 2) + statements.map{ |s| "#{' ' * indent}#{s.gen_adoc(indent, indent_spaces:)}" }.join("\n") + end + end + + class CsrFieldReadExpressionAst + def gen_adoc(indent = 0, indent_spaces: 2) + csr_text = "CSR[#{idx.text_value}].#{csr_field_name.text_value}" + if idx.text_value =~ /[0-9]+/ + csr_text + else + "%%LINK%csr_field;#{idx.text_value}.#{csr_field_name.text_value};#{csr_text}%%" + end + end + end + + class CsrReadExpressionAst + def gen_adoc(indent = 0, indent_spaces: 2) + csr_text = "CSR[#{idx.text_value}]" + if idx.text_value =~ /[0-9]+/ + csr_text + else + "%%LINK%csr;#{idx.text_value};#{csr_text}%%" + end + end + end + + class IfAst + def gen_adoc(indent = 0, indent_spaces: 2) + lines = ["if (#{if_cond.gen_adoc(0, indent_spaces:)}) {"] + if_body.stmts.each do |s| + lines << s.gen_adoc(indent + indent_spaces, indent_spaces:) + end + elseifs.each do |eif| + lines << "} else if (#{eif.cond.gen_adoc(0, indent_spaces:)}) {" + eif.body.stmts.each do |s| + lines << s.gen_adoc(indent + indent_spaces, indent_spaces:) + end + end + unless final_else_body.stmts.empty? + lines << "} else {" + final_else_body.stmts.each do |s| + lines << s.gen_adoc(indent + indent_spaces, indent_spaces:) + end + end + lines << "}" + + lines.map { |l| "#{' ' * indent}#{l}"}.join("\n") end end end diff --git a/lib/idl/passes/prune.rb b/lib/idl/passes/prune.rb new file mode 100644 index 000000000..5b0f9fb46 --- /dev/null +++ b/lib/idl/passes/prune.rb @@ -0,0 +1,223 @@ +# frozen_string_literal: true + +require_relative "../ast" + +module Treetop + module Runtime + class SyntaxNode + # @!macro [new] prune + # @param symtab [Idl::SymbolTable] Context of the compilation + # @return [AstNode] A new abstract syntax tree with all dead/unreachable code removed + def prune(symtab) + new_elements = elements.nil? ? [] : elements.map { |e| e.prune(symtab) } + new_node = clone # self.class.new(input, interval, new_elements) + new_node.elements.clear + new_node.elements.concat(new_elements) + + # extension_modules.each do |m| + # new_node.extend m + # end + + if is_a?(Idl::AstNode) + begin + if new_node.is_a?(Idl::Declaration) + new_node.add_symbol(symtab) + end + if new_node.is_a?(Idl::Executable) + new_node.execute(symtab) # to update values + end + rescue Idl::AstNode::ValueError + # new_node.type_check(symtab) + end + end + + new_node + end + end + end +end + +module Idl + # set up a default + class AstNode + def prune(_symtab) + clone + end + end + class FunctionCallExpressionAst + def prune(symtab) + FunctionCallExpressionAst.new(input, interval, name, @targs.map { |t| t.prune(symtab) }, @args.map { |a| a.prune(symtab)} ) + end + end + class FunctionBodyAst + def prune(symtab) + symtab.push + raise "?" if symtab.get("current_mode").nil? + func_def = find_ancestor(FunctionDefAst) + unless func_def.nil? + return FunctionBodyAst.new(input, interval, statements) if func_def.templated? # can't prune a template because we don't have all types + + # push template values + func_def.template_names.each_with_index do |tname, idx| + symtab.add(tname, Var.new(tname, func_def.template_types(symtab)[idx])) + end + + # push args + func_def.arguments(symtab).each do |arg_type, arg_name| + symtab.add(arg_name, Var.new(arg_name, arg_type)) + end + end + begin + # go through the statements, and stop if we find one that retuns + statements.each_with_index do |s, idx| + if s.is_a?(Returns) + v = s.return_value(symtab) + return FunctionBodyAst.new(input, interval, statements[0..idx].map { |s| s.prune(symtab) }) unless v.nil? + else + s.execute(symtab) + end + end + + FunctionBodyAst.new(input, interval, statements.map { |s| s.prune(symtab) }) + rescue ValueError + FunctionBodyAst.new(input, interval, statements.map { |s| s.prune(symtab) }) + ensure + symtab.pop + end + end + end + class StatementAst + def prune(symtab) + pruned_action = action.prune(symtab) + if pruned_action.is_a?(Declaration) + pruned_action.add_symbol(symtab) + end + if pruned_action.is_a?(Executable) + begin + pruned_action.execute(symtab) + rescue ValueError + # ok + end + end + StatementAst.new(pruned_action) + end + end + class AryElementAccessAst + def prune(symtab) + AryElementAccessAst.new(input, interval, @var.prune(symtab), @index.prune(symtab)) + end + end + class AryRangeAccessAst + def prune(symtab) + AryRangeAccessAst.new(input, interval, @var.prune(symtab), @msb.prune(symtab), @lsb.prune(symtab)) + end + end + class BinaryExpressionAst + # @!macro prune + def prune(symtab) + if op == "&&" + begin + if @lhs.value(symtab) == false + @rhs.prune(symtab) + else + BinaryExpressionAst.new(input, interval, @lhs.prune(symtab), @op, @rhs.prune(symtab)) + end + rescue ValueError + BinaryExpressionAst.new(input, interval, @lhs.prune(symtab), @op, @rhs.prune(symtab)) + end + elsif op == "||" + begin + if @lhs.value(symtab) == true + @rhs.prune(symtab) + else + BinaryExpressionAst.new(input, interval, @lhs.prune(symtab), @op, @rhs.prune(symtab)) + end + rescue ValueError + BinaryExpressionAst.new(input, interval, @lhs.prune(symtab), @op, @rhs.prune(symtab)) + end + else + BinaryExpressionAst.new(input, interval, @lhs.prune(symtab), @op, @rhs.prune(symtab)) + end + end + end + + class IfBodyAst + def prune(symtab) + pruned_stmts = [] + stmts.each do |s| + pruned_stmts << s.prune(symtab) + end + IfBodyAst.new(pruned_stmts) + end + end + + class ElseIfAst + def prune(symtab) + ElseIfAst.new(cond.prune(symtab), body.prune(symtab).stmts) + end + end + + class IfAst + # @!macro prune + def prune(symtab) + if if_cond.value(symtab) + if_body.prune(symtab) + elsif !elseifs.empty? + # we know that the if condition is false, so now we treat the else if + # as the starting point and try again + IfAst.new( + elseifs[0].cond.prune(symtab), + elseifs[0].body.prune(symtab), + elseifs[1..].map { |e| e.prune(symtab) }, + final_else_body.prune(symtab)) + elsif !final_else_body.stmts.empty? + # the if is false, and there are no else ifs, so the result of the prune is just the pruned else body + final_else_body.prune(symtab) + else + # the if is false, and there are no else ifs or elses. This is just a no-op + NoopAst.new + end + rescue ValueError + # we don't know the value of the if condition + # we still might know the value of an else if + unknown_elsifs = [] + elseifs.each do |eif| + begin + if eif.cond.value(symtab) + # this elseif is true, so turn it into an else and then we are done + return IfAst.new(if_cond.prune(symtab), if_body.prune(symtab), unknown_elsifs.map { |u| u.prune(symtab)}, eif.body.prune(symtab)) + else + # this elseif is false, so we can remove it + next + end + rescue ValueError + unknown_elsifs << eif + end + end + # we get here, then we don't know the value of anything. just return this if with everything pruned + IfAst.new(if_cond.prune(symtab), if_body.prune(symtab), elseifs.map { |eif| eif.prune(symtab)}, final_else_body.prune(symtab)) + end + end + + class ConditionalStatementAst + def prune(symtab) + if condition.value(symtab) + StatementAst.new(action.prune(symtab)) + else + NoopAst.new() + end + rescue ValueError + # condition not known + ConditionalStatementAst.new(action.prune(symtab), condition.prune(symtab)) + end + end + + # class TernaryOperatorExpressionAst + # def prune(symtab) + # begin + # rescue ValueError + # TernaryOperatorExpressionAst.new() + # end + # end + # end +end diff --git a/lib/idl/symbol_table.rb b/lib/idl/symbol_table.rb index 1f6cc03e2..f91bdddce 100644 --- a/lib/idl/symbol_table.rb +++ b/lib/idl/symbol_table.rb @@ -9,7 +9,7 @@ class Var def initialize(name, type, value = nil, decode_var: false, template_index: nil, function_name: nil) @name = name - raise 'unexpected' unless type.is_a?(Type) + raise ArgumentError, "Expecting a Type, got #{type.class.name}" unless type.is_a?(Type) @type = type @value = value diff --git a/lib/idl/tests/helpers.rb b/lib/idl/tests/helpers.rb new file mode 100644 index 000000000..5393332d1 --- /dev/null +++ b/lib/idl/tests/helpers.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +# Extension mock that returns an extension name +class MockExtension + attr_reader :name + def initialize(name) + @name = name + end +end + +# ArchDef mock that knows about XLEN and extensions +class MockArchDef + def config_params = { "XLEN" => 32 } + def extensions = [MockExtension.new("I")] +end + +module TestMixin + def setup + @archdef = MockArchDef.new + @symtab = Idl::SymbolTable.new(@archdef) + @compiler = Idl::Compiler.new(@archdef) + end +end \ No newline at end of file diff --git a/lib/idl/tests/test_expressions.rb b/lib/idl/tests/test_expressions.rb new file mode 100644 index 000000000..01523317d --- /dev/null +++ b/lib/idl/tests/test_expressions.rb @@ -0,0 +1,129 @@ +require "minitest/autorun" + +$root ||= (Pathname.new(__FILE__) / ".." / ".." / ".." / "..").realpath + +require_relative "../../idl" +require_relative "helpers" + +# Test IDL expressions +class TestExpressions < Minitest::Test + include TestMixin + + def test_that_operators_are_left_recusrive + idl = <<~IDL.strip + 4 - 3 - 1 + IDL + + ast = @compiler.compile_expression(idl, @symtab) + assert_equal 0, ast.value(@symtab) + assert_equal "((4 - 3) - 1)", ast.to_idl + end + + def test_that_values_are_tuncated + idl = <<~IDL.strip + 4'hf + 4'h1 + IDL + + ast = @compiler.compile_expression(idl, @symtab) + assert_equal 0, ast.value(@symtab) + + idl = <<~IDL.strip + 4'hf + 5'h1 + IDL + + ast = @compiler.compile_expression(idl, @symtab) + assert_equal 16, ast.value(@symtab) + end + + def test_that_multplication_is_higher_precedence_than_addition + idl = <<~IDL.strip + 4 + 5'd3 * 2 + IDL + + ast = @compiler.compile_expression(idl, @symtab) + refute_equal 14, ast.value(@symtab) + assert_equal 10, ast.value(@symtab) + end + + def test_that_integer_literals_give_correct_values + idl = "8'd13" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal 13, ast.value(@symtab) + + idl = "16'hd" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal 13, ast.value(@symtab) + + idl = "12'o15" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal 13, ast.value(@symtab) + + idl = "4'b1101" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal 13, ast.value(@symtab) + + idl = "-8'sd13" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal(-13, ast.value(@symtab)) + + idl = "-16'shd" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal(-13, ast.value(@symtab)) + + idl = "-12'so15" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal(-13, ast.value(@symtab)) + + idl = "-4'sb1101" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal 3, ast.value(@symtab) + + idl = "4'sb1101" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal(-3, ast.value(@symtab)) + + idl = "32'h80000000" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal 0x80000000, ast.value(@symtab) + + idl = "32'h8000_0000" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal 0x80000000, ast.value(@symtab) + + idl = "8'13" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal 13, ast.value(@symtab) + + # 13 decimal, unsigned XLEN-bit wide + idl = "'13" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal 13, ast.value(@symtab) + + # 13 decimal, signed XLEN-bit wide + idl = "'s13" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal 13, ast.value(@symtab) + + # compilation error: 300 does not fit in 8 bits + idl = "'h1_0000_0000" + assert_raises(Idl::AstNode::TypeError) { @compiler.compile_expression(idl, @symtab, pass_error: true) } + + # 3 decimal: the literal is 13, unsigned, in 4-bits. when negated, the sign bit is lost + idl = "-4'd13" + ast = @compiler.compile_expression(idl, @symtab) + assert_equal 3, ast.value(@symtab) + + # compilation error: 300 does not fit in 8 bits + idl = "8'sd300" + assert_raises(Idl::AstNode::TypeError) { @compiler.compile_expression(idl, @symtab, pass_error: true) } + + # compilation error: bit width must be positive + idl = "0'15" + assert_raises(Idl::AstNode::TypeError) { @compiler.compile_expression(idl, @symtab, pass_error: true) } + + # compilation error: value does not fit in four bita + idl = "4'hff" + assert_raises(Idl::AstNode::TypeError) { @compiler.compile_expression(idl, @symtab, pass_error: true) } + end + +end diff --git a/lib/idl/tests/test_variables.rb b/lib/idl/tests/test_variables.rb new file mode 100644 index 000000000..61ad9117f --- /dev/null +++ b/lib/idl/tests/test_variables.rb @@ -0,0 +1,22 @@ +require "minitest/autorun" + +$root ||= (Pathname.new(__FILE__) / ".." / ".." / ".." / "..").realpath + +require_relative "../../idl" +require_relative "helpers" + +# test IDL variables +class TestVariables < Minitest::Test + include TestMixin + + def test_that_constants_are_read_only + idl = <<~IDL.strip + XReg MyConstant = 15; + MyContant = 0; + IDL + + assert_raises(Idl::AstNode::TypeError) do + @compiler.compile_func_body(idl, symtab: @symtab, no_rescue: true) + end + end +end diff --git a/lib/idl/type.rb b/lib/idl/type.rb index 136d65fa2..87d7dce7f 100644 --- a/lib/idl/type.rb +++ b/lib/idl/type.rb @@ -27,6 +27,17 @@ def integral? @kind == :bits end + def default + case @kind + when :bits, :enum_ref, :bitfield + 0 + when :boolean + false + else + raise "No default for #{@kind}" + end + end + attr_reader :kind, :qualifiers, :width, :sub_type, :tuple_types, :return_type, :arguments, :enum_class def qualify(qualifier) @@ -366,9 +377,9 @@ def clone def value(element_name) i = @element_names.index(element_name) - raise "Could not find #{element_name} in enumeration #{@name}" if i.nil? + return nil if i.nil? - return @element_values[i] + @element_values[i] end end @@ -453,7 +464,7 @@ def type_check_call(template_values = []) def template_names = @func_def_ast.template_names - def template_types = @func_def_ast.template_types + def template_types(symtab) = @func_def_ast.template_types(symtab) def templated? = @func_def_ast.templated? @@ -472,7 +483,7 @@ def apply_template_values(template_values = []) template_values.each_with_index do |value, idx| raise "template value should be an Integer" unless value.is_a?(Integer) - symtab.add!(template_names[idx], Var.new(template_names[idx], template_types[idx], value, template_index: idx, function_name: @func_def_ast.name)) + symtab.add!(template_names[idx], Var.new(template_names[idx], template_types(symtab)[idx], value, template_index: idx, function_name: @func_def_ast.name)) end symtab end @@ -540,17 +551,17 @@ def argument_name(index, template_values = []) def body = @func_def_ast.body end - # a function that is templated, and hasn't been fully typed checked yet - # because it needs to have template arguments resolved - class TemplateFunctionType < Type - attr_reader :template_types, :ast - - def initialize(func_name, template_types, ast) - super(:template_function, name: func_name, arguments: arguments) - @template_types = template_types - @ast = ast - end - end + # # a function that is templated, and hasn't been fully typed checked yet + # # because it needs to have template arguments resolved + # class TemplateFunctionType < Type + # attr_reader :template_types, :ast + + # def initialize(func_name, template_types, ast) + # super(:template_function, name: func_name, arguments: arguments) + # @template_types = template_types + # @ast = ast + # end + # end # XReg is really a Bits<> type, so we override it just to get # prettier prints diff --git a/lib/opcodes.rb b/lib/opcodes.rb index 6490c1dee..29938e715 100644 --- a/lib/opcodes.rb +++ b/lib/opcodes.rb @@ -55,9 +55,16 @@ class DecodeVariable # For example, if the field is offset[5:3], left_shift is 3 attr_reader :left_shift - def extract_location(location_string) - parts = location_string.split("|") + def extract_location(location) @encoding_fields = [] + + if location.is_a?(Integer) + @encoding_fields << EncodingField.new("", location..location) + return + end + + location_string = location + parts = location_string.split("|") parts.each do |part| if part =~ /^([0-9]+)$/ bit = ::Regexp.last_match(1) diff --git a/schemas/config_schema.json b/schemas/config_schema.json index 4460c9fc5..9374a40dd 100644 --- a/schemas/config_schema.json +++ b/schemas/config_schema.json @@ -14,8 +14,18 @@ "IMP_ID", "MISALIGNED_LDST", "NUM_HPM_COUNTERS", + "REPORT_VA_IN_MTVAL_ON_BREAKPOINT", + "REPORT_VA_IN_MTVAL_ON_LOAD_MISALIGNED", + "REPORT_VA_IN_MTVAL_ON_STORE_AMO_MISALIGNED", + "REPORT_VA_IN_MTVAL_ON_INSTRUCTION_MISALIGNED", + "REPORT_VA_IN_MTVAL_ON_LOAD_ACCESS_FAULT", + "REPORT_VA_IN_MTVAL_ON_STORE_AMO_ACCESS_FAULT", + "REPORT_VA_IN_MTVAL_ON_INSTRUCTION_ACCESS_FAULT", + "REPORT_VA_IN_MTVAL_ON_LOAD_PAGE_FAULT", + "REPORT_VA_IN_MTVAL_ON_STORE_AMO_PAGE_FAULT", + "REPORT_VA_IN_MTVAL_ON_INSTRUCTION_PAGE_FAULT", + "REPORT_ENCODING_IN_MTVAL_ON_ILLEGAL_INSTRUCTION", "TRAP_ON_ILLEGAL_WLRL", - "REPORT_EBREAK_PC_IN_TVAL", "CONFIG_PTR_ADDRESS", "PHYS_ADDR_WIDTH", "CACHE_BLOCK_SIZE" @@ -152,10 +162,202 @@ "default": true, "description": "When true, writing an illegal value to a WLRL CSR field raises an Illegal Instruction exception.\nWhen false, writing an illegal value to a WLRL CSR field is ignored." }, - "REPORT_EBREAK_PC_IN_TVAL": { + + "REPORT_VA_IN_MTVAL_ON_BREAKPOINT": { "type": "boolean", - "description": "When true, *tval is written with the virtual PC of the EBREAK instruction (same information as *epc).\nWhen false, *tval is written with 0 on an EBREAK instruction\n\nregardless, *tval is always written with a virtual PC when an external breakpoint is generated." + "default": false, + "description": "When true, mtval is written with the virtual PC of the EBREAK instruction (same information as mepc).\nWhen false, mtval is written with 0 on an EBREAK instruction\n\nregardless, mtval is always written with a virtual PC when an external breakpoint is generated." + }, + "REPORT_VA_IN_MTVAL_ON_LOAD_MISALIGNED": { + "type": "boolean", + "default": false, + "description": "When true, mtval is written with the virtual address when a misaligned load causes a LoadAddressMisaligned exception.\nWhen false, mtval is written with 0" + }, + "REPORT_VA_IN_MTVAL_ON_STORE_AMO_MISALIGNED": { + "type": "boolean", + "default": false, + "description": "When true, mtval is written with the virtual address when a misaligned store or atomic causes a StoreAmoAddressMisaligned exception.\nWhen false, mtval is written with 0" + }, + "REPORT_VA_IN_MTVAL_ON_INSTRUCTION_MISALIGNED": { + "type": "boolean", + "default": false, + "description": "When true, mtval is written with the virtual address when a misaligned store or atomic causes a StoreAmoAddressMisaligned exception.\nWhen false, mtval is written with 0" + }, + "REPORT_VA_IN_MTVAL_ON_LOAD_ACCESS_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, mtval is written with the virtual address when a load causes a LoadAccessFault exception.\nWhen false, mtval is written with 0" + }, + "REPORT_VA_IN_MTVAL_ON_STORE_AMO_ACCESS_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, mtval is written with the virtual address when a store or atomic causes a StoreAmoAccessFault exception.\nWhen false, mtval is written with 0" + }, + "REPORT_VA_IN_MTVAL_ON_INSTRUCTION_ACCESS_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, mtval is written with the virtual address when a store or atomic causes a StoreAmoAccessFault exception.\nWhen false, mtval is written with 0" + }, + "REPORT_VA_IN_MTVAL_ON_LOAD_PAGE_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, mtval is written with the virtual address when a load causes a LoadPageFault exception.\nWhen false, mtval is written with 0" + }, + "REPORT_VA_IN_MTVAL_ON_STORE_AMO_PAGE_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, mtval is written with the virtual address when a store or atomic causes a StoreAmoPageFault exception.\nWhen false, mtval is written with 0" + }, + "REPORT_VA_IN_MTVAL_ON_INSTRUCTION_PAGE_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, mtval is written with the virtual address when a store or atomic causes a StoreAmoPageFault exception.\nWhen false, mtval is written with 0" + }, + "REPORT_ENCODING_IN_MTVAL_ON_ILLEGAL_INSTRUCTION": { + "type": "boolean", + "default": false, + "description": "When true, mtval is written with the faulting instruciton encoding when a IllegalInstruction exception occurs.\nWhen false, mtval is written with 0" + }, + "REPORT_CAUSE_IN_MTVAL_ON_SOFTWARE_CHECK": { + "type": "boolean", + "default": false, + "description": "When true, mtval is written with the casue when a SoftwareCheck exception occurs.\nWhen false, mtval is written with 0" + }, + "MTVAL_WIDTH": { + "type": "integer", + "maximum": 64, + "description": "Number of implemented bits in MTVAL. Must be >= largest virtual address size if a VA is ever written to mtval by hardware or if Sdext is implemented. Must also be able to hold the minimum of MXLEN or ILEN if encodings are reported on IllegalInstruction exceptions" + }, + + "REPORT_VA_IN_STVAL_ON_BREAKPOINT": { + "type": "boolean", + "default": false, + "description": "When true, stval is written with the virtual PC of the EBREAK instruction (same information as mepc).\nWhen false, stval is written with 0 on an EBREAK instruction\n\nregardless, stval is always written with a virtual PC when an external breakpoint is generated." + }, + "REPORT_VA_IN_STVAL_ON_LOAD_MISALIGNED": { + "type": "boolean", + "default": false, + "description": "When true, stval is written with the virtual address when a misaligned load causes a LoadAddressMisaligned exception.\nWhen false, stval is written with 0" + }, + "REPORT_VA_IN_STVAL_ON_STORE_AMO_MISALIGNED": { + "type": "boolean", + "default": false, + "description": "When true, stval is written with the virtual address when a misaligned store or atomic causes a StoreAmoAddressMisaligned exception.\nWhen false, stval is written with 0" + }, + "REPORT_VA_IN_STVAL_ON_INSTRUCTION_MISALIGNED": { + "type": "boolean", + "default": false, + "description": "When true, stval is written with the virtual address when a misaligned store or atomic causes a StoreAmoAddressMisaligned exception.\nWhen false, stval is written with 0" + }, + "REPORT_VA_IN_STVAL_ON_LOAD_ACCESS_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, stval is written with the virtual address when a load causes a LoadAccessFault exception.\nWhen false, stval is written with 0" + }, + "REPORT_VA_IN_STVAL_ON_STORE_AMO_ACCESS_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, stval is written with the virtual address when a store or atomic causes a StoreAmoAccessFault exception.\nWhen false, stval is written with 0" + }, + "REPORT_VA_IN_STVAL_ON_INSTRUCTION_ACCESS_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, stval is written with the virtual address when a store or atomic causes a StoreAmoAccessFault exception.\nWhen false, stval is written with 0" + }, + "REPORT_VA_IN_STVAL_ON_LOAD_PAGE_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, stval is written with the virtual address when a load causes a LoadPageFault exception.\nWhen false, stval is written with 0" + }, + "REPORT_VA_IN_STVAL_ON_STORE_AMO_PAGE_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, stval is written with the virtual address when a store or atomic causes a StoreAmoPageFault exception.\nWhen false, stval is written with 0" + }, + "REPORT_VA_IN_STVAL_ON_INSTRUCTION_PAGE_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, stval is written with the virtual address when a store or atomic causes a StoreAmoPageFault exception.\nWhen false, stval is written with 0" + }, + "REPORT_ENCODING_IN_STVAL_ON_ILLEGAL_INSTRUCTION": { + "type": "boolean", + "default": false, + "description": "When true, stval is written with the faulting instruciton encoding when a IllegalInstruction exception occurs.\nWhen false, stval is written with 0" + }, + "REPORT_CAUSE_IN_STVAL_ON_SOFTWARE_CHECK": { + "type": "boolean", + "default": false, + "description": "When true, stval is written with the casue when a SoftwareCheck exception occurs.\nWhen false, stval is written with 0" + }, + "STVAL_WIDTH": { + "type": "integer", + "maximum": 64, + "description": "Number of implemented bits in STVAL. Must be >= largest virtual address size if a VA is ever written to stval by hardware or if Sdext is implemented. Must also be able to hold the minimum of SXLEN or ILEN if encodings are reported on IllegalInstruction exceptions" + }, + + "REPORT_VA_IN_VSTVAL_ON_BREAKPOINT": { + "type": "boolean", + "default": false, + "description": "When true, vstval is written with the virtual PC of the EBREAK instruction (same information as mepc).\nWhen false, vstval is written with 0 on an EBREAK instruction\n\nregardless, vstval is always written with a virtual PC when an external breakpoint is generated." + }, + "REPORT_VA_IN_VSTVAL_ON_LOAD_MISALIGNED": { + "type": "boolean", + "default": false, + "description": "When true, vstval is written with the virtual address when a misaligned load causes a LoadAddressMisaligned exception.\nWhen false, vstval is written with 0" + }, + "REPORT_VA_IN_VSTVAL_ON_STORE_AMO_MISALIGNED": { + "type": "boolean", + "default": false, + "description": "When true, vstval is written with the virtual address when a misaligned store or atomic causes a StoreAmoAddressMisaligned exception.\nWhen false, vstval is written with 0" + }, + "REPORT_VA_IN_VSTVAL_ON_INSTRUCTION_MISALIGNED": { + "type": "boolean", + "default": false, + "description": "When true, vstval is written with the virtual address when a misaligned store or atomic causes a StoreAmoAddressMisaligned exception.\nWhen false, vstval is written with 0" + }, + "REPORT_VA_IN_VSTVAL_ON_LOAD_ACCESS_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, vstval is written with the virtual address when a load causes a LoadAccessFault exception.\nWhen false, vstval is written with 0" + }, + "REPORT_VA_IN_VSTVAL_ON_STORE_AMO_ACCESS_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, vstval is written with the virtual address when a store or atomic causes a StoreAmoAccessFault exception.\nWhen false, vstval is written with 0" + }, + "REPORT_VA_IN_VSTVAL_ON_INSTRUCTION_ACCESS_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, vstval is written with the virtual address when a store or atomic causes a StoreAmoAccessFault exception.\nWhen false, vstval is written with 0" + }, + "REPORT_VA_IN_VSTVAL_ON_LOAD_PAGE_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, vstval is written with the virtual address when a load causes a LoadPageFault exception.\nWhen false, vstval is written with 0" + }, + "REPORT_VA_IN_VSTVAL_ON_STORE_AMO_PAGE_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, vstval is written with the virtual address when a store or atomic causes a StoreAmoPageFault exception.\nWhen false, vstval is written with 0" + }, + "REPORT_VA_IN_VSTVAL_ON_INSTRUCTION_PAGE_FAULT": { + "type": "boolean", + "default": false, + "description": "When true, vstval is written with the virtual address when a store or atomic causes a StoreAmoPageFault exception.\nWhen false, vstval is written with 0" + }, + "REPORT_ENCODING_IN_VSTVAL_ON_ILLEGAL_INSTRUCTION": { + "type": "boolean", + "default": false, + "description": "When true, vstval is written with the faulting instruciton encoding when a IllegalInstruction exception occurs.\nWhen false, vstval is written with 0" + }, + "REPORT_CAUSE_IN_VSTVAL_ON_SOFTWARE_CHECK": { + "type": "boolean", + "default": false, + "description": "When true, vstval is written with the casue when a SoftwareCheck exception occurs.\nWhen false, vstval is written with 0" }, + + + "CONFIG_PTR_ADDRESS": { "type": "integer", "minimum": 0, diff --git a/schemas/ext_schema.json b/schemas/ext_schema.json index 7f2d1c0c9..53a0dc680 100644 --- a/schemas/ext_schema.json +++ b/schemas/ext_schema.json @@ -7,17 +7,83 @@ "required": ["description", "versions"], "properties": { "name": { "$ref": "schema_defs.json#/$defs/extension_name" }, - "description": { "type": "string" }, + "long_name": { + "type": "string", + "description": "One line description for the extension" + }, + "description": { + "type": "string", + "description": "Full documentation of the extension" + }, + "company": { + "description": "The company that developed this extension", + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Name of the company that developed this extension. Should be \"RISC-V International\" for standard extensions" + }, + "url": { + "type": "string", + "format": "uri", + "description": "Website of the company that developed this extension. Should be \"https://riscv.org\" for standard extensions" + } + } + }, + "doc_license": { + "description": "License that applies to the textual documantation for this extension", + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "License name" + }, + "url": { + "type": "string", + "format": "uri", + "description": "Link to license text" + } + }, + "additionalProperties": false + }, "type": { "enum": ["unprivileged", "privileged"] }, "versions": { "type": "array", "items": { "type": "object", - "required": ["version", "ratification_date"], + "required": ["version", "state"], "properties": { "version": { "$ref": "schema_defs.json#/$defs/extension_version" }, + "state": { + "description": "Current state of this version", + "enum": [ + "development", + "frozen", + "public-review", + "ratified", + "nonstandard-released" + ] + }, + "repositories": { + "description": "Repositories associated with this extension", + "type": "array", + "items": { + "type": "object", + "properties": { + "url": { + "type": "string", + "format": "uri" + }, + "branch": { + "type": "string", + "description": "Branch/tag where the work is done" + } + }, + "additionalProperties": false + } + }, "ratification_date": { "oneOf": [ {"type": "string", "pattern": "^20[0-9][0-9]-[0-9][0-9]$", "$comment": "When ratification date is known" }, @@ -40,6 +106,28 @@ { "$ref": "schema_defs.json#/$defs/extension_requirement" }, { "type": "array", "items": { "$ref": "schema_defs.json#/$defs/extension_requirement" }} ] + }, + "contributors": { + "description": "List of contributors to this version of the extension", + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Contributor name, in 'GIVEN_NAME SURNAME' format" + }, + "company": { + "type": "string", + "description": "Company the contributor worked for, or 'Individual'" + }, + "email": { + "type": "string", + "format": "email", + "description": "E-mail address for the contributor" + } + } + } } }, "additionalProperties": false diff --git a/schemas/inst_schema.json b/schemas/inst_schema.json index 8e8ec4c57..8673cc64c 100644 --- a/schemas/inst_schema.json +++ b/schemas/inst_schema.json @@ -2,15 +2,19 @@ "$schema": "http://json-schema.org/draft-07/schema#", "$defs": { - "extension": { - "type": "string", - "pattern": "^[A-W,Y]|([XZ][a-z]+)$", - "description": "RISC-V Extension" - }, "field_location": { "description": "Location specifier for a field", - "type": "string", - "pattern": "^(([0-9]+)|([0-9]+-[0-9]+))(\\|(([0-9]+)|([0-9]+-[0-9]+)))*$" + "oneOf": [ + { + "type": "string", + "pattern": "^(([0-9]+)|([0-9]+-[0-9]+))(\\|(([0-9]+)|([0-9]+-[0-9]+)))*$" + }, + { + "type": "integer", + "minimum": 0, + "maximum": 31 + } + ] }, "field": { "description": "Decode field", @@ -42,7 +46,7 @@ "encoding": { "type": "object", "properties": { - "mask": { + "match": { "oneOf": [ { "type": "string", @@ -56,7 +60,7 @@ } ] }, - "not_mask": { + "not_match": { "description": "Bit values that cannot match for the instruction. Used to exclude encodings where all but one value are valid (e.g., common with the C encodings)", "oneOf": [ { @@ -71,7 +75,7 @@ } ] }, - "fields": { + "variables": { "type": "array", "items": { "$ref": "#/$defs/field" @@ -102,12 +106,12 @@ "definedBy": { "oneOf": [ { - "$ref": "#/$defs/extension" + "$ref": "schema_defs.json#/$defs/extension_requirement" }, { "type": "array", "items": { - "$ref": "#/$defs/extension" + "$ref": "schema_defs.json#/$defs/extension_requirement" } } ], @@ -116,12 +120,12 @@ "excludedBy": { "oneOf": [ { - "$ref": "#/$defs/extension" + "$ref": "schema_defs.json#/$defs/extension_requirement" }, { "type": "array", "items": { - "$ref": "#/$defs/extension" + "$ref": "schema_defs.json#/$defs/extension_requirement" } } ], @@ -189,6 +193,21 @@ "assembly": { "type": "string", "description": "Assembly format of the instruction. Can use decode variables" + }, + "pseudoinstructions": { + "description": "Variations of this instruction that form a pseudoinstruction", + "type": "object", + "properties": { + "when": { + "type": "string", + "description": "Condition when the instruction has an alias" + }, + "to": { + "type": "string", + "description": "pseduoinstruction format" + } + }, + "additionalProperties": false } } } diff --git a/schemas/schema_defs.json b/schemas/schema_defs.json index dec4d76de..27a5e2106 100644 --- a/schemas/schema_defs.json +++ b/schemas/schema_defs.json @@ -19,14 +19,21 @@ } ] }, - "extension_version_requirement": { + "requirement_string": { + "type": "string", + "pattern": "^((>=)|(>)|(~>)|(<)|(<=)|(=))?\\s*[0-9]+(\\.[0-9]+(\\.[0-9]+(-[a-fA-F0-9]+)?)?)?$" + }, + "version_requirements": { + "description": "A (set of) version requirments", "oneOf": [ { - "type": "number" + "$ref": "#/$defs/requirement_string" }, { - "type": "string", - "pattern": "^((>=)|(>)|(~>)|(<)|(<=)|(==))?\\s*[0-9]+(\\.[0-9]+(\\.[0-9]+(-[a-fA-F0-9]+)?)?)?$" + "type": "array", + "items": { + "$ref": "#/$defs/requirement_string" + } } ] }, @@ -43,16 +50,25 @@ "additionalItems": false }, "extension_requirement": { - "type": "array", - "items": [ + "description": "A requirement on an extension. Can either specify just an extension name, in which case version '>= 0' is implied, or both a name and a requirement", + "oneOf": [ { "$ref": "#/$defs/extension_name" }, { - "$ref": "#/$defs/extension_version_requirement" + "type": "array", + "items": [ + { + "$ref": "#/$defs/extension_name" + }, + { + "$ref": "#/$defs/version_requirements" + } + ], + "additionalItems": false } - ], - "additionalItems": false + ] + } } } \ No newline at end of file diff --git a/tasks/adoc_gen.rake b/tasks/adoc_gen.rake index 4ad6a52f2..0a4ae25d1 100644 --- a/tasks/adoc_gen.rake +++ b/tasks/adoc_gen.rake @@ -9,6 +9,7 @@ require_relative "../lib/arch_def" "#{$root}/.stamps/arch-gen-#{config_name}.stamp", ($root / "views" / "adoc" / "#{type}.adoc.erb").to_s, "lib/arch_def.rb", + "lib/idl/passes/gen_adoc.rb", "tasks/adoc_gen.rake", "#{$root}/.stamps" ] @@ -43,6 +44,7 @@ require_relative "../lib/arch_def" end when "func" isa_def = arch_def.global_ast + global_symtab = arch_def.sym_table path = dir_path / "funcs.adoc" File.write(path, erb.result(binding)) else diff --git a/tasks/ext_pdf_gen.rake b/tasks/ext_pdf_gen.rake new file mode 100644 index 000000000..7210aa26f --- /dev/null +++ b/tasks/ext_pdf_gen.rake @@ -0,0 +1,95 @@ +# frozen_string_literal: true + +require "pathname" + +require "asciidoctor-pdf" +require "asciidoctor-diagram" + +require_relative "../lib/idl/passes/gen_adoc" + +# Utilities for generating an Antora site out of an architecture def +module AsciidocUtils + class << self + def resolve_links(path_or_str) + str = + if path_or_str.is_a?(Pathname) + path_or_str.read + else + path_or_str + end + str.gsub(/%%LINK%([^;%]+)\s*;\s*([^;%]+)\s*;\s*([^%]+)%%/) do + type = Regexp.last_match[1] + name = Regexp.last_match[2] + link_text = Regexp.last_match[3] + + case type + when "inst" + "xref:insns-#{name.gsub(',', '_')}[#{link_text.gsub(']', '\]')}]" + when "csr" + # "xref:csrs:#{name}.adoc##{name}-def[#{link_text.gsub(']', '\]')}]" + link_text + when "csr_field" + csr_name, field_name = name.split('.') + # "xref:csrs:#{csr_name}.adoc##{csr_name}-#{field_name}-def[#{link_text.gsub(']', '\]')}]" + link_text + when "ext" + # "xref:exts:#{name}.adoc##{name}-def[#{link_text.gsub(']', '\]')}]" + link_text + when "func" + # "xref:funcs:funcs.adoc##{name}-func-def[#{link_text.gsub(']', '\]')}]" + link_text + else + raise "Unhandled link type '#{type}' for '#{name}' #{match.captures}" + end + end + end + end +end + +rule %r{#{$root}/gen/.*/pdf/.*_extension\.pdf} => proc { |tname| + config_name = Pathname.new(tname).relative_path_from($root / "gen").to_s.split("/")[0] + ext_name = Pathname.new(tname).basename(".pdf").to_s.split("_")[0..-2].join("_") + [ + "#{$root}/gen/#{config_name}/adoc/#{ext_name}_extension.adoc" + ] +} do |t| + config_name = Pathname.new(t.name).relative_path_from($root / "gen").to_s.split("/")[0] + ext_name = Pathname.new(t.name).basename(".pdf").to_s.split("_")[0..-2].join("_") + adoc_file = "#{$root}/gen/#{config_name}/adoc/#{ext_name}_extension.adoc" + + FileUtils.mkdir_p File.dirname(t.name) + File.write t.name, Asciidoctor.convert_file(adoc_file, backend: "pdf", safe: :safe) +end + +rule %r{#{$root}/gen/.*/adoc/.*_extension\.adoc} => proc { |tname| + config_name = Pathname.new(tname).relative_path_from($root / "gen").to_s.split("/")[0] + [ + "#{$root}/.stamps/arch-gen-#{config_name}.stamp", + ($root / "views" / "adoc" / "ext_pdf.adoc.erb").to_s, + __FILE__ + ] +} do |t| + config_name = Pathname.new(t.name).relative_path_from("#{$root}/gen").to_s.split("/")[0] + ext_name = Pathname.new(t.name).basename(".pdf").to_s.split("_")[0..-2].join("_") + + template_path = $root / "views" / "adoc" / "ext_pdf.adoc.erb" + erb = ERB.new(template_path.read, trim_mode: "-") + erb.filename = template_path.to_s + + arch_def = ArchDef.new(config_name) + ext = arch_def.extension(ext_name) + FileUtils.mkdir_p File.dirname(t.name) + File.write t.name, AsciidocUtils.resolve_links(erb.result(binding)) +end + +namespace :gen do + desc <<~DESC + Generate PDF documentation for :extension using configuration :config_name + DESC + task :ext_pdf, [:extension, :config_name] do |_t, args| + config = args[:config_name] + extension = args[:extension] + + Rake::Task[$root / "gen" / config.to_s / "pdf" / "#{extension}_extension.pdf"].invoke + end +end diff --git a/tasks/html_gen.rake b/tasks/html_gen.rake index 1a6414f4b..e12d1413c 100644 --- a/tasks/html_gen.rake +++ b/tasks/html_gen.rake @@ -10,22 +10,23 @@ module AntoraUtils else path_or_str end - str.gsub(/%%LINK\[([^;\]%]+)\s*;\s*([^;\]%]+)\s*;\s*([^\]%]+)\]%%/) do + str.gsub(/%%LINK%([^;%]+)\s*;\s*([^;%]+)\s*;\s*([^%]+)%%/) do type = Regexp.last_match[1] name = Regexp.last_match[2] link_text = Regexp.last_match[3] - case type when "inst" - "xref:insts:#{name}.adoc##{name}-def[#{link_text}]" + "xref:insts:#{name}.adoc##{name}-def[#{link_text.gsub(']', '\]')}]" when "csr" - "xref:csrs:#{name}.adoc##{name}-def[#{link_text}]" + "xref:csrs:#{name}.adoc##{name}-def[#{link_text.gsub(']', '\]')}]" when "csr_field" - csr_name, field_name = name.split(".") - "xref:csrs:#{csr_name}.adoc##{csr_name}-#{field_name}-def[#{link_text}]" + csr_name, field_name = name.split('.') + "xref:csrs:#{csr_name}.adoc##{csr_name}-#{field_name}-def[#{link_text.gsub(']', '\]')}]" when "ext" - "xref:exts:#{name}.adoc##{name}-def[#{link_text}]" + "xref:exts:#{name}.adoc##{name}-def[#{link_text.gsub(']', '\]')}]" + when "func" + "xref:funcs:funcs.adoc##{name}-func-def[#{link_text.gsub(']', '\]')}]" else raise "Unhandled link type '#{type}' for '#{name}' #{match.captures}" end @@ -39,7 +40,6 @@ end config_name = Pathname.new(tname).relative_path_from("#{$root}/gen").to_s.split("/")[0] [ "#{$root}/\.stamps/adoc-gen-#{type}s-#{config_name}\.stamp", - # "#{$root}/gen/#{config_name}/adoc/#{type}s/#{rest}", __FILE__ ] } do |t| diff --git a/tasks/top.rake b/tasks/top.rake index 4327eeae1..f206f8f3c 100644 --- a/tasks/top.rake +++ b/tasks/top.rake @@ -4,6 +4,7 @@ $root = Pathname.new(__FILE__).dirname.dirname.realpath $lib = $root / "lib" require "yard" +require "minitest/test_task" require_relative $root / "lib" / "validate" @@ -12,6 +13,7 @@ directory "#{$root}/.stamps" load "#{$root}/tasks/arch_gen.rake" load "#{$root}/tasks/adoc_gen.rake" load "#{$root}/tasks/html_gen.rake" +load "#{$root}/tasks/ext_pdf_gen.rake" namespace :gen do task :html @@ -61,3 +63,7 @@ namespace :serve do sh "yard server -p #{args[:port]} --reload" end end + +Minitest::TestTask.create :idl_test do |t| + t.test_globs = ["#{$root}/lib/idl/tests/test_*.rb"] +end diff --git a/views/adoc/csr.adoc.erb b/views/adoc/csr.adoc.erb index 7896b7219..b6a17f509 100644 --- a/views/adoc/csr.adoc.erb +++ b/views/adoc/csr.adoc.erb @@ -73,7 +73,7 @@ a| <%= arch_def.find_replace_links(field.description) %> This CSR may store a value that is different from what software attempts to write. -When a software write occurs (_e.g._, through %%LINK[inst;cssrw;csrrw]%%), the following determines the +When a software write occurs (_e.g._, through %%LINK%inst;cssrw;csrrw%%), the following determines the written value: [idl] diff --git a/views/adoc/ext.adoc.erb b/views/adoc/ext.adoc.erb index 69f329bd4..52a59d839 100644 --- a/views/adoc/ext.adoc.erb +++ b/views/adoc/ext.adoc.erb @@ -6,16 +6,16 @@ This extension not implemented by the <%= ext.arch_def.name %> configuration. <%- end -%> -<%- if ext.respond_to?(:implies) && !ext.implies.empty? -%> +<%- if !ext.implies.empty? -%> This extension implies the following extension(s): -`<%= ext.name %>` => <%= ext.implies.map { |e| arch_def.find_replace_links "`#{e}`" }.join(", ") %> +`<%= ext.name %>` => <%= ext.implies.map { |e| arch_def.find_replace_links "`#{e.name}`, version #{e.version}" }.join(", ") %> <%- end -%> == Versions <%- ext.versions.each do |v| -%> -<%- implemented = ext.arch_def.implemented_extensions.include?(ExtensionVersion.new(ext.name, v["version"], ext.arch_def)) -%> +<%- implemented = arch_def.implemented_extensions.include?(ExtensionVersion.new(ext.name, v["version"])) -%> <%= v["version"] %>:: Ratification date::: <%= v["ratification_date"] %> diff --git a/views/adoc/ext_pdf.adoc.erb b/views/adoc/ext_pdf.adoc.erb new file mode 100644 index 000000000..7a4686773 --- /dev/null +++ b/views/adoc/ext_pdf.adoc.erb @@ -0,0 +1,193 @@ += <%= ext.long_name %> + +:description: <%= ext.long_name %> +:company: <%= ext.company %> +:url-riscv: https://riscv.org +:doctype: book +:preface-title: Licensing and Acknowledgements +:colophon: +:appendix-caption: Appendix +:title-logo-image: image:RISC-V-logo.svg[pdfwidth=3.25in,align=center] +:back-cover-image: image:circuit.png[opacity=25%] +// Settings +:experimental: +:reproducible: +:wavedrom: <%= $root %>/node_modules/.bin/wavedrom-cli +// needs to be changed +:imagesoutdir: images +:icons: font +:lang: en +:listing-caption: Listing +:sectnums: +:toc: left +:toclevels: 4 +:source-highlighter: pygments +ifdef::backend-pdf[] +:source-highlighter: coderay +endif::[] +:data-uri: +:hide-uri-scheme: +:stem: +:footnote: +:xrefstyle: short + + + +<<< +[colophon] +== Colophon + +This document is released under the <%= ext.doc_license["url"] %>[<%= ext.doc_license["name"] %>]. + +<<< +[acknowledgements] +== Acknowledgements + +<%- ext.versions.each do |version| -%> +Contributors to version <%= version["version"] %> of the specification (in alphabetical order) include: + + +<%- version["contributors"].sort { |a, b| a["name"].split(" ").last <=> b["name"].split(" ").last }.each do |c| -%> + * <%= c["name"] %> <<%= c["email"] %>> (<%= c["company"] %>) +<%- end -%> +<%- end -%> + +We express our gratitude to everyone that contributed to, reviewed or +improved this specification through their comments and questions. + +<<< +== Versions + +The following versions have been defined: + +<%- ext.versions.each do |version| -%> +-- +Version:: <%= version["version"] %> +State:: <%= version["state"] %> +<%- if version.key?("ratification_date") -%> +Ratification Date:: <%= version["ratification_date"] %> +<%- end -%> +<%- if version.key?("url") -%> +Design document:: <%= version["url"] %> +<%- end -%> +<%- if version.key?("change") -%> +Changes:: +<%= version["changes"] %> +<%- end -%> +-- +<%- end -%> + +<<< +== Extension description + +<%= ext.description %> + +<%- unless ext.implies.nil? -%> +<%- ext.implies.each do |e| -%> +<%- end -%> +<%- end -%> + +<<< +== Instruction summary + +The following instructions are added by this extension: + +[%autowidth] +|=== +| RV32 | RV64 | Mnemonic | Instruction | <%= ext.versions.map { |v| "v#{v["version"]}" }.join(" | ") %> + +<%- ext.instructions.each do |i| -%> +| <%= i.rv32? ? "X" : "" %> +| <%= i.rv64? ? "X" : "" %> +| `<%= i.name %> <%= i.assembly.gsub("x", "r") %>` +| xref:insns-<%= i.name.gsub('.', '_') %>[<%= i.long_name %>] +| <%= ext.versions.map { |v| i.defined_by?(ext.name, v["version"]) ? "X" : "" }.join(" | ") %> +<%- end -%> +|=== + +<<< +[#insns,reftext="Instructions (in alphabetical order)"] +== Instructions (in alphabetical order) + +<%- ext.instructions.each do |i| -%> +[#insns-<%= i.name.gsub('.', '_') %>,reftext=<%= i.long_name %>] +=== <%= i.name %> + +Synopsis:: +<%= i.long_name %> + +Mnemoic:: +---- +<%= i.name %><%= i.assembly.gsub('x', 'r') %> +---- + +Encoding:: +<%- if arch_def.multi_xlen? && i.multi_encoding? -%> +[NOTE] +This instruction has different encodings in RV32 and RV64 + +RV32:: +[wavedrom, ,svg,subs='attributes',width="100%"] +.... +<%= JSON.dump i.wavedrom_desc(32) %> +.... + +RV64:: +[wavedrom, ,svg,subs='attributes',width="100%"] +.... +<%= JSON.dump i.wavedrom_desc(64) %> +.... +<%- else -%> +[wavedrom, ,svg,subs='attributes',width="100%"] +.... +<%= JSON.dump i.wavedrom_desc(arch_def.config_params["XLEN"]) %> +.... +<%- end -%> + +Description:: +<%= i.description %> + +Decode Variables:: + +<%- if i.arch_def.multi_xlen? && i.multi_encoding? -%> +RV32:: ++ +---- +<%- i.decode_variables(32).each do |d| -%> +<%= d.sext? ? 'signed ' : '' %>Bits<<%= d.size %>> <%= d.name %> = <%= d.extract %>; +<%- end -%> +---- + +RV64:: ++ +---- +<%- i.decode_variables(64).each do |d| -%> +<%= d.sext? ? 'signed ' : '' %>Bits<<%= d.size %>> <%= d.name %> = <%= d.extract %>; +<%- end -%> +---- +<%- else -%> +---- +<%- i.decode_variables(i.arch_def.config_params["XLEN"]).each do |d| -%> +<%= d.sext? ? 'signed ' : '' %>Bits<<%= d.size %>> <%= d.name %> = <%= d.extract %>; +<%- end -%> +---- +<%- end -%> + +Operation:: +[souce,idl] +---- +<%= i.operation_ast.gen_adoc %> +---- + +Included in:: +[%header,cols="4,2,2"] +|=== +|Extension +|Minimum version +|Lifecycle state + +|Zba (<<#zba>>) +|0.93 +|Frozen +|=== +<<< +<%- end -%> \ No newline at end of file diff --git a/views/adoc/func.adoc.erb b/views/adoc/func.adoc.erb index 3b2cd0ae0..d36676563 100644 --- a/views/adoc/func.adoc.erb +++ b/views/adoc/func.adoc.erb @@ -1,3 +1,5 @@ +:tabs-sync-option: + // defintions and helper functions for ISA definitions = Functions @@ -13,11 +15,24 @@ h| Return Type l| <%= f.return_type_list_str.join(', ') %> h| Arguments l| <%= f.arguments_list_str.join (', ') %> |=== -<%- if f.respond_to?(:body_block) -%> +<%- unless f.builtin? -%> +<%- body_ast = f.body_block.function_body -%> +[tabs] +==== +Original:: ++ +[subs="specialchars,macros"] +---- +<%= body_ast.gen_adoc.gsub('(', 'pass:[(]') %> +---- + +Pruned:: ++ [subs="specialchars,macros"] ---- -<%= f.unindent(f.body_block.function_body.gen_adoc.gsub('(', 'pass:[(]')) %> +<%= body_ast.prune(global_symtab.deep_clone).gen_adoc.gsub('(', 'pass:[(]') %> ---- +==== <%- end -%> <%- end -%> \ No newline at end of file diff --git a/views/adoc/inst.adoc.erb b/views/adoc/inst.adoc.erb index 8d97afc7d..62b7001d6 100644 --- a/views/adoc/inst.adoc.erb +++ b/views/adoc/inst.adoc.erb @@ -7,7 +7,7 @@ == Encoding -<%- if inst.arch_def.multi_xlen? && inst.multi_encoding? -%> +<%- if arch_def.multi_xlen? && inst.multi_encoding? -%> [NOTE] This instruction has different encodings in RV32 and RV64. @@ -30,7 +30,7 @@ RV64:: <%- else -%> [wavedrom, ,svg,subs='attributes',width="100%"] .... -<%= JSON.dump inst.wavedrom_desc(inst.arch_def.config_params["XLEN"]) %> +<%= JSON.dump inst.wavedrom_desc(arch_def.config_params["XLEN"]) %> .... <%- end -%> @@ -62,7 +62,7 @@ RV64:: == Decode Variables -<%- if inst.arch_def.multi_xlen? && inst.multi_encoding? -%> +<%- if arch_def.multi_xlen? && inst.multi_encoding? -%> [tabs] ==== RV32:: @@ -83,7 +83,7 @@ RV64:: ==== <%- else -%> ---- -<%- inst.decode_variables(inst.arch_def.config_params["XLEN"]).each do |d| -%> +<%- inst.decode_variables(arch_def.config_params["XLEN"]).each do |d| -%> <%= d.sext? ? 'signed ' : '' %>Bits<<%= d.size %>> <%= d.name %> = <%= d.extract %>; <%- end -%> ---- @@ -91,7 +91,23 @@ RV64:: == Execution +<%- if inst.operation_ast(arch_def.idl_compiler).nil? -%> + +<%- else -%> +[tabs] +==== +Pruned:: ++ [subs="specialchars,macros"] ---- -<%= inst.operation_source %> +<%= inst.pruned_operation_ast(arch_def.sym_table).gen_adoc %> ---- + +Original:: ++ +[subs="specialchars,macros"] +---- +<%= inst.operation_ast(arch_def.idl_compiler).gen_adoc %> +---- +==== +<%- end -%> \ No newline at end of file diff --git a/views/adoc/toc.adoc.erb b/views/adoc/toc.adoc.erb index dd14331f4..0282723d5 100644 --- a/views/adoc/toc.adoc.erb +++ b/views/adoc/toc.adoc.erb @@ -2,17 +2,17 @@ .Extensions <%- arch_def.implemented_extensions.sort { |a, b| a.name <=> b.name }.each do |ext| -%> -* %%LINK[ext;<%= ext.name %>;<%= ext.name %>]%% +* %%LINK%ext;<%= ext.name %>;<%= ext.name %>%% <%- end -%> .Control and Status Registers <%- arch_def.implemented_csrs.sort { |a, b| a.name <=> b.name }.each do |csr| -%> -* %%LINK[csr;<%= csr.name %>;<%= csr.name %>]%% +* %%LINK%csr;<%= csr.name %>;<%= csr.name %>%% <%- end -%> .Instructions <%- arch_def.implemented_instructions.sort { |a, b| a.name <=> b.name }.each do |inst| -%> -* %%LINK[inst;<%= inst.name %>;<%= inst.name %>]%% +* %%LINK%inst;<%= inst.name %>;<%= inst.name %>%% <%- end -%> .IDL functions