summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYingchi Long <i@lyc.dev>2023-12-14 15:33:55 +0800
committerYingchi Long <i@lyc.dev>2023-12-14 15:37:00 +0800
commitbe22a6090f699f0793d87abf3d288b5549922f03 (patch)
treeaeaa052361ffc3ed150037406896cb4075200fb0
parent2255795f281862b11e22920b982d57787808ecbb (diff)
[BPF] get external linkage for calling convetion functionsupstream/users/inclyc/bpf/gisel/standalone-cc
NFC. For support calling conv in gisel, sharing code with BPFISelLowering.
-rw-r--r--llvm/lib/Target/BPF/BPFCallingConv.cpp19
-rw-r--r--llvm/lib/Target/BPF/BPFCallingConv.h39
-rw-r--r--llvm/lib/Target/BPF/BPFCallingConv.td4
-rw-r--r--llvm/lib/Target/BPF/BPFISelLowering.cpp4
-rw-r--r--llvm/lib/Target/BPF/CMakeLists.txt3
5 files changed, 65 insertions, 4 deletions
diff --git a/llvm/lib/Target/BPF/BPFCallingConv.cpp b/llvm/lib/Target/BPF/BPFCallingConv.cpp
new file mode 100644
index 000000000000..29793b36e28b
--- /dev/null
+++ b/llvm/lib/Target/BPF/BPFCallingConv.cpp
@@ -0,0 +1,19 @@
+//=== BPFCallingConv.cpp ---- BPF Calling Convention Routines ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements BPF Calling Convention Routines
+//
+//===----------------------------------------------------------------------===//
+
+#include "BPFCallingConv.h"
+#include "BPFRegisterInfo.h"
+#include "BPFSubtarget.h"
+
+using namespace llvm;
+
+#include "BPFGenCallingConv.inc"
diff --git a/llvm/lib/Target/BPF/BPFCallingConv.h b/llvm/lib/Target/BPF/BPFCallingConv.h
new file mode 100644
index 000000000000..1d2eded065f0
--- /dev/null
+++ b/llvm/lib/Target/BPF/BPFCallingConv.h
@@ -0,0 +1,39 @@
+//=== BPFCallingConv.h ----- BPF Calling Convention Routines ----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains BPF Calling Convention Routines declaration
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIB_TARGET_BPF_BPFCALLINGCONV_H
+#define LLVM_LIB_TARGET_BPF_BPFCALLINGCONV_H
+
+#include "llvm/CodeGen/CallingConvLower.h"
+
+namespace llvm {
+
+bool CC_BPF32(unsigned ValNo, MVT ValVT, MVT LocVT,
+ CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags,
+ CCState &State);
+
+bool CC_BPF32(unsigned ValNo, MVT ValVT, MVT LocVT,
+ CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags,
+ CCState &State);
+bool CC_BPF64(unsigned ValNo, MVT ValVT, MVT LocVT,
+ CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags,
+ CCState &State);
+bool RetCC_BPF32(unsigned ValNo, MVT ValVT, MVT LocVT,
+ CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags,
+ CCState &State);
+bool RetCC_BPF64(unsigned ValNo, MVT ValVT, MVT LocVT,
+ CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags,
+ CCState &State);
+
+} // namespace llvm
+
+#endif
diff --git a/llvm/lib/Target/BPF/BPFCallingConv.td b/llvm/lib/Target/BPF/BPFCallingConv.td
index ef4ef1930aa8..9e30d03b5ebe 100644
--- a/llvm/lib/Target/BPF/BPFCallingConv.td
+++ b/llvm/lib/Target/BPF/BPFCallingConv.td
@@ -11,9 +11,11 @@
//===----------------------------------------------------------------------===//
// BPF 64-bit C return-value convention.
+let Entry = 1 in
def RetCC_BPF64 : CallingConv<[CCIfType<[i64], CCAssignToReg<[R0]>>]>;
// BPF 64-bit C Calling convention.
+let Entry = 1 in
def CC_BPF64 : CallingConv<[
// Promote i8/i16/i32 args to i64
CCIfType<[ i8, i16, i32 ], CCPromoteToType<i64>>,
@@ -26,12 +28,14 @@ def CC_BPF64 : CallingConv<[
]>;
// Return-value convention when -mattr=+alu32 enabled
+let Entry = 1 in
def RetCC_BPF32 : CallingConv<[
CCIfType<[i32], CCAssignToRegWithShadow<[W0], [R0]>>,
CCIfType<[i64], CCAssignToRegWithShadow<[R0], [W0]>>
]>;
// Calling convention when -mattr=+alu32 enabled
+let Entry = 1 in
def CC_BPF32 : CallingConv<[
// Promote i8/i16/i32 args to i64
CCIfType<[i32], CCAssignToRegWithShadow<[W1, W2, W3, W4, W5],
diff --git a/llvm/lib/Target/BPF/BPFISelLowering.cpp b/llvm/lib/Target/BPF/BPFISelLowering.cpp
index 2fe86e75ddae..9c24db1df863 100644
--- a/llvm/lib/Target/BPF/BPFISelLowering.cpp
+++ b/llvm/lib/Target/BPF/BPFISelLowering.cpp
@@ -13,6 +13,7 @@
#include "BPFISelLowering.h"
#include "BPF.h"
+#include "BPFCallingConv.h"
#include "BPFSubtarget.h"
#include "BPFTargetMachine.h"
#include "llvm/CodeGen/CallingConvLower.h"
@@ -317,9 +318,6 @@ SDValue BPFTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
}
}
-// Calling Convention Implementation
-#include "BPFGenCallingConv.inc"
-
SDValue BPFTargetLowering::LowerFormalArguments(
SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &DL,
diff --git a/llvm/lib/Target/BPF/CMakeLists.txt b/llvm/lib/Target/BPF/CMakeLists.txt
index d88e7ade40b9..0b9d59ed8119 100644
--- a/llvm/lib/Target/BPF/CMakeLists.txt
+++ b/llvm/lib/Target/BPF/CMakeLists.txt
@@ -24,6 +24,7 @@ add_llvm_target(BPFCodeGen
BPFAbstractMemberAccess.cpp
BPFAdjustOpt.cpp
BPFAsmPrinter.cpp
+ BPFCallingConv.cpp
BPFCheckAndAdjustIR.cpp
BPFFrameLowering.cpp
BPFInstrInfo.cpp
@@ -62,7 +63,7 @@ add_llvm_target(BPFCodeGen
ADD_TO_COMPONENT
BPF
- )
+)
add_subdirectory(AsmParser)
add_subdirectory(Disassembler)