Add initial crt0 for Ventus OpenCL kernel.

This commit is contained in:
Aries 2023-01-03 16:08:42 +08:00
parent f9dd113822
commit fe59748e79
1 changed files with 44 additions and 0 deletions

View File

@ -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