Skip to content

symbolic opcodes#4

Merged
mmcloughlin merged 10 commits intodevfrom
mbm/symbolic-opcodes
Oct 5, 2024
Merged

symbolic opcodes#4
mmcloughlin merged 10 commits intodevfrom
mbm/symbolic-opcodes

Conversation

@mmcloughlin
Copy link
Copy Markdown
Owner

@mmcloughlin mmcloughlin commented Oct 4, 2024

Experimental support for symbolic opcodes in ASLp.

Opcode semantics generation now accepts an "opcode" template, for example:

ASLi> :sem A64 0x122:9|sh:1|imm:12|0xa4:10
Decoding instruction A64 0x122:9|sh:1|imm:12|0xa4:10
bits ( 64 ) imm__3 ;
if eq_bits.0 {{ 1 }} ( sh [ 0 +: 1 ],'0' ) then {
imm__3 = ZeroExtend.0 {{ 12,64 }} ( imm [ 0 +: 12 ],64 ) ;
}  else {
if eq_bits.0 {{ 1 }} ( sh [ 0 +: 1 ],'1' ) then {
imm__3 = ZeroExtend.0 {{ 24,64 }} ( append_bits.0 {{ 12,12 }} ( imm [ 0 +: 12 ],'000000000000' ),64 ) ;
}  else {
assert FALSE ;
}
}
__array _R [ 4 ] = add_bits.0 {{ 64 }} ( __array _R [ 5 ],imm__3 ) ;

@mmcloughlin mmcloughlin force-pushed the mbm/symbolic-opcodes branch from f9f6040 to 822b023 Compare October 5, 2024 19:58
@mmcloughlin mmcloughlin changed the base branch from partial_eval to dev October 5, 2024 19:58
@mmcloughlin mmcloughlin changed the title WIP: symbolic opcodes symbolic opcodes Oct 5, 2024
@mmcloughlin mmcloughlin merged commit e5190a0 into dev Oct 5, 2024
mmcloughlin added a commit that referenced this pull request Oct 26, 2025
Experimental support for symbolic opcodes in ASLp.

Opcode semantics generation now accepts an "opcode" template, for
example:

```
ASLi> :sem A64 0x122:9|sh:1|imm:12|0xa4:10
Decoding instruction A64 0x122:9|sh:1|imm:12|0xa4:10
bits ( 64 ) imm__3 ;
if eq_bits.0 {{ 1 }} ( sh [ 0 +: 1 ],'0' ) then {
imm__3 = ZeroExtend.0 {{ 12,64 }} ( imm [ 0 +: 12 ],64 ) ;
}  else {
if eq_bits.0 {{ 1 }} ( sh [ 0 +: 1 ],'1' ) then {
imm__3 = ZeroExtend.0 {{ 24,64 }} ( append_bits.0 {{ 12,12 }} ( imm [ 0 +: 12 ],'000000000000' ),64 ) ;
}  else {
assert FALSE ;
}
}
__array _R [ 4 ] = add_bits.0 {{ 64 }} ( __array _R [ 5 ],imm__3 ) ;
```
mmcloughlin added a commit that referenced this pull request Jan 23, 2026
* symbolic opcodes (#4)

Experimental support for symbolic opcodes in ASLp.

Opcode semantics generation now accepts an "opcode" template, for
example:

```
ASLi> :sem A64 0x122:9|sh:1|imm:12|0xa4:10
Decoding instruction A64 0x122:9|sh:1|imm:12|0xa4:10
bits ( 64 ) imm__3 ;
if eq_bits.0 {{ 1 }} ( sh [ 0 +: 1 ],'0' ) then {
imm__3 = ZeroExtend.0 {{ 12,64 }} ( imm [ 0 +: 12 ],64 ) ;
}  else {
if eq_bits.0 {{ 1 }} ( sh [ 0 +: 1 ],'1' ) then {
imm__3 = ZeroExtend.0 {{ 24,64 }} ( append_bits.0 {{ 12,12 }} ( imm [ 0 +: 12 ],'000000000000' ),64 ) ;
}  else {
assert FALSE ;
}
}
__array _R [ 4 ] = add_bits.0 {{ 64 }} ( __array _R [ 5 ],imm__3 ) ;
```

* fix symbolic field handling by `CommonSubExprElim` (#5)

  Fix a problem with the treatment of symbolic field variables by
  common-subexpression-elimination.

  When a common subexpression has been identified, it needs to place it in
  the statement list. It does this by placing it in the first position
  after all its dependencies have been assigned. The problem comes because
  a common subexpression that depends on a symbolic field won't ever find
  an assignment to the symbolic field.

  This is what the algorithm was probably supposed to do, but as they
  explain in a comment what they actually do is place the definition of
  the common subexpression in the first place after all its dependencies
  have _appeared_ (whether assigned to or not). Therefore in practice,
  common expressions involving symbolic fields would end up placed after
  their first use.

  This PR fixes it by:

  * Passing a list of globals into CSE which are treated as predefined
  * Appending symbolic fields to the global identifier set

* resolve merge conflict markers

* dis_decode_entry_sym

* sym_and_bits: use sym_slice and sym_append_bits

* tests/test_asl.ml: fix call to dis_decode_entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant