[decompiler] Make addition nicer (#733)

* temp

* update refs

* update reference

* fix tests
This commit is contained in:
water111
2021-08-01 18:24:58 -04:00
committed by GitHub
parent e70d179496
commit 12446037bd
42 changed files with 294 additions and 536 deletions
+76 -24
View File
@@ -689,6 +689,54 @@ void SimpleExpressionElement::update_from_stack_si_1(const Env& env,
make_cast_if_needed(arg, in_type, TypeSpec("int"), pool, env)));
}
namespace {
std::vector<Form*> get_addition_elements(Form* in) {
auto gen_elt = in->try_as_element<GenericElement>();
if (gen_elt && gen_elt->op().is_fixed(FixedOperatorKind::ADDITION)) {
return gen_elt->elts();
} else {
return {in};
}
}
FormElement* make_and_compact_addition(Form* arg0,
Form* arg1,
const std::optional<TypeSpec>& arg0_cast,
const std::optional<TypeSpec>& arg1_cast,
FormPool& pool,
const Env& env) {
if (!arg1_cast) {
auto arg0_elts = get_addition_elements(arg0);
assert(!arg0_elts.empty());
if (arg0_cast) {
arg0_elts.front() = cast_form(arg0_elts.front(), *arg0_cast, pool, env);
}
// it's fine to only cast the first thing here - the rest are already cast properly.
auto arg1_elts = get_addition_elements(arg1);
assert(!arg1_elts.empty());
if (arg1_cast) {
arg1_elts.front() = cast_form(arg1_elts.front(), *arg1_cast, pool, env);
}
// add all together
arg0_elts.insert(arg0_elts.end(), arg1_elts.begin(), arg1_elts.end());
return pool.alloc_element<GenericElement>(
GenericOperator::make_fixed(FixedOperatorKind::ADDITION), arg0_elts);
} else {
if (arg0_cast) {
arg0 = cast_form(arg0, *arg0_cast, pool, env);
}
if (arg1_cast) {
arg1 = cast_form(arg1, *arg1_cast, pool, env);
}
return pool.alloc_element<GenericElement>(
GenericOperator::make_fixed(FixedOperatorKind::ADDITION), arg0, arg1);
}
}
} // namespace
void SimpleExpressionElement::update_from_stack_add_i(const Env& env,
FormPool& pool,
FormStack& stack,
@@ -953,7 +1001,7 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env,
}
}
if ((arg0_i && arg1_i) || (arg0_u && arg1_u)) {
if (false && ((arg0_i && arg1_i) || (arg0_u && arg1_u))) {
auto new_form = pool.alloc_element<GenericElement>(
GenericOperator::make_fixed(FixedOperatorKind::ADDITION), args.at(0), args.at(1));
result->push_back(new_form);
@@ -968,21 +1016,19 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env,
GenericOperator::make_fixed(FixedOperatorKind::ADDITION_PTR), args.at(1), args.at(0));
result->push_back(new_form);
} else {
auto casted0 = args.at(0);
std::optional<TypeSpec> arg0_cast, arg1_cast;
if (!arg0_i && !arg0_u && arg0_type.typespec() != TypeSpec("binteger") &&
!env.dts->ts.tc(TypeSpec("integer"), arg0_type.typespec())) {
casted0 = pool.alloc_single_element_form<CastElement>(
nullptr, TypeSpec(arg0_i ? "int" : "uint"), args.at(0));
arg0_cast = TypeSpec(arg0_i ? "int" : "uint");
}
auto casted1 = pool.alloc_single_element_form<CastElement>(
nullptr, TypeSpec(arg0_i ? "int" : "uint"), args.at(1));
if (!arg1_i && !arg1_u) {
arg1_cast = TypeSpec(arg0_i ? "int" : "uint");
}
FormElement* new_form = pool.alloc_element<GenericElement>(
GenericOperator::make_fixed(FixedOperatorKind::ADDITION), casted0, casted1);
result->push_back(new_form);
result->push_back(
make_and_compact_addition(args.at(0), args.at(1), arg0_cast, arg1_cast, pool, env));
}
}
@@ -3388,24 +3434,16 @@ FormElement* ConditionElement::make_zero_check_generic(const Env& env,
const std::vector<TypeSpec>& source_types) {
// (zero? (+ thing small-integer)) -> (= thing (- small-integer))
assert(source_forms.size() == 1);
auto mr = match(Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::ADDITION),
{Matcher::any(0), Matcher::any_integer(1)}),
source_forms.at(0));
if (mr.matched) {
s64 value = -mr.maps.ints.at(1);
auto value_form = pool.alloc_single_element_form<SimpleAtomElement>(
nullptr, SimpleAtom::make_int_constant(value));
return pool.alloc_element<GenericElement>(GenericOperator::make_fixed(FixedOperatorKind::EQ),
std::vector<Form*>{mr.maps.forms.at(0), value_form});
}
auto enum_type_info = env.dts->ts.try_enum_lookup(source_types.at(0));
if (enum_type_info && !enum_type_info->is_bitfield()) {
// (zero? (+ (the-as uint arg0) (the-as uint -2))) check enum value
mr = match(Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::ADDITION),
{make_int_uint_cast_matcher(Matcher::any(0)),
make_int_uint_cast_matcher(Matcher::any_integer(1))}),
source_forms.at(0));
auto mr = match(
Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::ADDITION),
{make_int_uint_cast_matcher(Matcher::any(0)),
Matcher::match_or({Matcher::any_integer(1),
make_int_uint_cast_matcher(Matcher::any_integer(1))})}),
source_forms.at(0));
if (mr.matched) {
s64 value = mr.maps.ints.at(1);
value = -value;
@@ -3416,6 +3454,20 @@ FormElement* ConditionElement::make_zero_check_generic(const Env& env,
}
}
{
auto mr = match(Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::ADDITION),
{Matcher::any(0), Matcher::any_integer(1)}),
source_forms.at(0));
if (mr.matched) {
s64 value = -mr.maps.ints.at(1);
auto value_form = pool.alloc_single_element_form<SimpleAtomElement>(
nullptr, SimpleAtom::make_int_constant(value));
return pool.alloc_element<GenericElement>(
GenericOperator::make_fixed(FixedOperatorKind::EQ),
std::vector<Form*>{mr.maps.forms.at(0), value_form});
}
}
auto nice_constant = try_make_constant_from_int_for_compare(0, source_types.at(0), pool, env);
if (nice_constant) {
return pool.alloc_element<GenericElement>(
@@ -339,10 +339,7 @@
(->
(the-as
(pointer uint128)
(+
(the-as uint (-> arg0 mood-sun-table data 0 env-color))
(the-as uint (* s5-0 32))
)
(+ (the-as uint (-> arg0 mood-sun-table data 0 env-color)) (* s5-0 32))
)
)
)
@@ -362,17 +359,11 @@
(-> arg0 current-sun env-color)
(the-as
vector
(+
(the-as uint (-> arg0 mood-sun-table data 0 env-color))
(the-as uint (* s5-0 32))
)
(+ (the-as uint (-> arg0 mood-sun-table data 0 env-color)) (* s5-0 32))
)
(the-as
vector
(+
(the-as uint (-> arg0 mood-sun-table data 0 env-color))
(the-as uint (* s4-0 32))
)
(+ (the-as uint (-> arg0 mood-sun-table data 0 env-color)) (* s4-0 32))
)
f30-0
)
@@ -434,10 +425,7 @@
(->
(the-as
(pointer uint128)
(+
(the-as uint (-> arg0 mood-fog-table data 0 fog-dists))
(the-as uint (* 48 arg1))
)
(+ (the-as uint (-> arg0 mood-fog-table data 0 fog-dists)) (* 48 arg1))
)
)
)
@@ -446,10 +434,7 @@
(->
(the-as
(pointer uint128)
(+
(the-as uint (-> arg0 mood-fog-table data 0 erase-color))
(the-as uint (* 48 arg1))
)
(+ (the-as uint (-> arg0 mood-fog-table data 0 erase-color)) (* 48 arg1))
)
)
)
@@ -458,10 +443,7 @@
(->
(the-as
(pointer uint128)
(+
(the-as uint (-> arg0 mood-lights-table data 0 prt-color))
(the-as uint (* 80 arg3))
)
(+ (the-as uint (-> arg0 mood-lights-table data 0 prt-color)) (* 80 arg3))
)
)
)
@@ -474,10 +456,7 @@
(->
(the-as
(pointer uint128)
(+
(the-as uint (-> arg0 mood-sun-table data 0 env-color))
(the-as uint (* arg2 32))
)
(+ (the-as uint (-> arg0 mood-sun-table data 0 env-color)) (* arg2 32))
)
)
)
@@ -486,10 +465,7 @@
(->
(the-as
(pointer uint128)
(+
(the-as uint (-> arg0 mood-lights-table data 0 shadow))
(the-as uint (* 80 arg3))
)
(+ (the-as uint (-> arg0 mood-lights-table data 0 shadow)) (* 80 arg3))
)
)
)
@@ -719,7 +695,7 @@
(arg6 float)
)
(let* ((s5-0 (&-> arg0 state arg3))
(s4-0 (+ (-> s5-0 0) (the-as uint arg1)))
(s4-0 (+ (-> s5-0 0) arg1))
(a0-1 (-> s5-0 1))
(v1-2 (-> s5-0 2))
(s0-0 (-> s5-0 3))
@@ -1073,12 +1049,7 @@
(arg7 int)
)
(let* ((gp-0 (&-> arg0 state arg2))
(f0-1
(the
float
(* (logand (+ (-> arg0 state arg3) (the-as uint arg7)) 255) 512)
)
)
(f0-1 (the float (* (logand (+ (-> arg0 state arg3) arg7) 255) 512)))
(f0-4 (+ arg4 (* (cos f0-1) arg5)))
(f30-1 (* 0.003921569 (the float (-> gp-0 0))))
)
@@ -1157,9 +1128,9 @@
(f0-1 (* 0.125 (the float (logand a2-1 7))))
)
(let ((a2-4 (logand (+ v1-2 -1) 3)))
(set! (-> arg0 times (+ arg1 (the-as int a2-4)) w) (- 1.0 f0-1))
(set! (-> arg0 times (+ arg1 a2-4) w) (- 1.0 f0-1))
)
(set! (-> arg0 times (+ arg1 (the-as int v1-2)) w) f0-1)
(set! (-> arg0 times (+ arg1 v1-2) w) f0-1)
f0-1
)
)
@@ -2238,10 +2209,7 @@
(let
((f0-19
(vector-vector-distance
(the-as
vector
(+ (the-as uint *rolling-spheres-light2*) (the-as uint (* s4-4 16)))
)
(the-as vector (+ (the-as uint *rolling-spheres-light2*) (* s4-4 16)))
s5-3
)
)
@@ -3809,7 +3777,3 @@
(update-mood-itimes arg0)
(none)
)
@@ -23,7 +23,7 @@
;; definition for function float-lookup-redline
(defun float-lookup-redline ((arg0 float))
(let ((a0-3 (mod (+ (+ (the int arg0) -1) *redline-index*) 400)))
(let ((a0-3 (mod (+ (the int arg0) -1 *redline-index*) 400)))
(-> *redline-table* a0-3)
)
)
@@ -48,7 +48,7 @@
;; definition for function float-lookup-blueline
(defun float-lookup-blueline ((arg0 float))
(let ((a0-3 (mod (+ (+ (the int arg0) -1) *blueline-index*) 400)))
(let ((a0-3 (mod (+ (the int arg0) -1 *blueline-index*) 400)))
(-> *blueline-table* a0-3)
)
)
@@ -73,7 +73,7 @@
;; definition for function float-lookup-greenline
(defun float-lookup-greenline ((arg0 float))
(let ((a0-3 (mod (+ (+ (the int arg0) -1) *greenline-index*) 400)))
(let ((a0-3 (mod (+ (the int arg0) -1 *greenline-index*) 400)))
(-> *greenline-table* a0-3)
)
)
@@ -98,7 +98,7 @@
;; definition for function float-lookup-yellowline
(defun float-lookup-yellowline ((arg0 float))
(let ((a0-3 (mod (+ (+ (the int arg0) -1) *yellowline-index*) 400)))
(let ((a0-3 (mod (+ (the int arg0) -1 *yellowline-index*) 400)))
(-> *yellowline-table* a0-3)
)
)
@@ -123,7 +123,7 @@
;; definition for function float-lookup-timeplot
(defun float-lookup-timeplot ((arg0 float))
(let ((a0-3 (mod (+ (+ (the int arg0) -1) *timeplot-index*) 400)))
(let ((a0-3 (mod (+ (the int arg0) -1 *timeplot-index*) 400)))
(-> *timeplot-table* a0-3)
)
)
@@ -645,10 +645,7 @@
(- (-> obj summed-len) (-> obj point arg0 tp-length))
)
(vector-!
(the-as
vector
(+ (the-as uint (-> obj point 0 direction)) (the-as uint (* 48 arg0)))
)
(the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 arg0)))
(the-as vector (-> obj point v1-11))
(the-as vector (-> obj point arg0))
)
@@ -656,10 +653,7 @@
(set!
(-> obj point arg0 tp-length)
(vector-normalize-ret-len!
(the-as
vector
(+ (the-as uint (-> obj point 0 direction)) (the-as uint (* 48 arg0)))
)
(the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 arg0)))
1.0
)
)
@@ -754,16 +748,13 @@
(vector-dot
(the-as
vector
(+
(the-as uint (-> obj point 0 direction))
(the-as uint (* 48 v1-15))
)
(+ (the-as uint (-> obj point 0 direction)) (* 48 v1-15))
)
(the-as
vector
(+
(the-as uint (the-as vector (-> obj point 0 direction)))
(the-as uint (* 48 a0-14))
(* 48 a0-14)
)
)
)
@@ -818,16 +809,13 @@
(vector-dot
(the-as
vector
(+
(the-as uint (-> obj point 0 direction))
(the-as uint (* 48 s4-1))
)
(+ (the-as uint (-> obj point 0 direction)) (* 48 s4-1))
)
(the-as
vector
(+
(the-as uint (the-as vector (-> obj point 0 direction)))
(the-as uint (* 48 v1-11))
(* 48 v1-11)
)
)
)
@@ -858,20 +846,14 @@
(s2-0 (-> obj end-point))
)
(vector-!
(the-as
vector
(+ (the-as uint (-> obj point 0 direction)) (the-as uint (* 48 s2-0)))
)
(the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 s2-0)))
arg0
(the-as vector (-> obj point s2-0))
)
(set!
(-> obj point s2-0 tp-length)
(vector-normalize-ret-len!
(the-as
vector
(+ (the-as uint (-> obj point 0 direction)) (the-as uint (* 48 s2-0)))
)
(the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 s2-0)))
1.0
)
)
@@ -1031,14 +1013,8 @@
(let ((s1-0 (-> obj point v1-8 next)))
(vector-!
s2-0
(the-as
vector
(+ (the-as uint (-> obj point 0 direction)) (the-as uint (* 48 s1-0)))
)
(the-as
vector
(+ (the-as uint (-> obj point 0 direction)) (the-as uint (* 48 v1-8)))
)
(the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 s1-0)))
(the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 v1-8)))
)
(let* ((f0-4 (vector-normalize-ret-len! s2-0 1.0))
(f0-5 (* 0.5 f0-4))
@@ -2418,7 +2394,3 @@
)
arg0
)
@@ -85,16 +85,16 @@
(+! (-> arg0 data s5-0 total) (logand -16 (+ v1-11 15)))
)
(set! (-> arg0 data (+ s5-0 1) name) "collision-poly")
(+! (-> arg0 data (+ s5-0 1) count) (the-as int (-> s4-0 poly-count)))
(+! (-> arg0 data (+ s5-0 1) count) (-> s4-0 poly-count))
(let ((v1-22 (+ (-> s4-0 strip-data-len) (-> s4-0 poly-count))))
(+! (-> arg0 data (+ s5-0 1) used) (the-as int v1-22))
(+! (-> arg0 data (+ s5-0 1) total) (the-as int v1-22))
(+! (-> arg0 data (+ s5-0 1) used) v1-22)
(+! (-> arg0 data (+ s5-0 1) total) v1-22)
)
(set! (-> arg0 data (+ s5-0 2) name) "collision-vertex")
(+! (-> arg0 data (+ s5-0 2) count) (the-as int (-> s4-0 vertex-count)))
(+! (-> arg0 data (+ s5-0 2) count) (-> s4-0 vertex-count))
(let ((v1-31 (* (-> s4-0 vertex-data-qwc) 16)))
(+! (-> arg0 data (+ s5-0 2) used) (the-as int v1-31))
(let ((v0-2 (+ (-> arg0 data (+ s5-0 2) total) (the-as int v1-31))))
(+! (-> arg0 data (+ s5-0 2) used) v1-31)
(let ((v0-2 (+ (-> arg0 data (+ s5-0 2) total) v1-31)))
(set! (-> arg0 data (+ s5-0 2) total) v0-2)
(the-as collide-fragment v0-2)
)
@@ -699,10 +699,7 @@
;; definition for method 5 of type collide-shape-prim-group
;; INFO: Return type mismatch uint vs int.
(defmethod asize-of collide-shape-prim-group ((obj collide-shape-prim-group))
(the-as
int
(+ (-> obj type size) (the-as uint (* (+ (-> obj allocated-prims) -1) 4)))
)
(the-as int (+ (-> obj type size) (* (+ (-> obj allocated-prims) -1) 4)))
)
;; definition for method 0 of type collide-shape
@@ -802,7 +799,7 @@
(object-new
allocation
type-to-make
(the-as int (+ (-> type-to-make size) (the-as uint (* (+ arg0 -1) 32))))
(the-as int (+ (-> type-to-make size) (* (+ arg0 -1) 32)))
)
)
)
@@ -820,10 +817,7 @@
;; definition for method 5 of type collide-sticky-rider-group
;; INFO: Return type mismatch uint vs int.
(defmethod asize-of collide-sticky-rider-group ((obj collide-sticky-rider-group))
(the-as
int
(+ (-> obj type size) (the-as uint (* (+ (-> obj allocated-riders) -1) 32)))
)
(the-as int (+ (-> obj type size) (* (+ (-> obj allocated-riders) -1) 32)))
)
;; definition for symbol *collide-shape-prim-backgnd*, type collide-shape-prim-mesh
@@ -109,7 +109,7 @@
(new-dynamic-structure
allocation
type-to-make
(the-as int (+ (-> type-to-make size) (the-as uint (* 48 v1-1))))
(the-as int (+ (-> type-to-make size) (* 48 v1-1)))
)
)
)
@@ -55,13 +55,7 @@
(object-new
allocation
type-to-make
(the-as
int
(+
(+ (-> type-to-make size) (the-as uint (* (+ data-count -1) 16)))
(the-as uint data-size)
)
)
(the-as int (+ (-> type-to-make size) (* (+ data-count -1) 16) data-size))
)
)
)
@@ -84,10 +78,7 @@
(defmethod asize-of res-lump ((obj res-lump))
(the-as
int
(+
(+ (-> obj type psize) (the-as uint (* (-> obj allocated-length) 16)))
(the-as uint (-> obj data-size))
)
(+ (-> obj type psize) (* (-> obj allocated-length) 16) (-> obj data-size))
)
)
@@ -1426,7 +1426,7 @@
(+ (- -1 s5-0) (-> arg0 sel-length))
)
)
(set! s4-0 (+ (+ s4-0 3) (-> s3-0 pix-width)))
(set! s4-0 (+ s4-0 3 (-> s3-0 pix-width)))
)
)
)
@@ -161,9 +161,9 @@
(.sync.l)
(.sync.p)
(.mfpc v1-1 pcr0)
(+! (-> obj accum0) (the-as uint v1-1))
(+! (-> obj accum0) v1-1)
(.mfpc v1-3 pcr1)
(+! (-> obj accum1) (the-as uint v1-3))
(+! (-> obj accum1) v1-3)
(label cfg-2)
0
(none)
@@ -190,7 +190,3 @@
(set! (-> perf-stat method-table 12) nothing)
(set! (-> perf-stat method-table 13) nothing)
)
@@ -44,9 +44,7 @@
(tag-start pointer)
(tag-end (pointer dma-tag))
)
(let
((bucket (the-as dma-bucket (+ (the-as uint base) (the-as uint (* idx 16)))))
)
(let ((bucket (the-as dma-bucket (+ (the-as uint base) (* idx 16)))))
(set! (-> (the-as dma-bucket (-> bucket last)) next) (the-as uint tag-start))
(set! (-> bucket last) tag-end)
)
@@ -94,11 +94,7 @@
(defmethod new dma-buffer ((allocation symbol) (type-to-make type) (arg0 int))
(let
((v0-0
(object-new
allocation
type-to-make
(+ (+ arg0 -4) (the-as int (-> type-to-make size)))
)
(object-new allocation type-to-make (+ arg0 -4 (-> type-to-make size)))
)
)
(set! (-> v0-0 base) (-> v0-0 data))
@@ -121,7 +117,7 @@
;; definition for method 5 of type dma-buffer
(defmethod asize-of dma-buffer ((obj dma-buffer))
(+ (+ (-> obj allocated-length) -4) (the-as int (-> dma-buffer size)))
(+ (-> obj allocated-length) -4 (-> dma-buffer size))
)
;; definition for function dma-buffer-length
@@ -715,7 +715,7 @@
)
)
(disasm-vif-tag
(the-as (pointer vif-tag) (+ addr (the-as uint v0-10)))
(the-as (pointer vif-tag) (+ addr v0-10))
(the-as int (- (* qwc 4) (the-as uint (/ v0-10 4))))
stream-2
(= mode-2 'details)
@@ -743,10 +743,7 @@
)
(set!
data-2
(the-as
dma-packet
(+ (the-as uint data-2) (the-as uint (* (+ qwc 1) 16)))
)
(the-as dma-packet (+ (the-as uint data-2) (* (+ qwc 1) 16)))
)
data-2
)
@@ -291,7 +291,7 @@
(defun dump-vu1-range ((start uint) (total-count uint))
(let ((s4-0 (the-as (pointer uint32) #x1100c000)))
(dotimes (s3-0 (the-as int total-count))
(let ((s2-0 (+ s3-0 (the-as int start))))
(let ((s2-0 (+ s3-0 start)))
(format
0
"~4,'0X: ~8x ~8x ~8x ~8x"
@@ -138,7 +138,7 @@
joint-control-channel
(+
(the-as uint arg0)
(the-as uint (* 48 (- (the int arg1) (-> arg0 group-sub-index))))
(* 48 (- (the int arg1) (-> arg0 group-sub-index)))
)
)
frame-num
@@ -169,10 +169,7 @@
(object-new
allocation
type-to-make
(the-as
int
(+ (-> type-to-make size) (the-as uint (* (+ length -1) 32)))
)
(the-as int (+ (-> type-to-make size) (* (+ length -1) 32)))
)
)
)
@@ -258,25 +255,25 @@
(format #t "~Tlength: ~D~%" (-> obj length))
(format #t "~Talive-list:~%")
(let ((s5-0 *print-column*))
(set! *print-column* (+ *print-column* (the-as uint 64)))
(set! *print-column* (+ *print-column* 64))
(inspect (-> obj alive-list))
(set! *print-column* s5-0)
)
(format #t "~Talive-list-end:~%")
(let ((s5-1 *print-column*))
(set! *print-column* (+ *print-column* (the-as uint 64)))
(set! *print-column* (+ *print-column* 64))
(inspect (-> obj alive-list-end))
(set! *print-column* s5-1)
)
(format #t "~Tdead-list:~%")
(let ((s5-2 *print-column*))
(set! *print-column* (+ *print-column* (the-as uint 64)))
(set! *print-column* (+ *print-column* 64))
(inspect (-> obj dead-list))
(set! *print-column* s5-2)
)
(format #t "~Tdead-list-end:~%")
(let ((s5-3 *print-column*))
(set! *print-column* (+ *print-column* (the-as uint 64)))
(set! *print-column* (+ *print-column* 64))
(inspect (-> obj dead-list-end))
(set! *print-column* s5-3)
)
@@ -292,10 +289,7 @@
;; definition for method 5 of type engine
;; INFO: Return type mismatch uint vs int.
(defmethod asize-of engine ((obj engine))
(the-as
int
(+ (-> engine size) (the-as uint (* (+ (-> obj allocated-length) -1) 32)))
)
(the-as int (+ (-> engine size) (* (+ (-> obj allocated-length) -1) 32)))
)
;; definition for method 10 of type engine
@@ -417,12 +417,9 @@
(*
(+
*profile-x*
(the-as
int
(/
(* (-> block time-stamp) (the-as uint *profile-w*))
(the-as uint *ticks-per-frame*)
)
(/
(* (-> block time-stamp) (the-as uint *profile-w*))
(the-as uint *ticks-per-frame*)
)
)
16
@@ -436,7 +433,7 @@
(-> (the-as (pointer gs-xyzf) t2-8) 0)
(new 'static 'gs-xyzf
:z #x3fffff
:y (* (+ (+ *profile-y* screen-y) *profile-h*) 16)
:y (* (+ *profile-y* screen-y *profile-h*) 16)
:x left
)
)
@@ -951,7 +951,7 @@
(object-new
allocation
type-to-make
(the-as int (+ (-> type-to-make size) (the-as uint (* (+ arg0 -1) 8))))
(the-as int (+ (-> type-to-make size) (* (+ arg0 -1) 8)))
)
)
@@ -164,10 +164,7 @@
(defun merc-fragment-fp-data ((arg0 merc-fragment))
(the-as
pointer
(+
(the-as uint arg0)
(the-as uint (* (-> arg0 header mm-quadword-fp-off) 16))
)
(+ (the-as uint arg0) (* (-> arg0 header mm-quadword-fp-off) 16))
)
)
@@ -259,7 +259,7 @@
(a3-9
(the-as
uint128
(-> *ocean-map* ocean-colors colors (+ (+ a1-11 1) (* 52 a0-16)))
(-> *ocean-map* ocean-colors colors (+ a1-11 1 (* 52 a0-16)))
)
)
(t0-10
@@ -271,12 +271,7 @@
(a0-22
(the-as
uint128
(->
*ocean-map*
ocean-colors
colors
(+ (+ a1-11 1) (* 52 (+ a0-16 1)))
)
(-> *ocean-map* ocean-colors colors (+ a1-11 1 (* 52 (+ a0-16 1))))
)
)
)
@@ -457,23 +452,13 @@
((a0-22
(the-as
uint128
(->
*ocean-map*
ocean-colors
colors
(+ (* 52 (the-as int arg1)) (the-as int arg2))
)
(-> *ocean-map* ocean-colors colors (+ (* 52 (the-as int arg1)) arg2))
)
)
(a1-13
(the-as
uint128
(->
*ocean-map*
ocean-colors
colors
(+ (+ arg2 1) (the-as uint (* 52 (the-as int arg1))))
)
(-> *ocean-map* ocean-colors colors (+ arg2 1 (* 52 (the-as int arg1))))
)
)
(a2-14
@@ -483,7 +468,7 @@
*ocean-map*
ocean-colors
colors
(+ (* 52 (the-as int (+ arg1 1))) (the-as int arg2))
(+ (* 52 (the-as int (+ arg1 1))) arg2)
)
)
)
@@ -494,7 +479,7 @@
*ocean-map*
ocean-colors
colors
(+ (+ arg2 1) (the-as uint (* 52 (the-as int (+ arg1 1)))))
(+ arg2 1 (* 52 (the-as int (+ arg1 1))))
)
)
)
@@ -1136,7 +1121,7 @@
(dotimes (t3-10 4)
(let ((t4-5 (-> sv-40 mask t3-10)))
(when (nonzero? t4-5)
(let ((t5-2 (+ (* a3-1 4) (the-as uint t3-10))))
(let ((t5-2 (+ (* a3-1 4) t3-10)))
(if (< t5-2 (the-as uint a0-11))
(set! a0-11 (the-as int t5-2))
)
@@ -1146,7 +1131,7 @@
)
(dotimes (t5-3 4)
(when (logtest? t4-5 (ash 1 t5-3))
(let ((t6-9 (+ (* t1-0 4) (the-as uint t5-3))))
(let ((t6-9 (+ (* t1-0 4) t5-3)))
(if (< t6-9 (the-as uint a2-2))
(set! a2-2 (the-as int t6-9))
)
@@ -1193,7 +1178,7 @@
*ocean-map*
ocean-trans-indices
data
(+ (* (the-as uint 48) s5-1) (the-as int s3-1))
(+ (* (the-as uint 48) s5-1) s3-1)
)
)
)
@@ -1240,7 +1225,3 @@
0
(none)
)
@@ -196,7 +196,7 @@
(s4-0
(the-as
mei-ripple
(+ (the-as uint a1-6) (the-as uint (* (-> a1-6 ripple-offset) 16)))
(+ (the-as uint a1-6) (* (-> a1-6 ripple-offset) 16))
)
)
(gp-0 (-> v1-1 ripple))
@@ -224,15 +224,10 @@
(dst
(the-as
qword
(+
(the-as uint (-> obj header))
(the-as uint (* (+ (-> obj header data 1) 1) 16))
)
(+ (the-as uint (-> obj header)) (* (+ (-> obj header data 1) 1) 16))
)
)
(tex-dst
(the-as qword (+ (the-as int dst) (the-as int (* shader-count 64))))
)
(tex-dst (the-as qword (+ (the-as int dst) (* shader-count 64))))
(src (the-as qword (-> obj textures)))
)
(dotimes (a0-1 (the-as int shader-count))
@@ -106,7 +106,7 @@
(object-new
allocation
type-to-make
(the-as int (+ (-> type-to-make size) (the-as uint (* (+ size -1) 4))))
(the-as int (+ (-> type-to-make size) (* (+ size -1) 4)))
)
)
)
@@ -460,7 +460,7 @@
int
(+
(-> type-to-make size)
(the-as uint (* (+ (+ adgif-data-size -1) vec-data-size) 16))
(* (+ adgif-data-size -1 vec-data-size) 16)
)
)
)
@@ -496,7 +496,7 @@
int
(+
(-> type-to-make size)
(the-as uint (* (+ (+ adgif-data-size -1) vec-data-size) 16))
(* (+ adgif-data-size -1 vec-data-size) 16)
)
)
)
@@ -739,7 +739,7 @@
(-> pkt2 dma)
(new 'static 'dma-tag
:id (dma-tag-id ref)
:addr (+ (-> sprites vec-data) (the-as uint (* 48 start-sprite-idx)))
:addr (+ (-> sprites vec-data) (* 48 start-sprite-idx))
:qwc qwc-pkt2
)
)
@@ -758,7 +758,7 @@
(-> pkt3 dma)
(new 'static 'dma-tag
:id (dma-tag-id ref)
:addr (+ (-> sprites adgif-data) (the-as uint (* 80 start-sprite-idx)))
:addr (+ (-> sprites adgif-data) (* 80 start-sprite-idx))
:qwc qwc-pkt3
)
)
@@ -854,7 +854,7 @@
(-> pkt2 dma)
(new 'static 'dma-tag
:id (dma-tag-id ref)
:addr (+ (-> sprites vec-data) (the-as uint (* 48 start-sprite-idx)))
:addr (+ (-> sprites vec-data) (* 48 start-sprite-idx))
:qwc qwc-pkt2
)
)
@@ -873,7 +873,7 @@
(-> pkt3 dma)
(new 'static 'dma-tag
:id (dma-tag-id ref)
:addr (+ (-> sprites adgif-data) (the-as uint (* 80 start-sprite-idx)))
:addr (+ (-> sprites adgif-data) (* 80 start-sprite-idx))
:qwc qwc-pkt3
)
)
@@ -23,7 +23,7 @@
;; definition for method 5 of type texture-page
;; INFO: Return type mismatch uint vs int.
(defmethod asize-of texture-page ((obj texture-page))
(the-as int (+ (-> obj type size) (the-as uint (* (-> obj length) 4))))
(the-as int (+ (-> obj type size) (* (-> obj length) 4)))
)
;; definition for method 8 of type texture-page
@@ -638,10 +638,10 @@
(let* ((block-width (gs-block-width tex-format))
(block-height (gs-block-height tex-format))
(real-width
(* (/ (+ (+ block-width -1) tex-width) block-width) block-width)
(* (/ (+ block-width -1 tex-width) block-width) block-width)
)
(real-height
(* (/ (+ (+ block-height -1) tex-height) block-height) block-height)
(* (/ (+ block-height -1 tex-height) block-height) block-height)
)
(width-blocks (/ real-width block-width))
(height-blocks (/ real-height block-height))
@@ -660,11 +660,9 @@
(defun gs-blocks-used ((tex-width int) (tex-height int) (tex-format gs-psm))
(let* ((page-width (gs-page-width tex-format))
(page-height (gs-page-height tex-format))
(real-width
(* (/ (+ (+ page-width -1) tex-width) page-width) page-width)
)
(real-width (* (/ (+ page-width -1 tex-width) page-width) page-width))
(real-height
(* (/ (+ (+ page-height -1) tex-height) page-height) page-height)
(* (/ (+ page-height -1 tex-height) page-height) page-height)
)
(width-blocks (/ real-width page-width))
(height-blocks (/ real-height page-height))
@@ -673,7 +671,8 @@
)
(if (or (< a0-9 page-width) (< a1-7 page-height))
(+
(+ (gs-largest-block a0-9 a1-7 tex-format) 1)
(gs-largest-block a0-9 a1-7 tex-format)
1
(* (+ (* width-blocks height-blocks) -1) 32)
)
(* (* height-blocks width-blocks) 32)
@@ -792,7 +791,7 @@
((obj texture-page) (segment-count int) (additional-size int))
(let ((v1-0 additional-size))
(dotimes (a2-1 segment-count)
(+! v1-0 (the-as int (-> obj segment a2-1 size)))
(+! v1-0 (-> obj segment a2-1 size))
)
(logand (/ v1-0 64) 63)
)
@@ -1009,11 +1008,7 @@
)
)
(dotimes (upload-chunk-idx chunk-count)
(let
((current-dest-chunk
(+ tex-dest-base-chunk (the-as uint upload-chunk-idx))
)
)
(let ((current-dest-chunk (+ tex-dest-base-chunk upload-chunk-idx)))
(cond
((zero? chunks-to-upload-count)
(when (!= (-> pool ids current-dest-chunk) tex-id)
@@ -1025,10 +1020,7 @@
((= (-> pool ids current-dest-chunk) tex-id)
(upload-vram-data
dma-buf
(the-as
int
(* (+ tex-dest-base-chunk (the-as uint first-chunk-idx-to-upload)) 64)
)
(the-as int (* (+ tex-dest-base-chunk first-chunk-idx-to-upload) 64))
(&+ tex-data (shl first-chunk-idx-to-upload 14))
(* chunks-to-upload-count 32)
)
@@ -1046,10 +1038,7 @@
(when (nonzero? chunks-to-upload-count)
(upload-vram-data
dma-buf
(the-as
int
(* (+ tex-dest-base-chunk (the-as uint first-chunk-idx-to-upload)) 64)
)
(the-as int (* (+ tex-dest-base-chunk first-chunk-idx-to-upload) 64))
(&+ tex-data (shl first-chunk-idx-to-upload 14))
(* chunks-to-upload-count 32)
)
@@ -1161,7 +1150,7 @@
)
)
(dotimes (chunk-idx upload-chunks)
(let ((vram-chunk (+ dest-block (the-as uint chunk-idx))))
(let ((vram-chunk (+ dest-block chunk-idx)))
(cond
((zero? modified-chunk-count)
(when (!= (-> pool ids vram-chunk) page-id)
@@ -1223,10 +1212,7 @@
)
)
(dotimes (upload-chunk-idx chunk-count)
(set!
current-dest-chunk
(+ tex-dest-base-chunk (the-as uint upload-chunk-idx))
)
(set! current-dest-chunk (+ tex-dest-base-chunk upload-chunk-idx))
(set!
need-tex
(nonzero? (logand allow-cache-mask (ash 1 upload-chunk-idx)))
@@ -1242,10 +1228,7 @@
((or (= (-> pool ids current-dest-chunk) page-id) (not need-tex))
(upload-vram-data
dma-buf
(the-as
int
(* (+ tex-dest-base-chunk (the-as uint first-chunk-idx-to-upload)) 64)
)
(the-as int (* (+ tex-dest-base-chunk first-chunk-idx-to-upload) 64))
(&+ tex-data (shl first-chunk-idx-to-upload 14))
(* chunks-to-upload-count 32)
)
@@ -1262,10 +1245,7 @@
(when (nonzero? chunks-to-upload-count)
(upload-vram-data
dma-buf
(the-as
int
(* (+ tex-dest-base-chunk (the-as uint first-chunk-idx-to-upload)) 64)
)
(the-as int (* (+ tex-dest-base-chunk first-chunk-idx-to-upload) 64))
(&+ tex-data (shl first-chunk-idx-to-upload 14))
(* chunks-to-upload-count 32)
)
@@ -1353,11 +1333,8 @@
((< (the-as uint #x24000) page-seg-2-size)
(let ((after-seg-2-data (&+ (-> page segment 2 block-data) #x90000)))
(let ((seg-2-data (-> page segment 2 block-data)))
(set! (-> page segment 2 size) (+ -147456 (the-as int page-seg-2-size)))
(set!
(-> page segment 2 dest)
(+ #x24000 (the-as int (-> pool segment-near dest)))
)
(set! (-> page segment 2 size) (+ -147456 page-seg-2-size))
(set! (-> page segment 2 dest) (+ #x24000 (-> pool segment-near dest)))
(set!
(-> heap current)
(&+ (-> page segment 2 block-data) (* (-> page segment 2 size) 4))
@@ -1402,7 +1379,7 @@
(update-vram-pages pool (-> pool segment-near) page 2)
(cond
((< (the-as uint #x24000) seg2-size)
(set! (-> page segment 2 size) (+ -147456 (the-as int seg2-size)))
(set! (-> page segment 2 size) (+ -147456 seg2-size))
(set!
(-> heap current)
(&+ (-> page segment 2 block-data) (* (-> page segment 2 size) 4))
@@ -2793,10 +2770,7 @@
(and
main-font-tx
(-> main-font-tx page)
(=
(-> obj cur)
(+ heap-before-font-tex (the-as int (-> main-font-tx page size)))
)
(= (-> obj cur) (+ heap-before-font-tex (-> main-font-tx page size)))
)
(set! (-> obj cur) heap-before-font-tex)
(format 0 "ERROR: could not resize heap to remove gamefont.~%")
@@ -2810,10 +2784,7 @@
;; definition for method 5 of type texture-page-dir
;; INFO: Return type mismatch uint vs int.
(defmethod asize-of texture-page-dir ((obj texture-page-dir))
(the-as
int
(+ (-> texture-page-dir size) (the-as uint (* 12 (+ (-> obj length) -1))))
)
(the-as int (+ (-> texture-page-dir size) (* 12 (+ (-> obj length) -1))))
)
;; definition for method 4 of type texture-page-dir
@@ -2847,23 +2818,20 @@
(num-mips (-> tex num-mips))
)
(if (zero? seg-id)
(set!
(-> tex clutdest)
(+ (- (-> tex clutdest) dst-block) (the-as uint v1-0))
)
(set! (-> tex clutdest) (+ (- (-> tex clutdest) dst-block) v1-0))
)
(dotimes (mip-id (the-as int num-mips))
(let ((t4-0 mip-id)
(t5-0 num-mips)
)
(if (= seg-id (if (>= (the-as uint 2) t5-0)
(+ (- -1 t4-0) (the-as int t5-0))
(+ (- -1 t4-0) t5-0)
(max 0 (- 2 t4-0))
)
)
(set!
(-> tex dest mip-id)
(+ (- (-> tex dest mip-id) dst-block) (the-as uint v1-0))
(+ (- (-> tex dest mip-id) dst-block) v1-0)
)
)
)
@@ -3181,13 +3149,13 @@
((1)
(set!
(-> arg0 tex1 k)
(+ (+ (logand (ash s5-0 (- 5 (log2 s5-0))) 31) -350) (* (log2 s5-0) 32))
(+ (logand (ash s5-0 (- 5 (log2 s5-0))) 31) -350 (* (log2 s5-0) 32))
)
)
(else
(set!
(-> arg0 tex1 k)
(+ (+ (logand (ash s5-0 (- 4 (log2 s5-0))) 15) -175) (* (log2 s5-0) 16))
(+ (logand (ash s5-0 (- 4 (log2 s5-0))) 15) -175 (* (log2 s5-0) 16))
)
)
)
@@ -32,10 +32,10 @@
(when
(nonzero?
(+
(+
(+ (+ (-> stat groups) (-> stat fragments)) (-> stat tris))
(-> stat dverts)
)
(-> stat groups)
(-> stat fragments)
(-> stat tris)
(-> stat dverts)
(-> stat instances)
)
)
@@ -341,7 +341,7 @@
(when GSH_ENABLE
(let ((bucket GSH_BUCKET))
(let ((which-stat GSH_WHICH_STAT))
(set! gp-0 (+ (* bucket 2) (the-as uint which-stat)))
(set! gp-0 (+ (* bucket 2) which-stat))
)
(when GSH_MAX_DISPLAY
(let
@@ -432,10 +432,10 @@
)
(cond
((zero? a1-63)
(set! a0-64 (+ #x60020 (the-as int a0-64)))
(set! a0-64 (+ #x60020 a0-64))
)
((= a1-63 1)
(set! a0-64 (+ #x300c0 (the-as int a0-64)))
(set! a0-64 (+ #x300c0 a0-64))
)
)
(set! (-> *perf-stats* data v1-27 select) a1-63)
@@ -489,9 +489,9 @@
(.sync.l)
(.sync.p)
(.mfpc a0-1 pcr0)
(+! (-> v1-1 0 accum0) (the-as uint a0-1))
(+! (-> v1-1 0 accum0) a0-1)
(.mfpc a0-3 pcr1)
(+! (-> v1-1 0 accum1) (the-as uint a0-3))
(+! (-> v1-1 0 accum1) a0-3)
)
(label cfg-2)
0
@@ -534,7 +534,3 @@
0
(none)
)
@@ -143,7 +143,7 @@
(format #t "_#x~X________________~%" arg1)
(inspect arg1)
(let ((s4-0 *print-column*))
(set! *print-column* (+ *print-column* (the-as uint 64)))
(set! *print-column* (+ *print-column* 64))
(if (> (-> arg1 front) 0)
(inspect-bsp-tree arg0 (the-as bsp-node (-> arg1 front)))
(format #t "_#x~X________________~%" arg1)
@@ -90,10 +90,7 @@
;; definition for function wind-get-hashed-index
(defun wind-get-hashed-index ((arg0 vector))
(logand
(+
(+ (the int (-> arg0 x)) (the int (-> arg0 z)))
(the-as int (-> *wind-work* wind-time))
)
(+ (the int (-> arg0 x)) (the int (-> arg0 z)) (-> *wind-work* wind-time))
63
)
)
@@ -1317,12 +1317,9 @@
sv-56
(+
sv-56
(the-as
int
(-
(-> *display* base-frame-counter)
(-> *display* old-base-frame-counter)
)
(-
(-> *display* base-frame-counter)
(-> *display* old-base-frame-counter)
)
)
)
@@ -35,10 +35,7 @@
(object-new
allocation
type-to-make
(+
(+ (/ (logand -8 (+ length 7)) 8) -1)
(the-as int (-> type-to-make size))
)
(+ (/ (logand -8 (+ length 7)) 8) -1 (-> type-to-make size))
)
)
)
@@ -58,10 +55,7 @@
(defmethod asize-of bit-array ((obj bit-array))
(the-as
int
(+
(-> obj type size)
(the-as uint (/ (logand -8 (+ (-> obj allocated-length) 7)) 8))
)
(+ (-> obj type size) (/ (logand -8 (+ (-> obj allocated-length) 7)) 8))
)
)
@@ -546,7 +546,7 @@
(object-new
allocation
type-to-make
(the-as int (+ (-> type-to-make size) (the-as uint (* sphere-count 16))))
(the-as int (+ (-> type-to-make size) (* sphere-count 16)))
)
)
)
@@ -216,16 +216,13 @@
(-> pad buzz-time buzz-idx)
(max
(the-as int (-> pad buzz-time buzz-idx))
(the-as int (+ (get-current-time) (the-as uint duration)))
(the-as int (+ (get-current-time) duration))
)
)
)
((< (-> pad buzz-val buzz-idx) (the-as uint buzz-amount))
(set! (-> pad buzz-val buzz-idx) (the-as uint buzz-amount))
(set!
(-> pad buzz-time buzz-idx)
(+ (get-current-time) (the-as uint duration))
)
(set! (-> pad buzz-time buzz-idx) (+ (get-current-time) duration))
)
)
0
@@ -36,12 +36,7 @@
rpc-buffer
((allocation symbol) (type-to-make type) (arg0 uint) (arg1 uint))
(let*
((a2-2
(+
(+ (-> type-to-make size) 63)
(the-as uint (* (the-as int arg0) (the-as int arg1)))
)
)
((a2-2 (+ (-> type-to-make size) 63 (* (the-as int arg0) (the-as int arg1))))
(v0-0 (object-new allocation type-to-make (the-as int a2-2)))
)
(set! (-> v0-0 elt-size) arg0)
@@ -100,10 +100,7 @@
(set! (-> arg0 begin-level) 0)
0
(.mfc0 a1-0 Count)
(+!
(-> arg0 prev-time-elapsed)
(the-as uint (- a1-0 (the-as int (-> arg0 start-time))))
)
(+! (-> arg0 prev-time-elapsed) (- a1-0 (the-as int (-> arg0 start-time))))
)
(the-as uint 0)
)
@@ -130,10 +127,7 @@
(when (zero? (-> arg0 begin-level))
0
(.mfc0 a1-0 Count)
(+!
(-> arg0 prev-time-elapsed)
(the-as uint (- a1-0 (the-as int (-> arg0 start-time))))
)
(+! (-> arg0 prev-time-elapsed) (- a1-0 (the-as int (-> arg0 start-time))))
)
(the-as uint 0)
)
@@ -146,7 +140,7 @@
(when (> (-> arg0 begin-level) 0)
0
(.mfc0 v1-3 Count)
(+! v0-0 (the-as uint (- v1-3 (the-as int (-> arg0 start-time)))))
(+! v0-0 (- v1-3 (the-as int (-> arg0 start-time))))
)
v0-0
)
@@ -91,7 +91,7 @@
;; definition for function new-sound-id
(defun new-sound-id ()
(set! *current-sound-id* (+ *current-sound-id* (the-as uint 1)))
(set! *current-sound-id* (+ *current-sound-id* 1))
(if (< (the-as int *current-sound-id*) #x10000)
(set! *current-sound-id* (the-as sound-id #x10000))
)
@@ -840,8 +840,9 @@
(set!
(-> obj play-time)
(+
(+ (-> *display* base-frame-counter) (-> obj time-base))
(the-as uint (rand-vu-int-count (the-as int (-> obj time-random))))
(-> *display* base-frame-counter)
(-> obj time-base)
(rand-vu-int-count (the-as int (-> obj time-random)))
)
)
(set! (-> obj playing-id) (new-sound-id))
@@ -929,8 +930,9 @@
(set!
(-> obj play-time)
(+
(+ (-> *display* base-frame-counter) (-> obj time-base))
(the-as uint (rand-vu-int-count (the-as int (-> obj time-random))))
(-> *display* base-frame-counter)
(-> obj time-base)
(rand-vu-int-count (the-as int (-> obj time-random)))
)
)
)
@@ -120,7 +120,7 @@
(set! (-> gp-0 origin x) -44.0)
(set! (-> gp-0 origin y) 90.0)
(dotimes (s4-1 3)
(let* ((s2-0 (+ (+ s4-1 3840) s5-1))
(let* ((s2-0 (+ s4-1 3840 s5-1))
(s3-0 (lookup-text! *common-text* (the-as game-text-id s2-0) #t))
)
(when (= s2-0 3841)
+10 -19
View File
@@ -516,10 +516,7 @@
int
(+
(-> obj type size)
(the-as
uint
(* (-> obj allocated-length) (the-as int (-> obj type heap-base)))
)
(* (-> obj allocated-length) (the-as int (-> obj type heap-base)))
)
)
)
@@ -536,14 +533,11 @@
type-to-make
(the-as
int
(+
(-> type-to-make size)
(the-as uint (* len (if (type-type? content-type number)
(the-as int (-> content-type size))
4
)
)
)
(+ (-> type-to-make size) (* len (if (type-type? content-type number)
(the-as int (-> content-type size))
4
)
)
)
)
)
@@ -775,13 +769,10 @@
int
(+
(-> array size)
(the-as
uint
(* (-> obj allocated-length) (if (type-type? (-> obj content-type) number)
(the-as int (-> obj content-type size))
4
)
)
(* (-> obj allocated-length) (if (type-type? (-> obj content-type) number)
(the-as int (-> obj content-type size))
4
)
)
)
)
+10 -29
View File
@@ -116,17 +116,11 @@
)
((=
(-> a2-0 heap-cur)
(+
(+ (+ (-> obj stack-size) -4) (the-as int (-> obj type size)))
(the-as int obj)
)
(+ (+ (-> obj stack-size) -4 (-> obj type size)) (the-as int obj))
)
(set!
(-> a2-0 heap-cur)
(the-as
pointer
(+ (+ (+ arg0 -4) (the-as int (-> obj type size))) (the-as int obj))
)
(the-as pointer (+ (+ arg0 -4 (-> obj type size)) (the-as int obj)))
)
(set! (-> obj stack-size) arg0)
)
@@ -193,7 +187,7 @@
;; definition for method 5 of type cpu-thread
;; INFO: Return type mismatch uint vs int.
(defmethod asize-of cpu-thread ((obj cpu-thread))
(the-as int (+ (-> obj type size) (the-as uint (-> obj stack-size))))
(the-as int (+ (-> obj type size) (-> obj stack-size)))
)
;; definition for function remove-exit
@@ -364,7 +358,7 @@
(object-new
allocation
type-to-make
(the-as int (+ (-> process size) (the-as uint arg1)))
(the-as int (+ (-> process size) arg1))
)
(+ (the-as int allocation) 4)
)
@@ -473,7 +467,7 @@
(format #t "~Theap-top: #x~X~%" (-> obj heap-top))
(format #t "~Theap-cur: #x~X~%" (-> obj heap-cur))
(let ((s5-0 *print-column*))
(set! *print-column* (+ *print-column* (the-as uint 64)))
(set! *print-column* (+ *print-column* 64))
(format #t "----~%")
(inspect-process-heap obj)
(format #t "----~%")
@@ -487,7 +481,7 @@
;; definition for method 5 of type process
;; INFO: Return type mismatch uint vs int.
(defmethod asize-of process ((obj process))
(the-as int (+ (-> process size) (the-as uint (-> obj allocated-length))))
(the-as int (+ (-> process size) (-> obj allocated-length)))
)
;; definition for method 2 of type process
@@ -641,10 +635,7 @@
type-to-make
(the-as
int
(+
(+ (-> type-to-make size) (the-as uint (logand -16 (+ (* 12 arg1) 15))))
(the-as uint arg2)
)
(+ (-> type-to-make size) (logand -16 (+ (* 12 arg1) 15)) arg2)
)
)
)
@@ -676,7 +667,7 @@
(set! (-> obj first-shrink) #f)
(set!
(-> obj heap base)
(the-as pointer (logand -16 (+ (+ (the-as int obj) 115) (* 12 arg1))))
(the-as pointer (logand -16 (+ (the-as int obj) 115 (* 12 arg1))))
)
(set! (-> obj heap current) (-> obj heap base))
(set! (-> obj heap top) (&+ (-> obj heap base) arg2))
@@ -693,10 +684,7 @@
((obj dead-pool-heap) (arg0 dead-pool-heap-rec))
(the-as pointer (if (-> arg0 process)
(+
(+
(+ (-> arg0 process allocated-length) -4)
(the-as int (-> process size))
)
(+ (-> arg0 process allocated-length) -4 (-> process size))
(the-as int (-> arg0 process))
)
(-> obj heap base)
@@ -861,14 +849,7 @@
(let ((s4-0 (-> obj dead-list next))
(s3-0 (the-as process #f))
)
(let
((s1-0
(find-gap-by-size
obj
(the-as int (+ (-> process size) (the-as uint arg1)))
)
)
)
(let ((s1-0 (find-gap-by-size obj (the-as int (+ (-> process size) arg1)))))
(cond
((and s4-0 s1-0)
(set! (-> obj dead-list next) (-> s4-0 next))
@@ -16,7 +16,7 @@
;; definition for method 5 of type string
(defmethod asize-of string ((obj string))
(+ (+ (-> obj allocated-length) 1) (the-as int (-> string size)))
(+ (-> obj allocated-length) 1 (-> string size))
)
;; definition for function copy-string<-string
@@ -46,7 +46,7 @@
(object-new
allocation
type-to-make
(+ (+ s2-1 1) (the-as int (-> type-to-make size)))
(+ s2-1 1 (-> type-to-make size))
)
)
)
@@ -57,11 +57,7 @@
(else
(let
((v0-2
(object-new
allocation
type-to-make
(+ (+ arg0 1) (the-as int (-> type-to-make size)))
)
(object-new allocation type-to-make (+ arg0 1 (-> type-to-make size)))
)
)
(set! (-> v0-2 allocated-length) arg0)
@@ -532,34 +528,16 @@
(>= (-> next-char-2 0) (the-as uint 65))
(>= (the-as uint 70) (-> next-char-2 0))
)
(set!
result
(the-as
int
(+ (+ (-> next-char-2 0) -55) (the-as uint (* result 16)))
)
)
(set! result (the-as int (+ (-> next-char-2 0) -55 (* result 16))))
)
((and
(>= (-> next-char-2 0) (the-as uint 97))
(>= (the-as uint 102) (-> next-char-2 0))
)
(set!
result
(the-as
int
(+ (+ (-> next-char-2 0) -87) (the-as uint (* result 16)))
)
)
(set! result (the-as int (+ (-> next-char-2 0) -87 (* result 16))))
)
(else
(set!
result
(the-as
int
(+ (+ (-> next-char-2 0) -48) (the-as uint (* result 16)))
)
)
(set! result (the-as int (+ (-> next-char-2 0) -48 (* result 16))))
)
)
(set! next-char-2 (&-> next-char-2 1))
@@ -573,10 +551,7 @@
(>= (-> a0-4 0) (the-as uint 48))
(>= (the-as uint 49) (-> a0-4 0))
)
(set!
result
(the-as int (+ (+ (-> a0-4 0) -48) (the-as uint (* result 2))))
)
(set! result (the-as int (+ (-> a0-4 0) -48 (* result 2))))
(set! a0-4 (&-> a0-4 1))
)
)
@@ -594,10 +569,7 @@
(>= (-> str-ptr 0) (the-as uint 48))
(>= (the-as uint 57) (-> str-ptr 0))
)
(set!
result
(the-as int (+ (+ (-> str-ptr 0) -48) (the-as uint (* 10 result))))
)
(set! result (the-as int (+ (-> str-ptr 0) -48 (* 10 result))))
(set! str-ptr (&-> str-ptr 1))
)
)
+24 -31
View File
@@ -62,7 +62,7 @@ TEST_F(FormRegressionTest, ExprAdditionMixed1) {
" jr ra\n"
" daddu sp, sp, r0";
std::string type = "(function int uint int)";
std::string expected = "(+ arg0 (the-as int arg1))";
std::string expected = "(+ arg0 arg1)";
test_with_expr(func, type, expected);
}
@@ -73,7 +73,7 @@ TEST_F(FormRegressionTest, ExprAdditionMixed2) {
" jr ra\n"
" daddu sp, sp, r0";
std::string type = "(function uint int uint)";
std::string expected = "(+ arg0 (the-as uint arg1))";
std::string expected = "(+ arg0 arg1)";
test_with_expr(func, type, expected);
}
@@ -106,7 +106,7 @@ TEST_F(FormRegressionTest, ExprAdditionMixed1WrongReturn) {
" jr ra\n"
" daddu sp, sp, r0";
std::string type = "(function int uint uint)";
std::string expected = "(the-as uint (+ arg0 (the-as int arg1)))";
std::string expected = "(the-as uint (+ arg0 arg1))";
test_with_expr(func, type, expected);
}
@@ -117,7 +117,7 @@ TEST_F(FormRegressionTest, ExprAdditionMixed2WrongReturn) {
" jr ra\n"
" daddu sp, sp, r0";
std::string type = "(function uint int int)";
std::string expected = "(the-as int (+ arg0 (the-as uint arg1)))";
std::string expected = "(the-as int (+ arg0 arg1))";
test_with_expr(func, type, expected);
}
@@ -1660,12 +1660,11 @@ TEST_F(FormRegressionTest, ExprInlineArrayMethod5) {
std::string type = "(function inline-array-class int)";
std::string expected =
"(the-as int\n"
" (+ (-> arg0 type size)\n"
" (the-as uint\n"
" (* (-> arg0 allocated-length)"
" (the-as int (-> arg0 type heap-base)))\n"
" )\n"
"(the-as\n"
" int\n"
" (+\n"
" (-> arg0 type size)\n"
" (* (-> arg0 allocated-length) (the-as int (-> arg0 type heap-base)))\n"
" )\n"
" )";
test_with_expr(func, type, expected, true, "inline-array-class");
@@ -1735,12 +1734,12 @@ TEST_F(FormRegressionTest, ExprArrayMethod0) {
" (object-new\n"
" arg0\n"
" arg1\n"
" (the-as\n"
" int\n"
" (+\n"
" (-> arg1 size)\n"
" (the-as uint (* arg3 (if (type-type? arg2 number) (the-as int (-> arg2 size)) 4)))\n"
" )\n"
" (the-as int (+ (-> arg1 size) (* arg3 (if (type-type? arg2 number)\n"
" (the-as int (-> arg2 size))\n"
" 4\n"
" )\n"
" )\n"
" )\n"
" )\n"
" )\n"
" )\n"
@@ -1807,22 +1806,16 @@ TEST_F(FormRegressionTest, ExprArrayMethod5) {
std::string type = "(function array int)";
std::string expected =
" (the-as\n"
" int\n"
" (+\n"
" (-> array size)\n"
" (the-as\n"
" uint\n"
" (*\n"
" (-> arg0 allocated-length)\n"
" (if\n"
" (type-type? (-> arg0 content-type) number)\n"
" (the-as int (-> arg0 content-type size))\n"
" 4\n"
" )\n"
" )\n"
" )\n"
"(the-as\n"
" int\n"
" (+\n"
" (-> array size)\n"
" (* (-> arg0 allocated-length) (if (type-type? (-> arg0 content-type) number)\n"
" (the-as int (-> arg0 content-type size))\n"
" 4\n"
" )\n"
" )\n"
" )\n"
" )";
test_with_expr(func, type, expected, true, "array");
}
@@ -990,8 +990,7 @@ TEST_F(FormRegressionTest, DmaBucketInsertTag) {
std::string type = "(function dma-bucket int pointer (pointer dma-tag) pointer)";
std::string expected =
"(begin\n"
" (let\n"
" ((v1-1 (the-as dma-bucket (+ (the-as uint arg0) (the-as uint (* arg1 16))))))\n"
" (let ((v1-1 (the-as dma-bucket (+ (the-as uint arg0) (* arg1 16)))))\n"
" (set! (-> (the-as dma-bucket (-> v1-1 last)) next) (the-as uint arg2))\n"
" (set! (-> v1-1 last) arg3)\n"
" )\n"
@@ -2342,25 +2342,16 @@ TEST_F(FormRegressionTest, ExprStringToInt) {
" (>= (-> a0-3 0) (the-as uint 65))\n"
" (>= (the-as uint 70) (-> a0-3 0))\n"
" )\n"
" (set!\n"
" v0-0\n"
" (the-as int (+ (+ (-> a0-3 0) -55) (the-as uint (* v0-0 16))))\n"
" )\n"
" (set! v0-0 (the-as int (+ (-> a0-3 0) -55 (* v0-0 16))))\n"
" )\n"
" ((and\n"
" (>= (-> a0-3 0) (the-as uint 97))\n"
" (>= (the-as uint 102) (-> a0-3 0))\n"
" )\n"
" (set!\n"
" v0-0\n"
" (the-as int (+ (+ (-> a0-3 0) -87) (the-as uint (* v0-0 16))))\n"
" )\n"
" (set! v0-0 (the-as int (+ (-> a0-3 0) -87 (* v0-0 16))))\n"
" )\n"
" (else\n"
" (set!\n"
" v0-0\n"
" (the-as int (+ (+ (-> a0-3 0) -48) (the-as uint (* v0-0 16))))\n"
" )\n"
" (set! v0-0 (the-as int (+ (-> a0-3 0) -48 (* v0-0 16))))\n"
" )\n"
" )\n"
" (set! a0-3 (&-> a0-3 1))\n"
@@ -2374,10 +2365,7 @@ TEST_F(FormRegressionTest, ExprStringToInt) {
" (>= (-> a0-4 0) (the-as uint 48))\n"
" (>= (the-as uint 49) (-> a0-4 0))\n"
" )\n"
" (set!\n"
" v0-0\n"
" (the-as int (+ (+ (-> a0-4 0) -48) (the-as uint (* v0-0 2))))\n"
" )\n"
" (set! v0-0 (the-as int (+ (-> a0-4 0) -48 (* v0-0 2))))\n"
" (set! a0-4 (&-> a0-4 1))\n"
" )\n"
" )\n"
@@ -2392,7 +2380,7 @@ TEST_F(FormRegressionTest, ExprStringToInt) {
" )\n"
" (while\n"
" (and (>= (-> a0-1 0) (the-as uint 48)) (>= (the-as uint 57) (-> a0-1 0)))\n"
" (set! v0-0 (the-as int (+ (+ (-> a0-1 0) -48) (the-as uint (* 10 v0-0)))))\n"
" (set! v0-0 (the-as int (+ (-> a0-1 0) -48 (* 10 v0-0))))\n"
" (set! a0-1 (&-> a0-1 1))\n"
" )\n"
" )\n"
+23 -53
View File
@@ -270,17 +270,11 @@ TEST_F(FormRegressionTest, ExprMethod9Thread) {
" )\n"
" ((=\n"
" (-> a2-0 heap-cur)\n"
" (+\n"
" (+ (+ (-> arg0 stack-size) -4) (the-as int (-> arg0 type size)))\n"
" (the-as int arg0)\n"
" )\n"
" (+ (+ (-> arg0 stack-size) -4 (-> arg0 type size)) (the-as int arg0))\n"
" )\n"
" (set!\n"
" (-> a2-0 heap-cur)\n"
" (the-as\n"
" pointer\n"
" (+ (+ (+ arg1 -4) (the-as int (-> arg0 type size))) (the-as int arg0))\n"
" )\n"
" (the-as pointer (+ (+ arg1 -4 (-> arg0 type size)) (the-as int arg0)))\n"
" )\n"
" (set! (-> arg0 stack-size) arg1)\n"
" )\n"
@@ -383,7 +377,7 @@ TEST_F(FormRegressionTest, ExprMethod5CpuThread) {
" jr ra\n"
" daddu sp, sp, r0";
std::string type = "(function cpu-thread int)";
std::string expected = "(the-as int (+ (-> arg0 type size) (the-as uint (-> arg0 stack-size))))";
std::string expected = "(the-as int (+ (-> arg0 type size) (-> arg0 stack-size)))";
test_with_expr(func, type, expected, false);
}
@@ -638,11 +632,7 @@ TEST_F(FormRegressionTest, ExprMethod0Process) {
std::string type = "(function symbol type basic int process)";
std::string expected =
"(let ((v0-0 (if (= (-> arg0 type) symbol)\n"
" (object-new\n"
" arg0\n"
" arg1\n"
" (the-as int (+ (-> process size) (the-as uint arg3)))\n"
" )\n"
" (object-new arg0 arg1 (the-as int (+ (-> process size) arg3)))\n"
" (+ (the-as int arg0) 4)\n"
" )\n"
" )\n"
@@ -766,8 +756,7 @@ TEST_F(FormRegressionTest, ExprMethod5Process) {
" jr ra\n"
" daddu sp, sp, r0";
std::string type = "(function process int)";
std::string expected =
"(the-as int (+ (-> process size) (the-as uint (-> arg0 allocated-length))))";
std::string expected = "(the-as int (+ (-> process size) (-> arg0 allocated-length)))";
test_with_expr(func, type, expected);
}
@@ -1250,13 +1239,7 @@ TEST_F(FormRegressionTest, ExprMethod0DeadPoolHeap) {
" (object-new\n"
" arg0\n"
" arg1\n"
" (the-as\n"
" int\n"
" (+\n"
" (+ (-> arg1 size) (the-as uint (logand -16 (+ (* 12 arg3) 15))))\n"
" (the-as uint arg4)\n"
" )\n"
" )\n"
" (the-as int (+ (-> arg1 size) (logand -16 (+ (* 12 arg3) 15)) arg4))\n"
" )\n"
" )\n"
" )\n"
@@ -1287,7 +1270,7 @@ TEST_F(FormRegressionTest, ExprMethod0DeadPoolHeap) {
" (set! (-> obj first-shrink) #f)\n"
" (set!\n"
" (-> obj heap base)\n"
" (the-as pointer (logand -16 (+ (+ (the-as int obj) 115) (* 12 arg3))))\n"
" (the-as pointer (logand -16 (+ (the-as int obj) 115 (* 12 arg3))))\n"
" )\n"
" (set! (-> obj heap current) (-> obj heap base))\n"
" (set! (-> obj heap top) (&+ (-> obj heap base) arg4))\n"
@@ -1328,10 +1311,7 @@ TEST_F(FormRegressionTest, ExprMethod22DeadPoolHeap) {
std::string expected =
"(the-as pointer (if (-> arg1 process)\n"
" (+\n"
" (+\n"
" (+ (-> arg1 process allocated-length) -4)\n"
" (the-as int (-> process size))\n"
" )\n"
" (+ (-> arg1 process allocated-length) -4 (-> process size))\n"
" (the-as int (-> arg1 process))\n"
" )\n"
" (-> arg0 heap base)\n"
@@ -2004,40 +1984,33 @@ TEST_F(FormRegressionTest, ExprMethod14DeadPoolHeap) {
" daddiu sp, sp, 112";
std::string type = "(function dead-pool-heap type int process)";
std::string expected =
"(let\n"
" ((s4-0 (-> arg0 dead-list next)) (s3-0 (the-as process #f)))\n"
" (let\n"
" ((s1-0 (find-gap-by-size arg0 (the-as int (+ (-> process size) (the-as uint arg2))))))\n"
"(let ((s4-0 (-> arg0 dead-list next))\n"
" (s3-0 (the-as process #f))\n"
" )\n"
" (let ((s1-0 (find-gap-by-size arg0 (the-as int (+ (-> process size) arg2)))))\n"
" (cond\n"
" ((and s4-0 s1-0)\n"
" (set! (-> arg0 dead-list next) (-> s4-0 next))\n"
" (let\n"
" ((v1-5 (-> s1-0 next)))\n"
" (let ((v1-5 (-> s1-0 next)))\n"
" (set! (-> s1-0 next) s4-0)\n"
" (set! (-> s4-0 next) v1-5)\n"
" (if v1-5 (set! (-> v1-5 prev) s4-0))\n"
" (if v1-5\n"
" (set! (-> v1-5 prev) s4-0)\n"
" )\n"
" )\n"
" (set! (-> s4-0 prev) s1-0)\n"
" (if\n"
" (= s1-0 (-> arg0 alive-list prev))\n"
" (if (= s1-0 (-> arg0 alive-list prev))\n"
" (set! (-> arg0 alive-list prev) s4-0)\n"
" )\n"
" (let\n"
" ((a0-4 (gap-location arg0 s1-0)))\n"
" (let ((a0-4 (gap-location arg0 s1-0)))\n"
" (set!\n"
" s3-0\n"
" ((method-of-type process new)\n"
" (the-as symbol a0-4)\n"
" process\n"
" (quote process)\n"
" arg2\n"
" )\n"
" ((method-of-type process new) (the-as symbol a0-4) process 'process arg2)\n"
" )\n"
" )\n"
" (set! (-> s4-0 process) s3-0)\n"
" (set! (-> s3-0 ppointer) (&-> s4-0 process))\n"
" (if\n"
" (= (-> arg0 first-gap) s1-0)\n"
" (if (= (-> arg0 first-gap) s1-0)\n"
" (set! (-> arg0 first-gap) (find-gap arg0 s4-0))\n"
" )\n"
" (if\n"
@@ -2052,11 +2025,9 @@ TEST_F(FormRegressionTest, ExprMethod14DeadPoolHeap) {
" (set! (-> arg0 child) (&-> s4-0 process))\n"
" )\n"
" (else\n"
" (when\n"
" (and *debug-segment* (!= arg0 *debug-dead-pool*))\n"
" (when (and *debug-segment* (!= arg0 *debug-dead-pool*))\n"
" (set! s3-0 (get-process *debug-dead-pool* arg1 arg2))\n"
" (if\n"
" (and s3-0 *vis-boot*)\n"
" (if (and s3-0 *vis-boot*)\n"
" (format\n"
" 0\n"
" \"WARNING: ~A ~A had to be allocated from the debug pool, because ~A was "
@@ -2070,8 +2041,7 @@ TEST_F(FormRegressionTest, ExprMethod14DeadPoolHeap) {
" )\n"
" )\n"
" )\n"
" (if\n"
" s3-0\n"
" (if s3-0\n"
" (set! (-> s3-0 type) arg1)\n"
" (format\n"
" 0\n"