diff options
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
| -rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 96 | 
1 files changed, 80 insertions, 16 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index fa72019eb08b2..1ded824ba5b02 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -175,6 +175,25 @@ public:    // because of jumps.    VarBypassDetector Bypasses; +  // CodeGen lambda for loops and support for ordered clause +  typedef llvm::function_ref<void(CodeGenFunction &, const OMPLoopDirective &, +                                  JumpDest)> +      CodeGenLoopTy; +  typedef llvm::function_ref<void(CodeGenFunction &, SourceLocation, +                                  const unsigned, const bool)> +      CodeGenOrderedTy; + +  // Codegen lambda for loop bounds in worksharing loop constructs +  typedef llvm::function_ref<std::pair<LValue, LValue>( +      CodeGenFunction &, const OMPExecutableDirective &S)> +      CodeGenLoopBoundsTy; + +  // Codegen lambda for loop bounds in dispatch-based loop implementation +  typedef llvm::function_ref<std::pair<llvm::Value *, llvm::Value *>( +      CodeGenFunction &, const OMPExecutableDirective &S, Address LB, +      Address UB)> +      CodeGenDispatchBoundsTy; +    /// \brief CGBuilder insert helper. This function is called after an    /// instruction is created using Builder.    void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name, @@ -2756,7 +2775,6 @@ public:    void EmitOMPTaskLoopDirective(const OMPTaskLoopDirective &S);    void EmitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective &S);    void EmitOMPDistributeDirective(const OMPDistributeDirective &S); -  void EmitOMPDistributeLoop(const OMPDistributeDirective &S);    void EmitOMPDistributeParallelForDirective(        const OMPDistributeParallelForDirective &S);    void EmitOMPDistributeParallelForSimdDirective( @@ -2813,32 +2831,78 @@ public:    void EmitOMPPrivateLoopCounters(const OMPLoopDirective &S,                                    OMPPrivateScope &LoopScope); +  /// Helper for the OpenMP loop directives. +  void EmitOMPLoopBody(const OMPLoopDirective &D, JumpDest LoopExit); + +  /// \brief Emit code for the worksharing loop-based directive. +  /// \return true, if this construct has any lastprivate clause, false - +  /// otherwise. +  bool EmitOMPWorksharingLoop(const OMPLoopDirective &S, Expr *EUB, +                              const CodeGenLoopBoundsTy &CodeGenLoopBounds, +                              const CodeGenDispatchBoundsTy &CGDispatchBounds); +  private:    /// Helpers for blocks    llvm::Value *EmitBlockLiteral(const CGBlockInfo &Info);    /// Helpers for the OpenMP loop directives. -  void EmitOMPLoopBody(const OMPLoopDirective &D, JumpDest LoopExit);    void EmitOMPSimdInit(const OMPLoopDirective &D, bool IsMonotonic = false);    void EmitOMPSimdFinal(        const OMPLoopDirective &D,        const llvm::function_ref<llvm::Value *(CodeGenFunction &)> &CondGen); -  /// \brief Emit code for the worksharing loop-based directive. -  /// \return true, if this construct has any lastprivate clause, false - -  /// otherwise. -  bool EmitOMPWorksharingLoop(const OMPLoopDirective &S); -  void EmitOMPOuterLoop(bool IsMonotonic, bool DynamicOrOrdered, -      const OMPLoopDirective &S, OMPPrivateScope &LoopScope, bool Ordered, -      Address LB, Address UB, Address ST, Address IL, llvm::Value *Chunk); + +  void EmitOMPDistributeLoop(const OMPLoopDirective &S, +                             const CodeGenLoopTy &CodeGenLoop, Expr *IncExpr); + +  /// struct with the values to be passed to the OpenMP loop-related functions +  struct OMPLoopArguments { +    /// loop lower bound +    Address LB = Address::invalid(); +    /// loop upper bound +    Address UB = Address::invalid(); +    /// loop stride +    Address ST = Address::invalid(); +    /// isLastIteration argument for runtime functions +    Address IL = Address::invalid(); +    /// Chunk value generated by sema +    llvm::Value *Chunk = nullptr; +    /// EnsureUpperBound +    Expr *EUB = nullptr; +    /// IncrementExpression +    Expr *IncExpr = nullptr; +    /// Loop initialization +    Expr *Init = nullptr; +    /// Loop exit condition +    Expr *Cond = nullptr; +    /// Update of LB after a whole chunk has been executed +    Expr *NextLB = nullptr; +    /// Update of UB after a whole chunk has been executed +    Expr *NextUB = nullptr; +    OMPLoopArguments() = default; +    OMPLoopArguments(Address LB, Address UB, Address ST, Address IL, +                     llvm::Value *Chunk = nullptr, Expr *EUB = nullptr, +                     Expr *IncExpr = nullptr, Expr *Init = nullptr, +                     Expr *Cond = nullptr, Expr *NextLB = nullptr, +                     Expr *NextUB = nullptr) +        : LB(LB), UB(UB), ST(ST), IL(IL), Chunk(Chunk), EUB(EUB), +          IncExpr(IncExpr), Init(Init), Cond(Cond), NextLB(NextLB), +          NextUB(NextUB) {} +  }; +  void EmitOMPOuterLoop(bool DynamicOrOrdered, bool IsMonotonic, +                        const OMPLoopDirective &S, OMPPrivateScope &LoopScope, +                        const OMPLoopArguments &LoopArgs, +                        const CodeGenLoopTy &CodeGenLoop, +                        const CodeGenOrderedTy &CodeGenOrdered);    void EmitOMPForOuterLoop(const OpenMPScheduleTy &ScheduleKind,                             bool IsMonotonic, const OMPLoopDirective &S, -                           OMPPrivateScope &LoopScope, bool Ordered, Address LB, -                           Address UB, Address ST, Address IL, -                           llvm::Value *Chunk); -  void EmitOMPDistributeOuterLoop( -      OpenMPDistScheduleClauseKind ScheduleKind, -      const OMPDistributeDirective &S, OMPPrivateScope &LoopScope, -      Address LB, Address UB, Address ST, Address IL, llvm::Value *Chunk); +                           OMPPrivateScope &LoopScope, bool Ordered, +                           const OMPLoopArguments &LoopArgs, +                           const CodeGenDispatchBoundsTy &CGDispatchBounds); +  void EmitOMPDistributeOuterLoop(OpenMPDistScheduleClauseKind ScheduleKind, +                                  const OMPLoopDirective &S, +                                  OMPPrivateScope &LoopScope, +                                  const OMPLoopArguments &LoopArgs, +                                  const CodeGenLoopTy &CodeGenLoopContent);    /// \brief Emit code for sections directive.    void EmitSections(const OMPExecutableDirective &S);  | 
