• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#define DEFAULT_SHORTY_PTR_REG rax
17#define DEFAULT_SHORTY_REG r10d
18
19.macro INIT_SHORTY_REG shorty_reg = %DEFAULT_SHORTY_REG, shorty_ptr_reg = %DEFAULT_SHORTY_PTR_REG
20    movzwl (\shorty_ptr_reg), \shorty_reg // read new shorty value and advance shorty_ptr
21    addq $2, \shorty_ptr_reg
22.endm
23
24.macro NEXT_SHORTY out_reg, shorty_reg = %DEFAULT_SHORTY_REG, shorty_ptr_reg = %DEFAULT_SHORTY_PTR_REG
25    cmpl $-1, \shorty_reg // check \shorty_reg = 0xFFFFFFFF
26    jne 1f
27    movzwl (\shorty_ptr_reg), \shorty_reg // read new shorty value and advance shorty_ptr
28    addq $2, \shorty_ptr_reg
291:
30    movl \shorty_reg, \out_reg
31    andl $0xF, \out_reg // extract next shorty value
32    shrl $4, \shorty_reg
33    orl $0xFFFFF000, \shorty_reg // fill the high 20 bits by 0xFFFFF
34.endm
35
36.macro SKIP_SHORTY shorty_reg = %DEFAULT_SHORTY_REG, shorty_ptr_reg = %DEFAULT_SHORTY_PTR_REG
37    cmpl $-1, \shorty_reg // check \shorty_reg = 0xFFFFFFFF
38    jne 1f
39    movzwl (\shorty_ptr_reg), \shorty_reg // read new shorty value and advance shorty_ptr
40    addq $2, \shorty_ptr_reg
411:
42    shrl $4, \shorty_reg
43    orl $0xFFFFF000, \shorty_reg // fill the high 20 bits by 0xFFFFF
44.endm
45