@@ -3096,12 +3096,26 @@ void FunctionValidator::visitStructRMW(StructRMW* curr) {
3096
3096
return ;
3097
3097
}
3098
3098
auto & field = fields[curr->index ];
3099
+ shouldBeEqual (
3100
+ field.mutable_ , Mutable, curr, " struct.atomic.rmw field must be mutable" );
3101
+ shouldBeFalse (
3102
+ field.isPacked (), curr, " struct.atomic.rmw field must not be packed" );
3103
+ bool isAny =
3104
+ field.type .isRef () &&
3105
+ Type::isSubType (
3106
+ field.type ,
3107
+ Type (HeapTypes::any.getBasic (field.type .getHeapType ().getShared ()),
3108
+ Nullable));
3109
+ if (!shouldBeTrue (field.type == Type::i32 || field.type == Type::i64 ||
3110
+ (isAny && curr->op == RMWXchg),
3111
+ curr,
3112
+ " struct.atomic.rmw field type invalid for operation" )) {
3113
+ return ;
3114
+ }
3099
3115
shouldBeSubType (curr->value ->type ,
3100
3116
field.type ,
3101
3117
curr,
3102
3118
" struct.atomic.rmw value must have the proper type" );
3103
- shouldBeEqual (
3104
- field.mutable_ , Mutable, curr, " struct.atomic.rmw field must be mutable" );
3105
3119
}
3106
3120
3107
3121
void FunctionValidator::visitStructCmpxchg (StructCmpxchg* curr) {
@@ -3134,6 +3148,21 @@ void FunctionValidator::visitStructCmpxchg(StructCmpxchg* curr) {
3134
3148
return ;
3135
3149
}
3136
3150
auto & field = fields[curr->index ];
3151
+ shouldBeEqual (
3152
+ field.mutable_ , Mutable, curr, " struct.atomic.rmw field must be mutable" );
3153
+ shouldBeFalse (
3154
+ field.isPacked (), curr, " struct.atomic.rmw field must not be packed" );
3155
+ bool isEq =
3156
+ field.type .isRef () &&
3157
+ Type::isSubType (
3158
+ field.type ,
3159
+ Type (HeapTypes::eq.getBasic (field.type .getHeapType ().getShared ()),
3160
+ Nullable));
3161
+ if (!shouldBeTrue (field.type == Type::i32 || field.type == Type::i64 || isEq,
3162
+ curr,
3163
+ " struct.atomic.rmw field type invalid for operation" )) {
3164
+ return ;
3165
+ }
3137
3166
shouldBeSubType (
3138
3167
curr->expected ->type ,
3139
3168
field.type ,
@@ -3144,8 +3173,6 @@ void FunctionValidator::visitStructCmpxchg(StructCmpxchg* curr) {
3144
3173
field.type ,
3145
3174
curr,
3146
3175
" struct.atomic.rmw.cmpxchg replacement value must have the proper type" );
3147
- shouldBeEqual (
3148
- field.mutable_ , Mutable, curr, " struct.atomic.rmw field must be mutable" );
3149
3176
}
3150
3177
3151
3178
void FunctionValidator::visitArrayNew (ArrayNew* curr) {
0 commit comments