@@ -390,75 +390,65 @@ def descr(self, buf):
390390
391391
392392class LoadInstr (Instruction ):
393- def __init__ (self , parent , ptr , name = '' , align = None , atomic_ordering = None ):
393+ def __init__ (self , parent , ptr , name = '' , align = None , atomic_ordering = None ,
394+ volatile = False ):
394395 if atomic_ordering is not None and align is None :
395396 msg = "atomic load requires the align paramter to be specified"
396397 raise ValueError (msg )
397398 super (LoadInstr , self ).__init__ (parent , ptr .type .pointee , "load" ,
398399 [ptr ], name = name )
399400 self .align = align
400401 self .atomic_ordering = atomic_ordering
402+ self .volatile = volatile
401403
402404 def descr (self , buf ):
403405 [val ] = self .operands
404- if self .atomic_ordering is None :
405- if self .align is not None :
406- align = ', align %d' % (self .align )
407- else :
408- align = ''
409- buf .append ("load {0}, {1} {2}{3}{4}\n " .format (
410- val .type .pointee ,
411- val .type ,
412- val .get_reference (),
413- align ,
414- self ._stringify_metadata (leading_comma = True ),
415- ))
416- else :
417- buf .append ("load atomic {0}, {1} {2} {3}, align {4}{5}\n " .format (
418- val .type .pointee ,
419- val .type ,
420- val .get_reference (),
421- self .atomic_ordering ,
422- self .align ,
423- self ._stringify_metadata (leading_comma = True ),
424- ))
406+
407+ flags = []
408+ if self .atomic_ordering is not None :
409+ flags .append ('atomic' )
410+ if self .volatile :
411+ flags .append ('volatile' )
412+
413+ opname = ' ' .join (['load' ] + flags )
414+ ordering = ('' if self .atomic_ordering is None
415+ else f' { self .atomic_ordering } ' )
416+ align = '' if self .align is None else f', align { self .align } '
417+ metadata = self ._stringify_metadata (leading_comma = True )
418+
419+ buf .append (f"{ opname } { val .type .pointee } , { val .type } "
420+ f"{ val .get_reference ()} { ordering } { align } { metadata } \n " )
425421
426422
427423class StoreInstr (Instruction ):
428- def __init__ (self , parent , val , ptr , align = None , atomic_ordering = None ):
424+ def __init__ (self , parent , val , ptr , align = None , atomic_ordering = None ,
425+ volatile = False ):
429426 if atomic_ordering is not None and align is None :
430427 msg = "atomic store requires the align paramter to be specified"
431428 raise ValueError (msg )
432429 super (StoreInstr , self ).__init__ (parent , types .VoidType (), "store" ,
433430 [val , ptr ])
434431 self .align = align
435432 self .atomic_ordering = atomic_ordering
433+ self .volatile = volatile
436434
437435 def descr (self , buf ):
438436 val , ptr = self .operands
439- if self .atomic_ordering is None :
440- if self .align is not None :
441- align = ', align %d' % (self .align )
442- else :
443- align = ''
444- buf .append ("store {0} {1}, {2} {3}{4}{5}\n " .format (
445- val .type ,
446- val .get_reference (),
447- ptr .type ,
448- ptr .get_reference (),
449- align ,
450- self ._stringify_metadata (leading_comma = True ),
451- ))
452- else :
453- buf .append ("store atomic {0} {1}, {2} {3} {4}, align {5}{6}\n " .format (
454- val .type ,
455- val .get_reference (),
456- ptr .type ,
457- ptr .get_reference (),
458- self .atomic_ordering ,
459- self .align ,
460- self ._stringify_metadata (leading_comma = True ),
461- ))
437+
438+ flags = []
439+ if self .atomic_ordering is not None :
440+ flags .append ('atomic' )
441+ if self .volatile :
442+ flags .append ('volatile' )
443+
444+ opname = ' ' .join (['store' ] + flags )
445+ ordering = ('' if self .atomic_ordering is None
446+ else f' { self .atomic_ordering } ' )
447+ align = '' if self .align is None else f', align { self .align } '
448+ metadata = self ._stringify_metadata (leading_comma = True )
449+
450+ buf .append (f"{ opname } { val .type } { val .get_reference ()} , { ptr .type } "
451+ f"{ ptr .get_reference ()} { ordering } { align } { metadata } \n " )
462452
463453
464454class LoadAtomicInstr (LoadInstr ):
0 commit comments