mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
10af09a34f
The patch adds a possibility to make library calls on NVPTX. An important thing about library functions - they must be defined within the current module. This basically should guarantee that we produce a valid PTX assembly (without calls to not defined functions). The one who wants to use the libcalls is probably will have to link against compiler-rt or any other implementation. Currently, it's completely impossible to make library calls because of error LLVM ERROR: Cannot select: i32 = ExternalSymbol '...'. But we can lower ExternalSymbol to TargetExternalSymbol and verify if the function definition is available. Also, there was an issue with a DAG during legalisation. When we expand instruction into libcall, the inner call-chain isn't being "integrated" into outer chain. Since the last "data-flow" (call retval load) node is located in call-chain earlier than CALLSEQ_END node, the latter becomes a leaf and therefore a dead node (and is being removed quite fast). Proposed here solution relies on another data-flow pseudo nodes (ProxyReg) which purpose is only to keep CALLSEQ_END at legalisation and instruction selection phases - we remove the pseudo instructions before register scheduling phase. Patch by Denys Zariaiev! Differential Revision: https://reviews.llvm.org/D34708 llvm-svn: 350069
32 lines
882 B
LLVM
32 lines
882 B
LLVM
; RUN: llc < %s -march=nvptx 2>&1 | FileCheck %s
|
|
; Allow to make libcalls that are defined in the current module
|
|
|
|
; Underlying libcall declaration
|
|
; CHECK: .visible .func (.param .align 16 .b8 func_retval0[16]) __umodti3
|
|
|
|
define i128 @remainder(i128, i128) {
|
|
bb0:
|
|
; CHECK: { // callseq 0, 0
|
|
; CHECK: call.uni (retval0),
|
|
; CHECK-NEXT: __umodti3,
|
|
; CHECK-NEXT: (
|
|
; CHECK-NEXT: param0,
|
|
; CHECK-NEXT: param1
|
|
; CHECK-NEXT: );
|
|
; CHECK-NEXT: ld.param.v2.b64 {%[[REG0:rd[0-9]+]], %[[REG1:rd[0-9]+]]}, [retval0+0];
|
|
; CHECK-NEXT: } // callseq 0
|
|
%a = urem i128 %0, %1
|
|
br label %bb1
|
|
|
|
bb1:
|
|
; CHECK-NEXT: st.param.v2.b64 [func_retval0+0], {%[[REG0]], %[[REG1]]};
|
|
; CHECK-NEXT: ret;
|
|
ret i128 %a
|
|
}
|
|
|
|
; Underlying libcall definition
|
|
; CHECK: .visible .func (.param .align 16 .b8 func_retval0[16]) __umodti3(
|
|
define i128 @__umodti3(i128, i128) {
|
|
ret i128 0
|
|
}
|