[clang] [llvm] [Hexagon] Add XQFloat code generation and post-RA QFP handling (PR #198902)

Fateme Hosseini via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 25 10:05:04 PDT 2026


================
@@ -0,0 +1,51 @@
+// ---------------------------------------------------------------------------
+// Tests for the hvx qfloat modes backend flag.
+// ---------------------------------------------------------------------------
+
+// Test for correct backend flag with case-insensitive values.
+// CHECK-STRICT-IEEE: "-mllvm" "-hexagon-qfloat-mode=strict-ieee"
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv79 -mhvx \
+// RUN:   -mhvx-qfloat=strict-ieee 2>&1 | FileCheck -check-prefix=CHECK-STRICT-IEEE %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv79 -mhvx \
+// RUN:   -mhvx-qfloat=sTriCt-Ieee 2>&1 | FileCheck -check-prefix=CHECK-STRICT-IEEE %s
+
+// CHECK-IEEE: "-mllvm" "-hexagon-qfloat-mode=ieee"
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv79 -mhvx \
+// RUN:   -mhvx-qfloat=ieee 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv79 -mhvx \
+// RUN:   -mhvx-qfloat=IEEE 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+
+// CHECK-LOSSY: "-mllvm" "-hexagon-qfloat-mode=lossy"
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv79 -mhvx \
+// RUN:   -mhvx-qfloat=lossy 2>&1 | FileCheck -check-prefix=CHECK-LOSSY %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv79 -mhvx \
+// RUN:   -mhvx-qfloat=lOSSy 2>&1 | FileCheck -check-prefix=CHECK-LOSSY %s
+
+// CHECK-LEGACY: "-mllvm" "-hexagon-qfloat-mode=legacy"
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv79 -mhvx \
+// RUN:   -mhvx-qfloat=legacy 2>&1 | FileCheck -check-prefix=CHECK-LEGACY %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv79 -mhvx \
+// RUN:   -mhvx-qfloat=LEGacy 2>&1 | FileCheck -check-prefix=CHECK-LEGACY %s
+
+// Test for default mode, if no mode is specified on v79.
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv79 -mhvx \
+// RUN:   -mhvx-qfloat 2>&1 | FileCheck -check-prefix=CHECK-LOSSY %s
+
+// Test for arches lower than v79 does not pass any backend flag.
+// CHECK-MODE-NOT: "-mllvm" "-hexagon-qfloat-mode="
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv75 -mhvx \
+// RUN:   -mhvx-qfloat 2>&1 | FileCheck -check-prefix=CHECK-MODE %s
+
+// Test for arches lower than v79 warns that qfloat mode is ignored.
+// CHECK-MODE-WARN: warning: ignoring 'ieee' in '-mhvx-qfloat=ieee' option as it is not currently supported for target 'HVX v75'
+// CHECK-MODE-WARN-NOT: "-mllvm" "-hexagon-qfloat-mode="
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv75 -mhvx \
+// RUN:   -mhvx-qfloat=ieee 2>&1 | FileCheck -check-prefix=CHECK-MODE-WARN %s
+// Test that an invalid qfloat mode is an error.
+// CHECK-INVALID: error: invalid value 'iee' in '-mhvx-qfloat=iee'
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv79 -mhvx \
+// RUN:   -mhvx-qfloat=iee 2>&1 | FileCheck -check-prefix=CHECK-INVALID %s
+// Test that -fno-integrated-as suppresses the qfloat backend flag.
+// CHECK-NO-INTEG-AS-NOT: "-hexagon-qfloat-mode=
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv79 -mhvx \
+// RUN:   -mhvx-qfloat=ieee -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-NO-INTEG-AS %s
----------------
fhossein-quic wrote:

My understanding is that this flag only affects (2). The guard I originally added was gating (2), which was a mistake, so I removed it. This patch doesn't add anything related to (1).

I also ran some tests with and without the integrated assembler. The non-integrated path does fail, but it appears to be a pre-existing issue unrelated to this patch. It seems that we don't pass -mhvx to the external assembler upstream, so all HVX instructions fail to assemble. That seems like a separate issue that should be fixed independently.

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


More information about the cfe-commits mailing list