[decompiler] Fix rlet in top level and detect matrix and stack inline construction (#547)

* top level in rlet

* detect matrix and vector inline 0

* pretty print the symbol map
This commit is contained in:
water111
2021-05-31 18:14:18 -04:00
committed by GitHub
parent 84c0522102
commit 3d8013633a
19 changed files with 422 additions and 458 deletions
+17 -7
View File
@@ -943,7 +943,7 @@ void RLetElement::apply(const std::function<void(FormElement*)>& f) {
body->apply(f);
}
goos::Object RLetElement::to_form_internal(const Env& env) const {
goos::Object RLetElement::reg_list() const {
std::vector<goos::Object> regs;
for (auto& reg : sorted_regs) {
if (reg.get_kind() == Reg::RegisterKind::VF ||
@@ -953,17 +953,27 @@ goos::Object RLetElement::to_form_internal(const Env& env) const {
pretty_print::build_list(pretty_print::to_symbol(fmt::format("{} :class vf", reg_name))));
}
}
return pretty_print::build_list(regs);
}
std::vector<goos::Object> rletForm;
rletForm.push_back(pretty_print::to_symbol("rlet"));
rletForm.push_back(pretty_print::build_list(regs));
// NOTE - initialize any relevant registers in the body first
bool RLetElement::needs_vf0_init() const {
for (auto& reg : sorted_regs) {
if (reg.get_kind() == Reg::RegisterKind::VF && reg.to_string() == "vf0") {
rletForm.push_back(pretty_print::to_symbol("(init-vf0-vector)")); // Defined in vector-h.gc
return true;
}
}
return false;
}
goos::Object RLetElement::to_form_internal(const Env& env) const {
std::vector<goos::Object> rletForm;
rletForm.push_back(pretty_print::to_symbol("rlet"));
rletForm.push_back(reg_list());
// NOTE - initialize any relevant registers in the body first
if (needs_vf0_init()) {
rletForm.push_back(pretty_print::to_symbol("(init-vf0-vector)")); // Defined in vector-h.gc
}
body->inline_forms(rletForm, env);
return pretty_print::build_list(rletForm);
+2
View File
@@ -665,6 +665,8 @@ class RLetElement : public FormElement {
explicit RLetElement(Form* _body, RegSet _regs);
goos::Object to_form_internal(const Env& env) const override;
goos::Object reg_list() const;
bool needs_vf0_init() const;
void apply(const std::function<void(FormElement*)>& f) override;
void apply_form(const std::function<void(Form*)>& f) override;
void collect_vars(RegAccessSet& vars, bool recursive) const override;
+9
View File
@@ -551,6 +551,13 @@ DerefTokenMatcher DerefTokenMatcher::string(const std::string& str) {
return result;
}
DerefTokenMatcher DerefTokenMatcher::integer(int value) {
DerefTokenMatcher result;
result.m_kind = Kind::CONSTANT_INTEGER;
result.m_int = value;
return result;
}
DerefTokenMatcher DerefTokenMatcher::any_string(int match_id) {
DerefTokenMatcher result;
result.m_kind = Kind::ANY_STRING;
@@ -570,6 +577,8 @@ bool DerefTokenMatcher::do_match(const DerefToken& input, MatchResult::Maps* map
return true;
}
return false;
case Kind::CONSTANT_INTEGER:
return input.kind() == DerefToken::Kind::INTEGER_CONSTANT && input.is_int(m_int);
default:
assert(false);
return false;
+3 -1
View File
@@ -95,15 +95,17 @@ MatchResult match(const Matcher& spec, Form* input);
class DerefTokenMatcher {
public:
static DerefTokenMatcher string(const std::string& str);
static DerefTokenMatcher integer(int value);
static DerefTokenMatcher any_string(int match_id = -1);
enum class Kind { STRING, ANY_STRING, INVALID };
enum class Kind { STRING, ANY_STRING, CONSTANT_INTEGER, INVALID };
bool do_match(const DerefToken& input, MatchResult::Maps* maps_out) const;
private:
Kind m_kind = Kind::INVALID;
std::string m_str;
int m_int = -1;
int m_str_out_id = -1;
};
+41
View File
@@ -141,6 +141,26 @@ std::string careful_function_to_string(
}
} // namespace
std::string add_indent(const std::string& in, int indent, bool indent_first_line) {
if (in.empty()) {
return in;
}
std::string indent_str(indent, ' ');
std::string result;
char prev_char = indent_first_line ? '\n' : ' ';
for (char c : in) {
if (prev_char == '\n') {
result += indent_str;
}
result += c;
prev_char = c;
}
return result;
}
std::string write_from_top_level(const Function& top_level,
const DecompilerTypeSystem& dts,
const LinkedObjectFile& file,
@@ -198,6 +218,23 @@ std::string write_from_top_level(const Function& top_level,
}
}
// look for the whole thing being in an rlet
bool in_rlet = false;
if (forms.size() == 1) {
auto as_rlet = dynamic_cast<RLetElement*>(forms.at(0));
if (as_rlet) {
forms = as_rlet->body->elts();
in_rlet = true;
result += "(rlet ";
result += add_indent(pretty_print::to_string(as_rlet->reg_list()), 6, false);
result += '\n';
if (as_rlet->needs_vf0_init()) {
result += "(init-vf0-vector)\n";
}
result += '\n';
}
}
// (set! identity L312)
constexpr int func_name = 1;
constexpr int label = 2;
@@ -370,6 +407,10 @@ std::string write_from_top_level(const Function& top_level,
result += ")\n";
}
if (in_rlet) {
result += ")\n";
}
return result;
}
} // namespace decompiler
+99
View File
@@ -261,6 +261,100 @@ FormElement* fix_up_abs_2(LetElement* in, const Env& env, FormPool& pool) {
return in;
}
FormElement* fix_up_vector_inline_zero(LetElement* in, const Env& env, FormPool& pool) {
/*
* (let ((local-trans (new 'stack-no-clear 'vector)))
* (set! (-> local-trans quad) (the-as uint128 0))
*/
if (in->entries().size() != 1) {
return nullptr;
}
if (in->body()->elts().empty()) {
return nullptr;
}
Form* src = in->entries().at(0).src;
auto src_as_stackvar = src->try_as_element<StackVarDefElement>();
if (!src_as_stackvar) {
return nullptr;
}
bool is_vector = src_as_stackvar->type() == TypeSpec("vector");
bool is_matrix = src_as_stackvar->type() == TypeSpec("matrix");
if (is_vector) {
auto first_elt = in->body()->elts().at(0);
auto matcher = Matcher::set(
Matcher::deref(Matcher::any_reg(0), false, {DerefTokenMatcher::string("quad")}),
Matcher::cast("uint128", Matcher::integer(0)));
Form hack;
hack.elts().push_back(first_elt);
auto mr = match(matcher, &hack);
if (mr.matched) {
auto var = in->entries().at(0).dest;
auto var_name = env.get_variable_name(var);
if (var_name != env.get_variable_name(*mr.maps.regs.at(0))) {
return nullptr;
}
auto new_op = pool.alloc_single_element_form<GenericElement>(
nullptr,
GenericOperator::make_function(
pool.alloc_single_element_form<ConstantTokenElement>(nullptr, "new-stack-vector0")));
src->parent_element = in;
in->entries().at(0).src = new_op;
in->body()->elts().erase(in->body()->elts().begin());
return in;
}
} else if (is_matrix) {
if (in->body()->elts().size() < 4) {
return nullptr;
}
auto var = in->entries().at(0).dest;
auto var_name = env.get_variable_name(var);
for (int i = 0; i < 4; i++) {
auto elt = in->body()->elts().at(i);
auto matcher = Matcher::set(
Matcher::deref(Matcher::any_reg(0), false,
{DerefTokenMatcher::string("vector"), DerefTokenMatcher::integer(i),
DerefTokenMatcher::string("quad")}),
Matcher::cast("uint128", Matcher::integer(0)));
Form hack;
hack.elts().push_back(elt);
auto mr = match(matcher, &hack);
if (mr.matched) {
if (var_name != env.get_variable_name(*mr.maps.regs.at(0))) {
return nullptr;
}
} else {
return nullptr;
}
}
auto new_op = pool.alloc_single_element_form<GenericElement>(
nullptr,
GenericOperator::make_function(
pool.alloc_single_element_form<ConstantTokenElement>(nullptr, "new-stack-matrix0")));
src->parent_element = in;
in->entries().at(0).src = new_op;
in->body()->elts().erase(in->body()->elts().begin(), in->body()->elts().begin() + 4);
return in;
}
return nullptr;
}
/*!
* Attempt to rewrite a let as another form. If it cannot be rewritten, this will return nullptr.
*/
@@ -280,6 +374,11 @@ FormElement* rewrite_let(LetElement* in, const Env& env, FormPool& pool) {
return as_abs_2;
}
auto as_vector = fix_up_vector_inline_zero(in, env, pool);
if (as_vector) {
return as_vector;
}
// nothing matched.
return nullptr;
}
+2 -1
View File
@@ -57,7 +57,8 @@ std::string SymbolMapBuilder::convert_to_json() const {
result[file.object_file_name] = syms;
}
return result.dump();
// adding the 4 here should make it pretty print
return result.dump(4);
}
namespace {
+1 -3
View File
@@ -287,9 +287,7 @@
"Unused function to adjust trans based on inputs from the pad."
;; local-trans is the translation in the camera frame.
(let ((local-trans (new 'stack-no-clear 'vector)))
(set! (-> local-trans quad) (the-as uint128 0))
(let ((local-trans (new-stack-vector0)))
;; circle/square move camera relative x (left and right)
(set! (-> local-trans x)
(cond
+44 -106
View File
@@ -177,12 +177,7 @@
"Set dst = src1 * src2. NOTE: this function is a wrapper around matrix*!
that adds no additional functionality. It seems to be a leftover from
a time when matrix*! wasn't safe to use in place. This is unused."
(let ((temp-mat (new 'stack-no-clear 'matrix)))
(set! (-> temp-mat vector 0 quad) (the-as uint128 0))
(set! (-> temp-mat vector 1 quad) (the-as uint128 0))
(set! (-> temp-mat vector 2 quad) (the-as uint128 0))
(set! (-> temp-mat vector 3 quad) (the-as uint128 0))
;; if matrix*! was unsafe to use in place, this would make sense.
(let ((temp-mat (new-stack-matrix0)))
(matrix*! temp-mat src1 src2)
(set! (-> dst vector 0 quad) (-> temp-mat vector 0 quad))
(set! (-> dst vector 1 quad) (-> temp-mat vector 1 quad))
@@ -251,9 +246,8 @@
(defun vector3s-matrix*! ((dst vector3s) (vec vector3s) (mat matrix))
"Set dst to be ([src 1.0] * mat).xyz. Doesn't touch the w of dst.
dst and vec can be the same memory"
(let ((temp-vec3 (new 'stack-no-clear 'vector)))
(let ((temp-vec3 (new-stack-vector0)))
;; create a temporary vec with [x, y, z, 1.0]
(set! (-> temp-vec3 quad) (the-as uint128 0))
(let ((v1-0 temp-vec3))
(set! (-> v1-0 data 0) (-> vec data 0))
(set! (-> v1-0 data 1) (-> vec data 1))
@@ -272,8 +266,7 @@
(defun vector3s-rotate*! ((dst vector3s) (vec vector3s) (mat matrix))
"Set dst to vec rotated by the rotation in the homogeneous transform mat.
mat should not have a scale/shear (the upper 3x3 should be a pure rotation)."
(let ((temp-vec3 (new 'stack-no-clear 'vector)))
(set! (-> temp-vec3 quad) (the-as uint128 0))
(let ((temp-vec3 (new-stack-vector0)))
(let ((v1-0 temp-vec3))
(set! (-> v1-0 data 0) (-> vec data 0))
(set! (-> v1-0 data 1) (-> vec data 1))
@@ -717,114 +710,69 @@
(defun matrix-rotate-zyx! ((dst matrix) (rot-xyz-deg vector))
"Rotate in z,y,x order."
(let ((temp-mat (new 'stack-no-clear 'matrix)))
(set! (-> temp-mat vector 0 quad) (the-as uint128 0))
(set! (-> temp-mat vector 1 quad) (the-as uint128 0))
(set! (-> temp-mat vector 2 quad) (the-as uint128 0))
(set! (-> temp-mat vector 3 quad) (the-as uint128 0))
(let ((rot-mat (new 'stack-no-clear 'matrix)))
(set! (-> rot-mat vector 0 quad) (the-as uint128 0))
(set! (-> rot-mat vector 1 quad) (the-as uint128 0))
(set! (-> rot-mat vector 2 quad) (the-as uint128 0))
(set! (-> rot-mat vector 3 quad) (the-as uint128 0))
;; x-rot
(matrix-rotate-x! dst (-> rot-xyz-deg data 0))
;; y-rot
(matrix-rotate-y! temp-mat (-> rot-xyz-deg data 1))
;; rot-mat = yx
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-z! temp-mat (-> rot-xyz-deg data 2))
;; dst = z*yz
(matrix*! dst temp-mat rot-mat)
)
(let ((temp-mat (new-stack-matrix0))
(rot-mat (new-stack-matrix0)))
;; x-rot
(matrix-rotate-x! dst (-> rot-xyz-deg data 0))
;; y-rot
(matrix-rotate-y! temp-mat (-> rot-xyz-deg data 1))
;; rot-mat = yx
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-z! temp-mat (-> rot-xyz-deg data 2))
;; dst = z*yz
(matrix*! dst temp-mat rot-mat)
)
dst
)
(defun matrix-rotate-xyz! ((dst matrix) (rot-xyz-deg vector))
"Rotate in x,y,z order"
(let ((temp-mat (new 'stack-no-clear 'matrix)))
(set! (-> temp-mat vector 0 quad) (the-as uint128 0))
(set! (-> temp-mat vector 1 quad) (the-as uint128 0))
(set! (-> temp-mat vector 2 quad) (the-as uint128 0))
(set! (-> temp-mat vector 3 quad) (the-as uint128 0))
(let ((rot-mat (new 'stack-no-clear 'matrix)))
(set! (-> rot-mat vector 0 quad) (the-as uint128 0))
(set! (-> rot-mat vector 1 quad) (the-as uint128 0))
(set! (-> rot-mat vector 2 quad) (the-as uint128 0))
(set! (-> rot-mat vector 3 quad) (the-as uint128 0))
(matrix-rotate-z! dst (-> rot-xyz-deg data 2))
(matrix-rotate-y! temp-mat (-> rot-xyz-deg data 1))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-x! temp-mat (-> rot-xyz-deg data 0))
(matrix*! dst temp-mat rot-mat)
)
"Rotate in x,y,z order"
(let ((temp-mat (new-stack-matrix0))
(rot-mat (new-stack-matrix0)))
(matrix-rotate-z! dst (-> rot-xyz-deg data 2))
(matrix-rotate-y! temp-mat (-> rot-xyz-deg data 1))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-x! temp-mat (-> rot-xyz-deg data 0))
(matrix*! dst temp-mat rot-mat)
)
dst
)
(defun matrix-rotate-zxy! ((dst matrix) (rot-xyz-deg vector))
"Rotate in z,x,y order"
(let ((temp-mat (new 'stack-no-clear 'matrix)))
(set! (-> temp-mat vector 0 quad) (the-as uint128 0))
(set! (-> temp-mat vector 1 quad) (the-as uint128 0))
(set! (-> temp-mat vector 2 quad) (the-as uint128 0))
(set! (-> temp-mat vector 3 quad) (the-as uint128 0))
(let ((rot-mat (new 'stack-no-clear 'matrix)))
(set! (-> rot-mat vector 0 quad) (the-as uint128 0))
(set! (-> rot-mat vector 1 quad) (the-as uint128 0))
(set! (-> rot-mat vector 2 quad) (the-as uint128 0))
(set! (-> rot-mat vector 3 quad) (the-as uint128 0))
(matrix-rotate-y! dst (-> rot-xyz-deg data 1))
(matrix-rotate-x! temp-mat (-> rot-xyz-deg data 0))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-z! temp-mat (-> rot-xyz-deg data 2))
(matrix*! dst temp-mat rot-mat)
)
(let ((temp-mat (new-stack-matrix0))
(rot-mat (new-stack-matrix0)))
(matrix-rotate-y! dst (-> rot-xyz-deg data 1))
(matrix-rotate-x! temp-mat (-> rot-xyz-deg data 0))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-z! temp-mat (-> rot-xyz-deg data 2))
(matrix*! dst temp-mat rot-mat)
)
dst
)
(defun matrix-rotate-yxz! ((dst matrix) (rot-xyz-deg vector))
"Rotate in y,x,z order."
(let ((temp-mat (new 'stack-no-clear 'matrix)))
(set! (-> temp-mat vector 0 quad) (the-as uint128 0))
(set! (-> temp-mat vector 1 quad) (the-as uint128 0))
(set! (-> temp-mat vector 2 quad) (the-as uint128 0))
(set! (-> temp-mat vector 3 quad) (the-as uint128 0))
(let ((rot-mat (new 'stack-no-clear 'matrix)))
(set! (-> rot-mat vector 0 quad) (the-as uint128 0))
(set! (-> rot-mat vector 1 quad) (the-as uint128 0))
(set! (-> rot-mat vector 2 quad) (the-as uint128 0))
(set! (-> rot-mat vector 3 quad) (the-as uint128 0))
(matrix-rotate-z! dst (-> rot-xyz-deg data 2))
(matrix-rotate-x! temp-mat (-> rot-xyz-deg data 0))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-y! temp-mat (-> rot-xyz-deg data 1))
(matrix*! dst temp-mat rot-mat)
)
(let ((temp-mat (new-stack-matrix0))
(rot-mat (new-stack-matrix0)))
(matrix-rotate-z! dst (-> rot-xyz-deg data 2))
(matrix-rotate-x! temp-mat (-> rot-xyz-deg data 0))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-y! temp-mat (-> rot-xyz-deg data 1))
(matrix*! dst temp-mat rot-mat)
)
dst
)
(defun matrix-rotate-yzx! ((dst matrix) (rot-xyz-deg vector))
"Rotate in y,z,x order"
(let ((temp-mat (new 'stack-no-clear 'matrix)))
(set! (-> temp-mat vector 0 quad) (the-as uint128 0))
(set! (-> temp-mat vector 1 quad) (the-as uint128 0))
(set! (-> temp-mat vector 2 quad) (the-as uint128 0))
(set! (-> temp-mat vector 3 quad) (the-as uint128 0))
(let ((rot-mat (new 'stack-no-clear 'matrix)))
(set! (-> rot-mat vector 0 quad) (the-as uint128 0))
(set! (-> rot-mat vector 1 quad) (the-as uint128 0))
(set! (-> rot-mat vector 2 quad) (the-as uint128 0))
(set! (-> rot-mat vector 3 quad) (the-as uint128 0))
(matrix-rotate-z! dst (-> rot-xyz-deg data 0))
(matrix-rotate-x! temp-mat (-> rot-xyz-deg data 2))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-y! temp-mat (-> rot-xyz-deg data 1))
(matrix*! dst temp-mat rot-mat)
)
(let ((temp-mat (new-stack-matrix0))
(rot-mat (new-stack-matrix0)))
(matrix-rotate-z! dst (-> rot-xyz-deg data 0))
(matrix-rotate-x! temp-mat (-> rot-xyz-deg data 2))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-y! temp-mat (-> rot-xyz-deg data 1))
(matrix*! dst temp-mat rot-mat)
)
dst
)
@@ -880,17 +828,7 @@
(matrix-rotate-y! dst rot-y-deg)
;; this is weird. probably there is an inlined ctor in a new 'stack expression, used directly
;; in an argument. like (matrix-rotate-x! (new 'stack-with-ctor 'matrix) ...)
(let ((t9-1 matrix-rotate-x!)
(a0-2 (new 'stack-no-clear 'matrix))
)
(set! (-> a0-2 vector 0 quad) (the-as uint128 0))
(set! (-> a0-2 vector 1 quad) (the-as uint128 0))
(set! (-> a0-2 vector 2 quad) (the-as uint128 0))
(set! (-> a0-2 vector 3 quad) (the-as uint128 0))
(let ((a1-2 (t9-1 a0-2 rot-x-deg)))
(matrix*! dst a1-2 dst)
)
)
(matrix*! dst (matrix-rotate-x! (new-stack-matrix0) rot-x-deg) dst)
dst
)
+4 -21
View File
@@ -603,12 +603,7 @@
(vf6 :class vf)
(vf7 :class vf)
)
(let ((v1-0 (new 'stack-no-clear 'matrix)))
(set! (-> v1-0 vector 0 quad) (the-as uint128 0))
(set! (-> v1-0 vector 1 quad) (the-as uint128 0))
(set! (-> v1-0 vector 2 quad) (the-as uint128 0))
(set! (-> v1-0 vector 3 quad) (the-as uint128 0))
(let ((v1-0 (new-stack-matrix0)))
;; compute norm of rows of rotation matrix (vector-dot does only xyz)
(let ((f0-2 (vector-dot (-> arg1 vector 0) (-> arg1 vector 0))))
(let ((f1-3 (vector-dot (-> arg1 vector 1) (-> arg1 vector 1))))
@@ -854,11 +849,7 @@
(defun vector-x-quaternion! ((arg0 vector) (arg1 quaternion))
"Get the first row of the rotation matrix for this quaternion"
(let ((s5-0 (new 'stack-no-clear 'matrix)))
(set! (-> s5-0 vector 0 quad) (the-as uint128 0))
(set! (-> s5-0 vector 1 quad) (the-as uint128 0))
(set! (-> s5-0 vector 2 quad) (the-as uint128 0))
(set! (-> s5-0 vector 3 quad) (the-as uint128 0))
(let ((s5-0 (new-stack-matrix0)))
(quaternion->matrix s5-0 arg1)
(set! (-> arg0 quad) (-> (the-as (pointer uint128) (-> s5-0 data)) 0))
)
@@ -867,11 +858,7 @@
(defun vector-y-quaternion! ((arg0 vector) (arg1 quaternion))
"Get the second row of the rotation matrix for this quaternion"
(let ((s5-0 (new 'stack-no-clear 'matrix)))
(set! (-> s5-0 vector 0 quad) (the-as uint128 0))
(set! (-> s5-0 vector 1 quad) (the-as uint128 0))
(set! (-> s5-0 vector 2 quad) (the-as uint128 0))
(set! (-> s5-0 vector 3 quad) (the-as uint128 0))
(let ((s5-0 (new-stack-matrix0)))
(quaternion->matrix s5-0 arg1)
(set! (-> arg0 quad) (-> (the-as (pointer uint128) (&-> s5-0 data 4)) 0))
)
@@ -880,11 +867,7 @@
(defun vector-z-quaternion! ((arg0 vector) (arg1 quaternion))
"Get the third row of the rotation matrix for this quaternion"
(let ((s5-0 (new 'stack-no-clear 'matrix)))
(set! (-> s5-0 vector 0 quad) (the-as uint128 0))
(set! (-> s5-0 vector 1 quad) (the-as uint128 0))
(set! (-> s5-0 vector 2 quad) (the-as uint128 0))
(set! (-> s5-0 vector 3 quad) (the-as uint128 0))
(let ((s5-0 (new-stack-matrix0)))
(quaternion->matrix s5-0 arg1)
(set! (-> arg0 quad) (-> (the-as (pointer uint128) (&-> s5-0 data 8)) 0))
)
+6 -23
View File
@@ -40,16 +40,9 @@
(defun transform-matrix-calc! ((tf transform) (dst-mat matrix))
"Convert a transform to a matrix. This is not particularly efficient."
(let ((s4-0 (new 'stack-no-clear 'matrix)))
(set! (-> s4-0 vector 0 quad) (the-as uint128 0))
(set! (-> s4-0 vector 1 quad) (the-as uint128 0))
(set! (-> s4-0 vector 2 quad) (the-as uint128 0))
(set! (-> s4-0 vector 3 quad) (the-as uint128 0))
(let ((s3-0 (new 'stack-no-clear 'matrix)))
(set! (-> s3-0 vector 0 quad) (the-as uint128 0))
(set! (-> s3-0 vector 1 quad) (the-as uint128 0))
(set! (-> s3-0 vector 2 quad) (the-as uint128 0))
(set! (-> s3-0 vector 3 quad) (the-as uint128 0))
(let ((s4-0 (new-stack-matrix0))
(s3-0 (new-stack-matrix0))
)
;; start with identity
(matrix-identity! dst-mat)
;; set translation (which also sets identity...)
@@ -65,23 +58,14 @@
(matrix*! s3-0 s4-0 dst-mat)
;; apply scale
(matrix-scale! s4-0 (-> tf scale))
(matrix*! dst-mat s4-0 s3-0)
)
)
)
(defun transform-matrix-parent-calc! ((tf transform) (dst-mat matrix) (inv-scale vector))
"Convert a transform to a matrix, applying an inverse scaling."
(let ((s4-0 (new 'stack-no-clear 'matrix)))
(set! (-> s4-0 vector 0 quad) (the-as uint128 0))
(set! (-> s4-0 vector 1 quad) (the-as uint128 0))
(set! (-> s4-0 vector 2 quad) (the-as uint128 0))
(set! (-> s4-0 vector 3 quad) (the-as uint128 0))
(let ((s3-0 (new 'stack-no-clear 'matrix)))
(set! (-> s3-0 vector 0 quad) (the-as uint128 0))
(set! (-> s3-0 vector 1 quad) (the-as uint128 0))
(set! (-> s3-0 vector 2 quad) (the-as uint128 0))
(set! (-> s3-0 vector 3 quad) (the-as uint128 0))
(let ((s4-0 (new-stack-matrix0))
(s3-0 (new-stack-matrix0))
)
(matrix-identity! s3-0)
(matrix-translate! s3-0 (-> tf trans))
(matrix-inv-scale! s4-0 inv-scale)
@@ -95,7 +79,6 @@
(matrix-scale! s4-0 (-> tf scale))
(matrix*! dst-mat s4-0 s3-0)
)
)
)
(defun trs-matrix-calc! ((tf trs) (dst-mat matrix))
@@ -697,3 +697,24 @@
(dummy-10 () none 10)
)
)
(defmacro new-stack-matrix0 ()
"Get a new matrix on the stack that's set to zero."
`(let ((mat (new 'stack-no-clear 'matrix)))
(set! (-> mat quad 0) (the-as uint128 0))
(set! (-> mat quad 1) (the-as uint128 0))
(set! (-> mat quad 2) (the-as uint128 0))
(set! (-> mat quad 3) (the-as uint128 0))
mat
)
)
(defmacro new-stack-vector0 ()
"Get a stack vector that's set to 0.
This is more efficient than (new 'stack 'vector) because
this doesn't call the constructor."
`(let ((vec (new 'stack-no-clear 'vector)))
(set! (-> vec quad) (the-as uint128 0))
vec
)
)
@@ -372,8 +372,7 @@
(vf6 :class vf)
)
(init-vf0-vector)
(let ((local-trans (new 'stack-no-clear 'vector)))
(set! (-> local-trans quad) (the-as uint128 0))
(let ((local-trans (new-stack-vector0)))
(set! (-> local-trans x) (cond
((nonzero?
(logand
@@ -420,17 +419,12 @@
)
)
(set! (-> local-trans w) 1.0)
(let ((inv-cam-rot (new 'stack-no-clear 'vector)))
(set! (-> inv-cam-rot quad) (the-as uint128 0))
(let ((cam-rot-mat (new 'stack-no-clear 'matrix)))
(set! (-> cam-rot-mat vector 0 quad) (the-as uint128 0))
(set! (-> cam-rot-mat vector 1 quad) (the-as uint128 0))
(set! (-> cam-rot-mat vector 2 quad) (the-as uint128 0))
(set! (-> cam-rot-mat vector 3 quad) (the-as uint128 0))
(vector-negate! inv-cam-rot (-> trans rot))
(matrix-rotate-zyx! cam-rot-mat (-> trans rot))
(vector-matrix*! local-trans local-trans cam-rot-mat)
)
(let ((inv-cam-rot (new-stack-vector0))
(cam-rot-mat (new-stack-matrix0))
)
(vector-negate! inv-cam-rot (-> trans rot))
(matrix-rotate-zyx! cam-rot-mat (-> trans rot))
(vector-matrix*! local-trans local-trans cam-rot-mat)
)
(let ((a0-8 (-> trans trans)))
(let ((v1-23 (-> trans trans)))
@@ -656,90 +650,79 @@
(vf8 :class vf)
(vf9 :class vf)
)
(let ((gp-0 (new 'stack-no-clear 'matrix)))
(set! (-> gp-0 vector 0 quad) (the-as uint128 0))
(set! (-> gp-0 vector 1 quad) (the-as uint128 0))
(set! (-> gp-0 vector 2 quad) (the-as uint128 0))
(set! (-> gp-0 vector 3 quad) (the-as uint128 0))
(let ((s5-0 (new 'stack-no-clear 'matrix)))
(set! (-> s5-0 vector 0 quad) (the-as uint128 0))
(set! (-> s5-0 vector 1 quad) (the-as uint128 0))
(set! (-> s5-0 vector 2 quad) (the-as uint128 0))
(set! (-> s5-0 vector 3 quad) (the-as uint128 0))
(let ((s4-0 (new 'stack 'vector4s-3))
(s3-0 (new 'stack-no-clear 'vector))
)
(set! (-> s3-0 quad) (the-as uint128 0))
(let ((s2-0 (new 'stack 'vector4s-3)))
(matrix*! s5-0 arg0 (-> *math-camera* camera-temp))
(matrix-3x3-inverse-transpose! gp-0 arg0)
(let ((v1-3 s3-0))
(set! (-> v1-3 x) 0.4)
(set! (-> v1-3 y) 0.4)
(set! (-> v1-3 z) 0.4)
(set! (-> v1-3 w) 1.0)
)
(let ((v1-4 (-> s4-0 data)))
(set! (-> v1-4 0) 1.0)
(set! (-> v1-4 1) 1.0)
(set! (-> v1-4 2) 1.0)
(set! (-> v1-4 3) 1.0)
)
(let ((v1-5 (&-> s4-0 data 4)))
(set! (-> v1-5 0) 0.0)
(set! (-> v1-5 1) 0.0)
(set! (-> v1-5 2) 0.0)
(set! (-> v1-5 3) 1.0)
)
(let ((v1-6 (&-> s4-0 data 8)))
(set! (-> v1-6 0) 0.0)
(set! (-> v1-6 1) 0.0)
(set! (-> v1-6 2) 0.0)
(set! (-> v1-6 3) 1.0)
)
(let ((v1-7 (-> s2-0 data)))
(set! (-> v1-7 0) 1.0)
(set! (-> v1-7 1) 0.0)
(set! (-> v1-7 2) 0.0)
(set! (-> v1-7 3) 1.0)
)
(let ((v1-8 (&-> s2-0 data 4)))
(set! (-> v1-8 0) 0.0)
(set! (-> v1-8 1) 1.0)
(set! (-> v1-8 2) 0.0)
(set! (-> v1-8 3) 1.0)
)
(let ((v1-9 (&-> s2-0 data 8)))
(set! (-> v1-9 0) 0.0)
(set! (-> v1-9 1) 0.0)
(set! (-> v1-9 2) 1.0)
(set! (-> v1-9 3) 1.0)
)
(.lvf vf7 (&-> *math-camera* hmge-scale quad))
(.lvf vf8 (&-> *math-camera* hvdf-off quad))
(.lvf vf9 (&-> *math-camera* giftex))
(let ((v1-13 255))
(.mov vf6 v1-13)
)
(.mov v1-14 vf6)
(.itof.vf vf6 vf6)
(.lvf vf1 (&-> s5-0 vector 0 quad))
(.lvf vf2 (&-> s5-0 vector 1 quad))
(.lvf vf3 (&-> s5-0 vector 2 quad))
(.lvf vf4 (&-> s5-0 vector 3 quad))
(.lvf vf17 (&-> gp-0 vector 0 quad))
(.lvf vf18 (&-> gp-0 vector 1 quad))
(.lvf vf19 (&-> gp-0 vector 2 quad))
(.lvf vf23 (&-> s2-0 quad 0))
(.lvf vf24 (&-> s2-0 quad 1))
(.lvf vf25 (&-> s2-0 quad 2))
)
(.lvf vf27 (&-> s4-0 quad 0))
(.lvf vf28 (&-> s4-0 quad 1))
(.lvf vf29 (&-> s4-0 quad 2))
(.lvf vf26 (&-> s3-0 quad))
(let ((gp-0 (new-stack-matrix0))
(s5-0 (new-stack-matrix0))
(s4-0 (new 'stack 'vector4s-3))
(s3-0 (new-stack-vector0))
)
(let ((s2-0 (new 'stack 'vector4s-3)))
(matrix*! s5-0 arg0 (-> *math-camera* camera-temp))
(matrix-3x3-inverse-transpose! gp-0 arg0)
(let ((v1-3 s3-0))
(set! (-> v1-3 x) 0.4)
(set! (-> v1-3 y) 0.4)
(set! (-> v1-3 z) 0.4)
(set! (-> v1-3 w) 1.0)
)
(let ((v1-4 (-> s4-0 data)))
(set! (-> v1-4 0) 1.0)
(set! (-> v1-4 1) 1.0)
(set! (-> v1-4 2) 1.0)
(set! (-> v1-4 3) 1.0)
)
(let ((v1-5 (&-> s4-0 data 4)))
(set! (-> v1-5 0) 0.0)
(set! (-> v1-5 1) 0.0)
(set! (-> v1-5 2) 0.0)
(set! (-> v1-5 3) 1.0)
)
(let ((v1-6 (&-> s4-0 data 8)))
(set! (-> v1-6 0) 0.0)
(set! (-> v1-6 1) 0.0)
(set! (-> v1-6 2) 0.0)
(set! (-> v1-6 3) 1.0)
)
(let ((v1-7 (-> s2-0 data)))
(set! (-> v1-7 0) 1.0)
(set! (-> v1-7 1) 0.0)
(set! (-> v1-7 2) 0.0)
(set! (-> v1-7 3) 1.0)
)
(let ((v1-8 (&-> s2-0 data 4)))
(set! (-> v1-8 0) 0.0)
(set! (-> v1-8 1) 1.0)
(set! (-> v1-8 2) 0.0)
(set! (-> v1-8 3) 1.0)
)
(let ((v1-9 (&-> s2-0 data 8)))
(set! (-> v1-9 0) 0.0)
(set! (-> v1-9 1) 0.0)
(set! (-> v1-9 2) 1.0)
(set! (-> v1-9 3) 1.0)
)
(.lvf vf7 (&-> *math-camera* hmge-scale quad))
(.lvf vf8 (&-> *math-camera* hvdf-off quad))
(.lvf vf9 (&-> *math-camera* giftex))
(let ((v1-13 255))
(.mov vf6 v1-13)
)
(.mov v1-14 vf6)
(.itof.vf vf6 vf6)
(.lvf vf1 (&-> s5-0 vector 0 quad))
(.lvf vf2 (&-> s5-0 vector 1 quad))
(.lvf vf3 (&-> s5-0 vector 2 quad))
(.lvf vf4 (&-> s5-0 vector 3 quad))
(.lvf vf17 (&-> gp-0 vector 0 quad))
(.lvf vf18 (&-> gp-0 vector 1 quad))
(.lvf vf19 (&-> gp-0 vector 2 quad))
(.lvf vf23 (&-> s2-0 quad 0))
(.lvf vf24 (&-> s2-0 quad 1))
(.lvf vf25 (&-> s2-0 quad 2))
)
(.lvf vf27 (&-> s4-0 quad 0))
(.lvf vf28 (&-> s4-0 quad 1))
(.lvf vf29 (&-> s4-0 quad 2))
(.lvf vf26 (&-> s3-0 quad))
)
(none)
)
@@ -148,9 +148,8 @@
)
(init-vf0-vector)
(let ((f30-0 (- (quaternion-y-angle (the-as quaternion (-> arg0 root rot)))))
(s5-0 (new 'stack-no-clear 'vector))
(s5-0 (new-stack-vector0))
)
(set! (-> s5-0 quad) (the-as uint128 0))
(let ((f28-0 (+ (-> arg1 x) (* arg2 (-> arg1 z))))
(f26-0 (+ (-> arg1 y) (* arg3 (-> arg1 z))))
)
@@ -263,7 +262,3 @@
)
)
)
@@ -157,11 +157,7 @@
;; definition for function matrixp*!
;; Used lq/sq
(defun matrixp*! ((dst matrix) (src1 matrix) (src2 matrix))
(let ((temp-mat (new 'stack-no-clear 'matrix)))
(set! (-> temp-mat vector 0 quad) (the-as uint128 0))
(set! (-> temp-mat vector 1 quad) (the-as uint128 0))
(set! (-> temp-mat vector 2 quad) (the-as uint128 0))
(set! (-> temp-mat vector 3 quad) (the-as uint128 0))
(let ((temp-mat (new-stack-matrix0)))
(matrix*! temp-mat src1 src2)
(set! (-> dst vector 0 quad) (-> temp-mat vector 0 quad))
(set! (-> dst vector 1 quad) (-> temp-mat vector 1 quad))
@@ -225,8 +221,7 @@
;; definition for function vector3s-matrix*!
;; Used lq/sq
(defun vector3s-matrix*! ((dst vector3s) (vec vector3s) (mat matrix))
(let ((temp-vec3 (new 'stack-no-clear 'vector)))
(set! (-> temp-vec3 quad) (the-as uint128 0))
(let ((temp-vec3 (new-stack-vector0)))
(let ((v1-0 temp-vec3))
(set! (-> v1-0 x) (-> vec data 0))
(set! (-> v1-0 y) (-> vec data 1))
@@ -244,8 +239,7 @@
;; definition for function vector3s-rotate*!
;; Used lq/sq
(defun vector3s-rotate*! ((dst vector3s) (vec vector3s) (mat matrix))
(let ((temp-vec3 (new 'stack-no-clear 'vector)))
(set! (-> temp-vec3 quad) (the-as uint128 0))
(let ((temp-vec3 (new-stack-vector0)))
(let ((v1-0 temp-vec3))
(set! (-> v1-0 x) (-> vec data 0))
(set! (-> v1-0 y) (-> vec data 1))
@@ -660,22 +654,14 @@
;; definition for function matrix-rotate-zyx!
;; Used lq/sq
(defun matrix-rotate-zyx! ((dst matrix) (rot-xyz-deg vector))
(let ((temp-mat (new 'stack-no-clear 'matrix)))
(set! (-> temp-mat vector 0 quad) (the-as uint128 0))
(set! (-> temp-mat vector 1 quad) (the-as uint128 0))
(set! (-> temp-mat vector 2 quad) (the-as uint128 0))
(set! (-> temp-mat vector 3 quad) (the-as uint128 0))
(let ((rot-mat (new 'stack-no-clear 'matrix)))
(set! (-> rot-mat vector 0 quad) (the-as uint128 0))
(set! (-> rot-mat vector 1 quad) (the-as uint128 0))
(set! (-> rot-mat vector 2 quad) (the-as uint128 0))
(set! (-> rot-mat vector 3 quad) (the-as uint128 0))
(matrix-rotate-x! dst (-> rot-xyz-deg x))
(matrix-rotate-y! temp-mat (-> rot-xyz-deg y))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-z! temp-mat (-> rot-xyz-deg z))
(matrix*! dst temp-mat rot-mat)
)
(let ((temp-mat (new-stack-matrix0))
(rot-mat (new-stack-matrix0))
)
(matrix-rotate-x! dst (-> rot-xyz-deg x))
(matrix-rotate-y! temp-mat (-> rot-xyz-deg y))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-z! temp-mat (-> rot-xyz-deg z))
(matrix*! dst temp-mat rot-mat)
)
dst
)
@@ -683,22 +669,14 @@
;; definition for function matrix-rotate-xyz!
;; Used lq/sq
(defun matrix-rotate-xyz! ((dst matrix) (rot-xyz-deg vector))
(let ((temp-mat (new 'stack-no-clear 'matrix)))
(set! (-> temp-mat vector 0 quad) (the-as uint128 0))
(set! (-> temp-mat vector 1 quad) (the-as uint128 0))
(set! (-> temp-mat vector 2 quad) (the-as uint128 0))
(set! (-> temp-mat vector 3 quad) (the-as uint128 0))
(let ((rot-mat (new 'stack-no-clear 'matrix)))
(set! (-> rot-mat vector 0 quad) (the-as uint128 0))
(set! (-> rot-mat vector 1 quad) (the-as uint128 0))
(set! (-> rot-mat vector 2 quad) (the-as uint128 0))
(set! (-> rot-mat vector 3 quad) (the-as uint128 0))
(matrix-rotate-z! dst (-> rot-xyz-deg z))
(matrix-rotate-y! temp-mat (-> rot-xyz-deg y))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-x! temp-mat (-> rot-xyz-deg x))
(matrix*! dst temp-mat rot-mat)
)
(let ((temp-mat (new-stack-matrix0))
(rot-mat (new-stack-matrix0))
)
(matrix-rotate-z! dst (-> rot-xyz-deg z))
(matrix-rotate-y! temp-mat (-> rot-xyz-deg y))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-x! temp-mat (-> rot-xyz-deg x))
(matrix*! dst temp-mat rot-mat)
)
dst
)
@@ -706,22 +684,14 @@
;; definition for function matrix-rotate-zxy!
;; Used lq/sq
(defun matrix-rotate-zxy! ((dst matrix) (rot-xyz-deg vector))
(let ((temp-mat (new 'stack-no-clear 'matrix)))
(set! (-> temp-mat vector 0 quad) (the-as uint128 0))
(set! (-> temp-mat vector 1 quad) (the-as uint128 0))
(set! (-> temp-mat vector 2 quad) (the-as uint128 0))
(set! (-> temp-mat vector 3 quad) (the-as uint128 0))
(let ((rot-mat (new 'stack-no-clear 'matrix)))
(set! (-> rot-mat vector 0 quad) (the-as uint128 0))
(set! (-> rot-mat vector 1 quad) (the-as uint128 0))
(set! (-> rot-mat vector 2 quad) (the-as uint128 0))
(set! (-> rot-mat vector 3 quad) (the-as uint128 0))
(matrix-rotate-y! dst (-> rot-xyz-deg y))
(matrix-rotate-x! temp-mat (-> rot-xyz-deg x))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-z! temp-mat (-> rot-xyz-deg z))
(matrix*! dst temp-mat rot-mat)
)
(let ((temp-mat (new-stack-matrix0))
(rot-mat (new-stack-matrix0))
)
(matrix-rotate-y! dst (-> rot-xyz-deg y))
(matrix-rotate-x! temp-mat (-> rot-xyz-deg x))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-z! temp-mat (-> rot-xyz-deg z))
(matrix*! dst temp-mat rot-mat)
)
dst
)
@@ -729,22 +699,14 @@
;; definition for function matrix-rotate-yxz!
;; Used lq/sq
(defun matrix-rotate-yxz! ((dst matrix) (rot-xyz-deg vector))
(let ((temp-mat (new 'stack-no-clear 'matrix)))
(set! (-> temp-mat vector 0 quad) (the-as uint128 0))
(set! (-> temp-mat vector 1 quad) (the-as uint128 0))
(set! (-> temp-mat vector 2 quad) (the-as uint128 0))
(set! (-> temp-mat vector 3 quad) (the-as uint128 0))
(let ((rot-mat (new 'stack-no-clear 'matrix)))
(set! (-> rot-mat vector 0 quad) (the-as uint128 0))
(set! (-> rot-mat vector 1 quad) (the-as uint128 0))
(set! (-> rot-mat vector 2 quad) (the-as uint128 0))
(set! (-> rot-mat vector 3 quad) (the-as uint128 0))
(matrix-rotate-z! dst (-> rot-xyz-deg z))
(matrix-rotate-x! temp-mat (-> rot-xyz-deg x))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-y! temp-mat (-> rot-xyz-deg y))
(matrix*! dst temp-mat rot-mat)
)
(let ((temp-mat (new-stack-matrix0))
(rot-mat (new-stack-matrix0))
)
(matrix-rotate-z! dst (-> rot-xyz-deg z))
(matrix-rotate-x! temp-mat (-> rot-xyz-deg x))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-y! temp-mat (-> rot-xyz-deg y))
(matrix*! dst temp-mat rot-mat)
)
dst
)
@@ -752,22 +714,14 @@
;; definition for function matrix-rotate-yzx!
;; Used lq/sq
(defun matrix-rotate-yzx! ((dst matrix) (rot-xyz-deg vector))
(let ((temp-mat (new 'stack-no-clear 'matrix)))
(set! (-> temp-mat vector 0 quad) (the-as uint128 0))
(set! (-> temp-mat vector 1 quad) (the-as uint128 0))
(set! (-> temp-mat vector 2 quad) (the-as uint128 0))
(set! (-> temp-mat vector 3 quad) (the-as uint128 0))
(let ((rot-mat (new 'stack-no-clear 'matrix)))
(set! (-> rot-mat vector 0 quad) (the-as uint128 0))
(set! (-> rot-mat vector 1 quad) (the-as uint128 0))
(set! (-> rot-mat vector 2 quad) (the-as uint128 0))
(set! (-> rot-mat vector 3 quad) (the-as uint128 0))
(matrix-rotate-z! dst (-> rot-xyz-deg x))
(matrix-rotate-x! temp-mat (-> rot-xyz-deg z))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-y! temp-mat (-> rot-xyz-deg y))
(matrix*! dst temp-mat rot-mat)
)
(let ((temp-mat (new-stack-matrix0))
(rot-mat (new-stack-matrix0))
)
(matrix-rotate-z! dst (-> rot-xyz-deg x))
(matrix-rotate-x! temp-mat (-> rot-xyz-deg z))
(matrix*! rot-mat temp-mat dst)
(matrix-rotate-y! temp-mat (-> rot-xyz-deg y))
(matrix*! dst temp-mat rot-mat)
)
dst
)
@@ -817,16 +771,11 @@
;; Used lq/sq
(defun matrix-rotate-yx! ((dst matrix) (rot-y-deg float) (rot-x-deg float))
(matrix-rotate-y! dst rot-y-deg)
(let ((t9-1 matrix-rotate-x!)
(a0-2 (new 'stack-no-clear 'matrix))
)
(set! (-> a0-2 vector 0 quad) (the-as uint128 0))
(set! (-> a0-2 vector 1 quad) (the-as uint128 0))
(set! (-> a0-2 vector 2 quad) (the-as uint128 0))
(set! (-> a0-2 vector 3 quad) (the-as uint128 0))
(let ((a1-2 (t9-1 a0-2 rot-x-deg)))
(matrix*! dst a1-2 dst)
)
(let* ((t9-1 matrix-rotate-x!)
(a0-2 (new-stack-matrix0))
(a1-2 (t9-1 a0-2 rot-x-deg))
)
(matrix*! dst a1-2 dst)
)
dst
)
@@ -1688,7 +1637,3 @@
;; definition for method 9 of type matrix
;; ERROR: function was not converted to expressions. Cannot decompile.
@@ -617,11 +617,7 @@
(vf6 :class vf)
(vf7 :class vf)
)
(let ((v1-0 (new 'stack-no-clear 'matrix)))
(set! (-> v1-0 vector 0 quad) (the-as uint128 0))
(set! (-> v1-0 vector 1 quad) (the-as uint128 0))
(set! (-> v1-0 vector 2 quad) (the-as uint128 0))
(set! (-> v1-0 vector 3 quad) (the-as uint128 0))
(let ((v1-0 (new-stack-matrix0)))
(let* ((a3-0 (-> arg1 data))
(a2-0 (-> arg1 data))
(f0-0 (-> a3-0 0))
@@ -895,11 +891,7 @@
;; definition for function vector-x-quaternion!
;; Used lq/sq
(defun vector-x-quaternion! ((arg0 vector) (arg1 quaternion))
(let ((s5-0 (new 'stack-no-clear 'matrix)))
(set! (-> s5-0 vector 0 quad) (the-as uint128 0))
(set! (-> s5-0 vector 1 quad) (the-as uint128 0))
(set! (-> s5-0 vector 2 quad) (the-as uint128 0))
(set! (-> s5-0 vector 3 quad) (the-as uint128 0))
(let ((s5-0 (new-stack-matrix0)))
(quaternion->matrix s5-0 arg1)
(set! (-> arg0 quad) (-> (the-as (pointer uint128) (-> s5-0 data)) 0))
)
@@ -909,11 +901,7 @@
;; definition for function vector-y-quaternion!
;; Used lq/sq
(defun vector-y-quaternion! ((arg0 vector) (arg1 quaternion))
(let ((s5-0 (new 'stack-no-clear 'matrix)))
(set! (-> s5-0 vector 0 quad) (the-as uint128 0))
(set! (-> s5-0 vector 1 quad) (the-as uint128 0))
(set! (-> s5-0 vector 2 quad) (the-as uint128 0))
(set! (-> s5-0 vector 3 quad) (the-as uint128 0))
(let ((s5-0 (new-stack-matrix0)))
(quaternion->matrix s5-0 arg1)
(set! (-> arg0 quad) (-> (the-as (pointer uint128) (&-> s5-0 data 4)) 0))
)
@@ -923,11 +911,7 @@
;; definition for function vector-z-quaternion!
;; Used lq/sq
(defun vector-z-quaternion! ((arg0 vector) (arg1 quaternion))
(let ((s5-0 (new 'stack-no-clear 'matrix)))
(set! (-> s5-0 vector 0 quad) (the-as uint128 0))
(set! (-> s5-0 vector 1 quad) (the-as uint128 0))
(set! (-> s5-0 vector 2 quad) (the-as uint128 0))
(set! (-> s5-0 vector 3 quad) (the-as uint128 0))
(let ((s5-0 (new-stack-matrix0)))
(quaternion->matrix s5-0 arg1)
(set! (-> arg0 quad) (-> (the-as (pointer uint128) (&-> s5-0 data 8)) 0))
)
@@ -1015,13 +999,11 @@
(s3-0 (new 'stack-no-clear 'quaternion))
)
(set! (-> s3-0 vec quad) (the-as uint128 0))
(let ((t9-0 vector-x-quaternion!)
(a0-1 (new 'stack-no-clear 'vector))
)
(set! (-> a0-1 quad) (the-as uint128 0))
(let ((a1-3 (s4-0 s3-0 (t9-0 a0-1 arg1) arg2)))
(quaternion-normalize! (quaternion*! arg0 a1-3 arg1))
)
(let* ((t9-0 vector-x-quaternion!)
(a0-1 (new-stack-vector0))
(a1-3 (s4-0 s3-0 (t9-0 a0-1 arg1) arg2))
)
(quaternion-normalize! (quaternion*! arg0 a1-3 arg1))
)
)
)
@@ -1033,13 +1015,11 @@
(s3-0 (new 'stack-no-clear 'quaternion))
)
(set! (-> s3-0 vec quad) (the-as uint128 0))
(let ((t9-0 vector-z-quaternion!)
(a0-1 (new 'stack-no-clear 'vector))
)
(set! (-> a0-1 quad) (the-as uint128 0))
(let ((a1-3 (s4-0 s3-0 (t9-0 a0-1 arg1) arg2)))
(quaternion-normalize! (quaternion*! arg0 a1-3 arg1))
)
(let* ((t9-0 vector-z-quaternion!)
(a0-1 (new-stack-vector0))
(a1-3 (s4-0 s3-0 (t9-0 a0-1 arg1) arg2))
)
(quaternion-normalize! (quaternion*! arg0 a1-3 arg1))
)
)
)
@@ -48,27 +48,19 @@
;; definition for function transform-matrix-calc!
;; Used lq/sq
(defun transform-matrix-calc! ((tf transform) (dst-mat matrix))
(let ((s4-0 (new 'stack-no-clear 'matrix)))
(set! (-> s4-0 vector 0 quad) (the-as uint128 0))
(set! (-> s4-0 vector 1 quad) (the-as uint128 0))
(set! (-> s4-0 vector 2 quad) (the-as uint128 0))
(set! (-> s4-0 vector 3 quad) (the-as uint128 0))
(let ((s3-0 (new 'stack-no-clear 'matrix)))
(set! (-> s3-0 vector 0 quad) (the-as uint128 0))
(set! (-> s3-0 vector 1 quad) (the-as uint128 0))
(set! (-> s3-0 vector 2 quad) (the-as uint128 0))
(set! (-> s3-0 vector 3 quad) (the-as uint128 0))
(matrix-identity! dst-mat)
(matrix-translate! dst-mat (-> tf trans))
(matrix-rotate-y! s4-0 (-> tf rot y))
(matrix*! s3-0 s4-0 dst-mat)
(matrix-rotate-x! s4-0 (-> tf rot x))
(matrix*! dst-mat s4-0 s3-0)
(matrix-rotate-z! s4-0 (-> tf rot z))
(matrix*! s3-0 s4-0 dst-mat)
(matrix-scale! s4-0 (-> tf scale))
(matrix*! dst-mat s4-0 s3-0)
)
(let ((s4-0 (new-stack-matrix0))
(s3-0 (new-stack-matrix0))
)
(matrix-identity! dst-mat)
(matrix-translate! dst-mat (-> tf trans))
(matrix-rotate-y! s4-0 (-> tf rot y))
(matrix*! s3-0 s4-0 dst-mat)
(matrix-rotate-x! s4-0 (-> tf rot x))
(matrix*! dst-mat s4-0 s3-0)
(matrix-rotate-z! s4-0 (-> tf rot z))
(matrix*! s3-0 s4-0 dst-mat)
(matrix-scale! s4-0 (-> tf scale))
(matrix*! dst-mat s4-0 s3-0)
)
)
@@ -77,29 +69,21 @@
(defun
transform-matrix-parent-calc!
((tf transform) (dst-mat matrix) (inv-scale vector))
(let ((s4-0 (new 'stack-no-clear 'matrix)))
(set! (-> s4-0 vector 0 quad) (the-as uint128 0))
(set! (-> s4-0 vector 1 quad) (the-as uint128 0))
(set! (-> s4-0 vector 2 quad) (the-as uint128 0))
(set! (-> s4-0 vector 3 quad) (the-as uint128 0))
(let ((s3-0 (new 'stack-no-clear 'matrix)))
(set! (-> s3-0 vector 0 quad) (the-as uint128 0))
(set! (-> s3-0 vector 1 quad) (the-as uint128 0))
(set! (-> s3-0 vector 2 quad) (the-as uint128 0))
(set! (-> s3-0 vector 3 quad) (the-as uint128 0))
(matrix-identity! s3-0)
(matrix-translate! s3-0 (-> tf trans))
(matrix-inv-scale! s4-0 inv-scale)
(matrix*! dst-mat s4-0 s3-0)
(matrix-rotate-y! s4-0 (-> tf rot y))
(matrix*! s3-0 s4-0 dst-mat)
(matrix-rotate-x! s4-0 (-> tf rot x))
(matrix*! dst-mat s4-0 s3-0)
(matrix-rotate-z! s4-0 (-> tf rot z))
(matrix*! s3-0 s4-0 dst-mat)
(matrix-scale! s4-0 (-> tf scale))
(matrix*! dst-mat s4-0 s3-0)
)
(let ((s4-0 (new-stack-matrix0))
(s3-0 (new-stack-matrix0))
)
(matrix-identity! s3-0)
(matrix-translate! s3-0 (-> tf trans))
(matrix-inv-scale! s4-0 inv-scale)
(matrix*! dst-mat s4-0 s3-0)
(matrix-rotate-y! s4-0 (-> tf rot y))
(matrix*! s3-0 s4-0 dst-mat)
(matrix-rotate-x! s4-0 (-> tf rot x))
(matrix*! dst-mat s4-0 s3-0)
(matrix-rotate-z! s4-0 (-> tf rot z))
(matrix*! s3-0 s4-0 dst-mat)
(matrix-scale! s4-0 (-> tf scale))
(matrix*! dst-mat s4-0 s3-0)
)
)
@@ -107,7 +91,3 @@
(defun trs-matrix-calc! ((tf trs) (dst-mat matrix))
(transform-matrix-calc! (the-as transform (-> tf trans)) dst-mat)
)
+2 -10
View File
@@ -40,11 +40,7 @@ TEST_F(FormRegressionTest, MatrixPMult) {
std::string type = "(function matrix matrix matrix matrix)";
std::string expected =
"(begin\n"
" (let ((s5-0 (new (quote stack-no-clear) (quote matrix))))\n"
" (set! (-> s5-0 vector 0 quad) (the-as uint128 0))\n"
" (set! (-> s5-0 vector 1 quad) (the-as uint128 0))\n"
" (set! (-> s5-0 vector 2 quad) (the-as uint128 0))\n"
" (set! (-> s5-0 vector 3 quad) (the-as uint128 0))\n"
" (let ((s5-0 (new-stack-matrix0)))\n"
" (matrix*! s5-0 arg1 arg2)\n"
" (set! (-> arg0 vector 0 quad) (-> s5-0 vector 0 quad))\n"
" (set! (-> arg0 vector 1 quad) (-> s5-0 vector 1 quad))\n"
@@ -93,11 +89,7 @@ TEST_F(FormRegressionTest, VectorXQuaternionWithCast) {
std::string type = "(function quaternion quaternion quaternion)";
std::string expected =
"(begin\n"
" (let ((s5-0 (new (quote stack-no-clear) (quote matrix))))\n"
" (set! (-> s5-0 vector 0 quad) (the-as uint128 0))\n"
" (set! (-> s5-0 vector 1 quad) (the-as uint128 0))\n"
" (set! (-> s5-0 vector 2 quad) (the-as uint128 0))\n"
" (set! (-> s5-0 vector 3 quad) (the-as uint128 0))\n"
" (let ((s5-0 (new-stack-matrix0)))\n"
" (quaternion->matrix s5-0 arg1)\n"
" (set! (-> arg0 vec quad) (-> (the-as (pointer uint128) (-> s5-0 data)) 0))\n"
" )\n"
+2
View File
@@ -245,6 +245,8 @@ class OfflineDecompilation : public ::testing::Test {
object_files.insert(p.first);
}
config->allowed_objects = object_files;
// don't try to do this because we can't write the file
config->generate_symbol_definition_map = false;
std::vector<std::string> dgos = {"CGO/KERNEL.CGO", "CGO/ENGINE.CGO"};
std::vector<std::string> dgo_paths;