Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2012 The Native Client Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can | |
| 3 # be found in the LICENSE file. | |
| 4 # Copyright 2012 MIPS Technologies / RT-RK. | |
| 5 | |
| 6 # test cases for jmps/branches | |
| 7 # there are several kinds of jmps/branches in regards to destination address | |
| 8 # 1. jmps into 0-0x10000, null guard region, where everything is considered OK | |
| 9 # 2. jmps into 0x10000-0x20000, trampoline code section, jmps need to be bundle aligned | |
|
Brad Chen
2012/04/13 00:50:52
Please try to stick with 80-columns unless syntact
| |
| 10 # 3. jmps into code section, jmps need to be bundle aligned | |
| 11 # beside destination address we also check the position of jmp/b and link | |
|
Brad Chen
2012/04/13 00:50:52
Standard capitalization makes the comments more re
| |
| 12 # instructions, which need to bundle offset +8 | |
| 13 | |
| 14 | |
| 15 .globl _start | |
| 16 _start: | |
| 17 .align 4 | |
| 18 .set noreorder | |
| 19 | |
| 20 bundle_b_to_0_0x1000: | |
| 21 b _start - 0x10000 #destination addres is 0x10000 - OK | |
| 22 nop | |
|
Brad Chen
2012/04/13 00:50:52
It looks like the convention you are using is an i
| |
| 23 b _start - 0x1fff4 #destination addres is 0xc (null guard region)- OK | |
| 24 nop | |
| 25 | |
| 26 bundle_b_to_0x1000_0x20000: | |
| 27 b _start - 0x10000 # ok - trampoline start | |
| 28 nop | |
| 29 b _start - 0xfff4 # dest_addr = 0x1000c, error (middle of the trampolin e) | |
| 30 nop | |
| 31 | |
| 32 bundle_b_to_code_area: | |
| 33 b _start + 0x1000 # ok | |
| 34 nop | |
| 35 b _start + 0x1004 # ok, not on pseudo instruction | |
| 36 nop | |
| 37 b _start + 0x10 # ok | |
| 38 nop | |
| 39 b end_of_code # ok | |
| 40 nop | |
| 41 | |
| 42 bundle_j_to_0_0x1000: | |
| 43 #all is allowed, b/c that is guard region | |
| 44 j 0x0 | |
| 45 nop | |
| 46 j 0x4 | |
| 47 nop | |
| 48 | |
| 49 bundle_j_trampoline_area: | |
| 50 j 0x10000 | |
| 51 nop | |
| 52 jal 0x10004 # kProblemUnalignedJumpToTrampoline (not a trampoline start) | |
| 53 nop | |
| 54 | |
| 55 nop | |
| 56 nop | |
| 57 jal 0x10010 # ok - not a trampoline start, but there is a halt, s o ok. | |
| 58 nop | |
| 59 | |
| 60 nop | |
| 61 nop | |
| 62 jal 0x10020 # ok | |
| 63 nop | |
| 64 | |
| 65 bundle_j_negative: | |
| 66 j -0x4 # ok | |
| 67 nop | |
| 68 j -0x10 # ok | |
| 69 nop | |
| 70 | |
| 71 bundle_1st: | |
| 72 and $a0, $a0, $t7 | |
| 73 bundle_2nd: | |
| 74 sw $ra, 24($a0) | |
| 75 addiu $v0, $v0, 4 | |
| 76 addiu $v0, $v1, 0 | |
| 77 | |
| 78 bl_check: | |
| 79 nop | |
| 80 nop | |
| 81 bal bundle_1st #ok | |
| 82 nop | |
| 83 | |
| 84 bundle_check_b_dest_addr: | |
| 85 b bundle_1st # ok | |
| 86 nop | |
| 87 b bundle_2nd # kProblemBranchSplitsPattern | |
| 88 nop | |
| 89 | |
| 90 bal 0x10000 #error misaligned call | |
| 91 nop | |
| 92 jalx 0x3ffffff0 #error, forbidden instruction | |
| 93 nop | |
| 94 | |
| 95 jal 0x10000 #error misaligned call | |
| 96 nop | |
| 97 jal 0x3fffff0 #ok | |
| 98 nop | |
| 99 | |
| 100 b bundle_2nd # kProblemBranchSplitsPattern | |
| 101 nop | |
| 102 nop | |
| 103 nop | |
| 104 | |
| 105 end_of_code: | |
| OLD | NEW |