/*
- * Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ * Copyright(c) 2019-2022 Qualcomm Innovation Center, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
}
}
-static inline void gen_write_p3_0(TCGv control_reg)
+static void gen_write_p3_0(DisasContext *ctx, TCGv control_reg)
{
+ TCGv hex_p8 = tcg_temp_new();
for (int i = 0; i < NUM_PREGS; i++) {
- tcg_gen_extract_tl(hex_pred[i], control_reg, i * 8, 8);
+ tcg_gen_extract_tl(hex_p8, control_reg, i * 8, 8);
+ gen_log_pred_write(ctx, i, hex_p8);
+ ctx_log_pred_write(ctx, i);
}
+ tcg_temp_free(hex_p8);
}
/*
TCGv val)
{
if (reg_num == HEX_REG_P3_0) {
- gen_write_p3_0(val);
+ gen_write_p3_0(ctx, val);
} else {
gen_log_reg_write(reg_num, val);
ctx_log_reg_write(ctx, reg_num);
if (reg_num == HEX_REG_P3_0) {
TCGv val32 = tcg_temp_new();
tcg_gen_extrl_i64_i32(val32, val);
- gen_write_p3_0(val32);
+ gen_write_p3_0(ctx, val32);
tcg_gen_extrh_i64_i32(val32, val);
gen_log_reg_write(reg_num + 1, val32);
tcg_temp_free(val32);
check(c5, 0xdeadbeef);
}
+static void test_packet(void)
+{
+ /*
+ * Test that setting c4 inside a packet doesn't impact the predicates
+ * that are read during the packet.
+ */
+
+ int result;
+ int old_val = 0x0000001c;
+
+ /* Test a predicated register transfer */
+ result = old_val;
+ asm (
+ "c4 = %1\n\t"
+ "{\n\t"
+ " c4 = %2\n\t"
+ " if (!p2) %0 = %3\n\t"
+ "}\n\t"
+ : "+r"(result)
+ : "r"(0xffffffff), "r"(0xff00ffff), "r"(0x837ed653)
+ : "p0", "p1", "p2", "p3");
+ check(result, old_val);
+
+ /* Test a predicated store */
+ result = 0xffffffff;
+ asm ("c4 = %0\n\t"
+ "{\n\t"
+ " c4 = %1\n\t"
+ " if (!p2) memw(%2) = #0\n\t"
+ "}\n\t"
+ :
+ : "r"(0), "r"(0xffffffff), "r"(&result)
+ : "p0", "p1", "p2", "p3", "memory");
+ check(result, 0x0);
+}
+
int main()
{
int c4;
creg_alias_pair(0xffffffff, &pregs);
check(pregs.creg, 0xffffffff);
+ test_packet();
+
puts(err ? "FAIL" : "PASS");
return err;
}