From 7b6f1388d6ea5bc80f6f0fa05d89ee15dd618bd8 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Wed, 13 Jan 2016 01:41:58 -0600 Subject: [PATCH] OPCODE_ATOMIC_COMPARE_EXCHANGE --- src/xenia/cpu/hir/hir_builder.cc | 11 +++++++++++ src/xenia/cpu/hir/hir_builder.h | 2 ++ src/xenia/cpu/hir/opcodes.h | 12 +++++++----- src/xenia/cpu/hir/opcodes.inl | 6 ++++++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/xenia/cpu/hir/hir_builder.cc b/src/xenia/cpu/hir/hir_builder.cc index a27f0b86a..db278cd81 100644 --- a/src/xenia/cpu/hir/hir_builder.cc +++ b/src/xenia/cpu/hir/hir_builder.cc @@ -2074,6 +2074,17 @@ Value* HIRBuilder::AtomicExchange(Value* address, Value* new_value) { return i->dest; } +Value* HIRBuilder::AtomicCompareExchange(Value* address, Value* old_value, + Value* new_value) { + ASSERT_ADDRESS_TYPE(address); + Instr* i = AppendInstr(OPCODE_ATOMIC_COMPARE_EXCHANGE_info, 0, + AllocValue(INT8_TYPE)); + i->set_src1(address); + i->set_src2(old_value); + i->set_src3(new_value); + return i->dest; +} + } // namespace hir } // namespace cpu } // namespace xe diff --git a/src/xenia/cpu/hir/hir_builder.h b/src/xenia/cpu/hir/hir_builder.h index d6e0e8ccc..44a528f53 100644 --- a/src/xenia/cpu/hir/hir_builder.h +++ b/src/xenia/cpu/hir/hir_builder.h @@ -236,6 +236,8 @@ class HIRBuilder { Value* Unpack(Value* value, uint32_t pack_flags = 0); Value* AtomicExchange(Value* address, Value* new_value); + Value* AtomicCompareExchange(Value* address, Value* old_value, + Value* new_value); Value* AtomicAdd(Value* address, Value* value); Value* AtomicSub(Value* address, Value* value); diff --git a/src/xenia/cpu/hir/opcodes.h b/src/xenia/cpu/hir/opcodes.h index 84bf2b320..8e440c73e 100644 --- a/src/xenia/cpu/hir/opcodes.h +++ b/src/xenia/cpu/hir/opcodes.h @@ -76,13 +76,14 @@ enum PackType : uint16_t { // Special types: PACK_TYPE_D3DCOLOR = 0, PACK_TYPE_FLOAT16_2 = 1, - PACK_TYPE_FLOAT16_4 = 2, - PACK_TYPE_SHORT_2 = 3, - PACK_TYPE_UINT_2101010 = 4, + PACK_TYPE_FLOAT16_3 = 2, // FIXME: Not verified, but looks correct. + PACK_TYPE_FLOAT16_4 = 3, + PACK_TYPE_SHORT_2 = 4, + PACK_TYPE_UINT_2101010 = 5, // Types which use the bitmasks below for configuration: - PACK_TYPE_8_IN_16 = 5, - PACK_TYPE_16_IN_32 = 6, + PACK_TYPE_8_IN_16 = 6, + PACK_TYPE_16_IN_32 = 7, PACK_TYPE_MODE = 0x000F, // just to get the mode @@ -220,6 +221,7 @@ enum Opcode { OPCODE_PACK, OPCODE_UNPACK, OPCODE_ATOMIC_EXCHANGE, + OPCODE_ATOMIC_COMPARE_EXCHANGE, __OPCODE_MAX_VALUE, // Keep at end. }; diff --git a/src/xenia/cpu/hir/opcodes.inl b/src/xenia/cpu/hir/opcodes.inl index c5deb7ff8..a2968e238 100644 --- a/src/xenia/cpu/hir/opcodes.inl +++ b/src/xenia/cpu/hir/opcodes.inl @@ -631,3 +631,9 @@ DEFINE_OPCODE( "atomic_exchange", OPCODE_SIG_V_V_V, OPCODE_FLAG_VOLATILE) + +DEFINE_OPCODE( + OPCODE_ATOMIC_COMPARE_EXCHANGE, + "atomic_compare_exchange", + OPCODE_SIG_V_V_V_V, + OPCODE_FLAG_VOLATILE)