@@ -404,7 +404,11 @@ def CIR_LoadOp : CIR_Op<"load", [
404404 `cir.load` reads a value (lvalue to rvalue conversion) given an address
405405 backed up by a `cir.ptr` type. A unit attribute `deref` can be used to
406406 mark the resulting value as used by another operation to dereference
407- a pointer.
407+ a pointer. A unit attribute `volatile` can be used to indicate a volatile
408+ loading. Load can be marked atomic by using `atomic(<mem_order>)`.
409+
410+ `alignment` can be used to specify an alignment that's different from the
411+ default, which is computed from `result`'s type ABI data layout.
408412
409413 Example:
410414
@@ -416,18 +420,26 @@ def CIR_LoadOp : CIR_Op<"load", [
416420 // Load address from memory at address %0. %3 is used by at least one
417421 // operation that dereferences a pointer.
418422 %3 = cir.load deref %0 : !cir.ptr<!cir.ptr<i32>>
423+
424+ // Perform a volatile load from address in %0.
425+ %4 = cir.load volatile %0 : !cir.ptr<i32>, i32
426+
427+ // Others
428+ %x = cir.load align(16) atomic(seq_cst) %0 : !cir.ptr<i32>, i32
419429 ```
420430 }];
421431
422432 let arguments = (ins Arg<CIR_PointerType, "the address to load from",
423433 [MemRead]>:$addr,
424434 UnitAttr:$isDeref,
435+ UnitAttr:$is_volatile,
425436 OptionalAttr<I64Attr>:$alignment,
426437 OptionalAttr<CIR_MemOrder>:$mem_order);
427438 let results = (outs CIR_AnyType:$result);
428439
429440 let assemblyFormat = [{
430441 (`deref` $isDeref^)?
442+ (`volatile` $is_volatile^)?
431443 (`align` `(` $alignment^ `)`)?
432444 (`atomic` `(` $mem_order^ `)`)?
433445 $addr `:` qualified(type($addr)) `,` type($result) attr-dict
@@ -452,24 +464,32 @@ def CIR_StoreOp : CIR_Op<"store", [
452464 a volatile store. Store's can be marked atomic by using
453465 `atomic(<mem_order>)`.
454466
455- `align ` can be used to specify an alignment that's different from the
467+ `alignment ` can be used to specify an alignment that's different from the
456468 default, which is computed from `result`'s type ABI data layout.
457469
458470 Example:
459471
460472 ```mlir
461473 // Store a function argument to local storage, address in %0.
462474 cir.store %arg0, %0 : i32, !cir.ptr<i32>
475+
476+ // Perform a volatile store into memory location at the address in %0.
477+ cir.store volatile %arg0, %0 : i32, !cir.ptr<i32>
478+
479+ // Others
480+ cir.store align(16) atomic(seq_cst) %x, %addr : i32, !cir.ptr<i32>
463481 ```
464482 }];
465483
466484 let arguments = (ins CIR_AnyType:$value,
467485 Arg<CIR_PointerType, "the address to store the value",
468486 [MemWrite]>:$addr,
487+ UnitAttr:$is_volatile,
469488 OptionalAttr<I64Attr>:$alignment,
470489 OptionalAttr<CIR_MemOrder>:$mem_order);
471490
472491 let assemblyFormat = [{
492+ (`volatile` $is_volatile^)?
473493 (`align` `(` $alignment^ `)`)?
474494 (`atomic` `(` $mem_order^ `)`)?
475495 $value `,` $addr attr-dict `:` type($value) `,` qualified(type($addr))
0 commit comments