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 //===----------------------------------------------------------------------===//
10 #include "llvm/Function.h"
11 #include "llvm/iOther.h"
12 #include "llvm/DerivedTypes.h"
14 //----------------------------------------------------------------------------
15 // Global constants used in marking Cilk functions and function calls.
16 // These should be used only by the auto-parallelization pass.
17 //----------------------------------------------------------------------------
19 const std::string CilkSuffix(".llvm2cilk");
20 const std::string DummySyncFuncName("__sync.llvm2cilk");
22 //----------------------------------------------------------------------------
23 // Routines to identify Cilk functions, calls to Cilk functions, and syncs.
24 //----------------------------------------------------------------------------
26 bool isCilk(const Function& F)
29 return (F.getName().rfind(CilkSuffix) ==
30 F.getName().size() - CilkSuffix.size());
33 bool isCilkMain(const Function& F)
36 return (F.getName() == std::string("main") + CilkSuffix);
40 bool isCilk(const CallInst& CI)
42 return (CI.getCalledFunction() != NULL && isCilk(*CI.getCalledFunction()));
45 bool isSync(const CallInst& CI)
47 return (CI.getCalledFunction() != NULL &&
48 CI.getCalledFunction()->getName() == DummySyncFuncName);
52 //----------------------------------------------------------------------------