[llvm] [RISCV] Add initial assembler/MC layer support for big-endian (PR #146534)

Jessica Clarke via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 5 09:17:54 PDT 2025


================
@@ -150,21 +152,23 @@ extern "C" LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTarget() {
   initializeRISCVAsmPrinterPass(*PR);
 }
 
-static StringRef computeDataLayout(const Triple &TT,
-                                   const TargetOptions &Options) {
-  StringRef ABIName = Options.MCOptions.getABIName();
-  if (TT.isArch64Bit()) {
-    if (ABIName == "lp64e")
-      return "e-m:e-p:64:64-i64:64-i128:128-n32:64-S64";
+static std::string computeDataLayout(const Triple &TT,
+                                     const TargetOptions &Opts) {
+  const bool IsLittle = TT.isLittleEndian();
+  StringRef ABI = Opts.MCOptions.getABIName();
+  std::string DL;
 
-    return "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128";
+  if (TT.isArch64Bit()) {
+    DL = (Twine(IsLittle ? "e" : "E") + "-m:e-p:64:64-i64:64-i128:128-n32:64-" +
----------------
jrtc27 wrote:

This is quite a significant refactor. If you're going to decompose it like this, at least split it out properly? That is, pick e vs E in one place, pick 32-bit vs 64-bit in another and pick RVE vs RVI ABI in another, then glue it all together?

https://github.com/llvm/llvm-project/pull/146534


More information about the llvm-commits mailing list