Hello Maintainers:brbrPlease help review this patch when you have
time.brbrThanks.brbrOn 06/13/2015 09:19 PM, Chen Gang wrote:brgt;
The related instructions are exception, cntlz, cnttz, shufflebytes, andbrgt;
add_saturate.brgt;brgt; Signed-off-by: Chen Gang
lt;gang.chen.5...@gmail.comgt;brgt; ---brgt; target-tilegx/helper.c |
83 ++brgt;
target-tilegx/helper.h | 5 +++brgt; 2 files changed, 88
insertions(+)brgt; create mode 100644 target-tilegx/helper.cbrgt;
create mode 100644 target-tilegx/helper.hbrgt;brgt; diff --git
a/target-tilegx/helper.c b/target-tilegx/helper.cbrgt; new file mode
100644brgt; index 000..5ab41cdbrgt; --- /dev/nullbrgt; +++
b/target-tilegx/helper.cbrgt; @@ -0,0 +1,83 @@brgt; +/*brgt; + * QEMU
TILE-Gx helpersbrgt; + *brgt; + * Copyright (c) 2015 Chen Gangbrgt; +
*brgt; + * This library is free software; you can redistribute it
and/orbrgt; + * modify it under the terms of the GNU Lesser General
Publicbrgt; + * License as published by the Free Software Foundation;
eitherbrgt; + * version 2.1 of the License, or (at your option) any later
version.brgt; + *brgt; + * This library is distributed in the hope that
it will be useful,brgt; + * but WITHOUT ANY WARRANTY; without even the
implied warranty ofbrgt; + * MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNUbrgt; + * Lesser General Public License for more
details.brgt; + *brgt; + * You should have received a copy of the GNU
Lesser General Publicbrgt; + * License along with this library; if not,
seebrgt; + * lt;http://www.gnu.org/licenses/lgpl-2.1.htmlgt;brgt; +
*/brgt; +brgt; +#include cpu.hbrgt; +#include
qemu-common.hbrgt; +#include exec/helper-proto.hbrgt; +brgt;
+#define SIGNBIT32 0x8000brgt; +brgt; +int64_t
helper_add_saturate(CPUTLGState *env, uint64_t rsrc, uint64_t rsrcb)brgt;
+{brgt; +uint32_t rdst = rsrc + rsrcb;brgt; +brgt; +if (((rdst
^ rsrc) amp; SIGNBIT32) amp;amp; !((rsrc ^ rsrcb) amp; SIGNBIT32))
{brgt; +rdst = ~(((int32_t)rsrc gt;gt; 31) ^ SIGNBIT32);brgt; +
}brgt; +brgt; +return (int64_t)rdst;brgt; +}brgt; +brgt;
+void helper_exception(CPUTLGState *env, uint32_t excp)brgt; +{brgt; +
CPUState *cs = CPU(tilegx_env_get_cpu(env));brgt; +brgt; +
cs-gt;exception_index = excp;brgt; +cpu_loop_exit(cs);brgt;
+}brgt; +brgt; +uint64_t helper_cntlz(uint64_t arg)brgt; +{brgt; +
return clz64(arg);brgt; +}brgt; +brgt; +uint64_t
helper_cnttz(uint64_t arg)brgt; +{brgt; +return ctz64(arg);brgt;
+}brgt; +brgt; +/*brgt; + * Functional Descriptionbrgt; + *
uint64_t a = rf[SrcA];brgt; + * uint64_t b = rf[SrcB];brgt; + *
uint64_t d = rf[Dest];brgt; + * uint64_t output = 0;brgt; + *
unsigned int counter;brgt; + * for (counter = 0; counter lt; (WORD_SIZE
/ BYTE_SIZE); counter++)brgt; + * {brgt; + * int sel =
getByte (b, counter) amp; 0xf;brgt; + * uint8_t byte = (sel lt; 8)
? getByte (d, sel) : getByte (a, (sel - 8));brgt; + * output =
setByte (output, counter, byte);brgt; + * }brgt; + * rf[Dest] =
output;brgt; + */brgt; +uint64_t helper_shufflebytes(uint64_t rdst,
uint64_t rsrc, uint64_t rsrcb)brgt; +{brgt; +uint64_t vdst =
0;brgt; +int count;brgt; +brgt; +for (count = 0; count lt;
64; count += 8) {brgt; +uint64_t sel = rsrcb gt;gt; count;brgt;
+uint64_t src = (sel amp; 8) ? rsrc : rdst;brgt; +vdst |=
((src gt;gt; ((sel amp; 7) * 8)) amp; 0xff) lt;lt; count;brgt; +
}brgt; +brgt; +return vdst;brgt; +}brgt; diff --git
a/target-tilegx/helper.h b/target-tilegx/helper.hbrgt; new file mode
100644brgt; index 000..1411c19brgt; --- /dev/nullbrgt; +++
b/target-tilegx/helper.hbrgt; @@ -0,0 +1,5 @@brgt;
+DEF_HELPER_2(exception, noreturn, env, i32)brgt; +DEF_HELPER_FLAGS_1(cntlz,
TCG_CALL_NO_RWG_SE, i64, i64)brgt; +DEF_HELPER_FLAGS_1(cnttz,
TCG_CALL_NO_RWG_SE, i64, i64)brgt; +DEF_HELPER_FLAGS_3(shufflebytes,
TCG_CALL_NO_RWG_SE, i64, i64, i64, i64)brgt; +DEF_HELPER_3(add_saturate,
s64, env, i64, i64)brgt;brbr--brChen GangbrbrOpen, share, and
attitude like air, water, and life which God blessedbr