https://github.com/halide/Halide
Raw File
Tip revision: 94d7f0168da34fbfd15a63e5baa56b1649f23956 authored by Andrew Adams on 02 July 2021, 17:23:21 UTC
Don't reinterpret cast when codegenning vector concat
Tip revision: 94d7f01
pseudostack.cpp
#include "HalideRuntime.h"
#include "runtime_internal.h"

extern "C" {

WEAK_INLINE __attribute__((used)) void *pseudostack_alloc(void *user_context, halide_pseudostack_slot_t *slot, size_t sz) {
    if (__builtin_expect(sz > slot->size, 0)) {
        if (slot->ptr) {
            halide_free(user_context, slot->ptr);
        }
        slot->ptr = halide_malloc(user_context, sz);
        slot->size = sz;
    }
    return slot->ptr;
}

// Only called as a destructor at function exit
WEAK_INLINE __attribute__((used)) void pseudostack_free(void *user_context, void *ptr) {
    halide_pseudostack_slot_t *slot = (halide_pseudostack_slot_t *)ptr;
    slot->size = 0;
    if (slot->ptr) {
        halide_free(user_context, slot->ptr);
    }
    slot->ptr = nullptr;
}
}
back to top