mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
Move FunctionOp arg attr verify to model verify
This commit is contained in:
@@ -462,29 +462,6 @@ mlir::LogicalResult FunctionOp::verify() {
|
||||
return mlir::success();
|
||||
});
|
||||
|
||||
for (uint64_t Index = 0; Index < getArgCount(); ++Index) {
|
||||
uint64_t RegAttributeCount = 0;
|
||||
uint64_t StackAttributeCount = 0;
|
||||
|
||||
mlir::clift::AttrDictView View = getArgAttrs(Index);
|
||||
if (auto CAs = View.getOfType<mlir::ArrayAttr>("clift.c_attributes")) {
|
||||
for (mlir::Attribute CAttribute : CAs) {
|
||||
auto AttrName = mlir::cast<mlir::clift::CAttributeAttr>(CAttribute)
|
||||
.getName()
|
||||
.getName();
|
||||
if (AttrName == "_REG")
|
||||
++RegAttributeCount;
|
||||
else if (AttrName == "_STACK")
|
||||
++StackAttributeCount;
|
||||
}
|
||||
}
|
||||
|
||||
revng_assert(RegAttributeCount <= 1 and StackAttributeCount <= 1);
|
||||
if (RegAttributeCount + StackAttributeCount > 1)
|
||||
return emitOpError() << "An argument is not allowed to specify *both* "
|
||||
" `_REG` and `_STACK` attributes.";
|
||||
}
|
||||
|
||||
return mlir::failure(Result.wasInterrupted());
|
||||
}
|
||||
|
||||
|
||||
@@ -205,6 +205,33 @@ private:
|
||||
"definition: '"
|
||||
<< Op.getHandle() << "'";
|
||||
|
||||
for (unsigned Index = 0; Index < Op.getArgCount(); ++Index) {
|
||||
bool IsStack = false;
|
||||
bool IsRegister = false;
|
||||
|
||||
mlir::clift::AttrDictView View = Op.getArgAttrs(Index);
|
||||
if (auto CAs = View.getOfType<mlir::ArrayAttr>("clift.c_attributes")) {
|
||||
for (mlir::Attribute CAttribute : CAs) {
|
||||
auto AttrName = mlir::cast<clift::CAttributeAttr>(CAttribute)
|
||||
.getName()
|
||||
.getName();
|
||||
|
||||
if (AttrName == "_STACK" and std::exchange(IsStack, true))
|
||||
return getCurrentOp()->emitError() << "Function argument contains "
|
||||
"duplicate _STACK attribute.";
|
||||
|
||||
if (AttrName == "_REG" and std::exchange(IsRegister, true))
|
||||
return getCurrentOp()->emitError() << "Function argument contains "
|
||||
"duplicate _REG attribute.";
|
||||
|
||||
if (IsStack and IsRegister)
|
||||
return getCurrentOp()->emitError() << "Function argument contains "
|
||||
"both _STACK and _REG "
|
||||
"attributes.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mlir::success();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user