Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
Show First 20 Lines • Show All 411 Lines • ▼ Show 20 Lines | |||||
class LLVM_VectorReduction<string mnem> | class LLVM_VectorReduction<string mnem> | ||||
: LLVM_OneResultIntrOp<"vector.reduce." # mnem, | : LLVM_OneResultIntrOp<"vector.reduce." # mnem, | ||||
[], [0], [Pure]>, | [], [0], [Pure]>, | ||||
Arguments<(ins LLVM_Type)>; | Arguments<(ins LLVM_Type)>; | ||||
// LLVM vector reduction over a single vector, with an initial value, | // LLVM vector reduction over a single vector, with an initial value, | ||||
// and with permission to reassociate the reduction operations. | // and with permission to reassociate the reduction operations. | ||||
class LLVM_VectorReductionAcc<string mnem> | class LLVM_VectorReductionAcc<string mnem> | ||||
: LLVM_OpBase<LLVM_Dialect, "intr.vector.reduce." # mnem, | : LLVM_OneResultIntrOp<"vector.reduce." # mnem, | ||||
[Pure]>, | [], [0], [Pure]>, | ||||
Results<(outs LLVM_Type:$res)>, | Arguments<(ins LLVM_Type:$start_value, LLVM_Type:$input, | ||||
Arguments<(ins LLVM_Type, LLVM_Type, | |||||
DefaultValuedAttr<BoolAttr, "false">:$reassoc)> { | DefaultValuedAttr<BoolAttr, "false">:$reassoc)> { | ||||
let llvmBuilder = [{ | let llvmBuilder = [{ | ||||
llvm::Module *module = builder.GetInsertBlock()->getModule(); | llvm::Module *module = builder.GetInsertBlock()->getModule(); | ||||
llvm::Function *fn = llvm::Intrinsic::getDeclaration( | llvm::Function *fn = llvm::Intrinsic::getDeclaration( | ||||
module, | module, | ||||
llvm::Intrinsic::vector_reduce_}] # mnem # [{, | llvm::Intrinsic::vector_reduce_}] # mnem # [{, | ||||
{ }] # !interleave(ListIntSubst<LLVM_IntrPatterns.operand, [1]>.lst, | { }] # !interleave(ListIntSubst<LLVM_IntrPatterns.operand, [1]>.lst, | ||||
", ") # [{ | ", ") # [{ | ||||
}); | }); | ||||
auto operands = moduleTranslation.lookupValues(opInst.getOperands()); | auto operands = moduleTranslation.lookupValues(opInst.getOperands()); | ||||
llvm::FastMathFlags origFM = builder.getFastMathFlags(); | llvm::FastMathFlags origFM = builder.getFastMathFlags(); | ||||
llvm::FastMathFlags tempFM = origFM; | llvm::FastMathFlags tempFM = origFM; | ||||
tempFM.setAllowReassoc($reassoc); | tempFM.setAllowReassoc($reassoc); | ||||
builder.setFastMathFlags(tempFM); // set fastmath flag | builder.setFastMathFlags(tempFM); // set fastmath flag | ||||
$res = builder.CreateCall(fn, operands); | $res = builder.CreateCall(fn, operands); | ||||
builder.setFastMathFlags(origFM); // restore fastmath flag | builder.setFastMathFlags(origFM); // restore fastmath flag | ||||
}]; | }]; | ||||
let mlirBuilder = [{ | |||||
bool allowReassoc = inst->getFastMathFlags().allowReassoc(); | |||||
$res = $_builder.create<$_qualCppClassName>($_location, | |||||
$_resultType, $start_value, $input, allowReassoc); | |||||
}]; | |||||
} | } | ||||
def LLVM_OneResultOpBuilder : | def LLVM_OneResultOpBuilder : | ||||
OpBuilder<(ins "Type":$resultType, "ValueRange":$operands, | OpBuilder<(ins "Type":$resultType, "ValueRange":$operands, | ||||
CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes), | CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes), | ||||
[{ | [{ | ||||
if (resultType) $_state.addTypes(resultType); | if (resultType) $_state.addTypes(resultType); | ||||
$_state.addOperands(operands); | $_state.addOperands(operands); | ||||
Show All 38 Lines |