Skip to content

Commit

Permalink
Add basic compiler-rt builtins support for hexagon.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D46364

llvm-svn: 331881
  • Loading branch information
Sid Manning committed May 9, 2018
1 parent 3879fe0 commit ed3065f
Show file tree
Hide file tree
Showing 33 changed files with 5,470 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler-rt/cmake/builtin-config-ix.cmake
Expand Up @@ -25,6 +25,7 @@ int foo(int x, int y) {

set(ARM64 aarch64)
set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k)
set(HEXAGON hexagon)
set(X86 i386)
set(X86_64 x86_64)
set(MIPS32 mips mipsel)
Expand All @@ -42,7 +43,7 @@ if(APPLE)
endif()

set(ALL_BUILTIN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}
${MIPS32} ${MIPS64} ${PPC64} ${RISCV32} ${RISCV64} ${WASM32} ${WASM64})
${HEXAGON} ${MIPS32} ${MIPS64} ${PPC64} ${RISCV32} ${RISCV64} ${WASM32} ${WASM64})

include(CompilerRTUtils)
include(CompilerRTDarwinUtils)
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/cmake/config-ix.cmake
Expand Up @@ -174,6 +174,7 @@ endmacro()

set(ARM64 aarch64)
set(ARM32 arm armhf)
set(HEXAGON hexagon)
set(X86 i386)
set(X86_64 x86_64)
set(MIPS32 mips mipsel)
Expand Down
35 changes: 35 additions & 0 deletions compiler-rt/lib/builtins/CMakeLists.txt
Expand Up @@ -459,6 +459,41 @@ set(armv6m_SOURCES ${thumb1_SOURCES})
set(armv7m_SOURCES ${arm_SOURCES})
set(armv7em_SOURCES ${arm_SOURCES})

# hexagon arch
set(hexagon_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES})
set(hexagon_SOURCES
hexagon/common_entry_exit_abi1.S
hexagon/common_entry_exit_abi2.S
hexagon/common_entry_exit_legacy.S
hexagon/dfaddsub.S
hexagon/dfdiv.S
hexagon/dffma.S
hexagon/dfminmax.S
hexagon/dfmul.S
hexagon/dfsqrt.S
hexagon/divdi3.S
hexagon/divsi3.S
hexagon/fabs_opt.S
hexagon/fastmath2_dlib_asm.S
hexagon/fastmath2_ldlib_asm.S
hexagon/fastmath_dlib_asm.S
hexagon/fma_opt.S
hexagon/fmax_opt.S
hexagon/fmin_opt.S
hexagon/memcpy_forward_vp4cp4n2.S
hexagon/memcpy_likely_aligned.S
hexagon/moddi3.S
hexagon/modsi3.S
hexagon/sfdiv_opt.S
hexagon/sfsqrt_opt.S
hexagon/udivdi3.S
hexagon/udivmoddi4.S
hexagon/udivmodsi4.S
hexagon/udivsi3.S
hexagon/umoddi3.S
hexagon/umodsi3.S)


set(mips_SOURCES ${GENERIC_SOURCES})
set(mipsel_SOURCES ${mips_SOURCES})
set(mips64_SOURCES ${GENERIC_TF_SOURCES}
Expand Down
103 changes: 103 additions & 0 deletions compiler-rt/lib/builtins/hexagon/common_entry_exit_abi1.S
@@ -0,0 +1,103 @@
//===----------------------Hexagon builtin routine ------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

/* Functions that implement common sequences in function prologues and epilogues
used to save code size */

.macro FUNCTION_BEGIN name
.text
.globl \name
.type \name, @function
.falign
\name:
.endm

.macro FUNCTION_END name
.size \name, . - \name
.endm

.macro FALLTHROUGH_TAIL_CALL name0 name1
.size \name0, . - \name0
.globl \name1
.type \name1, @function
.falign
\name1:
.endm




/* Save r25:24 at fp+#-8 and r27:26 at fp+#-16. */




/* The compiler knows that the __save_* functions clobber LR. No other
registers should be used without informing the compiler. */

/* Since we can only issue one store per packet, we don't hurt performance by
simply jumping to the right point in this sequence of stores. */

FUNCTION_BEGIN __save_r24_through_r27
memd(fp+#-16) = r27:26
FALLTHROUGH_TAIL_CALL __save_r24_through_r27 __save_r24_through_r25
{
memd(fp+#-8) = r25:24
jumpr lr
}
FUNCTION_END __save_r24_through_r25




/* For each of the *_before_tailcall functions, jumpr lr is executed in parallel
with deallocframe. That way, the return gets the old value of lr, which is
where these functions need to return, and at the same time, lr gets the value
it needs going into the tail call. */

FUNCTION_BEGIN __restore_r24_through_r27_and_deallocframe_before_tailcall
r27:26 = memd(fp+#-16)
FALLTHROUGH_TAIL_CALL __restore_r24_through_r27_and_deallocframe_before_tailcall __restore_r24_through_r25_and_deallocframe_before_tailcall
{
r25:24 = memd(fp+#-8)
deallocframe
jumpr lr
}
FUNCTION_END __restore_r24_through_r25_and_deallocframe_before_tailcall




/* Here we use the extra load bandwidth to restore LR early, allowing the return
to occur in parallel with the deallocframe. */

FUNCTION_BEGIN __restore_r24_through_r27_and_deallocframe
{
lr = memw(fp+#4)
r27:26 = memd(fp+#-16)
}
{
r25:24 = memd(fp+#-8)
deallocframe
jumpr lr
}
FUNCTION_END __restore_r24_through_r27_and_deallocframe




/* Here the load bandwidth is maximized. */

FUNCTION_BEGIN __restore_r24_through_r25_and_deallocframe
{
r25:24 = memd(fp+#-8)
deallocframe
}
jumpr lr
FUNCTION_END __restore_r24_through_r25_and_deallocframe

0 comments on commit ed3065f

Please sign in to comment.