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