ObjFW  Check-in [bcff3f8c7a]

Overview
Comment:Add RISC-V 64/ELF assembly lookup implementation
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bcff3f8c7a77caa0a0e2407787edd247bbcafdfd8cec2cac04822227191b8c3c
User & Date: js on 2024-05-24 21:17:24
Other Links: manifest | tags
References
2024-05-24
21:18 Fixed ticket [2b89492bd0]: Write assembly for dispatch on RISC-V 32/64 plus 4 other changes artifact: 6a10036293 user: js
Context
2024-05-24
22:26
lookup-asm-riscv64-elf.S: Fix PIC check-in: add1755e4e user: js tags: trunk
21:17
Add RISC-V 64/ELF assembly lookup implementation check-in: bcff3f8c7a user: js tags: trunk
2024-05-22
23:54
Add OFCombinedJoyConsGameController check-in: 68ef38f917 user: js tags: trunk
Changes

Modified src/platform.h from [df35dfcbc5] to [6dfd8114dd].

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# if defined(__mc68020__) || defined(OF_M68030)
#  define OF_M68020
# endif
# if defined(__mc68010__) || defined(OF_M68020)
#  define OF_M68010
# endif
#elif defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64
# define OF_RISC_V_64
#elif defined(__riscv)
# define OF_RISC_V
#elif defined(__s390x__)
# define OF_S390X
#elif defined(__s390__)
# define OF_S390
#elif defined(__e2k__)
# define OF_ELBRUS_2000
#endif







|

|







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# if defined(__mc68020__) || defined(OF_M68030)
#  define OF_M68020
# endif
# if defined(__mc68010__) || defined(OF_M68020)
#  define OF_M68010
# endif
#elif defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64
# define OF_RISCV64
#elif defined(__riscv)
# define OF_RISCV
#elif defined(__s390x__)
# define OF_S390X
#elif defined(__s390__)
# define OF_S390
#elif defined(__e2k__)
# define OF_ELBRUS_2000
#endif

Added src/runtime/lookup-asm/lookup-asm-riscv64-elf.S version [d38e7921bf].



































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
 *
 * All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 3.0 only,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * version 3.0 for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3.0 along with this program. If not, see
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#include "platform.h"

.globl objc_msg_lookup
.globl objc_msg_lookup_stret
.globl objc_msg_lookup_super
.globl objc_msg_lookup_super_stret

.section .text
.macro GENERATE_LOOKUP name notFound
\name:
	beqz	a0, .LreturnNilMethod

	andi	t0, a0, 1
	bnez	t0, .LtaggedPointer_\name

	ld	t0, (a0)
	ld	t0, 64(t0)

.Lmain_\name:
#ifdef OF_SELUID24
	lbu	t1, 2(a1)
	slli	t1, t1, 3
#endif
	lbu	t2, 1(a1)
	slli	t2, t2, 3
	lbu	t3, (a1)
	slli	t3, t3, 3

#ifdef OF_SELUID24
	add	t0, t0, t1
	ld	t0, (t0)
#endif
	add	t0, t0, t2
	ld	t0, (t0)
	add	t0, t0, t3
	ld	t0, (t0)

	beqz	t0, 0f

	move	a0, t0
	ret

0:
	j	\notFound

.LtaggedPointer_\name:
	la	t1, objc_taggedPointerSecret
	ld	t1, (t1)
	xor	t1, a0, t1
	andi	t1, t1, 0xE
	slli	t1, t1, 2

	la	t0, objc_taggedPointerClasses
	add	t0, t0, t1
	ld	t0, (t0)
	ld	t0, 64(t0)

	j	.Lmain_\name
.type \name, @function
.size \name, .-\name
.endm

.macro GENERATE_LOOKUP_SUPER name lookup
\name:
	move	t0, a0
	ld	a0, (a0)
	beqz	a0, .LreturnNilMethod

	ld	t0, 8(t0)
	ld	t0, 64(t0)

	j	.Lmain_\lookup
.type \name, @function
.size \name, .-\name
.endm

GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound
GENERATE_LOOKUP objc_msg_lookup_stret objc_methodNotFound_stret
GENERATE_LOOKUP_SUPER objc_msg_lookup_super objc_msg_lookup
GENERATE_LOOKUP_SUPER objc_msg_lookup_super_stret objc_msg_lookup_stret

.LreturnNilMethod:
	lla	a0, .LnilMethod
	ret

.LnilMethod:
	li	a0, 0
	ret

#ifdef OF_LINUX
.section .note.GNU-stack, "", @progbits
#endif

Modified src/runtime/lookup-asm/lookup-asm.S from [f7a3f67111] to [05db03bf88].

38
39
40
41
42
43
44


45
46
47
48
49
50
51
#  include "lookup-asm-mips64-n64-elf.S"
# elif defined(OF_MIPS)
#  include "lookup-asm-mips-elf.S"
# elif defined(OF_SPARC64)
#  include "lookup-asm-sparc64-elf.S"
# elif defined(OF_SPARC)
#  include "lookup-asm-sparc-elf.S"


# endif
#elif defined(OF_MACH_O)
# if defined(OF_AMD64)
#  include "lookup-asm-amd64-macho.S"
# endif
#elif defined(OF_WINDOWS)
# if defined(OF_AMD64)







>
>







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#  include "lookup-asm-mips64-n64-elf.S"
# elif defined(OF_MIPS)
#  include "lookup-asm-mips-elf.S"
# elif defined(OF_SPARC64)
#  include "lookup-asm-sparc64-elf.S"
# elif defined(OF_SPARC)
#  include "lookup-asm-sparc-elf.S"
# elif defined(OF_RISCV64)
#  include "lookup-asm-riscv64-elf.S"
# endif
#elif defined(OF_MACH_O)
# if defined(OF_AMD64)
#  include "lookup-asm-amd64-macho.S"
# endif
#elif defined(OF_WINDOWS)
# if defined(OF_AMD64)

Modified src/runtime/private.h from [3b94bd139a] to [001133848f].

296
297
298
299
300
301
302
303

304
305
306
307
308
309
310
	    __VA_ARGS__)

#if defined(OF_ELF)
# if defined(OF_AMD64) || defined(OF_X86) || \
    defined(OF_POWERPC64) || defined(OF_POWERPC) || \
    defined(OF_ARM64) || defined(OF_ARM) || \
    defined(OF_MIPS64_N64) || defined(OF_MIPS) || \
    defined(OF_SPARC64) || defined(OF_SPARC)

#  define OF_ASM_LOOKUP
# endif
#elif defined(OF_MACH_O)
# if defined(OF_AMD64)
#  define OF_ASM_LOOKUP
# endif
#elif defined(OF_WINDOWS)







|
>







296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
	    __VA_ARGS__)

#if defined(OF_ELF)
# if defined(OF_AMD64) || defined(OF_X86) || \
    defined(OF_POWERPC64) || defined(OF_POWERPC) || \
    defined(OF_ARM64) || defined(OF_ARM) || \
    defined(OF_MIPS64_N64) || defined(OF_MIPS) || \
    defined(OF_SPARC64) || defined(OF_SPARC) || \
    defined(OF_RISCV64)
#  define OF_ASM_LOOKUP
# endif
#elif defined(OF_MACH_O)
# if defined(OF_AMD64)
#  define OF_ASM_LOOKUP
# endif
#elif defined(OF_WINDOWS)