OPCODE_ATOMIC_COMPARE_EXCHANGE

This commit is contained in:
Dr. Chat 2016-01-13 01:41:58 -06:00
parent 3ccb2a978d
commit 7b6f1388d6
4 changed files with 26 additions and 5 deletions

View File

@ -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

View File

@ -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);

View File

@ -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.
};

View File

@ -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)