adrp.S revision 1.1.1.1
1/* Tests the load page address instruction.
2
3   Copyright (C) 2019-2023 Free Software Foundation, Inc.
4
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 3 of the License, or
8   (at your option) any later version.
9
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14
15   You should have received a copy of the GNU General Public License
16   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18# mach: or1k
19# output: report(0x00002064);\n
20# output: report(0x00012138);\n
21# output: report(0x00002000);\n
22# output: report(0x00012000);\n
23# output: report(0x00002000);\n
24# output: report(0x00014000);\n
25# output: report(0x00000000);\n
26# output: exit(0)\n
27
28#include "or1k-asm-test-helpers.h"
29
30	STANDARD_TEST_ENVIRONMENT
31
32	.section .data
33	.org 0x10000
34	.align 4
35	.type   pi, @object
36	.size   pi, 4
37pi:
38	.float	3.14159
39
40	.section .text
41start_tests:
42	PUSH LINK_REGISTER_R9
43
44	/* Print out the PC.  To compare with that loaded by l.adrp.  */
45	l.jal	capture_pc
46	 l.nop
47capture_pc:
48	REPORT_REG_TO_CONSOLE r9
49
50	/* Print out our data address to compared with l.adrp offset.  */
51	l.movhi	r11, ha(pi)
52	l.addi	r11, r11, lo(pi)
53	REPORT_REG_TO_CONSOLE r11
54
55	/* Test l.adrp with symbols, loads page of symbol to register.  */
56	l.adrp	r4, start_tests
57	REPORT_REG_TO_CONSOLE r4
58
59	l.adrp	r4, pi
60	REPORT_REG_TO_CONSOLE r4
61
62	/* Test l.adrp with immediate, immediate is the page offset.  */
63	l.adrp	r4, 0x0
64	REPORT_REG_TO_CONSOLE r4
65
66	l.adrp	r4, 0x12000
67	REPORT_REG_TO_CONSOLE r4
68
69	l.adrp	r4, -0x2000
70	REPORT_REG_TO_CONSOLE r4
71
72	POP LINK_REGISTER_R9
73	RETURN_TO_LINK_REGISTER_R9
74