ldst_atomicity.c.inc (8b1b3db71a1df58a6e28956b72f143e8cf38bdf6) ldst_atomicity.c.inc (6046f6e94d8d530ecc28176232479889abbee47e)
1/*
2 * Routines common to user and system emulation of load/store.
3 *
4 * Copyright (c) 2022 Linaro, Ltd.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 *
8 * This work is licensed under the terms of the GNU GPL, version 2 or later.

--- 811 unchanged lines hidden (view full) ---

820 */
821static uint64_t store_whole_le16(void *pv, int size, Int128 val_le)
822{
823 int sz = size * 8;
824 int o = (uintptr_t)pv & 15;
825 int sh = o * 8;
826 Int128 m, v;
827
1/*
2 * Routines common to user and system emulation of load/store.
3 *
4 * Copyright (c) 2022 Linaro, Ltd.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 *
8 * This work is licensed under the terms of the GNU GPL, version 2 or later.

--- 811 unchanged lines hidden (view full) ---

820 */
821static uint64_t store_whole_le16(void *pv, int size, Int128 val_le)
822{
823 int sz = size * 8;
824 int o = (uintptr_t)pv & 15;
825 int sh = o * 8;
826 Int128 m, v;
827
828 qemu_build_assert(HAVE_ATOMIC128_RW);
828 qemu_build_assert(HAVE_CMPXCHG128);
829
830 /* Like MAKE_64BIT_MASK(0, sz), but larger. */
831 if (sz <= 64) {
832 m = int128_make64(MAKE_64BIT_MASK(0, sz));
833 } else {
834 m = int128_make128(-1, MAKE_64BIT_MASK(0, sz - 64));
835 }
836

--- 45 unchanged lines hidden (view full) ---

882 store_atom_insert_al4(pv - 1, (uint32_t)val << 8, MAKE_64BIT_MASK(8, 16));
883 return;
884 } else if ((pi & 7) == 3) {
885 if (HAVE_al8) {
886 store_atom_insert_al8(pv - 3, (uint64_t)val << 24, MAKE_64BIT_MASK(24, 16));
887 return;
888 }
889 } else if ((pi & 15) == 7) {
829
830 /* Like MAKE_64BIT_MASK(0, sz), but larger. */
831 if (sz <= 64) {
832 m = int128_make64(MAKE_64BIT_MASK(0, sz));
833 } else {
834 m = int128_make128(-1, MAKE_64BIT_MASK(0, sz - 64));
835 }
836

--- 45 unchanged lines hidden (view full) ---

882 store_atom_insert_al4(pv - 1, (uint32_t)val << 8, MAKE_64BIT_MASK(8, 16));
883 return;
884 } else if ((pi & 7) == 3) {
885 if (HAVE_al8) {
886 store_atom_insert_al8(pv - 3, (uint64_t)val << 24, MAKE_64BIT_MASK(24, 16));
887 return;
888 }
889 } else if ((pi & 15) == 7) {
890 if (HAVE_ATOMIC128_RW) {
890 if (HAVE_CMPXCHG128) {
891 Int128 v = int128_lshift(int128_make64(val), 56);
892 Int128 m = int128_lshift(int128_make64(0xffff), 56);
893 store_atom_insert_al16(pv - 7, v, m);
894 return;
895 }
896 } else {
897 g_assert_not_reached();
898 }

--- 52 unchanged lines hidden (view full) ---

951 return;
952 case MO_32:
953 if ((pi & 7) < 4) {
954 if (HAVE_al8) {
955 store_whole_le8(pv, 4, cpu_to_le32(val));
956 return;
957 }
958 } else {
891 Int128 v = int128_lshift(int128_make64(val), 56);
892 Int128 m = int128_lshift(int128_make64(0xffff), 56);
893 store_atom_insert_al16(pv - 7, v, m);
894 return;
895 }
896 } else {
897 g_assert_not_reached();
898 }

--- 52 unchanged lines hidden (view full) ---

951 return;
952 case MO_32:
953 if ((pi & 7) < 4) {
954 if (HAVE_al8) {
955 store_whole_le8(pv, 4, cpu_to_le32(val));
956 return;
957 }
958 } else {
959 if (HAVE_ATOMIC128_RW) {
959 if (HAVE_CMPXCHG128) {
960 store_whole_le16(pv, 4, int128_make64(cpu_to_le32(val)));
961 return;
962 }
963 }
964 cpu_loop_exit_atomic(cpu, ra);
965 default:
966 g_assert_not_reached();
967 }

--- 48 unchanged lines hidden (view full) ---

1016 case 4: /* atmax MO_32 */
1017 default:
1018 g_assert_not_reached();
1019 }
1020 return;
1021 }
1022 break;
1023 case MO_64:
960 store_whole_le16(pv, 4, int128_make64(cpu_to_le32(val)));
961 return;
962 }
963 }
964 cpu_loop_exit_atomic(cpu, ra);
965 default:
966 g_assert_not_reached();
967 }

--- 48 unchanged lines hidden (view full) ---

1016 case 4: /* atmax MO_32 */
1017 default:
1018 g_assert_not_reached();
1019 }
1020 return;
1021 }
1022 break;
1023 case MO_64:
1024 if (HAVE_ATOMIC128_RW) {
1024 if (HAVE_CMPXCHG128) {
1025 store_whole_le16(pv, 8, int128_make64(cpu_to_le64(val)));
1026 return;
1027 }
1028 break;
1029 default:
1030 g_assert_not_reached();
1031 }
1032 cpu_loop_exit_atomic(cpu, ra);

--- 38 unchanged lines hidden (view full) ---

1071 case MO_64:
1072 if (HAVE_al8) {
1073 store_atomic8(pv, a);
1074 store_atomic8(pv + 8, b);
1075 return;
1076 }
1077 break;
1078 case -MO_64:
1025 store_whole_le16(pv, 8, int128_make64(cpu_to_le64(val)));
1026 return;
1027 }
1028 break;
1029 default:
1030 g_assert_not_reached();
1031 }
1032 cpu_loop_exit_atomic(cpu, ra);

--- 38 unchanged lines hidden (view full) ---

1071 case MO_64:
1072 if (HAVE_al8) {
1073 store_atomic8(pv, a);
1074 store_atomic8(pv + 8, b);
1075 return;
1076 }
1077 break;
1078 case -MO_64:
1079 if (HAVE_ATOMIC128_RW) {
1079 if (HAVE_CMPXCHG128) {
1080 uint64_t val_le;
1081 int s2 = pi & 15;
1082 int s1 = 16 - s2;
1083
1084 if (HOST_BIG_ENDIAN) {
1085 val = bswap128(val);
1086 }
1087 switch (s2) {

--- 24 unchanged lines hidden ---
1080 uint64_t val_le;
1081 int s2 = pi & 15;
1082 int s1 = 16 - s2;
1083
1084 if (HOST_BIG_ENDIAN) {
1085 val = bswap128(val);
1086 }
1087 switch (s2) {

--- 24 unchanged lines hidden ---