# Changeset View

Changeset View

# Standalone View

Standalone View

# include/clang/AST/StmtOpenMP.h

Show First 20 Lines • Show All 312 Lines • ▼ Show 20 Line(s) | |||||

313 | class OMPLoopDirective : public OMPExecutableDirective { | 313 | class OMPLoopDirective : public OMPExecutableDirective { | ||

314 | friend class ASTStmtReader; | 314 | friend class ASTStmtReader; | ||

315 | /// \brief Number of collapsed loops as specified by 'collapse' clause. | 315 | /// \brief Number of collapsed loops as specified by 'collapse' clause. | ||

316 | unsigned CollapsedNum; | 316 | unsigned CollapsedNum; | ||

317 | 317 | | |||

318 | /// \brief Offsets to the stored exprs. | 318 | /// \brief Offsets to the stored exprs. | ||

319 | /// This enumeration contains offsets to all the pointers to children | 319 | /// This enumeration contains offsets to all the pointers to children | ||

320 | /// expressions stored in OMPLoopDirective. | 320 | /// expressions stored in OMPLoopDirective. | ||

321 | /// The first 9 children are nesessary for all the loop directives, and | 321 | /// The first 9 children are necessary for all the loop directives, | ||

322 | /// the next 10 are specific to the worksharing ones. | 322 | /// the next 8 are specific to the worksharing ones, and the next 11 are | ||

323 | /// used for combined constructs containing two pragmas associated to loops. | ||||

323 | /// After the fixed children, three arrays of length CollapsedNum are | 324 | /// After the fixed children, three arrays of length CollapsedNum are | ||

324 | /// allocated: loop counters, their updates and final values. | 325 | /// allocated: loop counters, their updates and final values. | ||

325 | /// PrevLowerBound and PrevUpperBound are used to communicate blocking | 326 | /// PrevLowerBound and PrevUpperBound are used to communicate blocking | ||

326 | /// information in composite constructs which require loop blocking | 327 | /// information in composite constructs which require loop blocking | ||

327 | /// DistInc is used to generate the increment expression for the distribute | 328 | /// DistInc is used to generate the increment expression for the distribute | ||

328 | /// loop when combined with a further nested loop | 329 | /// loop when combined with a further nested loop | ||

329 | /// PrevEnsureUpperBound is used as the EnsureUpperBound expression for the | 330 | /// PrevEnsureUpperBound is used as the EnsureUpperBound expression for the | ||

330 | /// for loop when combined with a previous distribute loop in the same pragma | 331 | /// for loop when combined with a previous distribute loop in the same pragma | ||

331 | /// (e.g. 'distribute parallel for') | 332 | /// (e.g. 'distribute parallel for') | ||

332 | /// | 333 | /// | ||

333 | enum { | 334 | enum { | ||

334 | AssociatedStmtOffset = 0, | 335 | AssociatedStmtOffset = 0, | ||

335 | IterationVariableOffset = 1, | 336 | IterationVariableOffset = 1, | ||

336 | LastIterationOffset = 2, | 337 | LastIterationOffset = 2, | ||

337 | CalcLastIterationOffset = 3, | 338 | CalcLastIterationOffset = 3, | ||

338 | PreConditionOffset = 4, | 339 | PreConditionOffset = 4, | ||

339 | CondOffset = 5, | 340 | CondOffset = 5, | ||

340 | InitOffset = 6, | 341 | InitOffset = 6, | ||

341 | IncOffset = 7, | 342 | IncOffset = 7, | ||

342 | PreInitsOffset = 8, | 343 | PreInitsOffset = 8, | ||

343 | // The '...End' enumerators do not correspond to child expressions - they | 344 | // The '...End' enumerators do not correspond to child expressions - they | ||

344 | // specify the offset to the end (and start of the following counters/ | 345 | // specify the offset to the end (and start of the following counters/ | ||

345 | // updates/finals arrays). | 346 | // updates/finals arrays). | ||

346 | DefaultEnd = 9, | 347 | DefaultEnd = 9, | ||

347 | // The following 12 exprs are used by worksharing and distribute loops only. | 348 | // The following 8 exprs are used by worksharing and distribute loops only. | ||

348 | IsLastIterVariableOffset = 9, | 349 | IsLastIterVariableOffset = 9, | ||

349 | LowerBoundVariableOffset = 10, | 350 | LowerBoundVariableOffset = 10, | ||

350 | UpperBoundVariableOffset = 11, | 351 | UpperBoundVariableOffset = 11, | ||

351 | StrideVariableOffset = 12, | 352 | StrideVariableOffset = 12, | ||

352 | EnsureUpperBoundOffset = 13, | 353 | EnsureUpperBoundOffset = 13, | ||

353 | NextLowerBoundOffset = 14, | 354 | NextLowerBoundOffset = 14, | ||

354 | NextUpperBoundOffset = 15, | 355 | NextUpperBoundOffset = 15, | ||

355 | NumIterationsOffset = 16, | 356 | NumIterationsOffset = 16, | ||

357 | // Offset to the end for worksharing loop directives. | ||||

358 | WorksharingEnd = 17, | ||||

356 | PrevLowerBoundVariableOffset = 17, | 359 | PrevLowerBoundVariableOffset = 17, | ||

357 | PrevUpperBoundVariableOffset = 18, | 360 | PrevUpperBoundVariableOffset = 18, | ||

358 | DistIncOffset = 19, | 361 | DistIncOffset = 19, | ||

359 | PrevEnsureUpperBoundOffset = 20, | 362 | PrevEnsureUpperBoundOffset = 20, | ||

363 | CombinedLowerBoundVariableOffset = 21, | ||||

364 | CombinedUpperBoundVariableOffset = 22, | ||||

365 | CombinedEnsureUpperBoundOffset = 23, | ||||

366 | CombinedInitOffset = 24, | ||||

367 | CombinedConditionOffset = 25, | ||||

368 | CombinedNextLowerBoundOffset = 26, | ||||

369 | CombinedNextUpperBoundOffset = 27, | ||||

360 | // Offset to the end (and start of the following counters/updates/finals | 370 | // Offset to the end (and start of the following counters/updates/finals | ||

361 | // arrays) for worksharing loop directives. | 371 | // arrays) for combined distribute loop directives. | ||

362 | WorksharingEnd = 21, | 372 | CombinedDistributeEnd = 28, | ||

363 | }; | 373 | }; | ||

364 | 374 | | |||

365 | /// \brief Get the counters storage. | 375 | /// \brief Get the counters storage. | ||

366 | MutableArrayRef<Expr *> getCounters() { | 376 | MutableArrayRef<Expr *> getCounters() { | ||

367 | Expr **Storage = reinterpret_cast<Expr **>( | 377 | Expr **Storage = reinterpret_cast<Expr **>( | ||

368 | &(*(std::next(child_begin(), getArraysOffset(getDirectiveKind()))))); | 378 | &(*(std::next(child_begin(), getArraysOffset(getDirectiveKind()))))); | ||

369 | return MutableArrayRef<Expr *>(Storage, CollapsedNum); | 379 | return MutableArrayRef<Expr *>(Storage, CollapsedNum); | ||

370 | } | 380 | } | ||

▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 425 | OMPLoopDirective(const T *That, StmtClass SC, OpenMPDirectiveKind Kind, | |||

418 | unsigned NumSpecialChildren = 0) | 428 | unsigned NumSpecialChildren = 0) | ||

419 | : OMPExecutableDirective(That, SC, Kind, StartLoc, EndLoc, NumClauses, | 429 | : OMPExecutableDirective(That, SC, Kind, StartLoc, EndLoc, NumClauses, | ||

420 | numLoopChildren(CollapsedNum, Kind) + | 430 | numLoopChildren(CollapsedNum, Kind) + | ||

421 | NumSpecialChildren), | 431 | NumSpecialChildren), | ||

422 | CollapsedNum(CollapsedNum) {} | 432 | CollapsedNum(CollapsedNum) {} | ||

423 | 433 | | |||

424 | /// \brief Offset to the start of children expression arrays. | 434 | /// \brief Offset to the start of children expression arrays. | ||

425 | static unsigned getArraysOffset(OpenMPDirectiveKind Kind) { | 435 | static unsigned getArraysOffset(OpenMPDirectiveKind Kind) { | ||

426 | return (isOpenMPWorksharingDirective(Kind) || | 436 | if (isOpenMPLoopBoundSharingDirective(Kind)) | ||

427 | isOpenMPTaskLoopDirective(Kind) || | 437 | return CombinedDistributeEnd; | ||

438 | if (isOpenMPWorksharingDirective(Kind) || isOpenMPTaskLoopDirective(Kind) || | ||||

428 | isOpenMPDistributeDirective(Kind)) | 439 | isOpenMPDistributeDirective(Kind)) | ||

429 | ? WorksharingEnd | 440 | return WorksharingEnd; | ||

430 | : DefaultEnd; | 441 | return DefaultEnd; | ||

431 | } | 442 | } | ||

432 | 443 | | |||

433 | /// \brief Children number. | 444 | /// \brief Children number. | ||

434 | static unsigned numLoopChildren(unsigned CollapsedNum, | 445 | static unsigned numLoopChildren(unsigned CollapsedNum, | ||

435 | OpenMPDirectiveKind Kind) { | 446 | OpenMPDirectiveKind Kind) { | ||

436 | return getArraysOffset(Kind) + 5 * CollapsedNum; // Counters, | 447 | return getArraysOffset(Kind) + 5 * CollapsedNum; // Counters, | ||

437 | // PrivateCounters, Inits, | 448 | // PrivateCounters, Inits, | ||

438 | // Updates and Finals | 449 | // Updates and Finals | ||

▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | |||||

510 | void setNumIterations(Expr *NI) { | 521 | void setNumIterations(Expr *NI) { | ||

511 | assert((isOpenMPWorksharingDirective(getDirectiveKind()) || | 522 | assert((isOpenMPWorksharingDirective(getDirectiveKind()) || | ||

512 | isOpenMPTaskLoopDirective(getDirectiveKind()) || | 523 | isOpenMPTaskLoopDirective(getDirectiveKind()) || | ||

513 | isOpenMPDistributeDirective(getDirectiveKind())) && | 524 | isOpenMPDistributeDirective(getDirectiveKind())) && | ||

514 | "expected worksharing loop directive"); | 525 | "expected worksharing loop directive"); | ||

515 | *std::next(child_begin(), NumIterationsOffset) = NI; | 526 | *std::next(child_begin(), NumIterationsOffset) = NI; | ||

516 | } | 527 | } | ||

517 | void setPrevLowerBoundVariable(Expr *PrevLB) { | 528 | void setPrevLowerBoundVariable(Expr *PrevLB) { | ||

518 | assert((isOpenMPWorksharingDirective(getDirectiveKind()) || | 529 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||

519 | isOpenMPTaskLoopDirective(getDirectiveKind()) || | 530 | "expected loop bound sharing directive"); | ||

520 | isOpenMPDistributeDirective(getDirectiveKind())) && | | |||

521 | "expected worksharing loop directive"); | | |||

522 | *std::next(child_begin(), PrevLowerBoundVariableOffset) = PrevLB; | 531 | *std::next(child_begin(), PrevLowerBoundVariableOffset) = PrevLB; | ||

523 | } | 532 | } | ||

524 | void setPrevUpperBoundVariable(Expr *PrevUB) { | 533 | void setPrevUpperBoundVariable(Expr *PrevUB) { | ||

525 | assert((isOpenMPWorksharingDirective(getDirectiveKind()) || | 534 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||

526 | isOpenMPTaskLoopDirective(getDirectiveKind()) || | 535 | "expected loop bound sharing directive"); | ||

527 | isOpenMPDistributeDirective(getDirectiveKind())) && | | |||

528 | "expected worksharing loop directive"); | | |||

529 | *std::next(child_begin(), PrevUpperBoundVariableOffset) = PrevUB; | 536 | *std::next(child_begin(), PrevUpperBoundVariableOffset) = PrevUB; | ||

530 | } | 537 | } | ||

531 | void setDistInc(Expr *DistInc) { | 538 | void setDistInc(Expr *DistInc) { | ||

532 | assert((isOpenMPWorksharingDirective(getDirectiveKind()) || | 539 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||

533 | isOpenMPTaskLoopDirective(getDirectiveKind()) || | 540 | "expected loop bound sharing directive"); | ||

534 | isOpenMPDistributeDirective(getDirectiveKind())) && | | |||

535 | "expected worksharing loop directive"); | | |||

536 | *std::next(child_begin(), DistIncOffset) = DistInc; | 541 | *std::next(child_begin(), DistIncOffset) = DistInc; | ||

537 | } | 542 | } | ||

538 | void setPrevEnsureUpperBound(Expr *PrevEUB) { | 543 | void setPrevEnsureUpperBound(Expr *PrevEUB) { | ||

539 | assert((isOpenMPWorksharingDirective(getDirectiveKind()) || | 544 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||

540 | isOpenMPTaskLoopDirective(getDirectiveKind()) || | 545 | "expected loop bound sharing directive"); | ||

541 | isOpenMPDistributeDirective(getDirectiveKind())) && | | |||

542 | "expected worksharing loop directive"); | | |||

543 | *std::next(child_begin(), PrevEnsureUpperBoundOffset) = PrevEUB; | 546 | *std::next(child_begin(), PrevEnsureUpperBoundOffset) = PrevEUB; | ||

544 | } | 547 | } | ||

548 | void setCombinedLowerBoundVariable(Expr *CombLB) { | ||||

549 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||||

550 | "expected loop bound sharing directive"); | ||||

551 | *std::next(child_begin(), CombinedLowerBoundVariableOffset) = CombLB; | ||||

552 | } | ||||

553 | void setCombinedUpperBoundVariable(Expr *CombUB) { | ||||

554 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||||

555 | "expected loop bound sharing directive"); | ||||

556 | *std::next(child_begin(), CombinedUpperBoundVariableOffset) = CombUB; | ||||

557 | } | ||||

558 | void setCombinedEnsureUpperBound(Expr *CombEUB) { | ||||

559 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||||

560 | "expected loop bound sharing directive"); | ||||

561 | *std::next(child_begin(), CombinedEnsureUpperBoundOffset) = CombEUB; | ||||

562 | } | ||||

563 | void setCombinedInit(Expr *CombInit) { | ||||

564 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||||

565 | "expected loop bound sharing directive"); | ||||

566 | *std::next(child_begin(), CombinedInitOffset) = CombInit; | ||||

567 | } | ||||

568 | void setCombinedCond(Expr *CombCond) { | ||||

569 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||||

570 | "expected loop bound sharing directive"); | ||||

571 | *std::next(child_begin(), CombinedConditionOffset) = CombCond; | ||||

572 | } | ||||

573 | void setCombinedNextLowerBound(Expr *CombNLB) { | ||||

574 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||||

575 | "expected loop bound sharing directive"); | ||||

576 | *std::next(child_begin(), CombinedNextLowerBoundOffset) = CombNLB; | ||||

577 | } | ||||

578 | void setCombinedNextUpperBound(Expr *CombNUB) { | ||||

579 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||||

580 | "expected loop bound sharing directive"); | ||||

581 | *std::next(child_begin(), CombinedNextUpperBoundOffset) = CombNUB; | ||||

582 | } | ||||

545 | void setCounters(ArrayRef<Expr *> A); | 583 | void setCounters(ArrayRef<Expr *> A); | ||

546 | void setPrivateCounters(ArrayRef<Expr *> A); | 584 | void setPrivateCounters(ArrayRef<Expr *> A); | ||

547 | void setInits(ArrayRef<Expr *> A); | 585 | void setInits(ArrayRef<Expr *> A); | ||

548 | void setUpdates(ArrayRef<Expr *> A); | 586 | void setUpdates(ArrayRef<Expr *> A); | ||

549 | void setFinals(ArrayRef<Expr *> A); | 587 | void setFinals(ArrayRef<Expr *> A); | ||

550 | 588 | | |||

551 | public: | 589 | public: | ||

590 | /// The expressions built to support OpenMP loops in combined/composite | ||||

591 | /// pragmas (e.g. pragma omp distribute parallel for) | ||||

592 | struct DistCombinedHelperExprs { | ||||

593 | /// DistributeLowerBound - used when composing 'omp distribute' with | ||||

594 | /// 'omp for' in a same construct. | ||||

595 | Expr *LB; | ||||

596 | /// DistributeUpperBound - used when composing 'omp distribute' with | ||||

597 | /// 'omp for' in a same construct. | ||||

598 | Expr *UB; | ||||

599 | /// DistributeEnsureUpperBound - used when composing 'omp distribute' | ||||

600 | /// with 'omp for' in a same construct, EUB depends on DistUB | ||||

601 | Expr *EUB; | ||||

602 | /// Distribute loop iteration variable init used when composing 'omp | ||||

603 | /// distribute' | ||||

604 | /// with 'omp for' in a same construct | ||||

605 | Expr *Init; | ||||

606 | /// Distribute Loop condition used when composing 'omp distribute' | ||||

607 | /// with 'omp for' in a same construct | ||||

608 | Expr *Cond; | ||||

609 | /// Update of LowerBound for statically sheduled omp loops for | ||||

610 | /// outer loop in combined constructs (e.g. 'distribute parallel for') | ||||

611 | Expr *NLB; | ||||

612 | /// Update of UpperBound for statically sheduled omp loops for | ||||

613 | /// outer loop in combined constructs (e.g. 'distribute parallel for') | ||||

614 | Expr *NUB; | ||||

615 | }; | ||||

616 | | ||||

552 | /// \brief The expressions built for the OpenMP loop CodeGen for the | 617 | /// \brief The expressions built for the OpenMP loop CodeGen for the | ||

553 | /// whole collapsed loop nest. | 618 | /// whole collapsed loop nest. | ||

554 | struct HelperExprs { | 619 | struct HelperExprs { | ||

555 | /// \brief Loop iteration variable. | 620 | /// \brief Loop iteration variable. | ||

556 | Expr *IterationVarRef; | 621 | Expr *IterationVarRef; | ||

557 | /// \brief Loop last iteration number. | 622 | /// \brief Loop last iteration number. | ||

558 | Expr *LastIteration; | 623 | Expr *LastIteration; | ||

559 | /// \brief Loop number of iterations. | 624 | /// \brief Loop number of iterations. | ||

▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||

606 | SmallVector<Expr *, 4> Inits; | 671 | SmallVector<Expr *, 4> Inits; | ||

607 | /// \brief Expressions for loop counters update for CodeGen. | 672 | /// \brief Expressions for loop counters update for CodeGen. | ||

608 | SmallVector<Expr *, 4> Updates; | 673 | SmallVector<Expr *, 4> Updates; | ||

609 | /// \brief Final loop counter values for GodeGen. | 674 | /// \brief Final loop counter values for GodeGen. | ||

610 | SmallVector<Expr *, 4> Finals; | 675 | SmallVector<Expr *, 4> Finals; | ||

611 | /// Init statement for all captured expressions. | 676 | /// Init statement for all captured expressions. | ||

612 | Stmt *PreInits; | 677 | Stmt *PreInits; | ||

613 | 678 | | |||

679 | /// Expressions used when combining OpenMP loop pragmas | ||||

680 | DistCombinedHelperExprs DistCombinedFields; | ||||

681 | | ||||

614 | /// \brief Check if all the expressions are built (does not check the | 682 | /// \brief Check if all the expressions are built (does not check the | ||

615 | /// worksharing ones). | 683 | /// worksharing ones). | ||

616 | bool builtAll() { | 684 | bool builtAll() { | ||

617 | return IterationVarRef != nullptr && LastIteration != nullptr && | 685 | return IterationVarRef != nullptr && LastIteration != nullptr && | ||

618 | NumIterations != nullptr && PreCond != nullptr && | 686 | NumIterations != nullptr && PreCond != nullptr && | ||

619 | Cond != nullptr && Init != nullptr && Inc != nullptr; | 687 | Cond != nullptr && Init != nullptr && Inc != nullptr; | ||

620 | } | 688 | } | ||

621 | 689 | | |||

Show All 27 Lines | 692 | void clear(unsigned Size) { | |||

649 | for (unsigned i = 0; i < Size; ++i) { | 717 | for (unsigned i = 0; i < Size; ++i) { | ||

650 | Counters[i] = nullptr; | 718 | Counters[i] = nullptr; | ||

651 | PrivateCounters[i] = nullptr; | 719 | PrivateCounters[i] = nullptr; | ||

652 | Inits[i] = nullptr; | 720 | Inits[i] = nullptr; | ||

653 | Updates[i] = nullptr; | 721 | Updates[i] = nullptr; | ||

654 | Finals[i] = nullptr; | 722 | Finals[i] = nullptr; | ||

655 | } | 723 | } | ||

656 | PreInits = nullptr; | 724 | PreInits = nullptr; | ||

725 | DistCombinedFields.LB = nullptr; | ||||

726 | DistCombinedFields.UB = nullptr; | ||||

727 | DistCombinedFields.EUB = nullptr; | ||||

728 | DistCombinedFields.Init = nullptr; | ||||

729 | DistCombinedFields.Cond = nullptr; | ||||

730 | DistCombinedFields.NLB = nullptr; | ||||

731 | DistCombinedFields.NUB = nullptr; | ||||

657 | } | 732 | } | ||

658 | }; | 733 | }; | ||

659 | 734 | | |||

660 | /// \brief Get number of collapsed loops. | 735 | /// \brief Get number of collapsed loops. | ||

661 | unsigned getCollapsedNumber() const { return CollapsedNum; } | 736 | unsigned getCollapsedNumber() const { return CollapsedNum; } | ||

662 | 737 | | |||

663 | Expr *getIterationVariable() const { | 738 | Expr *getIterationVariable() const { | ||

664 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | 739 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | ||

▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | 826 | Expr *getNumIterations() const { | |||

752 | assert((isOpenMPWorksharingDirective(getDirectiveKind()) || | 827 | assert((isOpenMPWorksharingDirective(getDirectiveKind()) || | ||

753 | isOpenMPTaskLoopDirective(getDirectiveKind()) || | 828 | isOpenMPTaskLoopDirective(getDirectiveKind()) || | ||

754 | isOpenMPDistributeDirective(getDirectiveKind())) && | 829 | isOpenMPDistributeDirective(getDirectiveKind())) && | ||

755 | "expected worksharing loop directive"); | 830 | "expected worksharing loop directive"); | ||

756 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | 831 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | ||

757 | *std::next(child_begin(), NumIterationsOffset))); | 832 | *std::next(child_begin(), NumIterationsOffset))); | ||

758 | } | 833 | } | ||

759 | Expr *getPrevLowerBoundVariable() const { | 834 | Expr *getPrevLowerBoundVariable() const { | ||

760 | assert((isOpenMPWorksharingDirective(getDirectiveKind()) || | 835 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||

761 | isOpenMPTaskLoopDirective(getDirectiveKind()) || | 836 | "expected loop bound sharing directive"); | ||

762 | isOpenMPDistributeDirective(getDirectiveKind())) && | | |||

763 | "expected worksharing loop directive"); | | |||

764 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | 837 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | ||

765 | *std::next(child_begin(), PrevLowerBoundVariableOffset))); | 838 | *std::next(child_begin(), PrevLowerBoundVariableOffset))); | ||

766 | } | 839 | } | ||

767 | Expr *getPrevUpperBoundVariable() const { | 840 | Expr *getPrevUpperBoundVariable() const { | ||

768 | assert((isOpenMPWorksharingDirective(getDirectiveKind()) || | 841 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||

769 | isOpenMPTaskLoopDirective(getDirectiveKind()) || | 842 | "expected loop bound sharing directive"); | ||

770 | isOpenMPDistributeDirective(getDirectiveKind())) && | | |||

771 | "expected worksharing loop directive"); | | |||

772 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | 843 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | ||

773 | *std::next(child_begin(), PrevUpperBoundVariableOffset))); | 844 | *std::next(child_begin(), PrevUpperBoundVariableOffset))); | ||

774 | } | 845 | } | ||

775 | Expr *getDistInc() const { | 846 | Expr *getDistInc() const { | ||

776 | assert((isOpenMPWorksharingDirective(getDirectiveKind()) || | 847 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||

777 | isOpenMPTaskLoopDirective(getDirectiveKind()) || | 848 | "expected loop bound sharing directive"); | ||

778 | isOpenMPDistributeDirective(getDirectiveKind())) && | | |||

779 | "expected worksharing loop directive"); | | |||

780 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | 849 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | ||

781 | *std::next(child_begin(), DistIncOffset))); | 850 | *std::next(child_begin(), DistIncOffset))); | ||

782 | } | 851 | } | ||

783 | Expr *getPrevEnsureUpperBound() const { | 852 | Expr *getPrevEnsureUpperBound() const { | ||

784 | assert((isOpenMPWorksharingDirective(getDirectiveKind()) || | 853 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||

785 | isOpenMPTaskLoopDirective(getDirectiveKind()) || | 854 | "expected loop bound sharing directive"); | ||

786 | isOpenMPDistributeDirective(getDirectiveKind())) && | | |||

787 | "expected worksharing loop directive"); | | |||

788 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | 855 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | ||

789 | *std::next(child_begin(), PrevEnsureUpperBoundOffset))); | 856 | *std::next(child_begin(), PrevEnsureUpperBoundOffset))); | ||

790 | } | 857 | } | ||

858 | Expr *getCombinedLowerBoundVariable() const { | ||||

859 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||||

860 | "expected loop bound sharing directive"); | ||||

861 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | ||||

862 | *std::next(child_begin(), CombinedLowerBoundVariableOffset))); | ||||

863 | } | ||||

864 | Expr *getCombinedUpperBoundVariable() const { | ||||

865 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||||

866 | "expected loop bound sharing directive"); | ||||

867 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | ||||

868 | *std::next(child_begin(), CombinedUpperBoundVariableOffset))); | ||||

869 | } | ||||

870 | Expr *getCombinedEnsureUpperBound() const { | ||||

871 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||||

872 | "expected loop bound sharing directive"); | ||||

873 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | ||||

874 | *std::next(child_begin(), CombinedEnsureUpperBoundOffset))); | ||||

875 | } | ||||

876 | Expr *getCombinedInit() const { | ||||

877 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||||

878 | "expected loop bound sharing directive"); | ||||

879 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | ||||

880 | *std::next(child_begin(), CombinedInitOffset))); | ||||

881 | } | ||||

882 | Expr *getCombinedCond() const { | ||||

883 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||||

884 | "expected loop bound sharing directive"); | ||||

885 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | ||||

886 | *std::next(child_begin(), CombinedConditionOffset))); | ||||

887 | } | ||||

888 | Expr *getCombinedNextLowerBound() const { | ||||

889 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||||

890 | "expected loop bound sharing directive"); | ||||

891 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | ||||

892 | *std::next(child_begin(), CombinedNextLowerBoundOffset))); | ||||

893 | } | ||||

894 | Expr *getCombinedNextUpperBound() const { | ||||

895 | assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && | ||||

896 | "expected loop bound sharing directive"); | ||||

897 | return const_cast<Expr *>(reinterpret_cast<const Expr *>( | ||||

898 | *std::next(child_begin(), CombinedNextUpperBoundOffset))); | ||||

899 | } | ||||

791 | const Stmt *getBody() const { | 900 | const Stmt *getBody() const { | ||

792 | // This relies on the loop form is already checked by Sema. | 901 | // This relies on the loop form is already checked by Sema. | ||

793 | Stmt *Body = getAssociatedStmt()->IgnoreContainers(true); | 902 | Stmt *Body = getAssociatedStmt()->IgnoreContainers(true); | ||

794 | Body = cast<ForStmt>(Body)->getBody(); | 903 | Body = cast<ForStmt>(Body)->getBody(); | ||

795 | for (unsigned Cnt = 1; Cnt < CollapsedNum; ++Cnt) { | 904 | for (unsigned Cnt = 1; Cnt < CollapsedNum; ++Cnt) { | ||

796 | Body = Body->IgnoreContainers(); | 905 | Body = Body->IgnoreContainers(); | ||

797 | Body = cast<ForStmt>(Body)->getBody(); | 906 | Body = cast<ForStmt>(Body)->getBody(); | ||

798 | } | 907 | } | ||

▲ Show 20 Lines • Show All 3056 Lines • Show Last 20 Lines |