|
|
|
@ -65,6 +65,14 @@ void WriteStorage32(EmitContext& ctx, const IR::Value& binding, const IR::Value&
|
|
|
|
|
WriteStorage(ctx, binding, offset, value, ctx.storage_types.U32, sizeof(u32),
|
|
|
|
|
&StorageDefinitions::U32, index_offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WriteStorageByCasLoop(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
|
|
|
|
Id value, Id bit_offset, Id bit_count) {
|
|
|
|
|
const Id pointer{StoragePointer(ctx, binding, offset, ctx.storage_types.U32, sizeof(u32),
|
|
|
|
|
&StorageDefinitions::U32)};
|
|
|
|
|
ctx.OpFunctionCall(ctx.TypeVoid(), ctx.write_storage_cas_loop_func, pointer, value, bit_offset,
|
|
|
|
|
bit_count);
|
|
|
|
|
}
|
|
|
|
|
} // Anonymous namespace
|
|
|
|
|
|
|
|
|
|
void EmitLoadGlobalU8(EmitContext&) {
|
|
|
|
@ -219,26 +227,42 @@ Id EmitLoadStorage128(EmitContext& ctx, const IR::Value& binding, const IR::Valu
|
|
|
|
|
|
|
|
|
|
void EmitWriteStorageU8(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
|
|
|
|
Id value) {
|
|
|
|
|
if (ctx.profile.support_int8) {
|
|
|
|
|
WriteStorage(ctx, binding, offset, ctx.OpSConvert(ctx.U8, value), ctx.storage_types.U8,
|
|
|
|
|
sizeof(u8), &StorageDefinitions::U8);
|
|
|
|
|
} else {
|
|
|
|
|
WriteStorageByCasLoop(ctx, binding, offset, value, ctx.BitOffset8(offset), ctx.Const(8u));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EmitWriteStorageS8(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
|
|
|
|
Id value) {
|
|
|
|
|
if (ctx.profile.support_int8) {
|
|
|
|
|
WriteStorage(ctx, binding, offset, ctx.OpSConvert(ctx.S8, value), ctx.storage_types.S8,
|
|
|
|
|
sizeof(s8), &StorageDefinitions::S8);
|
|
|
|
|
} else {
|
|
|
|
|
WriteStorageByCasLoop(ctx, binding, offset, value, ctx.BitOffset8(offset), ctx.Const(8u));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EmitWriteStorageU16(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
|
|
|
|
Id value) {
|
|
|
|
|
if (ctx.profile.support_int16) {
|
|
|
|
|
WriteStorage(ctx, binding, offset, ctx.OpSConvert(ctx.U16, value), ctx.storage_types.U16,
|
|
|
|
|
sizeof(u16), &StorageDefinitions::U16);
|
|
|
|
|
} else {
|
|
|
|
|
WriteStorageByCasLoop(ctx, binding, offset, value, ctx.BitOffset16(offset), ctx.Const(16u));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EmitWriteStorageS16(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
|
|
|
|
Id value) {
|
|
|
|
|
if (ctx.profile.support_int16) {
|
|
|
|
|
WriteStorage(ctx, binding, offset, ctx.OpSConvert(ctx.S16, value), ctx.storage_types.S16,
|
|
|
|
|
sizeof(s16), &StorageDefinitions::S16);
|
|
|
|
|
} else {
|
|
|
|
|
WriteStorageByCasLoop(ctx, binding, offset, value, ctx.BitOffset16(offset), ctx.Const(16u));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EmitWriteStorage32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
|
|
|
|