Skip to content

AVR: Move runtime libcall name setting out of TargetLowering #142545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Jun 3, 2025

RuntimeLibcallInfo needs to be accurate outside of codegen
contexts.

@arsenm arsenm added the backend:AVR label Jun 3, 2025 — with Graphite App
Copy link
Contributor Author

arsenm commented Jun 3, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arsenm arsenm requested a review from benshi001 June 3, 2025 06:15
@arsenm arsenm marked this pull request as ready for review June 3, 2025 06:15
@llvmbot llvmbot added the llvm:ir label Jun 3, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 3, 2025

@llvm/pr-subscribers-llvm-ir

Author: Matt Arsenault (arsenm)

Changes

RuntimeLibcallInfo needs to be accurate outside of codegen
contexts.


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

2 Files Affected:

  • (modified) llvm/lib/IR/RuntimeLibcalls.cpp (+18)
  • (modified) llvm/lib/Target/AVR/AVRISelLowering.cpp (-18)
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index 90c3bf0db0236..08b4d6dc485d0 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -240,6 +240,24 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
     setLibcallName(RTLIB::UREM_I8, nullptr);
     setLibcallName(RTLIB::UREM_I16, nullptr);
     setLibcallName(RTLIB::UREM_I32, nullptr);
+
+    // Division and modulus rtlib functions
+    setLibcallName(RTLIB::SDIVREM_I8, "__divmodqi4");
+    setLibcallName(RTLIB::SDIVREM_I16, "__divmodhi4");
+    setLibcallName(RTLIB::SDIVREM_I32, "__divmodsi4");
+    setLibcallName(RTLIB::UDIVREM_I8, "__udivmodqi4");
+    setLibcallName(RTLIB::UDIVREM_I16, "__udivmodhi4");
+    setLibcallName(RTLIB::UDIVREM_I32, "__udivmodsi4");
+
+    // Several of the runtime library functions use a special calling conv
+    setLibcallCallingConv(RTLIB::SDIVREM_I8, CallingConv::AVR_BUILTIN);
+    setLibcallCallingConv(RTLIB::SDIVREM_I16, CallingConv::AVR_BUILTIN);
+    setLibcallCallingConv(RTLIB::UDIVREM_I8, CallingConv::AVR_BUILTIN);
+    setLibcallCallingConv(RTLIB::UDIVREM_I16, CallingConv::AVR_BUILTIN);
+
+    // Trigonometric rtlib functions
+    setLibcallName(RTLIB::SIN_F32, "sin");
+    setLibcallName(RTLIB::COS_F32, "cos");
   }
 
   if (!TT.isWasm()) {
diff --git a/llvm/lib/Target/AVR/AVRISelLowering.cpp b/llvm/lib/Target/AVR/AVRISelLowering.cpp
index eca682895e24f..9747ad0c5cd58 100644
--- a/llvm/lib/Target/AVR/AVRISelLowering.cpp
+++ b/llvm/lib/Target/AVR/AVRISelLowering.cpp
@@ -198,24 +198,6 @@ AVRTargetLowering::AVRTargetLowering(const AVRTargetMachine &TM,
     // improvements in how we treat 16-bit "registers" to be feasible.
   }
 
-  // Division and modulus rtlib functions
-  setLibcallName(RTLIB::SDIVREM_I8, "__divmodqi4");
-  setLibcallName(RTLIB::SDIVREM_I16, "__divmodhi4");
-  setLibcallName(RTLIB::SDIVREM_I32, "__divmodsi4");
-  setLibcallName(RTLIB::UDIVREM_I8, "__udivmodqi4");
-  setLibcallName(RTLIB::UDIVREM_I16, "__udivmodhi4");
-  setLibcallName(RTLIB::UDIVREM_I32, "__udivmodsi4");
-
-  // Several of the runtime library functions use a special calling conv
-  setLibcallCallingConv(RTLIB::SDIVREM_I8, CallingConv::AVR_BUILTIN);
-  setLibcallCallingConv(RTLIB::SDIVREM_I16, CallingConv::AVR_BUILTIN);
-  setLibcallCallingConv(RTLIB::UDIVREM_I8, CallingConv::AVR_BUILTIN);
-  setLibcallCallingConv(RTLIB::UDIVREM_I16, CallingConv::AVR_BUILTIN);
-
-  // Trigonometric rtlib functions
-  setLibcallName(RTLIB::SIN_F32, "sin");
-  setLibcallName(RTLIB::COS_F32, "cos");
-
   setMinFunctionAlignment(Align(2));
   setMinimumJumpTableEntries(UINT_MAX);
 }

RuntimeLibcallInfo needs to be accurate outside of codegen
contexts.
@arsenm arsenm force-pushed the users/arsenm/avr/move-runtime-libcall-config-out-of-tli branch from b618424 to 7d6666f Compare June 3, 2025 14:56
Copy link
Member

@benshi001 benshi001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arsenm arsenm merged commit 437b160 into main Jun 4, 2025
6 of 11 checks passed
@arsenm arsenm deleted the users/arsenm/avr/move-runtime-libcall-config-out-of-tli branch June 4, 2025 01:52
rorth pushed a commit to rorth/llvm-project that referenced this pull request Jun 11, 2025
…2545)

RuntimeLibcallInfo needs to be accurate outside of codegen
contexts.
DhruvSrivastavaX pushed a commit to DhruvSrivastavaX/lldb-for-aix that referenced this pull request Jun 12, 2025
…2545)

RuntimeLibcallInfo needs to be accurate outside of codegen
contexts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants