[llvm-branch-commits] [llvm] RuntimeLibcalls: Add signatures for more runtime functions (PR #237483)
Sergei Barannikov via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Oct 30 23:36:58 PDT 2026
================
@@ -219,44 +219,55 @@ def ExceptionModelIsSjLj
// Declare all kinds of used libcalls
//--------------------------------------------------------------------
+class TypeSuffix<string S, FuncArgType Ty> {
+ string Suffix = S;
+ FuncArgType Type = Ty;
+}
+
// Integer
-foreach IntTy = ["I16", "I32", "I64", "I128"] in {
- def SHL_#IntTy : RuntimeLibcall;
- def SRL_#IntTy : RuntimeLibcall;
- def SRA_#IntTy : RuntimeLibcall;
+foreach IntTy = [TypeSuffix<"I16", Int16>, TypeSuffix<"I32", Int32>,
+ TypeSuffix<"I64", Int64>, TypeSuffix<"I128", Int128>] in {
+ def SHL_#IntTy.Suffix : RuntimeLibcall<IntTy.Type, [IntTy.Type, Int]>;
+ def SRL_#IntTy.Suffix : RuntimeLibcall<IntTy.Type, [IntTy.Type, Int]>;
+ def SRA_#IntTy.Suffix : RuntimeLibcall<IntTy.Type, [IntTy.Type, Int]>;
}
-foreach IntTy = ["I8", "I16", "I32", "I64", "I128"] in {
- def MUL_#IntTy : RuntimeLibcall;
+foreach IntTy = [TypeSuffix<"I8", Int8>, TypeSuffix<"I16", Int16>,
+ TypeSuffix<"I32", Int32>, TypeSuffix<"I64", Int64>,
+ TypeSuffix<"I128", Int128>] in {
+ def MUL_#IntTy.Suffix : RuntimeLibcall<IntTy.Type, [IntTy.Type, IntTy.Type]>;
+ def SDIV_#IntTy.Suffix : RuntimeLibcall<IntTy.Type, [IntTy.Type, IntTy.Type]>;
+ def SREM_#IntTy.Suffix : RuntimeLibcall<IntTy.Type, [IntTy.Type, IntTy.Type]>;
}
-foreach IntTy = ["I32", "I64", "I128" ] in {
- def MULO_#IntTy : RuntimeLibcall;
+foreach IntTy = [TypeSuffix<"I8", UInt8>, TypeSuffix<"I16", UInt16>,
+ TypeSuffix<"I32", UInt32>, TypeSuffix<"I64", UInt64>,
+ TypeSuffix<"I128", UInt128>] in {
+ def UDIV_#IntTy.Suffix : RuntimeLibcall<IntTy.Type, [IntTy.Type, IntTy.Type]>;
+ def UREM_#IntTy.Suffix : RuntimeLibcall<IntTy.Type, [IntTy.Type, IntTy.Type]>;
+}
+
+foreach IntTy = [TypeSuffix<"I32", Int32>, TypeSuffix<"I64", Int64>,
+ TypeSuffix<"I128", Int128>] in {
+ def MULO_#IntTy.Suffix
+ : RuntimeLibcall<IntTy.Type, [IntTy.Type, IntTy.Type, Ptr]>;
}
foreach IntTy = ["I8", "I16", "I32", "I64", "I128"] in {
- def SDIV_#IntTy : RuntimeLibcall;
- def UDIV_#IntTy : RuntimeLibcall;
- def SREM_#IntTy : RuntimeLibcall;
- def UREM_#IntTy : RuntimeLibcall;
def SDIVREM_#IntTy : RuntimeLibcall;
def UDIVREM_#IntTy : RuntimeLibcall;
}
-foreach IntTy = ["I32", "I64" ] in {
- def NEG_#IntTy : RuntimeLibcall;
+foreach IntTy = [TypeSuffix<"I32", Int32>, TypeSuffix<"I64", Int64>] in {
+ def NEG_#IntTy.Suffix : RuntimeLibcall<IntTy.Type, [IntTy.Type]>;
}
-foreach IntTy = ["I32", "I64", "I128"] in {
- def CTLZ_#IntTy : RuntimeLibcall;
- def CTPOP_#IntTy : RuntimeLibcall;
+foreach IntTy = [TypeSuffix<"I32", Int32>, TypeSuffix<"I64", Int64>,
+ TypeSuffix<"I128", Int128>] in {
+ def CTLZ_#IntTy.Suffix : RuntimeLibcall<Int, [IntTy.Type]>;
+ def CTPOP_#IntTy.Suffix : RuntimeLibcall<Int, [IntTy.Type]>;
----------------
s-barannikov wrote:
These take unsigned argument, if that matters
https://github.com/llvm/llvm-project/pull/237483
More information about the llvm-branch-commits
mailing list