@@ -525,9 +525,55 @@ enum AtomicOpcodes {
525525 I32AtomicStore16 = 0x1a ,
526526 I64AtomicStore8 = 0x1b ,
527527 I64AtomicStore16 = 0x1c ,
528- I64AtomicStore32 = 0x1d
528+ I64AtomicStore32 = 0x1d ,
529+
530+ AtomicRMWOps_Begin = 0x1e ,
531+ I32AtomicRMWAdd = 0x1e ,
532+ I64AtomicRMWAdd = 0x1f ,
533+ I32AtomicRMWAdd8U = 0x20 ,
534+ I32AtomicRMWAdd16U = 0x21 ,
535+ I64AtomicRMWAdd8U = 0x22 ,
536+ I64AtomicRMWAdd16U = 0x23 ,
537+ I64AtomicRMWAdd32U = 0x24 ,
538+ I32AtomicRMWSub = 0x25 ,
539+ I64AtomicRMWSub = 0x26 ,
540+ I32AtomicRMWSub8U = 0x27 ,
541+ I32AtomicRMWSub16U = 0x28 ,
542+ I64AtomicRMWSub8U = 0x29 ,
543+ I64AtomicRMWSub16U = 0x2a ,
544+ I64AtomicRMWSub32U = 0x2b ,
545+ I32AtomicRMWAnd = 0x2c ,
546+ I64AtomicRMWAnd = 0x2d ,
547+ I32AtomicRMWAnd8U = 0x2e ,
548+ I32AtomicRMWAnd16U = 0x2f ,
549+ I64AtomicRMWAnd8U = 0x30 ,
550+ I64AtomicRMWAnd16U = 0x31 ,
551+ I64AtomicRMWAnd32U = 0x32 ,
552+ I32AtomicRMWOr = 0x33 ,
553+ I64AtomicRMWOr = 0x34 ,
554+ I32AtomicRMWOr8U = 0x35 ,
555+ I32AtomicRMWOr16U = 0x36 ,
556+ I64AtomicRMWOr8U = 0x37 ,
557+ I64AtomicRMWOr16U = 0x38 ,
558+ I64AtomicRMWOr32U = 0x39 ,
559+ I32AtomicRMWXor = 0x3a ,
560+ I64AtomicRMWXor = 0x3b ,
561+ I32AtomicRMWXor8U = 0x3c ,
562+ I32AtomicRMWXor16U = 0x3d ,
563+ I64AtomicRMWXor8U = 0x3e ,
564+ I64AtomicRMWXor16U = 0x3f ,
565+ I64AtomicRMWXor32U = 0x40 ,
566+ I32AtomicRMWXchg = 0x41 ,
567+ I64AtomicRMWXchg = 0x42 ,
568+ I32AtomicRMWXchg8U = 0x43 ,
569+ I32AtomicRMWXchg16U = 0x44 ,
570+ I64AtomicRMWXchg8U = 0x45 ,
571+ I64AtomicRMWXchg16U = 0x46 ,
572+ I64AtomicRMWXchg32U = 0x47 ,
573+ AtomicRMWOps_End = 0x47 ,
529574};
530575
576+
531577enum MemoryAccess {
532578 Offset = 0x10 , // bit 4
533579 Alignment = 0x80 , // bit 7
@@ -676,6 +722,7 @@ class WasmBinaryWriter : public Visitor<WasmBinaryWriter, void> {
676722 void emitMemoryAccess (size_t alignment, size_t bytes, uint32_t offset);
677723 void visitLoad (Load *curr);
678724 void visitStore (Store *curr);
725+ void visitAtomicRMW (AtomicRMW *curr);
679726 void visitConst (Const *curr);
680727 void visitUnary (Unary *curr);
681728 void visitBinary (Binary *curr);
@@ -833,6 +880,7 @@ class WasmBinaryBuilder {
833880 void readMemoryAccess (Address& alignment, size_t bytes, Address& offset);
834881 bool maybeVisitLoad (Expression*& out, uint8_t code, bool isAtomic);
835882 bool maybeVisitStore (Expression*& out, uint8_t code, bool isAtomic);
883+ bool maybeVisitAtomicRMW (Expression*& out, uint8_t code);
836884 bool maybeVisitConst (Expression*& out, uint8_t code);
837885 bool maybeVisitUnary (Expression*& out, uint8_t code);
838886 bool maybeVisitBinary (Expression*& out, uint8_t code);
0 commit comments