Source: cbmc
Severity: normal
Tags: patch
User: debian-loonga...@lists.debian.org
Usertags: loong64
X-Debbugs-Cc: wuruil...@loongson.cn

Dear Maintainer,

The cbmc package compiled incorrectly on loongarch, the attached patch has 
fixed it. 
Please merge the code from the attached patch into the repository.

wuruilong

-- System Information:
Debian Release: trixie/sid
  APT prefers unreleased
  APT policy: (500, 'unreleased'), (500, 'unstable')
Architecture: loong64 (loongarch64)

Kernel: Linux 5.10.0-60.96.0.126.oe2203.loongarch64 (SMP w/32 CPU threads)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect
Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 cbmc (5.95.1-4) unstable; urgency=low
 .
   * Fix portability problems for hurd and sh4
Author: Michael Tautschnig <m...@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2024-04-28

--- cbmc-5.95.1.orig/src/goto-cc/gcc_mode.cpp
+++ cbmc-5.95.1/src/goto-cc/gcc_mode.cpp
@@ -536,6 +536,7 @@ int gcc_modet::doit()
       {"hexagon", "none" /* Hexagon */},
       {"i386", "i386" /* (not in llc's list: 32-bit x86) */},
       {"lanai", "none" /* Lanai */},
+      {"loongarch64", "loongarch64" /* 64-bit LOONGARCH */},
       {"mips", "mips" /* MIPS (32-bit big endian) */},
       {"mips64", "mips64" /* MIPS (64-bit big endian) */},
       {"mips64el", "mips64el" /* MIPS (64-bit little endian) */},
--- cbmc-5.95.1.orig/src/util/config.cpp
+++ cbmc-5.95.1/src/util/config.cpp
@@ -350,6 +350,35 @@ void configt::ansi_ct::set_arch_spec_alp
   }
 }
 
+void configt::ansi_ct::set_arch_spec_loongarch64()
+{
+       set_LP64();
+       endianness = endiannesst::IS_LITTLE_ENDIAN;
+       long_double_width = 16 * 8;
+       char_is_unsigned = false;
+       NULL_is_zero = true;
+
+       switch(mode)
+       {
+       case flavourt::GCC:
+         defines.push_back("__loongarch__");
+         break;
+         
+       case flavourt::VISUAL_STUDIO:
+         UNREACHABLE; // not supported by Visual Studio
+         break;
+       
+       case flavourt::CODEWARRIOR:
+       case flavourt::CLANG:
+       case flavourt::ARM:
+       case flavourt::ANSI:
+         break;
+
+       case flavourt::NONE:
+         UNREACHABLE;
+       }
+}
+
 void configt::ansi_ct::set_arch_spec_mips(const irep_idt &subarch)
 {
   if(subarch=="mipsel" ||
@@ -735,6 +764,8 @@ void configt::set_arch(const irep_idt &a
     ansi_c.set_arch_spec_power(arch);
   else if(arch == "riscv64")
     ansi_c.set_arch_spec_riscv64();
+  else if(arch == "loongarch64")
+    ansi_c.set_arch_spec_loongarch64();
   else if(arch=="sparc" ||
           arch=="sparc64")
     ansi_c.set_arch_spec_sparc(arch);
@@ -1395,6 +1426,8 @@ irep_idt configt::this_architecture()
     #endif
   #elif defined(__riscv)
     this_arch = "riscv64";
+  #elif defined(__loongarch__)
+    this_arch = "loongarch64";
   #elif defined(__sparc__)
     #ifdef __arch64__
       this_arch = "sparc64";
--- cbmc-5.95.1.orig/src/util/config.h
+++ cbmc-5.95.1/src/util/config.h
@@ -223,6 +224,7 @@ public:
     void set_arch_spec_power(const irep_idt &subarch);
     void set_arch_spec_arm(const irep_idt &subarch);
     void set_arch_spec_alpha();
+    void set_arch_spec_loongarch64();
     void set_arch_spec_mips(const irep_idt &subarch);
     void set_arch_spec_riscv64();
     void set_arch_spec_s390();

Reply via email to