LCOV - code coverage report
Current view: top level - py - asmbase.h (source / functions) Hit Total Coverage
Test: unix_coverage_v1.23.0-410-g82e69df33.info Lines: 8 8 100.0 %
Date: 2024-10-10 13:49:24 Functions: 0 0 -
Branches: 4 4 100.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * This file is part of the MicroPython project, http://micropython.org/
       3                 :            :  *
       4                 :            :  * The MIT License (MIT)
       5                 :            :  *
       6                 :            :  * Copyright (c) 2016 Damien P. George
       7                 :            :  *
       8                 :            :  * Permission is hereby granted, free of charge, to any person obtaining a copy
       9                 :            :  * of this software and associated documentation files (the "Software"), to deal
      10                 :            :  * in the Software without restriction, including without limitation the rights
      11                 :            :  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      12                 :            :  * copies of the Software, and to permit persons to whom the Software is
      13                 :            :  * furnished to do so, subject to the following conditions:
      14                 :            :  *
      15                 :            :  * The above copyright notice and this permission notice shall be included in
      16                 :            :  * all copies or substantial portions of the Software.
      17                 :            :  *
      18                 :            :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      19                 :            :  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      20                 :            :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      21                 :            :  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      22                 :            :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      23                 :            :  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      24                 :            :  * THE SOFTWARE.
      25                 :            :  */
      26                 :            : #ifndef MICROPY_INCLUDED_PY_ASMBASE_H
      27                 :            : #define MICROPY_INCLUDED_PY_ASMBASE_H
      28                 :            : 
      29                 :            : #include <stdint.h>
      30                 :            : #include <stddef.h>
      31                 :            : #include <stdbool.h>
      32                 :            : 
      33                 :            : #define MP_ASM_PASS_COMPUTE (1)
      34                 :            : #define MP_ASM_PASS_EMIT    (2)
      35                 :            : 
      36                 :            : typedef struct _mp_asm_base_t {
      37                 :            :     uint8_t pass;
      38                 :            : 
      39                 :            :     // Set to true using mp_asm_base_suppress_code() if the code generator
      40                 :            :     // should suppress emitted code due to it being dead code.
      41                 :            :     bool suppress;
      42                 :            : 
      43                 :            :     size_t code_offset;
      44                 :            :     size_t code_size;
      45                 :            :     uint8_t *code_base;
      46                 :            : 
      47                 :            :     size_t max_num_labels;
      48                 :            :     size_t *label_offsets;
      49                 :            : } mp_asm_base_t;
      50                 :            : 
      51                 :            : void mp_asm_base_init(mp_asm_base_t *as, size_t max_num_labels);
      52                 :            : void mp_asm_base_deinit(mp_asm_base_t *as, bool free_code);
      53                 :            : void mp_asm_base_start_pass(mp_asm_base_t *as, int pass);
      54                 :            : uint8_t *mp_asm_base_get_cur_to_write_bytes(void *as, size_t num_bytes_to_write);
      55                 :            : void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label);
      56                 :            : void mp_asm_base_align(mp_asm_base_t *as, unsigned int align);
      57                 :            : void mp_asm_base_data(mp_asm_base_t *as, unsigned int bytesize, uintptr_t val);
      58                 :            : 
      59                 :      36666 : static inline void mp_asm_base_suppress_code(mp_asm_base_t *as) {
      60                 :      36666 :     as->suppress = true;
      61                 :            : }
      62                 :            : 
      63                 :     409394 : static inline size_t mp_asm_base_get_code_pos(mp_asm_base_t *as) {
      64                 :     409394 :     return as->code_offset;
      65                 :            : }
      66                 :            : 
      67                 :       4517 : static inline size_t mp_asm_base_get_code_size(mp_asm_base_t *as) {
      68         [ +  + ]:       4517 :     return as->code_size;
      69                 :            : }
      70                 :            : 
      71                 :       4517 : static inline void *mp_asm_base_get_code(mp_asm_base_t *as) {
      72                 :            :     #if defined(MP_PLAT_COMMIT_EXEC)
      73                 :            :     return MP_PLAT_COMMIT_EXEC(as->code_base, as->code_size, NULL);
      74                 :            :     #else
      75         [ +  + ]:       4517 :     return as->code_base;
      76                 :            :     #endif
      77                 :            : }
      78                 :            : 
      79                 :            : #endif // MICROPY_INCLUDED_PY_ASMBASE_H

Generated by: LCOV version 1.15-5-g462f71d