Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / native_client / tests / toolchain / nop_test.S
1 /*
2  * Copyright (c) 2013 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 #include "native_client/src/trusted/service_runtime/nacl_config.h"
8
9         .text
10
11 /*
12  * This test attempts to get both the assembler and the linker to generate
13  * all the different kinds of nop instructions they will generate when
14  * doing alignment padding in the code segment.  Running the output through
15  * the validator ensures that it accepts all these nop forms.
16  */
17
18 .macro fill_before length
19         /*
20          * Fill space at the start of a bundle leaving exactly |length|
21          * bytes before the end of the bundle.
22          */
23         .fill ((1 << NACL_BLOCK_SHIFT) - \length) / NACL_HALT_LEN, \
24               NACL_HALT_LEN, NACL_HALT_OPCODE
25 .endm
26
27 .macro try length
28         /*
29          * Create the circumstance where exactly |length| bytes must be
30          * filled to perform '.p2align NACL_BLOCK_SHIFT', and then let the
31          * assembler fill it with its choice of nops.
32          */
33         .p2align NACL_BLOCK_SHIFT
34 test_as_nop_\length\():
35         fill_before \length
36         .p2align NACL_BLOCK_SHIFT
37         nop
38
39          /*
40           * Now create the same circumstance in the linker when it stitches
41           * this section to the next one (which has sh_addralign=32).
42           */
43         .pushsection .text.nop.\length, "ax", %progbits
44         .p2align NACL_BLOCK_SHIFT
45 test_ld_nop_\length\():
46         fill_before \length
47         .popsection
48 .endm
49
50 #if NACL_BLOCK_SHIFT == 5 && NACL_HALT_LEN == 1
51 try 1
52 try 2
53 try 3
54 try 4
55 try 5
56 try 6
57 try 7
58 try 8
59 try 9
60 try 10
61 try 11
62 try 12
63 try 13
64 try 14
65 try 15
66 try 16
67 try 17
68 try 18
69 try 19
70 try 20
71 try 21
72 try 22
73 try 23
74 try 24
75 try 25
76 try 26
77 try 27
78 try 29
79 try 30
80 try 31
81 #elif NACL_BLOCK_SHIFT == 4 && NACL_HALT_LEN == 4
82 try 4
83 try 8
84 try 12
85 #else
86 # error "architecture not handled by this test"
87 #endif
88
89         /*
90          * This section follows .text.nop.31 and creates (by virtue of its
91          * alignment) the need for the linker to generate the last nop
92          * sequence.
93          */
94         .pushsection .text.nop.end, "ax", %progbits
95         .p2align NACL_BLOCK_SHIFT
96         nop
97         .popsection