volatile means do not optimize into a register.  The compiler must perform the
actual memory access every time.

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ni, Ray
> Sent: Sunday, February 18, 2024 7:06 PM
> To: Zhou, Jianfeng <jianfeng.z...@intel.com>; devel@edk2.groups.io
> Cc: Laszlo Ersek <ler...@redhat.com>; Kumar, Rahul R
> <rahul.r.ku...@intel.com>; Gerd Hoffmann <kra...@redhat.com>
> Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg: code refine
> 
> 
> > -    PleB->Uint64 = LocalPleB.Uint64;
> >
> > +    *(volatile UINT64 *)&(PleB->Uint64) = LocalPleB.Uint64;
> 
> Jianfeng,
> If "volatile" is to tell compiler to generate single "mov" instruction
> for
> the assignment.
> 
> I am curious how it works in 32bit env where the general purpose
> registers are
> 32bit width?
> 
> Thanks,
> Ray
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115582): https://edk2.groups.io/g/devel/message/115582
Mute This Topic: https://groups.io/mt/104256295/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to