123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- // fpoint.h - [2020-04-13 11:57:47]
- #ifndef _FPOINT_H_
- #define _FPOINT_H_
- #include "common_type.h"
- #include "log.h"
- //-------------------------------------------------------------------------------------------------
- enum PointType : uint {
- PointType_0,
- PointType_14 = 14,
- PointType_18 = 18,
- PointType_26 = 26,
- };
- //-------------------------------------------------------------------------------------------------
- template <uint t>
- class fpoint {
- public:
- int var_0;
- //int test_4;//测试使用
- };
- //-------------------------------------------------------------------------------------------------
- template <PointType t>
- class fpoint2 {
- public:
- int x_0;
- int y_4;
- };
- //-------------------------------------------------------------------------------------------------
- template <uint t>
- class fpoint3 {
- public:
- fpoint3() {
- //x_0 = y_4 = z_8 = 0;
- }
- // 0016bea2 //^-^
- template <uint t1>
- __attribute__((noinline)) fpoint3(const fpoint3<t1>& pt1) {
- //这一段不知道为啥优化了
- x_0 = 0;
- y_4 = 0;
- z_8 = 0;
- x_0 = pt1.x_0 << 8;
- y_4 = pt1.y_4 << 8;
- z_8 = pt1.z_8 << 8;
- }
- int x_0;
- int y_4;
- int z_8;
- };
- //-------------------------------------------------------------------------------------------------
- template <uint t>
- class fpointQ {
- public:
- // 0016c652 //^_-
- fpointQ<t>& __attribute__((noinline)) operator+=(const fpointQ<t>& pt1) {
- /*
- 这几行赋值语句被优化成向量运算代码了
- 原始汇编:ldmia.w r0, {r2, r3, ip, lr}
- ldr r4, [r1, #0]
- add r2, r4
- str r2, [r0, #0]
- ...
- ldr r1, [r1, #12]
- add r1, lr
- str r1, [r0, #12]
- 自己汇编:adds r1,#36
- vld1.32 {d16,d17},[r1]
- vld1.32 {d18,d19},[r0]
- vadd q8,q9,q8
- vst1.32 {d16,d17{,[r0]
- */
- field_0 += pt1.field_0;
- field_4 += pt1.field_4;
- field_8 += pt1.field_8;
- field_C += pt1.field_C;
- return *this;
- }
- int field_0;
- int field_4;
- int field_8;
- int field_C;
- };
- //-------------------------------------------------------------------------------------------------
- template <uint t>
- class fpointQQ {
- public:
- fpointQQ() {
- for (int i = 0; i < 9; ++i)
- list_0[i] = 0;
- //field_24 = field_28 = field_2C = field_30 = 0;
- }
- // 0016da5e //^_-
- fpointQQ(const fpointQQ<t>& pt1) {
- int i = 0;
- // 16da6c
- for (i = 0; i < 9; ++i)
- list_0[i] = pt1.list_0[i];
- /*
- 这几行赋值语句被优化成向量运算代码了
- 原始汇编:ldr r2, [r1, #36]
- str r2, [r0, #36]
- ...
- ldr r1, [r1, #48]
- str r1, [r0, #48]
- 自己汇编:adds r1,#36
- vld1.32 {d16,d17},[r1]
- add.w r1,r0,#36
- vst1.32 {d16,d17{,[r1]
- */
- // field_24 = pt1.field_24;
- // field_28 = pt1.field_28;
- // field_2C = pt1.field_2C;
- // field_30 = pt1.field_30;
- fpointQ_24=pt1.fpointQ_24;
- }
- // 0016c4ba //^_-
- void Cache() {
- LOGE("Cache%x=",(uint)this);
- // int tmp_r6 = (int)(((int64)(field_28 * 2) * (int64)field_24) >> 18);
- // int tmp_r5 = (int)(((int64)(field_2C * 2) * (int64)field_30) >> 18);
- // list_0[1] = tmp_r6 - tmp_r5;
- // int tmp_r8 = (int)(((int64)(field_2C * 2) * (int64)field_24) >> 18);
- // int tmp_r7 = (int)(((int64)(field_28 * 2) * (int64)field_30) >> 18);
- // list_0[3] = tmp_r5 + tmp_r6;
- // list_0[2] = tmp_r8 + tmp_r7;
- // int tmp_r4 = (int)(((int64)field_30 * (int64)(field_24 * 2)) >> 18);
- // int tmp_r1 = 0x40000 - (int)(((int64)(field_24 * 2) * (int64)field_24) >> 18);
- // tmp_r5 = (int)(((int64)(field_2C * 2) * (int64)field_28) >> 18);
- // list_0[5] = tmp_r5 - tmp_r4;
- // list_0[6] = tmp_r7 - tmp_r8;
- // list_0[7] = tmp_r4 + tmp_r5;
- // tmp_r7 = (int)(((int64)(field_28 * 2) * (int64)field_28) >> 18);
- // int tmp_r3 = (int)(((int64)(field_2C * 2) * (int64)field_2C) >> 18);
- // list_0[0] = 0x40000 - tmp_r7 - tmp_r3;
- // list_0[4] = tmp_r1 - tmp_r3;
- // list_0[8] = tmp_r1 - tmp_r7;
- }
- // 0016c2b8 //^_^
- fpointQQ<t> Conj() const {
- fpointQQ<t> pt(*this);
- pt.field_24 = -pt.field_24;
- pt.field_28 = -pt.field_28;
- pt.field_2C = -pt.field_2C;
- pt.list_0[5] = list_0[7];
- pt.list_0[6] = list_0[2];
- pt.list_0[7] = list_0[5];
- pt.list_0[1] = list_0[3];
- pt.list_0[2] = list_0[6];
- pt.list_0[3] = list_0[1];
- return pt;
- }
- // 0016c2f0 //^_^
- fpoint3<t> Multiply(fpoint3<t>& pt2) const {
- fpoint3<t> pt0;
- int tmp_r6 = (int)(((int64)list_0[0] * (int64)pt2.x_0) >> 18);
- int tmp_r5 = (int)(((int64)list_0[1] * (int64)pt2.y_4) >> 18);
- tmp_r6 += tmp_r5;
- int tmp_r7 = (int)(((int64)list_0[2] * (int64)pt2.z_8) >> 18);
- pt0.x_0 = tmp_r6 + tmp_r7;
- tmp_r7 = (int)(((int64)list_0[3] * (int64)pt2.x_0) >> 18);
- tmp_r6 = (int)(((int64)list_0[4] * (int64)pt2.y_4) >> 18);
- tmp_r7 += tmp_r6;
- tmp_r6 = (int)(((int64)list_0[5] * (int64)pt2.z_8) >> 18);
- pt0.y_4 = tmp_r7 + tmp_r6;
- int tmp_r3 = (int)(((int64)list_0[6] * (int64)pt2.x_0) >> 18);
- tmp_r7 = (int)(((int64)list_0[7] * (int64)pt2.y_4) >> 18);
- tmp_r3 += tmp_r7;
- int tmp_r1 = (int)(((int64)list_0[8] * (int64)pt2.z_8) >> 18);
- pt0.z_8 = tmp_r3 + tmp_r1;
- return pt0;
- }
- int list_0[9];
- // int field_24;
- // int field_28;
- // int field_2C;
- // int field_30;
- fpointQ<t> fpointQ_24;
- };
- //-------------------------------------------------------------------------------------------------
- #endif //_FPOINT_H_
|