Skip to content
Snippets Groups Projects
Select Git revision
  • 71be1ddeb128e6068d2f1df605ec9c8c10f67091
  • master default protected
  • schneider/ir
  • rahix/user-space-ctx
  • schneider/iaq-python
  • schneider/ble-mini-demo
  • schneider/ble-ecg-stream-visu
  • schneider/mp-exception-print
  • schneider/sleep-display
  • schneider/deepsleep4
  • schneider/deepsleep2
  • schneider/deepsleep
  • schneider/ble-central
  • rahix/bluetooth-app-favorite
  • schneider/v1.17-changelog
  • schneider/ancs
  • schneider/png
  • schneider/freertos-list-debug
  • schneider/212-reset-hardware-when-entering-repl
  • schneider/bonding-fail-if-full
  • schneider/ble-fixes-2020-3
  • v1.18
  • v1.17
  • v1.16
  • v1.15
  • v1.14
  • v1.13
  • v1.12
  • v1.11
  • v1.10
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
41 results

readme.txt

Blame
  • emitnative.c 92.51 KiB
    /*
     * This file is part of the Micro Python project, http://micropython.org/
     *
     * The MIT License (MIT)
     *
     * Copyright (c) 2013, 2014 Damien P. George
     *
     * Permission is hereby granted, free of charge, to any person obtaining a copy
     * of this software and associated documentation files (the "Software"), to deal
     * in the Software without restriction, including without limitation the rights
     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     * copies of the Software, and to permit persons to whom the Software is
     * furnished to do so, subject to the following conditions:
     *
     * The above copyright notice and this permission notice shall be included in
     * all copies or substantial portions of the Software.
     *
     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     * THE SOFTWARE.
     */
    
    // Essentially normal Python has 1 type: Python objects
    // Viper has more than 1 type, and is just a more complicated (a superset of) Python.
    // If you declare everything in Viper as a Python object (ie omit type decls) then
    // it should in principle be exactly the same as Python native.
    // Having types means having more opcodes, like binary_op_nat_nat, binary_op_nat_obj etc.
    // In practice we won't have a VM but rather do this in asm which is actually very minimal.
    
    // Because it breaks strict Python equivalence it should be a completely separate
    // decorator.  It breaks equivalence because overflow on integers wraps around.
    // It shouldn't break equivalence if you don't use the new types, but since the
    // type decls might be used in normal Python for other reasons, it's probably safest,
    // cleanest and clearest to make it a separate decorator.
    
    // Actually, it does break equivalence because integers default to native integers,
    // not Python objects.
    
    // for x in l[0:8]: can be compiled into a native loop if l has pointer type
    
    #include <stdio.h>
    #include <string.h>
    #include <assert.h>
    
    #include "py/nlr.h"
    #include "py/emit.h"
    
    #if 0 // print debugging info
    #define DEBUG_PRINT (1)
    #define DEBUG_printf DEBUG_printf
    #else // don't print debugging info
    #define DEBUG_printf(...) (void)0
    #endif
    
    // wrapper around everything in this file
    #if (MICROPY_EMIT_X64 && N_X64) \
        || (MICROPY_EMIT_X86 && N_X86) \
        || (MICROPY_EMIT_THUMB && N_THUMB) \
        || (MICROPY_EMIT_ARM && N_ARM)
    
    #if N_X64
    
    // x64 specific stuff
    
    #include "py/asmx64.h"