mirror of
https://github.com/open-goal/jak-project
synced 2026-05-26 07:39:12 -04:00
cd68cb671e
Major change to how `deftype` shows up in our code: - the decompiler will no longer emit the `offset-assert`, `method-count-assert`, `size-assert` and `flag-assert` parameters. There are extremely few cases where having this in the decompiled code is helpful, as the types there come from `all-types` which already has those parameters. This also doesn't break type consistency because: - the asserts aren't compared. - the first step of the test uses `all-types`, which has the asserts, which will throw an error if they're bad. - the decompiler won't emit the `heap-base` parameter unless necessary now. - the decompiler will try its hardest to turn a fixed-offset field into an `overlay-at` field. It falls back to the old offset if all else fails. - `overlay-at` now supports field "dereferencing" to specify the offset that's within a field that's a structure, e.g.: ```lisp (deftype foobar (structure) ((vec vector :inline) (flags int32 :overlay-at (-> vec w)) ) ) ``` in this structure, the offset of `flags` will be 12 because that is the final offset of `vec`'s `w` field within this structure. - **removed ID from all method declarations.** IDs are only ever automatically assigned now. Fixes #3068. - added an `:overlay` parameter to method declarations, in order to declare a new method that goes on top of a previously-defined method. Syntax is `:overlay <method-name>`. Please do not ever use this. - added `state-methods` list parameter. This lets you quickly specify a list of states to be put in the method table. Same syntax as the `states` list parameter. The decompiler will try to put as many states in this as it can without messing with the method ID order. Also changes `defmethod` to make the first type definition (before the arguments) optional. The type can now be inferred from the first argument. Fixes #3093. --------- Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
162 lines
4.4 KiB
Common Lisp
Vendored
Generated
162 lines
4.4 KiB
Common Lisp
Vendored
Generated
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; definition of type tr-stat
|
|
(deftype tr-stat (structure)
|
|
((groups uint16)
|
|
(fragments uint16)
|
|
(tris uint32)
|
|
(dverts uint32)
|
|
(instances uint16)
|
|
(pad uint16)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type tr-stat
|
|
(defmethod inspect ((this tr-stat))
|
|
(format #t "[~8x] ~A~%" this 'tr-stat)
|
|
(format #t "~Tgroups: ~D~%" (-> this groups))
|
|
(format #t "~Tfragments: ~D~%" (-> this fragments))
|
|
(format #t "~Ttris: ~D~%" (-> this tris))
|
|
(format #t "~Tdverts: ~D~%" (-> this dverts))
|
|
(format #t "~Tinstances: ~D~%" (-> this instances))
|
|
(format #t "~Tpad: ~D~%" (-> this pad))
|
|
this
|
|
)
|
|
|
|
;; definition of type merc-global-stats
|
|
(deftype merc-global-stats (structure)
|
|
((merc tr-stat :inline)
|
|
(mercneric tr-stat :inline)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type merc-global-stats
|
|
(defmethod inspect ((this merc-global-stats))
|
|
(format #t "[~8x] ~A~%" this 'merc-global-stats)
|
|
(format #t "~Tmerc: #<tr-stat @ #x~X>~%" (-> this merc))
|
|
(format #t "~Tmercneric: #<tr-stat @ #x~X>~%" (-> this mercneric))
|
|
this
|
|
)
|
|
|
|
;; definition of type perf-stat
|
|
(deftype perf-stat (structure)
|
|
((frame-number uint32)
|
|
(count uint32)
|
|
(cycles uint32)
|
|
(instructions uint32)
|
|
(icache uint32)
|
|
(dcache uint32)
|
|
(select uint32)
|
|
(ctrl uint32)
|
|
(accum0 uint32)
|
|
(accum1 uint32)
|
|
(to-vu0-waits uint32)
|
|
(to-spr-waits uint32)
|
|
(from-spr-waits uint32)
|
|
)
|
|
:pack-me
|
|
(:methods
|
|
(perf-stat-method-9 (_type_) none)
|
|
(print-to-stream (_type_ string basic) none)
|
|
(reset! (_type_) none)
|
|
(read! (_type_) none)
|
|
(update-wait-stats (_type_ uint uint uint) none)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type perf-stat
|
|
(defmethod inspect ((this perf-stat))
|
|
(format #t "[~8x] ~A~%" this 'perf-stat)
|
|
(format #t "~Tframe-number: ~D~%" (-> this frame-number))
|
|
(format #t "~Tcount: ~D~%" (-> this count))
|
|
(format #t "~Tcycles: ~D~%" (-> this cycles))
|
|
(format #t "~Tinstructions: ~D~%" (-> this instructions))
|
|
(format #t "~Ticache: ~D~%" (-> this icache))
|
|
(format #t "~Tdcache: ~D~%" (-> this dcache))
|
|
(format #t "~Tselect: ~D~%" (-> this select))
|
|
(format #t "~Tctrl: ~D~%" (-> this ctrl))
|
|
(format #t "~Taccum0: ~D~%" (-> this accum0))
|
|
(format #t "~Taccum1: ~D~%" (-> this accum1))
|
|
(format #t "~Tto-vu0-waits: ~D~%" (-> this to-vu0-waits))
|
|
(format #t "~Tto-spr-waits: ~D~%" (-> this to-spr-waits))
|
|
(format #t "~Tfrom-spr-waits: ~D~%" (-> this from-spr-waits))
|
|
this
|
|
)
|
|
|
|
;; definition of type perf-stat-array
|
|
(deftype perf-stat-array (inline-array-class)
|
|
((data perf-stat :inline :dynamic)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type perf-stat-array
|
|
(defmethod inspect ((this perf-stat-array))
|
|
(format #t "[~8x] ~A~%" this (-> this type))
|
|
(format #t "~Tlength: ~D~%" (-> this length))
|
|
(format #t "~Tallocated-length: ~D~%" (-> this allocated-length))
|
|
(format #t "~Tdata[0] @ #x~X~%" (-> this data))
|
|
this
|
|
)
|
|
|
|
;; failed to figure out what this is:
|
|
(set! (-> perf-stat-array heap-base) (the-as uint 52))
|
|
|
|
;; definition for method 11 of type perf-stat
|
|
;; INFO: Return type mismatch int vs none.
|
|
(defmethod reset! ((this perf-stat))
|
|
(let ((v1-0 (-> this ctrl)))
|
|
(+! (-> this count) 1)
|
|
(b! (zero? v1-0) cfg-2 :delay (nop!))
|
|
(.mtc0 Perf 0)
|
|
(.sync.l)
|
|
(.sync.p)
|
|
(.mtpc pcr0 0)
|
|
(.mtpc pcr1 0)
|
|
(.sync.l)
|
|
(.sync.p)
|
|
(.mtc0 Perf v1-0)
|
|
)
|
|
(.sync.l)
|
|
(.sync.p)
|
|
(label cfg-2)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
;; definition for method 12 of type perf-stat
|
|
;; INFO: Return type mismatch int vs none.
|
|
(defmethod read! ((this perf-stat))
|
|
(local-vars (v1-1 int) (v1-3 int))
|
|
(b! (zero? (-> this ctrl)) cfg-2 :delay (nop!))
|
|
(.mtc0 Perf 0)
|
|
(.sync.l)
|
|
(.sync.p)
|
|
(.mfpc v1-1 pcr0)
|
|
(+! (-> this accum0) v1-1)
|
|
(.mfpc v1-3 pcr1)
|
|
(+! (-> this accum1) v1-3)
|
|
(label cfg-2)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
;; definition for method 13 of type perf-stat
|
|
;; INFO: Return type mismatch int vs none.
|
|
(defmethod update-wait-stats ((this perf-stat) (arg0 uint) (arg1 uint) (arg2 uint))
|
|
(when (nonzero? (-> this ctrl))
|
|
(+! (-> this to-vu0-waits) arg0)
|
|
(+! (-> this to-spr-waits) arg1)
|
|
(+! (-> this from-spr-waits) arg2)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
;; failed to figure out what this is:
|
|
(when (not *debug-segment*)
|
|
(set! (-> perf-stat method-table 11) nothing)
|
|
(set! (-> perf-stat method-table 12) nothing)
|
|
(set! (-> perf-stat method-table 13) nothing)
|
|
)
|