[decompiler] Support accessing 128-bit bitfields (#514)

* support some 128-bit bitfield stuff

* fix bug

* support type stuff correctly
This commit is contained in:
water111
2021-05-21 20:36:04 -04:00
committed by GitHub
parent 6ac399ca33
commit 3fbdd662dc
14 changed files with 497 additions and 279 deletions
+15 -82
View File
@@ -112,94 +112,27 @@
)
;; definition for method 3 of type vec4s
;; INFO: Return type mismatch uint128 vs vec4s.
;; WARN: Unsupported inline assembly instruction kind - [por gp, a0, r0]
;; WARN: Unsupported inline assembly instruction kind - [por a2, gp, r0]
;; WARN: Unsupported inline assembly instruction kind - [sllv a2, gp, r0]
;; WARN: Unsupported inline assembly instruction kind - [sllv a2, v1, r0]
;; WARN: Unsupported inline assembly instruction kind - [por v0, gp, r0]
(defmethod inspect vec4s ((obj vec4s))
(local-vars
(r0-0 none)
(v0-5 uint128)
(v1-0 uint128)
(v1-1 uint128)
(a2-0 uint128)
(a2-1 uint128)
(a2-3 uint128)
(gp-0 uint128)
)
(.por gp-0 obj r0-0)
(let ((t9-0 format)
(a0-1 #t)
(a1-0 "[~8x] ~A~%")
)
(.por a2-0 gp-0 r0-0)
(t9-0 a0-1 a1-0 a2-0 'vec4s)
)
(let ((t9-1 format)
(a0-2 #t)
(a1-1 "~Tx: ~f~%")
)
(.sllv a2-1 gp-0 r0-0)
(t9-1 a0-2 a1-1 a2-1)
)
(format #t "~Ty: ~f~%" (sar (the-as int gp-0) 32))
(let ((t9-3 format)
(a0-4 #t)
(a1-3 "~Tz: ~f~%")
)
(.pcpyud v1-0 gp-0 r0-0)
(.sllv a2-3 v1-0 r0-0)
(t9-3 a0-4 a1-3 a2-3)
)
(let ((t9-4 format)
(a0-5 #t)
(a1-4 "~Tw: ~f~%")
)
(.pcpyud v1-1 gp-0 r0-0)
(t9-4 a0-5 a1-4 (sar (the-as int v1-1) 32))
)
(.por v0-5 gp-0 r0-0)
(the-as vec4s v0-5)
(format #t "[~8x] ~A~%" obj 'vec4s)
(format #t "~Tx: ~f~%" (-> obj x))
(format #t "~Ty: ~f~%" (-> obj y))
(format #t "~Tz: ~f~%" (-> obj z))
(format #t "~Tw: ~f~%" (-> obj w))
obj
)
;; definition for method 2 of type vec4s
;; INFO: Return type mismatch uint128 vs vec4s.
;; WARN: Unsupported inline assembly instruction kind - [por gp, a0, r0]
;; WARN: Unsupported inline assembly instruction kind - [sllv a2, gp, r0]
;; WARN: Unsupported inline assembly instruction kind - [sllv t0, v1, r0]
;; WARN: Unsupported inline assembly instruction kind - [por t2, gp, r0]
;; WARN: Unsupported inline assembly instruction kind - [por v0, gp, r0]
(defmethod print vec4s ((obj vec4s))
(local-vars
(r0-0 none)
(v0-1 uint128)
(v1-0 uint128)
(v1-1 uint128)
(a2-0 uint128)
(t0-0 uint128)
(t2-0 uint128)
(gp-0 uint128)
(format
#t
"#<vector ~F ~F ~F ~F @ #x~X>"
(-> obj x)
(-> obj y)
(-> obj z)
(-> obj w)
obj
)
(.por gp-0 obj r0-0)
(let ((t9-0 format)
(a0-1 #t)
(a1-0 "#<vector ~F ~F ~F ~F @ #x~X>")
)
(.sllv a2-0 gp-0 r0-0)
(let ((a3-0 (sar (the-as int gp-0) 32)))
(.pcpyud v1-0 gp-0 r0-0)
(.sllv t0-0 v1-0 r0-0)
(.pcpyud v1-1 gp-0 r0-0)
(let ((t1-0 (sar (the-as int v1-1) 32)))
(.por t2-0 gp-0 r0-0)
(t9-0 a0-1 a1-0 a2-0 a3-0 t0-0 t1-0 t2-0)
)
)
)
(.por v0-1 gp-0 r0-0)
(the-as vec4s v0-1)
obj
)
;; definition of type bfloat
@@ -286,9 +286,8 @@
;; definition for method 2 of type handle
;; WARN: Unsupported inline assembly instruction kind - [subu a2, v1, s7]
;; WARN: Unsupported inline assembly instruction kind - [sllv a2, v1, r0]
(defmethod print handle ((obj handle))
(local-vars (r0-0 none) (a2-0 int) (a2-2 (pointer process)) (s7-0 none))
(local-vars (a2-0 int) (s7-0 none))
(cond
((nonzero? obj)
(let ((t9-0 format)
@@ -297,15 +296,17 @@
(v1-0 obj)
)
(.subu a2-0 v1-0 s7-0)
(t9-0 a0-1 a1-0 (and (nonzero? a2-0) (begin
(.sllv a2-2 v1-0 r0-0)
(let ((a3-0 (-> a2-2 0)))
(if (= (-> v1-0 pid) (-> a3-0 pid))
a3-0
)
)
)
)
(t9-0
a0-1
a1-0
(and
(nonzero? a2-0)
(let ((a3-0 (-> (the-as (pointer process) (-> v1-0 process)) 0)))
(if (= (-> v1-0 pid) (-> a3-0 pid))
a3-0
)
)
)
(-> obj pid)
)
)