[llvm-commits] [polly] r151911 - /polly/trunk/lib/CodeGeneration.cpp

Tobias Grosser grosser at fim.uni-passau.de
Fri Mar 2 07:20:17 PST 2012


Author: grosser
Date: Fri Mar  2 09:20:17 2012
New Revision: 151911

URL: http://llvm.org/viewvc/llvm-project?rev=151911&view=rev
Log:
CodeGen: Prettify function

Modified:
    polly/trunk/lib/CodeGeneration.cpp

Modified: polly/trunk/lib/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=151911&r1=151910&r2=151911&view=diff
==============================================================================
--- polly/trunk/lib/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGeneration.cpp Fri Mar  2 09:20:17 2012
@@ -1321,50 +1321,38 @@
   Builder.SetInsertPoint(PrevInsertPoint);
 }
 
-void ClastStmtCodeGen::codegenForOpenMP(const clast_for *f) {
+void ClastStmtCodeGen::codegenForOpenMP(const clast_for *For) {
   Module *M = Builder.GetInsertBlock()->getParent()->getParent();
-  IntegerType *intPtrTy = TD->getIntPtrType(Builder.getContext());
+  IntegerType *IntPtrTy = TD->getIntPtrType(Builder.getContext());
 
   Function *SubFunction = addOpenMPSubfunction(M);
   SetVector<Value*> OMPDataVals = createOpenMPStructValues();
-  Value *structData = addValuesToOpenMPStruct(OMPDataVals, SubFunction);
+  Value *StructData = addValuesToOpenMPStruct(OMPDataVals, SubFunction);
 
-  addOpenMPSubfunctionBody(SubFunction, f, structData, OMPDataVals);
+  addOpenMPSubfunctionBody(SubFunction, For, StructData, OMPDataVals);
 
   // Create call for GOMP_parallel_loop_runtime_start.
-  Value *subfunctionParam = Builder.CreateBitCast(structData,
+  Value *SubfunctionParam = Builder.CreateBitCast(StructData,
                                                   Builder.getInt8PtrTy(),
                                                   "omp_data");
 
-  Value *numberOfThreads = Builder.getInt32(0);
-  Value *lowerBound = ExpGen.codegen(f->LB, intPtrTy);
-  Value *upperBound = ExpGen.codegen(f->UB, intPtrTy);
+  Value *NumberOfThreads = Builder.getInt32(0);
+  Value *LowerBound = ExpGen.codegen(For->LB, IntPtrTy);
+  Value *UpperBound = ExpGen.codegen(For->UB, IntPtrTy);
 
   // Add one as the upper bound provided by openmp is a < comparison
   // whereas the codegenForSequential function creates a <= comparison.
-  upperBound = Builder.CreateAdd(upperBound, ConstantInt::get(intPtrTy, 1));
-  APInt APStride = APInt_from_MPZ(f->stride);
-  Value *stride = ConstantInt::get(intPtrTy,
-                                   APStride.zext(intPtrTy->getBitWidth()));
-
-  SmallVector<Value *, 6> Arguments;
-  Arguments.push_back(SubFunction);
-  Arguments.push_back(subfunctionParam);
-  Arguments.push_back(numberOfThreads);
-  Arguments.push_back(lowerBound);
-  Arguments.push_back(upperBound);
-  Arguments.push_back(stride);
-
-  Function *parallelStartFunction =
-    M->getFunction("GOMP_parallel_loop_runtime_start");
-  Builder.CreateCall(parallelStartFunction, Arguments);
-
-  // Create call to the subfunction.
-  Builder.CreateCall(SubFunction, subfunctionParam);
-
-  // Create call for GOMP_parallel_end.
-  Function *FN = M->getFunction("GOMP_parallel_end");
-  Builder.CreateCall(FN);
+  UpperBound = Builder.CreateAdd(UpperBound, ConstantInt::get(IntPtrTy, 1));
+  APInt APStride = APInt_from_MPZ(For->stride);
+  Value *Stride = ConstantInt::get(IntPtrTy,
+                                   APStride.zext(IntPtrTy->getBitWidth()));
+
+  Value *Arguments[] = { SubFunction, SubfunctionParam, NumberOfThreads,
+    LowerBound, UpperBound, Stride};
+  Builder.CreateCall(M->getFunction("GOMP_parallel_loop_runtime_start"),
+                     Arguments);
+  Builder.CreateCall(SubFunction, SubfunctionParam);
+  Builder.CreateCall(M->getFunction("GOMP_parallel_end"));
 }
 
 bool ClastStmtCodeGen::isInnermostLoop(const clast_for *f) {





More information about the llvm-commits mailing list