[PATCH] D52784: [ARM][AArch64] Pass through endianness flags to the GNU assembler

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 10 12:01:28 PDT 2018


nickdesaulniers added inline comments.


================
Comment at: lib/Driver/ToolChains/Gnu.cpp:543-549
+static const char* GetEndianArg(bool IsBigEndian, const ArgList &Args) {
+  if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian,
+                               options::OPT_mbig_endian)) {
+      IsBigEndian = !A->getOption().matches(options::OPT_mlittle_endian);
+  }
+  return (IsBigEndian) ? "-EB" : "-EL";
+}
----------------
If you passed `llvm::Triple` instead of `bool`, then I think you could do something like:

```
static const char* GetEndianArg(const llvm::Triple &triple, const ArgList &Args) {
  const bool IsBigEndian = triple == llvm::Triple::armeb ||
                           triple == llvm::Triple::thumbeb ||
                           triple == llvm::Triple::aarch64_be ||
                           Args.getLastArg(options::OPT_mlittle_endian,
                                           options::OPT_mbig_endian)->getOption().matches(options::OPT_mbig_endian);
  return IsBigEndian ? "-EB" : "-EL";
}
```

Might encapsulate the logic from the call sites better, but that's a minor nit.


================
Comment at: lib/Driver/ToolChains/Gnu.cpp:544-547
+  if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian,
+                               options::OPT_mbig_endian)) {
+      IsBigEndian = !A->getOption().matches(options::OPT_mlittle_endian);
+  }
----------------
Just so I understand this check, even if we didn't have a BE triple, we set `IsBigEndian` if `-mlittle-endian` was not set?  Is `-mlittle-endian` a default set flag, or does this set `"-EB"` even if no `-m*-endian` flag is specified (I think we want little-endian to be the default, and IIUC, this would change that)?


https://reviews.llvm.org/D52784





More information about the cfe-commits mailing list