Revision c1885fc710ddebff3e50023e662e9f822a7f2a3d authored by Alexander Root on 04 December 2020, 00:14:07 UTC, committed by GitHub on 04 December 2020, 00:14:07 UTC
* Add shift_left fix for signed integers by possibly negative values + regression test

* add required condition on shift_left integer fix

* add type check to shift_left minimum condition

* fix constant folding of shifts with |b| >= type.bits() for types that allow overflow (failes correctness/simplify test)

* make regression tests use scoped bindings

* change condition in case int24/int48 proposal happens soon

* revert changes based on overflow expectations

* add more regression tests

* clarify comment

* add shift_left min handler for b only UB

* fix clang-tidy complaint

* relax shift_left of non-negative value constraint

* pull case outside of unnecessary preconditions

* fix clang-format complaint

* fix broken precondition

* add typecheck to possibly save a can_prove() call

* add easy-out type check to precondition

* Add descriptive comment to bug fix + add another early-exit precondition

Co-authored-by: Steven Johnson <srj@google.com>
1 parent 28f9aef
Raw File
Var.cpp
#include "Var.h"
#include "IR.h"
#include "Util.h"

namespace Halide {

Var::Var(const std::string &n)
    : e(Internal::Variable::make(Int(32), n)) {
}

Var::Var()
    : e(Internal::Variable::make(Int(32), Internal::make_entity_name(this, "Halide:.*:Var", 'v'))) {
}

Var Var::implicit(int n) {
    return Var("_" + std::to_string(n));
}

bool Var::is_implicit(const std::string &name) {
    return Internal::starts_with(name, "_") &&
           name.find_first_not_of("0123456789", 1) == std::string::npos;
}

const std::string &Var::name() const {
    return e.as<Internal::Variable>()->name;
}

namespace Internal {
std::vector<Var> make_argument_list(int dimensionality) {
    std::vector<Var> args(dimensionality);
    for (int i = 0; i < dimensionality; i++) {
        args[i] = Var::implicit(i);
    }
    return args;
}

}  // namespace Internal

}  // namespace Halide
back to top