Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion llvm/include/llvm/IR/RuntimeLibcalls.td
Original file line number Diff line number Diff line change
Expand Up @@ -2808,13 +2808,30 @@ def WasmSystemLibrary
emscripten_return_address,
__stack_chk_fail, __stack_chk_guard)>;

//===----------------------------------------------------------------------===//
// BPF Runtime Libcalls
//===----------------------------------------------------------------------===//

def isBPF : RuntimeLibcallPredicate<"TT.isBPF()">;

def BPFSystemLibrary
: SystemRuntimeLibrary<isBPF,
(add (sub DefaultRuntimeLibcallImpls,
// i128 operations should be lowered by LLVM for BPF
__divti3,
__udivti3,
__modti3,
__umodti3,
__clzti2
))>;

//===----------------------------------------------------------------------===//
// Legacy Default Runtime Libcalls
//===----------------------------------------------------------------------===//

// TODO: Should make every target explicit.
def isDefaultLibcallArch : RuntimeLibcallPredicate<[{
TT.isMIPS() || TT.isLoongArch() || TT.isVE() || TT.isBPF() ||
TT.isMIPS() || TT.isLoongArch() || TT.isVE() ||
TT.getArch() == Triple::csky || TT.getArch() == Triple::arc ||
TT.getArch() == Triple::m68k || TT.getArch() == Triple::xtensa ||
(TT.isSystemZ() && !TT.isOSzOS())
Expand Down
39 changes: 0 additions & 39 deletions llvm/test/CodeGen/BPF/builtin_calls.ll

This file was deleted.

23 changes: 23 additions & 0 deletions llvm/test/CodeGen/BPF/i128_math.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
; RUN: llc -march=bpfel < %s | FileCheck %s
;
; C code for this test case:
;
; long func(long a, long b) {
; long x;
; return __builtin_mul_overflow(a, b, &x);
; }


declare { i64, i1 } @llvm.smul.with.overflow.i64(i64, i64)

define noundef range(i64 0, 2) i64 @func(i64 noundef %a, i64 noundef %b) local_unnamed_addr {
entry:
%0 = tail call { i64, i1 } @llvm.smul.with.overflow.i64(i64 %a, i64 %b)
%1 = extractvalue { i64, i1 } %0, 1
%conv = zext i1 %1 to i64
ret i64 %conv
}

; CHECK-LABEL: func
; CHECK-NOT: call __multi3
; CHECK: exit