p.printRegion(getRegion());
}
-void TargetOp::print(OpAsmPrinter &p) {
- p << " ";
- if (auto ifCond = if_expr())
- p << "if(" << ifCond << " : " << ifCond.getType() << ") ";
-
- if (auto device = this->device())
- p << "device(" << device << " : " << device.getType() << ") ";
-
- if (auto threads = thread_limit())
- p << "thread_limit(" << threads << " : " << threads.getType() << ") ";
-
- if (nowait())
- p << "nowait ";
-
- p.printRegion(getRegion());
-}
-
//===----------------------------------------------------------------------===//
// Parser and printer for Linear Clause
//===----------------------------------------------------------------------===//
return success();
}
-/// Parses a target operation.
-///
-/// operation ::= `omp.target` clause-list
-/// clause-list ::= clause | clause clause-list
-/// clause ::= if | device | thread_limit | nowait
-///
-ParseResult TargetOp::parse(OpAsmParser &parser, OperationState &result) {
- SmallVector<ClauseType> clauses = {ifClause, deviceClause, threadLimitClause,
- nowaitClause};
-
- SmallVector<int> segments;
-
- if (failed(parseClauses(parser, result, clauses, segments)))
- return failure();
-
- result.addAttribute(
- TargetOp::AttrSizedOperandSegments::getOperandSegmentSizeAttr(),
- parser.getBuilder().getI32VectorAttr(segments));
-
- Region *body = result.addRegion();
- SmallVector<OpAsmParser::OperandType> regionArgs;
- SmallVector<Type> regionArgTypes;
- if (parser.parseRegion(*body, regionArgs, regionArgTypes))
- return failure();
- return success();
-}
-
//===----------------------------------------------------------------------===//
// Parser, printer and verifier for SectionsOp
//===----------------------------------------------------------------------===//
"omp.target"(%if_cond, %device, %num_threads) ({
// CHECK: omp.terminator
omp.terminator
- }) {operand_segment_sizes = dense<[1,1,1]>: vector<3xi32>, nowait } : ( i1, si32, si32 ) -> ()
+ }) {if, device, nowait, operand_segment_sizes = dense<[1,1,1]>: vector<3xi32>, thread_limit} : ( i1, si32, si32 ) -> ()
// CHECK: omp.barrier
omp.barrier
// CHECK-LABEL: omp_target_pretty
func @omp_target_pretty(%if_cond : i1, %device : si32, %num_threads : si32) -> () {
// CHECK: omp.target if({{.*}}) device({{.*}})
- omp.target if(%if_cond : i1) device(%device : si32) {
+ omp.target if(%if_cond) device(%device : si32) {
omp.terminator
}
// CHECK: omp.target if({{.*}}) device({{.*}}) nowait
- omp.target if(%if_cond : i1) device(%device : si32) thread_limit(%num_threads : si32) nowait {
+ omp.target if(%if_cond) device(%device : si32) thread_limit(%num_threads : si32) nowait {
omp.terminator
}