cb424d7448
verify-patch-sanity.py validates every active recipe .patch has internally- consistent hunk line counts — catching the 'malformed patch at line N' failure at commit/CI/preflight time instead of hours into a cook. This cycle hit that class three times (qtwaylandscanner, sddm, xwayland), each only discovered when cookbook tried to apply the patch. Running it across the repo found 29 latent malformed patches (validated against GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22'). They were harmless only because they sit in vendored recipes (baked, not re- applied) — but would fail on any version-bump re-derivation. --fix recounts the hunk headers (body untouched) and repaired all 29. Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test (test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats (empty placeholders, bare-@@ git hunks).
93 lines
3.3 KiB
C++
93 lines
3.3 KiB
C++
//===- CastInterfaces.cpp -------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir/Interfaces/CastInterfaces.h"
|
|
|
|
#include "mlir/IR/BuiltinDialect.h"
|
|
#include "mlir/IR/BuiltinOps.h"
|
|
|
|
using namespace mlir;
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// Helper functions for CastOpInterface
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// Attempt to fold the given cast operation.
|
|
LogicalResult
|
|
impl::foldCastInterfaceOp(Operation *op, ArrayRef<Attribute> attrOperands,
|
|
SmallVectorImpl<OpFoldResult> &foldResults) {
|
|
OperandRange operands = op->getOperands();
|
|
if (operands.empty())
|
|
return failure();
|
|
ResultRange results = op->getResults();
|
|
|
|
// Check for the case where the input and output types match 1-1.
|
|
if (operands.getTypes() == results.getTypes()) {
|
|
foldResults.append(operands.begin(), operands.end());
|
|
return success();
|
|
}
|
|
|
|
return failure();
|
|
}
|
|
|
|
/// Attempt to verify the given cast operation.
|
|
LogicalResult impl::verifyCastInterfaceOp(Operation *op) {
|
|
auto resultTypes = op->getResultTypes();
|
|
if (resultTypes.empty())
|
|
return op->emitOpError()
|
|
<< "expected at least one result for cast operation";
|
|
|
|
auto operandTypes = op->getOperandTypes();
|
|
if (!cast<CastOpInterface>(op).areCastCompatible(operandTypes, resultTypes)) {
|
|
InFlightDiagnostic diag = op->emitOpError("operand type");
|
|
if (operandTypes.empty())
|
|
diag << "s []";
|
|
else if (llvm::size(operandTypes) == 1)
|
|
diag << " " << *operandTypes.begin();
|
|
else
|
|
diag << "s " << operandTypes;
|
|
return diag << " and result type" << (resultTypes.size() == 1 ? " " : "s ")
|
|
<< resultTypes << " are cast incompatible";
|
|
}
|
|
|
|
return success();
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// External model for BuiltinDialect ops
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace mlir {
|
|
namespace {
|
|
// This interface cannot be implemented directly on the op because the IR build
|
|
// unit cannot depend on the Interfaces build unit.
|
|
struct UnrealizedConversionCastOpInterface
|
|
: CastOpInterface::ExternalModel<UnrealizedConversionCastOpInterface,
|
|
UnrealizedConversionCastOp> {
|
|
static bool areCastCompatible(TypeRange inputs, TypeRange outputs) {
|
|
// `UnrealizedConversionCastOp` is agnostic of the input/output types.
|
|
return true;
|
|
}
|
|
};
|
|
} // namespace
|
|
} // namespace mlir
|
|
|
|
void mlir::builtin::registerCastOpInterfaceExternalModels(
|
|
DialectRegistry ®istry) {
|
|
registry.addExtension(+[](MLIRContext *ctx, BuiltinDialect *dialect) {
|
|
UnrealizedConversionCastOp::attachInterface<
|
|
UnrealizedConversionCastOpInterface>(*ctx);
|
|
});
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// Table-generated class definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir/Interfaces/CastInterfaces.cpp.inc"
|