LLVM  13.0.0git
Macros | Functions | Variables
OMPIRBuilder.cpp File Reference
#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/CodeExtractor.h"
#include <sstream>
#include "llvm/Frontend/OpenMP/OMPKinds.def"
Include dependency graph for OMPIRBuilder.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "openmp-ir-builder"
 
#define OMP_ATTRS_SET(VarName, AttrSet)   AttributeSet VarName = AttrSet;
 
#define OMP_RTL_ATTRS(Enum, FnAttrSet, RetAttrSet, ArgAttrSets)
 
#define OMP_RTL(Enum, Str, IsVarArg, ReturnType, ...)
 
#define OMP_RTL(Enum, Str, ...)
 
#define OMP_CANCEL_KIND(Enum, Str, DirectiveEnum, Value)
 
#define OMP_TYPE(VarName, InitValue)   VarName = InitValue;
 
#define OMP_ARRAY_TYPE(VarName, ElemTy, ArraySize)
 
#define OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...)
 
#define OMP_STRUCT_TYPE(VarName, StructName, ...)
 

Functions

static FunctionCallee getKmpcForStaticInitForType (Type *Ty, Module &M, OpenMPIRBuilder &OMPBuilder)
 
void setCanonicalLoopTripCount (CanonicalLoopInfo *CLI, Value *TripCount)
 
static FunctionCallee getKmpcForDynamicInitForType (Type *Ty, Module &M, OpenMPIRBuilder &OMPBuilder)
 Returns an LLVM function to call for initializing loop bounds using OpenMP dynamic scheduling depending on type. More...
 
static FunctionCallee getKmpcForDynamicNextForType (Type *Ty, Module &M, OpenMPIRBuilder &OMPBuilder)
 Returns an LLVM function to call for updating the next loop using OpenMP dynamic scheduling depending on type. More...
 
static void redirectTo (BasicBlock *Source, BasicBlock *Target, DebugLoc DL)
 Make Source branch to Target. More...
 
static void redirectAllPredecessorsTo (BasicBlock *OldTarget, BasicBlock *NewTarget, DebugLoc DL)
 Redirect all edges that branch to OldTarget to NewTarget. More...
 
static void removeUnusedBlocksFromParent (ArrayRef< BasicBlock * > BBs)
 Determine which blocks in BBs are reachable from outside and remove the ones that are not reachable from the function. More...
 

Variables

static cl::opt< bool > OptimisticAttributes ("openmp-ir-builder-optimistic-attributes", cl::Hidden, cl::desc("Use optimistic attributes describing " "'as-if' properties of runtime calls."), cl::init(false))
 

Detailed Description

This file implements the OpenMPIRBuilder class, which is used as a convenient way to create LLVM instructions for OpenMP directives.

Definition in file OMPIRBuilder.cpp.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "openmp-ir-builder"

Definition at line 30 of file OMPIRBuilder.cpp.

◆ OMP_ARRAY_TYPE

#define OMP_ARRAY_TYPE (   VarName,
  ElemTy,
  ArraySize 
)
Value:
VarName##Ty = ArrayType::get(ElemTy, ArraySize); \
VarName##PtrTy = PointerType::getUnqual(VarName##Ty);

◆ OMP_ATTRS_SET

#define OMP_ATTRS_SET (   VarName,
  AttrSet 
)    AttributeSet VarName = AttrSet;

◆ OMP_CANCEL_KIND

#define OMP_CANCEL_KIND (   Enum,
  Str,
  DirectiveEnum,
  Value 
)
Value:
case DirectiveEnum: \
CancelKind = Builder.getInt32(Value); \
break;

◆ OMP_FUNCTION_TYPE

#define OMP_FUNCTION_TYPE (   VarName,
  IsVarArg,
  ReturnType,
  ... 
)
Value:
VarName = FunctionType::get(ReturnType, {__VA_ARGS__}, IsVarArg); \
VarName##Ptr = PointerType::getUnqual(VarName);

◆ OMP_RTL [1/2]

#define OMP_RTL (   Enum,
  Str,
  IsVarArg,
  ReturnType,
  ... 
)
Value:
case Enum: \
IsVarArg); \
Fn = M.getFunction(Str); \
break;

◆ OMP_RTL [2/2]

#define OMP_RTL (   Enum,
  Str,
  ... 
)
Value:
case Enum: \
Fn = Function::Create(FnTy, GlobalValue::ExternalLinkage, Str, M); \
break;

◆ OMP_RTL_ATTRS

#define OMP_RTL_ATTRS (   Enum,
  FnAttrSet,
  RetAttrSet,
  ArgAttrSets 
)
Value:
case Enum: \
FnAttrs = FnAttrs.addAttributes(Ctx, FnAttrSet); \
RetAttrs = RetAttrs.addAttributes(Ctx, RetAttrSet); \
for (size_t ArgNo = 0; ArgNo < ArgAttrSets.size(); ++ArgNo) \
ArgAttrs[ArgNo] = \
ArgAttrs[ArgNo].addAttributes(Ctx, ArgAttrSets[ArgNo]); \
Fn.setAttributes(AttributeList::get(Ctx, FnAttrs, RetAttrs, ArgAttrs)); \
break;

◆ OMP_STRUCT_TYPE

#define OMP_STRUCT_TYPE (   VarName,
  StructName,
  ... 
)
Value:
T = StructType::getTypeByName(Ctx, StructName); \
if (!T) \
T = StructType::create(Ctx, {__VA_ARGS__}, StructName); \
VarName = T; \
VarName##Ptr = PointerType::getUnqual(T);

◆ OMP_TYPE

#define OMP_TYPE (   VarName,
  InitValue 
)    VarName = InitValue;

Function Documentation

◆ getKmpcForDynamicInitForType()

static FunctionCallee getKmpcForDynamicInitForType ( Type Ty,
Module M,
OpenMPIRBuilder OMPBuilder 
)
static

Returns an LLVM function to call for initializing loop bounds using OpenMP dynamic scheduling depending on type.

Only i32 and i64 are supported by the runtime. Always interpret integers as unsigned similarly to CanonicalLoopInfo.

Definition at line 1370 of file OMPIRBuilder.cpp.

References llvm::Type::getIntegerBitWidth(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), llvm_unreachable, and M.

Referenced by llvm::OpenMPIRBuilder::createDynamicWorkshareLoop().

◆ getKmpcForDynamicNextForType()

static FunctionCallee getKmpcForDynamicNextForType ( Type Ty,
Module M,
OpenMPIRBuilder OMPBuilder 
)
static

Returns an LLVM function to call for updating the next loop using OpenMP dynamic scheduling depending on type.

Only i32 and i64 are supported by the runtime. Always interpret integers as unsigned similarly to CanonicalLoopInfo.

Definition at line 1386 of file OMPIRBuilder.cpp.

References llvm::Type::getIntegerBitWidth(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), llvm_unreachable, and M.

Referenced by llvm::OpenMPIRBuilder::createDynamicWorkshareLoop().

◆ getKmpcForStaticInitForType()

static FunctionCallee getKmpcForStaticInitForType ( Type Ty,
Module M,
OpenMPIRBuilder OMPBuilder 
)
static

◆ redirectAllPredecessorsTo()

static void redirectAllPredecessorsTo ( BasicBlock OldTarget,
BasicBlock NewTarget,
DebugLoc  DL 
)
static

Redirect all edges that branch to OldTarget to NewTarget.

That is, after this OldTarget will be orphaned.

Definition at line 1529 of file OMPIRBuilder.cpp.

References DL, llvm::make_early_inc_range(), llvm::predecessors(), and redirectTo().

Referenced by llvm::OpenMPIRBuilder::collapseLoops(), and llvm::OpenMPIRBuilder::tileLoops().

◆ redirectTo()

static void redirectTo ( BasicBlock Source,
BasicBlock Target,
DebugLoc  DL 
)
static

Make Source branch to Target.

Handles two situations:

  • Source already has an unconditional branch.
  • Source is a degenerate block (no terminator because the BB is the current head of the IR construction).

Definition at line 1512 of file OMPIRBuilder.cpp.

References assert(), llvm::BranchInst::Create(), DL, llvm::BasicBlock::removePredecessor(), llvm::Sched::Source, and llvm::M68kBeads::Term.

Referenced by llvm::OpenMPIRBuilder::collapseLoops(), redirectAllPredecessorsTo(), and llvm::OpenMPIRBuilder::tileLoops().

◆ removeUnusedBlocksFromParent()

static void removeUnusedBlocksFromParent ( ArrayRef< BasicBlock * >  BBs)
static

Determine which blocks in BBs are reachable from outside and remove the ones that are not reachable from the function.

Definition at line 1537 of file OMPIRBuilder.cpp.

References BB, llvm::ArrayRef< T >::begin(), llvm::DeleteDeadBlocks(), llvm::ArrayRef< T >::end(), and llvm::make_early_inc_range().

Referenced by llvm::OpenMPIRBuilder::collapseLoops(), and llvm::OpenMPIRBuilder::tileLoops().

◆ setCanonicalLoopTripCount()

void setCanonicalLoopTripCount ( CanonicalLoopInfo CLI,
Value TripCount 
)

Variable Documentation

◆ OptimisticAttributes

cl::opt<bool> OptimisticAttributes("openmp-ir-builder-optimistic-attributes", cl::Hidden, cl::desc("Use optimistic attributes describing " "'as-if' properties of runtime calls."), cl::init(false))
static
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::tgtok::VarName
@ VarName
Definition: TGLexer.h:71
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::ARM::WinEH::ReturnType
ReturnType
Definition: ARMWinEH.h:25
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:651
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::pdb::PDB_SymType::Enum
@ Enum
get
Should compile to something r4 addze r3 instead we get
Definition: README.txt:24
llvm::Value
LLVM Value Representation.
Definition: Value.h:75