Skip to content

release/22.x: [Hexagon] Define __HVX_IEEE_FP__ when -mhvx-ieee-fp is enabled (#183829)#183978

Closed
llvmbot wants to merge 1 commit intollvm:release/22.xfrom
llvmbot:issue183746
Closed

release/22.x: [Hexagon] Define __HVX_IEEE_FP__ when -mhvx-ieee-fp is enabled (#183829)#183978
llvmbot wants to merge 1 commit intollvm:release/22.xfrom
llvmbot:issue183746

Conversation

@llvmbot
Copy link
Copy Markdown
Member

@llvmbot llvmbot commented Mar 1, 2026

Backport 136ba6e

Requested by: @androm3da

@llvmbot
Copy link
Copy Markdown
Member Author

llvmbot commented Mar 1, 2026

@androm3da What do you think about merging this PR to the release branch?

@llvmbot llvmbot requested a review from androm3da March 1, 2026 05:03
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:Hexagon clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Mar 1, 2026
@llvmbot
Copy link
Copy Markdown
Member Author

llvmbot commented Mar 1, 2026

@llvm/pr-subscribers-backend-x86
@llvm/pr-subscribers-backend-hexagon

@llvm/pr-subscribers-clang

Author: None (llvmbot)

Changes

Backport 136ba6e

Requested by: @androm3da


Full diff: https://github.com/llvm/llvm-project/pull/183978.diff

3 Files Affected:

  • (modified) clang/lib/Basic/Targets/Hexagon.cpp (+6)
  • (modified) clang/lib/Basic/Targets/Hexagon.h (+1)
  • (modified) clang/test/Preprocessor/hexagon-predefines.c (+13)
diff --git a/clang/lib/Basic/Targets/Hexagon.cpp b/clang/lib/Basic/Targets/Hexagon.cpp
index bd70bfe4fef51..9bf34e67a03fd 100644
--- a/clang/lib/Basic/Targets/Hexagon.cpp
+++ b/clang/lib/Basic/Targets/Hexagon.cpp
@@ -102,6 +102,9 @@ void HexagonTargetInfo::getTargetDefines(const LangOptions &Opts,
       Builder.defineMacro("__HVXDBL__");
   }
 
+  if (HasHVXIeeeFp)
+    Builder.defineMacro("__HVX_IEEE_FP__");
+
   if (hasFeature("audio")) {
     Builder.defineMacro("__HEXAGON_AUDIO__");
   }
@@ -148,6 +151,8 @@ bool HexagonTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
       UseLongCalls = true;
     else if (F == "-long-calls")
       UseLongCalls = false;
+    else if (F == "+hvx-ieee-fp")
+      HasHVXIeeeFp = true;
     else if (F == "+audio")
       HasAudio = true;
   }
@@ -242,6 +247,7 @@ bool HexagonTargetInfo::hasFeature(StringRef Feature) const {
       .Case("hvx", HasHVX)
       .Case("hvx-length64b", HasHVX64B)
       .Case("hvx-length128b", HasHVX128B)
+      .Case("hvx-ieee-fp", HasHVXIeeeFp)
       .Case("long-calls", UseLongCalls)
       .Case("audio", HasAudio)
       .Default(false);
diff --git a/clang/lib/Basic/Targets/Hexagon.h b/clang/lib/Basic/Targets/Hexagon.h
index 21da0fc4cbdd0..f034911d77b92 100644
--- a/clang/lib/Basic/Targets/Hexagon.h
+++ b/clang/lib/Basic/Targets/Hexagon.h
@@ -32,6 +32,7 @@ class LLVM_LIBRARY_VISIBILITY HexagonTargetInfo : public TargetInfo {
   bool HasHVX = false;
   bool HasHVX64B = false;
   bool HasHVX128B = false;
+  bool HasHVXIeeeFp = false;
   bool HasAudio = false;
   bool UseLongCalls = false;
 
diff --git a/clang/test/Preprocessor/hexagon-predefines.c b/clang/test/Preprocessor/hexagon-predefines.c
index bdedcf45ab118..4079f521580a8 100644
--- a/clang/test/Preprocessor/hexagon-predefines.c
+++ b/clang/test/Preprocessor/hexagon-predefines.c
@@ -105,8 +105,21 @@
 // CHECK-V68HVX-128B: #define __HVX_ARCH__ 68
 // CHECK-V68HVX-128B: #define __HVX_LENGTH__ 128
 // CHECK-V68HVX-128B: #define __HVX__ 1
+// CHECK-V68HVX-128B-NOT: #define __HVX_IEEE_FP__ 1
 // CHECK-V68HVX-128B: #define __hexagon__ 1
 
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv68 \
+// RUN: -target-feature +hvxv68 -target-feature +hvx-length128b \
+// RUN: -target-feature +hvx-ieee-fp %s | FileCheck \
+// RUN: %s -check-prefix CHECK-V68HVX-IEEE-FP
+// CHECK-V68HVX-IEEE-FP: #define __HEXAGON_ARCH__ 68
+// CHECK-V68HVX-IEEE-FP: #define __HEXAGON_V68__ 1
+// CHECK-V68HVX-IEEE-FP: #define __HVX_ARCH__ 68
+// CHECK-V68HVX-IEEE-FP: #define __HVX_IEEE_FP__ 1
+// CHECK-V68HVX-IEEE-FP: #define __HVX_LENGTH__ 128
+// CHECK-V68HVX-IEEE-FP: #define __HVX__ 1
+// CHECK-V68HVX-IEEE-FP: #define __hexagon__ 1
+
 // RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv69 \
 // RUN: -target-feature +hvxv69 -target-feature +hvx-length128b %s | FileCheck \
 // RUN: %s -check-prefix CHECK-V69HVX-128B

@github-project-automation github-project-automation bot moved this from Needs Triage to Needs Merge in LLVM Release Status Mar 1, 2026
@llvmbot llvmbot added backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics labels Mar 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

🐧 Linux x64 Test Results

  • 85392 tests passed
  • 1208 tests skipped
  • 1 test failed

Failed Tests

(click on a test name to see its output)

Clang

Clang.Headers/hexagon-hvx-ieee-headers.c
Exit Code: 2

Command Output (stdout):
--
# RUN: at line 3
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/22/include -nostdsysteminc -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Headers/../../lib/Headers/    -triple hexagon-unknown-elf -target-cpu hexagonv68     -target-feature +hvx-length128b -target-feature +hvxv68    -target-feature +hvx-ieee-fp -emit-llvm /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Headers/hexagon-hvx-ieee-headers.c -o - | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Headers/hexagon-hvx-ieee-headers.c
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/22/include -nostdsysteminc -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Headers/../../lib/Headers/ -triple hexagon-unknown-elf -target-cpu hexagonv68 -target-feature +hvx-length128b -target-feature +hvxv68 -target-feature +hvx-ieee-fp -emit-llvm /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Headers/hexagon-hvx-ieee-headers.c -o -
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Headers/hexagon-hvx-ieee-headers.c:19:10: error: call to undeclared function 'Q6_Vhf_vabs_Vhf'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
# |    19 |   return Q6_Vhf_vabs_Vhf(v);
# |       |          ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Headers/hexagon-hvx-ieee-headers.c:19:10: error: returning 'int' from a function with incompatible result type 'HEXAGON_Vect1024' (vector of 32 'long' values)
# |    19 |   return Q6_Vhf_vabs_Vhf(v);
# |       |          ^~~~~~~~~~~~~~~~~~
# | 2 errors generated.
# `-----------------------------
# error: command failed with exit status: 1
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Headers/hexagon-hvx-ieee-headers.c
# .---command stderr------------
# | FileCheck error: '<stdin>' is empty.
# | FileCheck command line:  /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Headers/hexagon-hvx-ieee-headers.c
# `-----------------------------
# error: command failed with exit status: 2

--

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

🪟 Windows x64 Test Results

  • 51795 tests passed
  • 901 tests skipped
  • 1 test failed

Failed Tests

(click on a test name to see its output)

Clang

Clang.Headers/hexagon-hvx-ieee-headers.c
Exit Code: 2

Command Output (stdout):
--
# RUN: at line 3
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\22\include -nostdsysteminc -internal-isystem C:\_work\llvm-project\llvm-project\clang\test\Headers/../../lib/Headers/    -triple hexagon-unknown-elf -target-cpu hexagonv68     -target-feature +hvx-length128b -target-feature +hvxv68    -target-feature +hvx-ieee-fp -emit-llvm C:\_work\llvm-project\llvm-project\clang\test\Headers\hexagon-hvx-ieee-headers.c -o - | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\clang\test\Headers\hexagon-hvx-ieee-headers.c
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\22\include' -nostdsysteminc -internal-isystem 'C:\_work\llvm-project\llvm-project\clang\test\Headers/../../lib/Headers/' -triple hexagon-unknown-elf -target-cpu hexagonv68 -target-feature +hvx-length128b -target-feature +hvxv68 -target-feature +hvx-ieee-fp -emit-llvm 'C:\_work\llvm-project\llvm-project\clang\test\Headers\hexagon-hvx-ieee-headers.c' -o -
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\clang\test\Headers\hexagon-hvx-ieee-headers.c:19:10: error: call to undeclared function 'Q6_Vhf_vabs_Vhf'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
# |    19 |   return Q6_Vhf_vabs_Vhf(v);
# |       |          ^
# | C:\_work\llvm-project\llvm-project\clang\test\Headers\hexagon-hvx-ieee-headers.c:19:10: error: returning 'int' from a function with incompatible result type 'HEXAGON_Vect1024' (vector of 32 'long' values)
# |    19 |   return Q6_Vhf_vabs_Vhf(v);
# |       |          ^~~~~~~~~~~~~~~~~~
# | 2 errors generated.
# `-----------------------------
# error: command failed with exit status: 1
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\clang\test\Headers\hexagon-hvx-ieee-headers.c'
# .---command stderr------------
# | FileCheck error: '<stdin>' is empty.
# | FileCheck command line:  c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\clang\test\Headers\hexagon-hvx-ieee-headers.c
# `-----------------------------
# error: command failed with exit status: 2

--

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@dyung
Copy link
Copy Markdown
Collaborator

dyung commented Mar 5, 2026

@androm3da, the test failures do appear to be related to this change, can you take a look?

@dyung dyung moved this from Needs Merge to Needs Fix in LLVM Release Status Mar 6, 2026
…llvm#184422)

Hexagon clang recently started to define __HVX_IEEE_FP__ when the
-mhvx-ieee-fp option is specified. Guard the intrinsic macros for
instructions that should only be available with -mhvx-ieee-fp with
__HVX_IEEE_FP__.

Additionally, the following NFC changes are included:

- NFC: Remove guards around HVX v60 intrinsic macros
  Hexagon v60 is the oldest Hexagon version that supports HVX so these
  guards were redundant. Presence of HVX is guarded separately, once
  per the whole file.

- Remove comments from closing guards (HVX protos)
  These comments served very limited function as they only guard
  one macro. Also, they were incorrect. Instead of fixing remove them.
  This will also reduce by the factor of two the amount of changes
  when guarding conditions change.

(cherry picked from commit e8e8d30)
@androm3da
Copy link
Copy Markdown
Member

@androm3da, the test failures do appear to be related to this change, can you take a look?

Sorry, @dyung somehow I must have gotten these two commits misconfigured by doing /cherry-picks wrong maybe.

Issue #183746 requires two cherry-picks:

136ba6e and then e8e8d30

136ba6e must land on release/22.x first - or the two could be squashed. I can fix it with a new PR targeting release/22.x with both commits, maybe that's the easiest way forward?

@llvmbot
Copy link
Copy Markdown
Member Author

llvmbot commented Mar 6, 2026

Failed to cherry-pick: `s

https://github.com/llvm/llvm-project/actions/runs/22765934935

Please manually backport the fix and push it to your github fork. Once this is done, please create a pull request

@androm3da
Copy link
Copy Markdown
Member

I can fix it with a new PR targeting release/22.x with both commits, maybe that's the easiest way forward?

I'll close this in favor of #185014

@androm3da androm3da closed this Mar 6, 2026
@dyung dyung moved this from Needs Fix to Done in LLVM Release Status Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:Hexagon backend:X86 clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:headers Headers provided by Clang, e.g. for intrinsics clang Clang issues not falling into any other category release:cherry-pick-failed

Projects

Development

Successfully merging this pull request may close these issues.

4 participants