MaskRay added inline comments.

================
Comment at: clang/lib/Basic/Targets/X86.cpp:564
+  if (HasLAHFSAHF)
+    Builder.defineMacro("__LAHF_SAHF__");
   if (HasLZCNT)
----------------
craig.topper wrote:
> MaskRay wrote:
> > craig.topper wrote:
> > > craig.topper wrote:
> > > > It looks like gcc may define this always in 32-bit mode?
> > > More confusingly, they define it in 32-bit mode unless -mno-sahf is on 
> > > the command line. Despite 32-bit mode always having LAHF/SAHF 
> > > instructions.
> > I think this means we fail to set sahf for all 32-bit CPUs. GCC 
> > gcc/config/i386/i386-options.c sets OPTION_MASK_ISA_SAHF on all 32-bit CPUs 
> > unless -mno-sahf.
> > 
> > According to 
> > https://git.noc.ruhr-uni-bochum.de/kostea7x/ghidra/-/commit/239106a356ef8555575a64cc2cfd3fd71b415406?view=parallel
> > some pre-2005 Intel and AMD 64-bit CPUs had problems so 'sahf' is disabled 
> > for some CPUs.
> > 
> The X86Subtarget and X86.td file calls "sahf" as HasLAHFSAHF64. And contains 
> we have this predicate for codegen uses.
> 
> {code}
>   bool hasLAHFSAHF() const { return HasLAHFSAHF64 || !is64Bit(); }
> {code}
> 
> 
> Does -mno-sahf prevent gcc from using LAHF/SAHF in 32-bit mode?
From `gcc/config/i386/i386-options.c sets OPTION_MASK_ISA_SAHF`, I think so, 
but there isn't any codegen test... (like many other components of GCC)

This discrepancy is not a big problem so let's always define it for 32-bit mode 
for now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89198/new/

https://reviews.llvm.org/D89198

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to