1 //===- Cilkifier.cpp - Support routines for Cilk code gen. ------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
9 #include "llvm/Support/Cilkifier.h"
10 #include "llvm/Function.h"
11 #include "llvm/iOther.h"
12 #include "llvm/DerivedTypes.h"
16 //----------------------------------------------------------------------------
17 // Global constants used in marking Cilk functions and function calls.
18 // These should be used only by the auto-parallelization pass.
19 //----------------------------------------------------------------------------
21 const std::string CilkSuffix(".llvm2cilk");
22 const std::string DummySyncFuncName("__sync.llvm2cilk");
24 //----------------------------------------------------------------------------
25 // Routines to identify Cilk functions, calls to Cilk functions, and syncs.
26 //----------------------------------------------------------------------------
28 bool isCilk(const Function& F)
31 return (F.getName().rfind(CilkSuffix) ==
32 F.getName().size() - CilkSuffix.size());
35 bool isCilkMain(const Function& F)
38 return (F.getName() == std::string("main") + CilkSuffix);
42 bool isCilk(const CallInst& CI)
44 return (CI.getCalledFunction() != NULL && isCilk(*CI.getCalledFunction()));
47 bool isSync(const CallInst& CI)
49 return (CI.getCalledFunction() != NULL &&
50 CI.getCalledFunction()->getName() == DummySyncFuncName);
54 //----------------------------------------------------------------------------