blob: e88402c710253e5b072d306de8c2c12695f55cc9 [file] [log] [blame]
Douglas Leung200f0402016-02-25 20:05:47 -08001%default { "load":"lw", "shift":"2", "data_offset":"MIRROR_INT_ARRAY_DATA_OFFSET" }
2 /*
3 * Array get, 32 bits or less. vAA <- vBB[vCC].
4 *
5 * Note: using the usual FETCH/and/shift stuff, this fits in exactly 17
6 * instructions. We use a pair of FETCH_Bs instead.
7 *
8 * for: aget, aget-boolean, aget-byte, aget-char, aget-short
9 *
10 * NOTE: assumes data offset for arrays is the same for all non-wide types.
11 * If this changes, specialize.
12 */
13 /* op vAA, vBB, vCC */
14 FETCH_B(a2, 1, 0) # a2 <- BB
15 GET_OPA(rOBJ) # rOBJ <- AA
16 FETCH_B(a3, 1, 1) # a3 <- CC
17 GET_VREG(a0, a2) # a0 <- vBB (array object)
18 GET_VREG(a1, a3) # a1 <- vCC (requested index)
19 # null array object?
20 beqz a0, common_errNullObject # yes, bail
21 LOAD_base_offMirrorArray_length(a3, a0) # a3 <- arrayObj->length
Douglas Leung200f0402016-02-25 20:05:47 -080022 EASN(a0, a0, a1, $shift) # a0 <- arrayObj + index*width
Douglas Leung200f0402016-02-25 20:05:47 -080023 # a1 >= a3; compare unsigned index
24 bgeu a1, a3, common_errArrayIndex # index >= length, bail
25 FETCH_ADVANCE_INST(2) # advance rPC, load rINST
26 $load a2, $data_offset(a0) # a2 <- vBB[vCC]
27 GET_INST_OPCODE(t0) # extract opcode from rINST
28 SET_VREG_GOTO(a2, rOBJ, t0) # vAA <- a2