diff --git a/decompiler/analysis/atomic_op_builder.cpp b/decompiler/analysis/atomic_op_builder.cpp index 5c50f3f62..c61fbb62d 100644 --- a/decompiler/analysis/atomic_op_builder.cpp +++ b/decompiler/analysis/atomic_op_builder.cpp @@ -537,6 +537,11 @@ std::unique_ptr convert_mtc1_1(const Instruction& i0, int idx) { } std::unique_ptr convert_mfc1_1(const Instruction& i0, int idx) { + if (i0.get_dst(0).is_reg(rr0()) && i0.get_src(0).is_reg(Register(Reg::FPR, 31))) { + // mfc r0, f31 is a nop + return std::make_unique(SpecialOp::Kind::NOP, idx); + } + if (i0.get_dst(0).is_reg(rr0()) || i0.get_dst(0).is_reg(make_gpr(Reg::AT)) || i0.get_dst(0).is_reg(rra())) { // sometimes mfc1 r0, f31 is used like a 'nop'. No idea why. diff --git a/test/decompiler/reference/jak1/engine/ambient/mood_REF.gc b/test/decompiler/reference/jak1/engine/ambient/mood_REF.gc index 7f947e222..4e288d09e 100644 --- a/test/decompiler/reference/jak1/engine/ambient/mood_REF.gc +++ b/test/decompiler/reference/jak1/engine/ambient/mood_REF.gc @@ -32,12 +32,8 @@ ;; definition for function update-mood-itimes ;; INFO: Used lq/sq ;; INFO: Return type mismatch int vs none. -;; WARN: Function may read a register that is not set: f31 (defun update-mood-itimes ((arg0 mood-context)) (local-vars - (r0-0 int) - (r0-1 int) - (r0-2 int) (v1-0 uint128) (v1-1 uint128) (v1-2 uint128) @@ -58,7 +54,6 @@ (t2-1 uint128) (t3-0 uint128) (t3-1 uint128) - (f31-0 none) ) (rlet ((vf1 :class vf) (vf2 :class vf) @@ -123,11 +118,11 @@ (.mov t3-0 vf8) (.pw.sra t1-1 t1-0 6) (.pw.sra t2-1 t2-0 6) - (.mov r0-0 f31-0) + (nop!) (.pw.sra t3-1 t3-0 6) - (.mov r0-1 f31-0) + (nop!) (.ppach v1-2 a1-1 v1-1) - (.mov r0-2 f31-0) + (nop!) (.ppach a1-2 a3-1 a2-1) (set! (-> arg0 itimes 0 quad) v1-2) (.ppach v1-3 t1-1 t0-1) diff --git a/test/decompiler/reference/jak1/engine/collide/collide-mesh_REF.gc b/test/decompiler/reference/jak1/engine/collide/collide-mesh_REF.gc index 511365005..94fa72bbe 100644 --- a/test/decompiler/reference/jak1/engine/collide/collide-mesh_REF.gc +++ b/test/decompiler/reference/jak1/engine/collide/collide-mesh_REF.gc @@ -357,12 +357,8 @@ ;; definition for method 10 of type collide-mesh ;; INFO: Used lq/sq -;; WARN: Function may read a register that is not set: f31 (defmethod overlap-test collide-mesh ((obj collide-mesh) (arg0 collide-mesh-cache-tri) (arg1 vector)) (local-vars - (r0-0 int) - (r0-1 int) - (r0-2 int) (v1-0 uint128) (a0-1 uint128) (a1-2 uint128) @@ -371,7 +367,6 @@ (a1-7 float) (a2-1 uint128) (a2-2 uint128) - (f31-0 none) ) (rlet ((acc :class vf) (vf0 :class vf) @@ -402,14 +397,14 @@ ) (let ((a1-1 (-> s4-0 bbox4w max quad))) (.pcgtw a2-2 a2-1 a0-1) - (.mov r0-0 f31-0) + (nop!) (.pcgtw a1-2 v1-0 a1-1) ) - (.mov r0-1 f31-0) + (nop!) (.por a1-3 a2-2 a1-2) (nop!) (.ppach a1-4 (the-as uint128 0) a1-3) - (.mov r0-2 f31-0) + (nop!) (let ((a1-5 (shl (the-as int a1-4) 16))) (nop!) (b! (nonzero? a1-5) cfg-1 :likely-delay (set! s4-0 (+ s4-0 96))) diff --git a/test/decompiler/reference/jak1/engine/collide/main-collide_REF.gc b/test/decompiler/reference/jak1/engine/collide/main-collide_REF.gc index f121e6c9e..1598a230d 100644 --- a/test/decompiler/reference/jak1/engine/collide/main-collide_REF.gc +++ b/test/decompiler/reference/jak1/engine/collide/main-collide_REF.gc @@ -3,21 +3,8 @@ ;; definition for function drawable-sphere-box-intersect? ;; INFO: Used lq/sq -;; WARN: Function may read a register that is not set: f31 (defun drawable-sphere-box-intersect? ((arg0 drawable) (arg1 bounding-box4w)) - (local-vars - (r0-0 int) - (r0-1 int) - (r0-2 int) - (r0-3 int) - (v1-1 uint128) - (v1-2 uint128) - (v1-3 uint128) - (a0-1 uint128) - (a1-2 uint128) - (a2-0 uint128) - (f31-0 none) - ) + (local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128) (a0-1 uint128) (a1-2 uint128) (a2-0 uint128)) (rlet ((vf1 :class vf) (vf2 :class vf) (vf3 :class vf) @@ -40,14 +27,14 @@ (nop!) (.pcgtw a1-2 a2-0 a1-1) ) - (.mov r0-0 f31-0) + (nop!) (.pcgtw v1-1 v1-0 a0-1) ) - (.mov r0-1 f31-0) + (nop!) (.por v1-2 a1-2 v1-1) - (.mov r0-2 f31-0) + (nop!) (.ppach v1-3 (the-as uint128 0) v1-2) - (.mov r0-3 f31-0) + (nop!) (let ((v1-4 (shl (the-as int v1-3) 16))) (nop!) (zero? v1-4) @@ -57,15 +44,8 @@ ;; definition for function instance-sphere-box-intersect? ;; INFO: Used lq/sq -;; WARN: Function may read a register that is not set: f31 (defun instance-sphere-box-intersect? ((arg0 drawable) (arg1 instance-tie) (arg2 bounding-box4w)) (local-vars - (r0-0 int) - (r0-1 int) - (r0-2 int) - (r0-3 int) - (r0-4 int) - (r0-5 int) (v1-3 uint128) (v1-4 uint128) (v1-5 uint128) @@ -80,7 +60,6 @@ (t1-0 uint128) (t2-1 uint128) (t2-2 uint128) - (f31-0 none) ) (rlet ((acc :class vf) (vf0 :class vf) @@ -107,9 +86,9 @@ (.pw.sra t1-0 a3-1 10) (let ((a3-2 (the-as uint128 (-> arg1 origin vector4h 2 long)))) (.pextlh t2-1 t2-0 0) - (.mov r0-0 f31-0) + (nop!) (.pw.sra t2-2 t2-1 16) - (.mov r0-1 f31-0) + (nop!) (.pextlh t0-1 t0-0 0) (.mov vf8 t1-0) (.pw.sra t0-2 t0-1 16) @@ -165,14 +144,14 @@ (nop!) (.pcgtw a1-2 a2-1 a1-1) ) - (.mov r0-2 f31-0) + (nop!) (.pcgtw v1-3 v1-2 a0-2) ) - (.mov r0-3 f31-0) + (nop!) (.por v1-4 a1-2 v1-3) - (.mov r0-4 f31-0) + (nop!) (.ppach v1-5 (the-as uint128 0) v1-4) - (.mov r0-5 f31-0) + (nop!) (let ((v1-6 (shl (the-as int v1-5) 16))) (nop!) (zero? v1-6) diff --git a/test/decompiler/reference/jak1/engine/gfx/ocean/ocean-mid_REF.gc b/test/decompiler/reference/jak1/engine/gfx/ocean/ocean-mid_REF.gc index 866afd884..40e4e88c8 100644 --- a/test/decompiler/reference/jak1/engine/gfx/ocean/ocean-mid_REF.gc +++ b/test/decompiler/reference/jak1/engine/gfx/ocean/ocean-mid_REF.gc @@ -661,14 +661,8 @@ ;; definition for function ocean-mid-add-upload-table ;; INFO: Used lq/sq -;; WARN: Function may read a register that is not set: f31 (defun ocean-mid-add-upload-table ((arg0 dma-buffer) (arg1 uint) (arg2 uint) (arg3 (pointer float)) (arg4 int) (arg5 symbol)) (local-vars - (r0-0 int) - (r0-1 int) - (r0-2 int) - (r0-3 int) - (r0-4 int) (v1-8 float) (a0-19 uint128) (a0-20 uint128) @@ -678,7 +672,6 @@ (a1-16 uint128) (a2-15 uint128) (a3-11 uint128) - (f31-0 none) ) (rlet ((vf1 :class vf) (vf2 :class vf) @@ -719,16 +712,16 @@ (a3-10 (the-as uint128 (-> *ocean-map* ocean-colors colors (+ arg2 1 (* 52 (the-as int (+ arg1 1))))))) ) (.pextlb a0-19 0 a0-18) - (.mov r0-0 f31-0) + (nop!) (.pextlb a1-14 0 a1-13) - (.mov r0-1 f31-0) + (nop!) (.pextlb a2-15 0 a2-14) - (.mov r0-2 f31-0) + (nop!) (.pextlb a3-11 0 a3-10) ) - (.mov r0-3 f31-0) + (nop!) (.pextlh a0-20 0 a0-19) - (.mov r0-4 f31-0) + (nop!) (.pextlh a1-15 0 a1-14) (.mov vf1 a0-20) (.pextlh a0-21 0 a2-15) diff --git a/test/decompiler/reference/jak1/engine/gfx/ocean/ocean-near_REF.gc b/test/decompiler/reference/jak1/engine/gfx/ocean/ocean-near_REF.gc index ecbed78cd..85e4f823d 100644 --- a/test/decompiler/reference/jak1/engine/gfx/ocean/ocean-near_REF.gc +++ b/test/decompiler/reference/jak1/engine/gfx/ocean/ocean-near_REF.gc @@ -435,14 +435,8 @@ ;; definition for function ocean-near-add-upload ;; INFO: Used lq/sq ;; INFO: Return type mismatch pointer vs none. -;; WARN: Function may read a register that is not set: f31 (defun ocean-near-add-upload ((arg0 dma-buffer) (arg1 uint) (arg2 uint)) (local-vars - (r0-0 int) - (r0-1 int) - (r0-2 int) - (r0-3 int) - (r0-4 int) (v1-17 uint128) (v1-18 uint128) (v1-19 float) @@ -453,7 +447,6 @@ (a2-30 uint128) (a2-31 uint128) (a3-27 uint128) - (f31-0 none) ) (rlet ((acc :class vf) (vf1 :class vf) @@ -566,16 +559,16 @@ (v1-16 (the-as uint128 (-> *ocean-map* ocean-colors colors (+ a0-14 1 (* 52 (+ v1-10 1)))))) ) (.pextlb a0-18 0 a2-29) - (.mov r0-0 f31-0) + (nop!) (.pextlb a2-30 0 a3-26) - (.mov r0-1 f31-0) + (nop!) (.pextlb a3-27 0 t0-15) - (.mov r0-2 f31-0) + (nop!) (.pextlb v1-17 0 v1-16) ) - (.mov r0-3 f31-0) + (nop!) (.pextlh a0-19 0 a0-18) - (.mov r0-4 f31-0) + (nop!) (.pextlh a2-31 0 a2-30) (.mov vf1 a0-19) (.pextlh a0-20 0 a3-27) diff --git a/test/decompiler/reference/jak1/engine/gfx/ocean/ocean-transition_REF.gc b/test/decompiler/reference/jak1/engine/gfx/ocean/ocean-transition_REF.gc index 7165170d9..31c0ed42f 100644 --- a/test/decompiler/reference/jak1/engine/gfx/ocean/ocean-transition_REF.gc +++ b/test/decompiler/reference/jak1/engine/gfx/ocean/ocean-transition_REF.gc @@ -100,14 +100,8 @@ ;; definition for function ocean-trans-add-upload-table ;; INFO: Used lq/sq -;; WARN: Function may read a register that is not set: f31 (defun ocean-trans-add-upload-table ((arg0 dma-buffer) (arg1 int) (arg2 int) (arg3 (pointer float)) (arg4 int) (arg5 symbol)) (local-vars - (r0-0 int) - (r0-1 int) - (r0-2 int) - (r0-3 int) - (r0-4 int) (v1-12 (inline-array vector)) (v1-14 float) (a0-23 uint128) @@ -118,7 +112,6 @@ (a2-15 uint128) (a2-16 uint128) (a3-10 uint128) - (f31-0 none) ) (rlet ((acc :class vf) (vf1 :class vf) @@ -215,17 +208,17 @@ (a0-22 (the-as uint128 (-> *ocean-map* ocean-colors colors (+ a1-11 1 (* 52 (+ a0-16 1)))))) ) (.pextlb a1-15 0 a2-14) - (.mov r0-0 f31-0) + (nop!) (.pextlb a2-15 0 a3-9) - (.mov r0-1 f31-0) + (nop!) (.pextlb a3-10 0 t0-10) - (.mov r0-2 f31-0) + (nop!) (.pextlb a0-23 0 a0-22) ) ) - (.mov r0-3 f31-0) + (nop!) (.pextlh a1-16 0 a1-15) - (.mov r0-4 f31-0) + (nop!) (.pextlh a2-16 0 a2-15) (.mov vf1 a1-16) (.pextlh a1-17 0 a3-10) @@ -302,14 +295,8 @@ ;; definition for function ocean-trans-add-upload-strip ;; INFO: Used lq/sq -;; WARN: Function may read a register that is not set: f31 (defun ocean-trans-add-upload-strip ((arg0 dma-buffer) (arg1 uint) (arg2 uint) (arg3 uint) (arg4 uint) (arg5 uint)) (local-vars - (r0-0 int) - (r0-1 int) - (r0-2 int) - (r0-3 int) - (r0-4 int) (v1-8 float) (a0-23 uint128) (a0-24 uint128) @@ -319,7 +306,6 @@ (a1-16 uint128) (a2-15 uint128) (a3-11 uint128) - (f31-0 none) ) (rlet ((vf1 :class vf) (vf2 :class vf) @@ -365,16 +351,16 @@ (a3-10 (the-as uint128 (-> *ocean-map* ocean-colors colors (+ arg2 1 (* 52 (the-as int (+ arg1 1))))))) ) (.pextlb a0-23 0 a0-22) - (.mov r0-0 f31-0) + (nop!) (.pextlb a1-14 0 a1-13) - (.mov r0-1 f31-0) + (nop!) (.pextlb a2-15 0 a2-14) - (.mov r0-2 f31-0) + (nop!) (.pextlb a3-11 0 a3-10) ) - (.mov r0-3 f31-0) + (nop!) (.pextlh a0-24 0 a0-23) - (.mov r0-4 f31-0) + (nop!) (.pextlh a1-15 0 a1-14) (.mov vf1 a0-24) (.pextlh a0-25 0 a2-15) diff --git a/test/decompiler/reference/jak1/engine/math/matrix_REF.gc b/test/decompiler/reference/jak1/engine/math/matrix_REF.gc index 3e698ffe0..d1ed68ca5 100644 --- a/test/decompiler/reference/jak1/engine/math/matrix_REF.gc +++ b/test/decompiler/reference/jak1/engine/math/matrix_REF.gc @@ -228,13 +228,8 @@ ;; definition for function matrix-transpose! ;; INFO: Used lq/sq -;; WARN: Function may read a register that is not set: f31 (defun matrix-transpose! ((dst matrix) (src matrix)) (local-vars - (r0-0 int) - (r0-1 int) - (r0-2 int) - (r0-3 int) (v1-0 uint128) (v1-1 uint128) (v1-2 uint128) @@ -243,7 +238,6 @@ (a3-1 uint128) (a3-2 uint128) (t0-1 uint128) - (f31-0 none) ) (nop!) (nop!) @@ -255,17 +249,17 @@ (.pextlw v1-0 t1-0 t0-0) (let ((a3-0 (-> src vector 3 quad))) (.pextuw a1-1 t1-0 t0-0) - (.mov r0-0 f31-0) + (nop!) (.pextlw t0-1 a3-0 a2-0) - (.mov r0-1 f31-0) + (nop!) (.pextuw a2-1 a3-0 a2-0) ) ) ) ) - (.mov r0-2 f31-0) + (nop!) (.pcpyld a3-1 t0-1 v1-0) - (.mov r0-3 f31-0) + (nop!) (.pcpyud v1-1 v1-0 t0-1) (set! (-> dst vector 0 quad) a3-1) (.pcpyld a3-2 a2-1 a1-1) diff --git a/test/decompiler/reference/jak2/engine/gfx/mood/mood_REF.gc b/test/decompiler/reference/jak2/engine/gfx/mood/mood_REF.gc index 49908e323..5ebb234da 100644 --- a/test/decompiler/reference/jak2/engine/gfx/mood/mood_REF.gc +++ b/test/decompiler/reference/jak2/engine/gfx/mood/mood_REF.gc @@ -25,12 +25,8 @@ ;; definition for function update-mood-itimes ;; INFO: Used lq/sq ;; WARN: Return type mismatch int vs none. -;; WARN: Function may read a register that is not set: f31 (defun update-mood-itimes ((arg0 mood-context)) (local-vars - (r0-0 int) - (r0-1 int) - (r0-2 int) (v1-1 uint128) (v1-2 uint128) (v1-3 uint128) @@ -51,7 +47,6 @@ (t2-1 uint128) (t3-0 uint128) (t3-1 uint128) - (f31-0 none) ) (rlet ((vf1 :class vf) (vf2 :class vf) @@ -118,11 +113,11 @@ (.mov t3-0 vf8) (.pw.sra t1-1 t1-0 6) (.pw.sra t2-1 t2-0 6) - (.mov r0-0 f31-0) + (nop!) (.pw.sra t3-1 t3-0 6) - (.mov r0-1 f31-0) + (nop!) (.ppach v1-3 a1-1 v1-2) - (.mov r0-2 f31-0) + (nop!) (.ppach a1-2 a3-1 a2-1) (set! (-> arg0 itimes 0 quad) v1-3) (.ppach v1-4 t1-1 t0-1) diff --git a/test/decompiler/reference/jak2/engine/math/matrix_REF.gc b/test/decompiler/reference/jak2/engine/math/matrix_REF.gc index 5a1110c7f..859306022 100644 --- a/test/decompiler/reference/jak2/engine/math/matrix_REF.gc +++ b/test/decompiler/reference/jak2/engine/math/matrix_REF.gc @@ -228,21 +228,8 @@ ;; definition for function matrix-transpose! ;; INFO: Used lq/sq -;; WARN: Function may read a register that is not set: f31 (defun matrix-transpose! ((arg0 matrix) (arg1 matrix)) - (local-vars - (r0-0 int) - (r0-1 int) - (r0-2 int) - (r0-3 int) - (v1-0 uint128) - (v1-1 uint128) - (v1-2 uint128) - (a1-1 uint128) - (a2-1 uint128) - (t0-1 uint128) - (f31-0 none) - ) + (local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128) (a1-1 uint128) (a2-1 uint128) (t0-1 uint128)) (nop!) (nop!) (let ((t0-0 (-> arg1 vector 0 quad))) @@ -253,17 +240,17 @@ (.pextlw v1-0 t1-0 t0-0) (let ((a3-0 (-> arg1 trans quad))) (.pextuw a1-1 t1-0 t0-0) - (.mov r0-0 f31-0) + (nop!) (.pextlw t0-1 a3-0 a2-0) - (.mov r0-1 f31-0) + (nop!) (.pextuw a2-1 a3-0 a2-0) ) ) ) ) - (.mov r0-2 f31-0) + (nop!) (let ((a3-1 (make-u128 t0-1 v1-0))) - (.mov r0-3 f31-0) + (nop!) (.pcpyud v1-1 v1-0 t0-1) (set! (-> arg0 vector 0 quad) (the-as uint128 a3-1)) ) @@ -786,21 +773,10 @@ ;; definition for function matrix-axis-sin-cos-vu! ;; INFO: Used lq/sq ;; WARN: Return type mismatch matrix vs none. -;; WARN: Function may read a register that is not set: f31 ;; ERROR: Unsupported inline assembly instruction kind - [prot3w a1, v1] ;; ERROR: Unsupported inline assembly instruction kind - [prot3w a2, a1] (defun matrix-axis-sin-cos-vu! ((arg0 matrix) (arg1 vector) (arg2 float) (arg3 float)) - (local-vars - (r0-0 int) - (r0-1 int) - (r0-2 int) - (r0-3 int) - (a1-2 uint128) - (a2-1 uint128) - (a3-1 uint128) - (a3-2 uint128) - (f31-0 none) - ) + (local-vars (a1-2 uint128) (a2-1 uint128) (a3-1 uint128) (a3-2 uint128)) (rlet ((vf0 :class vf) (vf1 :class vf) (vf10 :class vf) @@ -822,9 +798,9 @@ ) (.mov vf6 arg3) (.pceqw a3-1 v1-0 0) - (.mov r0-0 f31-0) + (nop!) (.ppach a3-2 (the-as uint128 0) a3-1) - (.mov r0-1 f31-0) + (nop!) (nop!) (.mov vf1 v1-0) (let ((v1-1 (logior a3-2 a1-1))) @@ -888,9 +864,9 @@ (let ((v1-3 #x3f800000)) (.svf (&-> arg0 trans quad) vf0) (let ((v1-4 (the-as uint128 (make-u128 0 v1-3)))) - (.mov r0-2 f31-0) + (nop!) (.prot3w a1-2 (the-as uint v1-4)) - (.mov r0-3 f31-0) + (nop!) (.prot3w a2-1 (the-as int a1-2)) (set! (-> arg0 vector 0 quad) v1-4) ) @@ -906,21 +882,10 @@ ;; definition for function matrix-axis-sin-cos! ;; INFO: Used lq/sq -;; WARN: Function may read a register that is not set: f31 ;; ERROR: Unsupported inline assembly instruction kind - [prot3w a0, v1] ;; ERROR: Unsupported inline assembly instruction kind - [prot3w a1, a0] (defun matrix-axis-sin-cos! ((arg0 matrix) (arg1 vector) (arg2 float) (arg3 float)) - (local-vars - (r0-0 int) - (r0-1 int) - (r0-2 int) - (r0-3 int) - (a0-4 uint128) - (a1-2 uint128) - (a1-3 uint128) - (a1-4 uint128) - (f31-0 none) - ) + (local-vars (a0-4 uint128) (a1-2 uint128) (a1-3 uint128) (a1-4 uint128)) (rlet ((vf0 :class vf) (vf1 :class vf) (vf10 :class vf) @@ -949,9 +914,9 @@ (.mov vf6 a1-1) ) (.pceqw a1-2 v1-1 0) - (.mov r0-0 f31-0) + (nop!) (.ppach a1-3 (the-as uint128 0) a1-2) - (.mov r0-1 f31-0) + (nop!) (nop!) (.mov vf1 v1-1) (let ((v1-2 (logior a1-3 a0-2))) @@ -1018,9 +983,9 @@ (let ((v1-4 #x3f800000)) (.svf (&-> v0-0 trans quad) vf0) (let ((v1-5 (the-as uint128 (make-u128 0 v1-4)))) - (.mov r0-2 f31-0) + (nop!) (.prot3w a0-4 (the-as uint v1-5)) - (.mov r0-3 f31-0) + (nop!) (.prot3w a1-4 (the-as int a0-4)) (set! (-> v0-0 vector 0 quad) v1-5) )