initial commit
[riscv-tests.git] / isa / rv64ui / ld.S
1 #*****************************************************************************
2 # ld.S
3 #-----------------------------------------------------------------------------
4 #
5 # Test ld instruction.
6 #
7
8 #include "riscv_test.h"
9 #include "test_macros.h"
10
11 RVTEST_RV64U
12 RVTEST_CODE_BEGIN
13
14 #-------------------------------------------------------------
15 # Basic tests
16 #-------------------------------------------------------------
17
18 TEST_LD_OP( 2, ld, 0x00ff00ff00ff00ff, 0, tdat );
19 TEST_LD_OP( 3, ld, 0xff00ff00ff00ff00, 8, tdat );
20 TEST_LD_OP( 4, ld, 0x0ff00ff00ff00ff0, 16, tdat );
21 TEST_LD_OP( 5, ld, 0xf00ff00ff00ff00f, 24, tdat );
22
23 # Test with negative offset
24
25 TEST_LD_OP( 6, ld, 0x00ff00ff00ff00ff, -24, tdat4 );
26 TEST_LD_OP( 7, ld, 0xff00ff00ff00ff00, -16, tdat4 );
27 TEST_LD_OP( 8, ld, 0x0ff00ff00ff00ff0, -8, tdat4 );
28 TEST_LD_OP( 9, ld, 0xf00ff00ff00ff00f, 0, tdat4 );
29
30 # Test with a negative base
31
32 TEST_CASE( 10, x3, 0x00ff00ff00ff00ff, \
33 la x1, tdat; \
34 addi x1, x1, -32; \
35 ld x3, 32(x1); \
36 )
37
38 # Test with unaligned base
39
40 TEST_CASE( 11, x3, 0xff00ff00ff00ff00, \
41 la x1, tdat; \
42 addi x1, x1, -3; \
43 ld x3, 11(x1); \
44 )
45
46 #-------------------------------------------------------------
47 # Bypassing tests
48 #-------------------------------------------------------------
49
50 TEST_LD_DEST_BYPASS( 12, 0, ld, 0x0ff00ff00ff00ff0, 8, tdat2 );
51 TEST_LD_DEST_BYPASS( 13, 1, ld, 0xf00ff00ff00ff00f, 8, tdat3 );
52 TEST_LD_DEST_BYPASS( 14, 2, ld, 0xff00ff00ff00ff00, 8, tdat1 );
53
54 TEST_LD_SRC1_BYPASS( 15, 0, ld, 0x0ff00ff00ff00ff0, 8, tdat2 );
55 TEST_LD_SRC1_BYPASS( 16, 1, ld, 0xf00ff00ff00ff00f, 8, tdat3 );
56 TEST_LD_SRC1_BYPASS( 17, 2, ld, 0xff00ff00ff00ff00, 8, tdat1 );
57
58 #-------------------------------------------------------------
59 # Test write-after-write hazard
60 #-------------------------------------------------------------
61
62 TEST_CASE( 18, x2, 2, \
63 la x3, tdat; \
64 ld x2, 0(x3); \
65 li x2, 2; \
66 )
67
68 TEST_CASE( 19, x2, 2, \
69 la x3, tdat; \
70 ld x2, 0(x3); \
71 nop; \
72 li x2, 2; \
73 )
74
75 TEST_PASSFAIL
76
77 RVTEST_CODE_END
78
79 .data
80 RVTEST_DATA_BEGIN
81
82 TEST_DATA
83
84 tdat:
85 tdat1: .dword 0x00ff00ff00ff00ff
86 tdat2: .dword 0xff00ff00ff00ff00
87 tdat3: .dword 0x0ff00ff00ff00ff0
88 tdat4: .dword 0xf00ff00ff00ff00f
89
90 RVTEST_DATA_END