100b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze%default { "store":"sw", "shift":"2", "data_offset":"MIRROR_INT_ARRAY_DATA_OFFSET" } 200b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze /* 300b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze * Array put, 32 bits or less. vBB[vCC] <- vAA. 400b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze * 500b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze * for: aput, aput-boolean, aput-byte, aput-char, aput-short 600b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze * 700b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze * NOTE: this assumes data offset for arrays is the same for all non-wide types. 800b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze * If this changes, specialize. 900b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze */ 1000b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze /* op vAA, vBB, vCC */ 1100b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze lbu a2, 2(rPC) # a2 <- BB 1200b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze lbu a3, 3(rPC) # a3 <- CC 1300b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze srl a4, rINST, 8 # a4 <- AA 1400b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze GET_VREG_U a0, a2 # a0 <- vBB (array object) 1500b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze GET_VREG a1, a3 # a1 <- vCC (requested index) 1600b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze beqz a0, common_errNullObject # bail if null array object 1700b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze lw a3, MIRROR_ARRAY_LENGTH_OFFSET(a0) # a3 <- arrayObj->length 1800b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze .if $shift 1900b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze # [d]lsa does not support shift count of 0. 2000b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze dlsa a0, a1, a0, $shift # a0 <- arrayObj + index*width 2100b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze .else 2200b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze daddu a0, a1, a0 # a0 <- arrayObj + index*width 2300b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze .endif 2400b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze bgeu a1, a3, common_errArrayIndex # unsigned compare: index >= length, bail 2500b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze FETCH_ADVANCE_INST 2 # advance rPC, load rINST 2600b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze GET_VREG a2, a4 # a2 <- vAA 2700b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze GET_INST_OPCODE v0 # extract opcode from rINST 2800b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze $store a2, $data_offset(a0) # vBB[vCC] <- a2 2900b53b7f3f9ce5996b767b52c28dd846f47a723cAlexey Frunze GOTO_OPCODE v0 # jump to next instruction 30