1/* Tests the load page address instruction.
2
3   Copyright (C) 2019-2024 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(0x0001a008);\n
21# output: report(0x00002000);\n
22# output: report(0x0001a000);\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
35pad:	.quad 	0
36	.type   pi, @object
37	.size   pi, 4
38pi:
39	.float	3.14159
40
41	.section .text
42start_tests:
43	PUSH LINK_REGISTER_R9
44
45	/* Print out the PC.  To compare with that loaded by l.adrp.  */
46	l.jal	capture_pc
47	 l.nop
48capture_pc:
49	REPORT_REG_TO_CONSOLE r9
50
51	/* Print out our data address to compared with l.adrp offset.  */
52	l.movhi	r11, ha(pi)
53	l.addi	r11, r11, lo(pi)
54	REPORT_REG_TO_CONSOLE r11
55
56	/* Test l.adrp with symbols, loads page of symbol to register.  */
57	l.adrp	r4, start_tests
58	REPORT_REG_TO_CONSOLE r4
59
60	l.adrp	r4, pi
61	REPORT_REG_TO_CONSOLE r4
62
63	/* Test l.adrp with immediate, immediate is the page offset.  */
64	l.adrp	r4, 0x0
65	REPORT_REG_TO_CONSOLE r4
66
67	l.adrp	r4, 0x12000
68	REPORT_REG_TO_CONSOLE r4
69
70	l.adrp	r4, -0x2000
71	REPORT_REG_TO_CONSOLE r4
72
73	POP LINK_REGISTER_R9
74	RETURN_TO_LINK_REGISTER_R9
75