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
ExternFuncArgument.h
#ifndef HALIDE_EXTERNFUNCARGUMENT_H
#define HALIDE_EXTERNFUNCARGUMENT_H
/** \file
* Defines the internal representation of a halide ExternFuncArgument
*/
#include "Buffer.h"
#include "Expr.h"
#include "FunctionPtr.h"
#include "Parameter.h"
namespace Halide {
/** An argument to an extern-defined Func. May be a Function, Buffer,
* ImageParam or Expr. */
struct ExternFuncArgument {
enum ArgType { UndefinedArg = 0,
FuncArg,
BufferArg,
ExprArg,
ImageParamArg };
ArgType arg_type = UndefinedArg;
Internal::FunctionPtr func;
Buffer<> buffer;
Expr expr;
Internal::Parameter image_param;
ExternFuncArgument(Internal::FunctionPtr f)
: arg_type(FuncArg), func(std::move(f)) {
}
template<typename T>
ExternFuncArgument(Buffer<T> b)
: arg_type(BufferArg), buffer(b) {
}
ExternFuncArgument(Expr e)
: arg_type(ExprArg), expr(std::move(e)) {
}
ExternFuncArgument(int e)
: arg_type(ExprArg), expr(e) {
}
ExternFuncArgument(float e)
: arg_type(ExprArg), expr(e) {
}
ExternFuncArgument(const Internal::Parameter &p)
: arg_type(ImageParamArg), image_param(p) {
// Scalar params come in via the Expr constructor.
internal_assert(p.is_buffer());
}
ExternFuncArgument() = default;
bool is_func() const {
return arg_type == FuncArg;
}
bool is_expr() const {
return arg_type == ExprArg;
}
bool is_buffer() const {
return arg_type == BufferArg;
}
bool is_image_param() const {
return arg_type == ImageParamArg;
}
bool defined() const {
return arg_type != UndefinedArg;
}
};
} // namespace Halide
#endif // HALIDE_EXTERNFUNCARGUMENT_H
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...