[OpenGOAL] make multiplication/divsion like GOAL and support in decompiler (#483)

* support in compiler

* multiplication in the decompiler

* update divisions
This commit is contained in:
water111
2021-05-14 18:43:12 -04:00
committed by GitHub
parent b3eb05e37f
commit d9f9d36f37
31 changed files with 441 additions and 326 deletions
@@ -24,7 +24,7 @@
(set! (-> s5-0 z) f0-2)
)
)
(when (= (logand (sar (the int (-> s5-0 w)) 2) 1) 1)
(when (= (logand (/ (the int (-> s5-0 w)) 4) 1) 1)
(set! (-> s5-0 x) (- (-> s5-0 x)))
(set! (-> s5-0 y) (- (-> s5-0 y)))
(set! (-> s5-0 z) (- (-> s5-0 z)))
@@ -46,18 +46,18 @@
)
(let ((v1-9 0))
)
(let* ((v1-12 (logand (sar (the int (-> s5-0 w)) 2) 1))
(a1-2 (-> EulSafe (logand (sar (the int (-> s5-0 w)) 3) 3)))
(let* ((v1-12 (logand (/ (the int (-> s5-0 w)) 4) 1))
(a1-2 (-> EulSafe (logand (/ (the int (-> s5-0 w)) 8) 3)))
(a0-21 (-> EulNext (+ a1-2 v1-12)))
(v1-17 (-> EulNext (+ (- 1 v1-12) a1-2)))
)
(cond
((= (logand (sar (the int (-> s5-0 w)) 1) 1) 1)
((= (logand (/ (the int (-> s5-0 w)) 2) 1) 1)
(set!
(->
(the-as
(pointer float)
(+ (+ (shl a1-2 4) (shl a1-2 2)) (the-as int arg0))
(+ (+ (* a1-2 16) (* a1-2 4)) (the-as int arg0))
)
)
f30-0
@@ -66,7 +66,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl a1-2 4) (shl a0-21 2)) (the-as int arg0))
(+ (+ (* a1-2 16) (* a0-21 4)) (the-as int arg0))
)
)
(* f28-0 f24-0)
@@ -75,7 +75,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl a1-2 4) (shl v1-17 2)) (the-as int arg0))
(+ (+ (* a1-2 16) (* v1-17 4)) (the-as int arg0))
)
)
(* f28-0 f26-0)
@@ -84,7 +84,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl a0-21 4) (shl a1-2 2)) (the-as int arg0))
(+ (+ (* a0-21 16) (* a1-2 4)) (the-as int arg0))
)
)
(* f28-0 f4-0)
@@ -93,7 +93,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl a0-21 4) (shl a0-21 2)) (the-as int arg0))
(+ (+ (* a0-21 16) (* a0-21 4)) (the-as int arg0))
)
)
(- f0-17 (* f30-0 f3-0))
@@ -102,7 +102,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl a0-21 4) (shl v1-17 2)) (the-as int arg0))
(+ (+ (* a0-21 16) (* v1-17 4)) (the-as int arg0))
)
)
(- (- f2-0) (* f30-0 f1-1))
@@ -111,7 +111,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl v1-17 4) (shl a1-2 2)) (the-as int arg0))
(+ (+ (* v1-17 16) (* a1-2 4)) (the-as int arg0))
)
)
(- (* f28-0 f22-0))
@@ -120,7 +120,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl v1-17 4) (shl a0-21 2)) (the-as int arg0))
(+ (+ (* v1-17 16) (* a0-21 4)) (the-as int arg0))
)
)
(+ f1-1 (* f30-0 f2-0))
@@ -129,7 +129,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl v1-17 4) (shl v1-17 2)) (the-as int arg0))
(+ (+ (* v1-17 16) (* v1-17 4)) (the-as int arg0))
)
)
(+ (- f3-0) (* f30-0 f0-17))
@@ -140,7 +140,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl a1-2 4) (shl a1-2 2)) (the-as int arg0))
(+ (+ (* a1-2 16) (* a1-2 4)) (the-as int arg0))
)
)
(* f30-0 f22-0)
@@ -149,7 +149,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl a1-2 4) (shl a0-21 2)) (the-as int arg0))
(+ (+ (* a1-2 16) (* a0-21 4)) (the-as int arg0))
)
)
(+ (- f1-1) (* f28-0 f2-0))
@@ -158,7 +158,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl a1-2 4) (shl v1-17 2)) (the-as int arg0))
(+ (+ (* a1-2 16) (* v1-17 4)) (the-as int arg0))
)
)
(+ f3-0 (* f28-0 f0-17))
@@ -167,7 +167,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl a0-21 4) (shl a1-2 2)) (the-as int arg0))
(+ (+ (* a0-21 16) (* a1-2 4)) (the-as int arg0))
)
)
(* f30-0 f4-0)
@@ -176,7 +176,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl a0-21 4) (shl a0-21 2)) (the-as int arg0))
(+ (+ (* a0-21 16) (* a0-21 4)) (the-as int arg0))
)
)
(+ f0-17 (* f28-0 f3-0))
@@ -185,7 +185,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl a0-21 4) (shl v1-17 2)) (the-as int arg0))
(+ (+ (* a0-21 16) (* v1-17 4)) (the-as int arg0))
)
)
(+ (- f2-0) (* f28-0 f1-1))
@@ -194,7 +194,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl v1-17 4) (shl a1-2 2)) (the-as int arg0))
(+ (+ (* v1-17 16) (* a1-2 4)) (the-as int arg0))
)
)
(- f28-0)
@@ -203,7 +203,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl v1-17 4) (shl a0-21 2)) (the-as int arg0))
(+ (+ (* v1-17 16) (* a0-21 4)) (the-as int arg0))
)
)
(* f30-0 f24-0)
@@ -212,7 +212,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl v1-17 4) (shl v1-17 2)) (the-as int arg0))
(+ (+ (* v1-17 16) (* v1-17 4)) (the-as int arg0))
)
)
(* f30-0 f26-0)
@@ -233,19 +233,19 @@
)
(let ((v1-2 0))
)
(let* ((v1-4 (logand (sar arg2 2) 1))
(s3-0 (-> EulSafe (logand (sar arg2 3) 3)))
(let* ((v1-4 (logand (/ arg2 4) 1))
(s3-0 (-> EulSafe (logand (/ arg2 8) 3)))
(s2-0 (-> EulNext (+ s3-0 v1-4)))
(s1-0 (-> EulNext (+ (- 1 v1-4) s3-0)))
)
(cond
((= (logand (sar arg2 1) 1) 1)
((= (logand (/ arg2 2) 1) 1)
(let*
((f0-0
(->
(the-as
(pointer float)
(+ (+ (shl s2-0 2) (shl s3-0 4)) (the-as int arg1))
(+ (+ (* s2-0 4) (* s3-0 16)) (the-as int arg1))
)
)
)
@@ -254,7 +254,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl s1-0 2) (shl s3-0 4)) (the-as int arg1))
(+ (+ (* s1-0 4) (* s3-0 16)) (the-as int arg1))
)
)
)
@@ -268,13 +268,13 @@
(->
(the-as
(pointer float)
(+ (+ (shl s2-0 2) (shl s3-0 4)) (the-as int arg1))
(+ (+ (* s2-0 4) (* s3-0 16)) (the-as int arg1))
)
)
(->
(the-as
(pointer float)
(+ (+ (shl s1-0 2) (shl s3-0 4)) (the-as int arg1))
(+ (+ (* s1-0 4) (* s3-0 16)) (the-as int arg1))
)
)
)
@@ -286,7 +286,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl s3-0 2) (shl s3-0 4)) (the-as int arg1))
(+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1))
)
)
)
@@ -297,14 +297,14 @@
(->
(the-as
(pointer float)
(+ (+ (shl s3-0 2) (shl s2-0 4)) (the-as int arg1))
(+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1))
)
)
(-
(->
(the-as
(pointer float)
(+ (+ (shl s3-0 2) (shl s1-0 4)) (the-as int arg1))
(+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1))
)
)
)
@@ -319,14 +319,14 @@
(->
(the-as
(pointer float)
(+ (+ (shl s1-0 2) (shl s2-0 4)) (the-as int arg1))
(+ (+ (* s1-0 4) (* s2-0 16)) (the-as int arg1))
)
)
)
(->
(the-as
(pointer float)
(+ (+ (shl s2-0 2) (shl s2-0 4)) (the-as int arg1))
(+ (+ (* s2-0 4) (* s2-0 16)) (the-as int arg1))
)
)
)
@@ -338,7 +338,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl s3-0 2) (shl s3-0 4)) (the-as int arg1))
(+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1))
)
)
)
@@ -354,7 +354,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl s3-0 2) (shl s3-0 4)) (the-as int arg1))
(+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1))
)
)
)
@@ -363,7 +363,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl s3-0 2) (shl s2-0 4)) (the-as int arg1))
(+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1))
)
)
)
@@ -377,13 +377,13 @@
(->
(the-as
(pointer float)
(+ (+ (shl s2-0 2) (shl s1-0 4)) (the-as int arg1))
(+ (+ (* s2-0 4) (* s1-0 16)) (the-as int arg1))
)
)
(->
(the-as
(pointer float)
(+ (+ (shl s1-0 2) (shl s1-0 4)) (the-as int arg1))
(+ (+ (* s1-0 4) (* s1-0 16)) (the-as int arg1))
)
)
)
@@ -395,7 +395,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl s3-0 2) (shl s1-0 4)) (the-as int arg1))
(+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1))
)
)
)
@@ -408,13 +408,13 @@
(->
(the-as
(pointer float)
(+ (+ (shl s3-0 2) (shl s2-0 4)) (the-as int arg1))
(+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1))
)
)
(->
(the-as
(pointer float)
(+ (+ (shl s3-0 2) (shl s3-0 4)) (the-as int arg1))
(+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1))
)
)
)
@@ -428,14 +428,14 @@
(->
(the-as
(pointer float)
(+ (+ (shl s1-0 2) (shl s2-0 4)) (the-as int arg1))
(+ (+ (* s1-0 4) (* s2-0 16)) (the-as int arg1))
)
)
)
(->
(the-as
(pointer float)
(+ (+ (shl s2-0 2) (shl s2-0 4)) (the-as int arg1))
(+ (+ (* s2-0 4) (* s2-0 16)) (the-as int arg1))
)
)
)
@@ -447,7 +447,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl s3-0 2) (shl s1-0 4)) (the-as int arg1))
(+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1))
)
)
)
@@ -461,7 +461,7 @@
)
)
)
(when (= (logand (sar arg2 2) 1) 1)
(when (= (logand (/ arg2 4) 1) 1)
(set! (-> arg0 x) (- (-> arg0 x)))
(set! (-> arg0 y) (- (-> arg0 y)))
(set! (-> arg0 z) (- (-> arg0 z)))
@@ -481,7 +481,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl a2-0 2) (shl a2-0 4)) (the-as int arg1))
(+ (+ (* a2-0 4) (* a2-0 16)) (the-as int arg1))
)
)
(-> arg1 data 10)
@@ -500,13 +500,13 @@
(->
(the-as
(pointer float)
(+ (+ (shl a3-0 2) (shl a3-0 4)) (the-as int arg1))
(+ (+ (* a3-0 4) (* a3-0 16)) (the-as int arg1))
)
)
(->
(the-as
(pointer float)
(+ (+ (shl v1-1 2) (shl v1-1 4)) (the-as int arg1))
(+ (+ (* v1-1 4) (* v1-1 16)) (the-as int arg1))
)
)
)
@@ -514,7 +514,7 @@
(->
(the-as
(pointer float)
(+ (+ (shl a2-0 2) (shl a2-0 4)) (the-as int arg1))
(+ (+ (* a2-0 4) (* a2-0 16)) (the-as int arg1))
)
)
)
@@ -522,7 +522,7 @@
)
)
(set!
(-> (the-as (pointer float) (+ (shl a2-0 2) (the-as int arg0))))
(-> (the-as (pointer float) (+ (* a2-0 4) (the-as int arg0))))
(* 0.5 f0-12)
)
(if (!= f0-12 0.0)
@@ -535,13 +535,13 @@
(->
(the-as
(pointer float)
(+ (+ (shl v1-1 2) (shl a3-0 4)) (the-as int arg1))
(+ (+ (* v1-1 4) (* a3-0 16)) (the-as int arg1))
)
)
(->
(the-as
(pointer float)
(+ (+ (shl a3-0 2) (shl v1-1 4)) (the-as int arg1))
(+ (+ (* a3-0 4) (* v1-1 16)) (the-as int arg1))
)
)
)
@@ -549,19 +549,19 @@
)
)
(set!
(-> (the-as (pointer float) (+ (shl a3-0 2) (the-as int arg0))))
(-> (the-as (pointer float) (+ (* a3-0 4) (the-as int arg0))))
(*
(+
(->
(the-as
(pointer float)
(+ (+ (shl a3-0 2) (shl a2-0 4)) (the-as int arg1))
(+ (+ (* a3-0 4) (* a2-0 16)) (the-as int arg1))
)
)
(->
(the-as
(pointer float)
(+ (+ (shl a2-0 2) (shl a3-0 4)) (the-as int arg1))
(+ (+ (* a2-0 4) (* a3-0 16)) (the-as int arg1))
)
)
)
@@ -569,19 +569,19 @@
)
)
(set!
(-> (the-as (pointer float) (+ (shl v1-1 2) (the-as int arg0))))
(-> (the-as (pointer float) (+ (* v1-1 4) (the-as int arg0))))
(*
(+
(->
(the-as
(pointer float)
(+ (+ (shl v1-1 2) (shl a2-0 4)) (the-as int arg1))
(+ (+ (* v1-1 4) (* a2-0 16)) (the-as int arg1))
)
)
(->
(the-as
(pointer float)
(+ (+ (shl a2-0 2) (shl v1-1 4)) (the-as int arg1))
(+ (+ (* a2-0 4) (* v1-1 16)) (the-as int arg1))
)
)
)
@@ -36,7 +36,7 @@
allocation
type-to-make
(+
(+ (sar (logand -8 (+ length 7)) 3) -1)
(+ (/ (logand -8 (+ length 7)) 8) -1)
(the-as int (-> type-to-make size))
)
)
@@ -60,14 +60,14 @@
int
(+
(-> obj type size)
(the-as uint (sar (logand -8 (+ (-> obj allocated-length) 7)) 3))
(the-as uint (/ (logand -8 (+ (-> obj allocated-length) 7)) 8))
)
)
)
;; definition for method 9 of type bit-array
(defmethod get-bit bit-array ((obj bit-array) (arg0 int))
(let ((v1-2 (-> obj bytes (sar arg0 3))))
(let ((v1-2 (-> obj bytes (/ arg0 8))))
(nonzero? (logand v1-2 (the-as uint (ash 1 (logand arg0 7)))))
)
)
@@ -75,9 +75,9 @@
;; definition for method 10 of type bit-array
(defmethod clear-bit bit-array ((obj bit-array) (arg0 int))
(set!
(-> obj bytes (sar arg0 3))
(-> obj bytes (/ arg0 8))
(logand
(-> obj bytes (sar arg0 3))
(-> obj bytes (/ arg0 8))
(the-as uint (lognot (ash 1 (logand arg0 7))))
)
)
@@ -87,15 +87,15 @@
;; definition for method 11 of type bit-array
(defmethod set-bit bit-array ((obj bit-array) (arg0 int))
(set!
(-> obj bytes (sar arg0 3))
(logior (-> obj bytes (sar arg0 3)) (the-as uint (ash 1 (logand arg0 7))))
(-> obj bytes (/ arg0 8))
(logior (-> obj bytes (/ arg0 8)) (the-as uint (ash 1 (logand arg0 7))))
)
0
)
;; definition for method 12 of type bit-array
(defmethod clear bit-array ((obj bit-array))
(let ((idx (sar (logand -8 (+ (-> obj allocated-length) 7)) 3)))
(let ((idx (/ (logand -8 (+ (-> obj allocated-length) 7)) 8)))
(while (nonzero? idx)
(+! idx -1)
(nop!)
@@ -963,7 +963,3 @@
;; definition for symbol *zero-vector*, type vector
(define *zero-vector* (new 'static 'vector))