forked from OSchip/llvm-project
[fir][NFC] Move fir.select_type builder to cpp file
Move the big builder out of the td file to the cpp file. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D110820
This commit is contained in:
parent
b04dd35f0e
commit
a149b103ca
|
@ -720,34 +720,7 @@ def fir_SelectTypeOp : fir_SwitchTerminatorOp<"select_type"> {
|
|||
"llvm::ArrayRef<mlir::Attribute>":$typeOperands,
|
||||
"llvm::ArrayRef<mlir::Block *>":$destinations,
|
||||
CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
|
||||
CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
|
||||
[{
|
||||
$_state.addOperands(selector);
|
||||
$_state.addAttribute(getCasesAttr(),
|
||||
$_builder.getArrayAttr(typeOperands));
|
||||
const auto count = destinations.size();
|
||||
for (auto d : destinations)
|
||||
$_state.addSuccessors(d);
|
||||
const auto opCount = destOperands.size();
|
||||
llvm::SmallVector<int32_t, 8> argOffs;
|
||||
int32_t sumArgs = 0;
|
||||
for (std::remove_const_t<decltype(count)> i = 0; i != count; ++i) {
|
||||
if (i < opCount) {
|
||||
$_state.addOperands(destOperands[i]);
|
||||
const auto argSz = destOperands[i].size();
|
||||
argOffs.push_back(argSz);
|
||||
sumArgs += argSz;
|
||||
} else {
|
||||
argOffs.push_back(0);
|
||||
}
|
||||
}
|
||||
$_state.addAttribute(getOperandSegmentSizeAttr(),
|
||||
$_builder.getI32VectorAttr({1, 0, sumArgs}));
|
||||
$_state.addAttribute(getTargetOffsetAttr(),
|
||||
$_builder.getI32VectorAttr(argOffs));
|
||||
$_state.addAttributes(attributes);
|
||||
}]
|
||||
>];
|
||||
CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
|
||||
|
||||
let parser = "return parseSelectType(parser, result);";
|
||||
|
||||
|
|
|
@ -2671,6 +2671,37 @@ static mlir::LogicalResult verify(fir::SelectTypeOp &op) {
|
|||
return mlir::success();
|
||||
}
|
||||
|
||||
void fir::SelectTypeOp::build(mlir::OpBuilder &builder,
|
||||
mlir::OperationState &result,
|
||||
mlir::Value selector,
|
||||
llvm::ArrayRef<mlir::Attribute> typeOperands,
|
||||
llvm::ArrayRef<mlir::Block *> destinations,
|
||||
llvm::ArrayRef<mlir::ValueRange> destOperands,
|
||||
llvm::ArrayRef<mlir::NamedAttribute> attributes) {
|
||||
result.addOperands(selector);
|
||||
result.addAttribute(getCasesAttr(), builder.getArrayAttr(typeOperands));
|
||||
const auto count = destinations.size();
|
||||
for (mlir::Block *dest : destinations)
|
||||
result.addSuccessors(dest);
|
||||
const auto opCount = destOperands.size();
|
||||
llvm::SmallVector<int32_t> argOffs;
|
||||
int32_t sumArgs = 0;
|
||||
for (std::remove_const_t<decltype(count)> i = 0; i != count; ++i) {
|
||||
if (i < opCount) {
|
||||
result.addOperands(destOperands[i]);
|
||||
const auto argSz = destOperands[i].size();
|
||||
argOffs.push_back(argSz);
|
||||
sumArgs += argSz;
|
||||
} else {
|
||||
argOffs.push_back(0);
|
||||
}
|
||||
}
|
||||
result.addAttribute(getOperandSegmentSizeAttr(),
|
||||
builder.getI32VectorAttr({1, 0, sumArgs}));
|
||||
result.addAttribute(getTargetOffsetAttr(), builder.getI32VectorAttr(argOffs));
|
||||
result.addAttributes(attributes);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ShapeOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
Loading…
Reference in New Issue