diff --git a/compiler-rt/lib/ventus/crt0.S b/compiler-rt/lib/ventus/crt0.S new file mode 100644 index 000000000000..63a0b6824fa5 --- /dev/null +++ b/compiler-rt/lib/ventus/crt0.S @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2023 Terapines Technology (Wuhan) Co., Ltd + * + * 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 + */ + +/** + * crt0.S : Entry point for Ventus OpenCL C kernel programs + */ + + .text + .global _start + .type _start, @function +_start: + # set global pointer register + .option push + .option norelax + la gp, __global_pointer + .option pop + + # allocate warp and per-thread level stack pointers + la sp, __stack_pointer # sp points to local memory + la tp, __thread_stack_pointer # tp points to private memory + + # clear BSS segment + la a0, _edata + la a2, _end + beq a0, a2, 2f +1: + sw zero, (a0) + addi a0, a0, 4 + bltu a0, a2, 1b + +2: + csrr a3, CSR_KNL # get addr of kernel metadata + lw a2, 0(a3) # get kernel program address + lw a0, 4(a3) # get kernel 1st arg address + jalr a2 # call kernel program + + # call exit routine + # tail exit +.size _start, .-_start