If "These should be used only by the auto-parallelization pass", we might as
[oota-llvm.git] / lib / Transforms / IPO / Cilkifier.cpp
1 //===- Cilkifier.cpp - Support routines for Cilk code gen. ------*- C++ -*-===//
2 //
3 // This is located here so that the code generator (dis) does not have to
4 // include and link with the libtipo.a archive containing class Cilkifier
5 // and the rest of the automatic parallelization code.
6 //===----------------------------------------------------------------------===//
7
8
9 #include "Cilkifier.h"
10 #include "llvm/Function.h"
11 #include "llvm/iOther.h"
12 #include "llvm/DerivedTypes.h"
13
14 //---------------------------------------------------------------------------- 
15 // Global constants used in marking Cilk functions and function calls.
16 // These should be used only by the auto-parallelization pass.
17 //---------------------------------------------------------------------------- 
18
19 const std::string CilkSuffix(".llvm2cilk");
20 const std::string DummySyncFuncName("__sync.llvm2cilk");
21
22 //---------------------------------------------------------------------------- 
23 // Routines to identify Cilk functions, calls to Cilk functions, and syncs.
24 //---------------------------------------------------------------------------- 
25
26 bool isCilk(const Function& F)
27 {
28   assert(F.hasName());
29   return (F.getName().rfind(CilkSuffix) ==
30           F.getName().size() - CilkSuffix.size());
31 }
32
33 bool isCilkMain(const Function& F)
34 {
35   assert(F.hasName());
36   return (F.getName() == std::string("main") + CilkSuffix);
37 }
38
39
40 bool isCilk(const CallInst& CI)
41 {
42   return (CI.getCalledFunction() != NULL && isCilk(*CI.getCalledFunction()));
43 }
44
45 bool isSync(const CallInst& CI)
46
47   return (CI.getCalledFunction() != NULL &&
48           CI.getCalledFunction()->getName() == DummySyncFuncName);
49 }
50
51
52 //----------------------------------------------------------------------------