Skip to content

Commit d80b3ac

Browse files
committed
[BPF] Define set of BPF libcalls
1 parent 3d596ad commit d80b3ac

File tree

3 files changed

+33
-40
lines changed

3 files changed

+33
-40
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3464,13 +3464,22 @@ def WasmSystemLibrary
34643464
emscripten_return_address,
34653465
__stack_chk_fail, __stack_chk_guard)>;
34663466

3467+
//===----------------------------------------------------------------------===//
3468+
// BPF Runtime Libcalls
3469+
//===----------------------------------------------------------------------===//
3470+
3471+
def isBPF : RuntimeLibcallPredicate<"TT.isBPF()">;
3472+
3473+
// No calls.
3474+
def BPFSystemLibrary : SystemRuntimeLibrary<isBPF, (add)>;
3475+
34673476
//===----------------------------------------------------------------------===//
34683477
// Legacy Default Runtime Libcalls
34693478
//===----------------------------------------------------------------------===//
34703479

34713480
// TODO: Should make every target explicit.
34723481
def isDefaultLibcallArch : RuntimeLibcallPredicate<[{
3473-
TT.isMIPS() || TT.isLoongArch() || TT.isVE() || TT.isBPF() ||
3482+
TT.isMIPS() || TT.isLoongArch() || TT.isVE() ||
34743483
TT.getArch() == Triple::csky || TT.getArch() == Triple::arc ||
34753484
TT.getArch() == Triple::m68k || TT.getArch() == Triple::xtensa ||
34763485
(TT.isSystemZ() && !TT.isOSzOS())

llvm/test/CodeGen/BPF/builtin_calls.ll

Lines changed: 0 additions & 39 deletions
This file was deleted.

llvm/test/CodeGen/BPF/i128_math.ll

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; RUN: llc -march=bpfel < %s | FileCheck %s
2+
;
3+
; C code for this test case:
4+
;
5+
; long func(long a, long b) {
6+
; long x;
7+
; return __builtin_mul_overflow(a, b, &x);
8+
; }
9+
10+
11+
declare { i64, i1 } @llvm.smul.with.overflow.i64(i64, i64)
12+
13+
define noundef range(i64 0, 2) i64 @func(i64 noundef %a, i64 noundef %b) local_unnamed_addr {
14+
entry:
15+
%0 = tail call { i64, i1 } @llvm.smul.with.overflow.i64(i64 %a, i64 %b)
16+
%1 = extractvalue { i64, i1 } %0, 1
17+
%conv = zext i1 %1 to i64
18+
ret i64 %conv
19+
}
20+
21+
; CHECK-LABEL: func
22+
; CHECK-NOT: call __multi3
23+
; CHECK: exit

0 commit comments

Comments
 (0)