summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2002-12-10 13:08:48 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2002-12-10 13:08:48 +0000
commitd9676ed983a27c61a5803e0aa008ff07fa797fde (patch)
tree424d642976cea4f9407bd525f6a71610f70fcc26 /llvm/lib/Transforms
parentc864ab1e33482e16ba99027f4d6d247bcbdef904 (diff)
downloadbcm5719-llvm-d9676ed983a27c61a5803e0aa008ff07fa797fde.tar.gz
bcm5719-llvm-d9676ed983a27c61a5803e0aa008ff07fa797fde.zip
External routines used to identify Cilk operations inserted by the
parallelization pass. llvm-svn: 4965
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/Cilkifier.cpp54
-rw-r--r--llvm/lib/Transforms/IPO/Cilkifier.h35
2 files changed, 89 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/Cilkifier.cpp b/llvm/lib/Transforms/IPO/Cilkifier.cpp
new file mode 100644
index 00000000000..498c58b6fd8
--- /dev/null
+++ b/llvm/lib/Transforms/IPO/Cilkifier.cpp
@@ -0,0 +1,54 @@
+//===- Cilkifier.cpp - Support routines for Cilk code gen. ------*- C++ -*-===//
+//
+// This is located here so that the code generator (dis) does not have to
+// include and link with the libtipo.a archive containing class Cilkifier
+// and the rest of the automatic parallelization code.
+//===----------------------------------------------------------------------===//
+
+
+#include "llvm/Support/Cilkifier.h"
+#include "llvm/Function.h"
+#include "llvm/iOther.h"
+#include "llvm/DerivedTypes.h"
+#include <vector>
+
+
+//----------------------------------------------------------------------------
+// Global constants used in marking Cilk functions and function calls.
+// These should be used only by the auto-parallelization pass.
+//----------------------------------------------------------------------------
+
+const std::string CilkSuffix(".llvm2cilk");
+const std::string DummySyncFuncName("__sync.llvm2cilk");
+
+//----------------------------------------------------------------------------
+// Routines to identify Cilk functions, calls to Cilk functions, and syncs.
+//----------------------------------------------------------------------------
+
+bool isCilk(const Function& F)
+{
+ assert(F.hasName());
+ return (F.getName().rfind(CilkSuffix) ==
+ F.getName().size() - CilkSuffix.size());
+}
+
+bool isCilkMain(const Function& F)
+{
+ assert(F.hasName());
+ return (F.getName() == std::string("main") + CilkSuffix);
+}
+
+
+bool isCilk(const CallInst& CI)
+{
+ return (CI.getCalledFunction() != NULL && isCilk(*CI.getCalledFunction()));
+}
+
+bool isSync(const CallInst& CI)
+{
+ return (CI.getCalledFunction() != NULL &&
+ CI.getCalledFunction()->getName() == DummySyncFuncName);
+}
+
+
+//----------------------------------------------------------------------------
diff --git a/llvm/lib/Transforms/IPO/Cilkifier.h b/llvm/lib/Transforms/IPO/Cilkifier.h
new file mode 100644
index 00000000000..be79ab6b222
--- /dev/null
+++ b/llvm/lib/Transforms/IPO/Cilkifier.h
@@ -0,0 +1,35 @@
+//===- Cilkifier.h - Support routines for Cilk code generation --*- C++ -*-===//
+//
+// This is located here so that the code generator (dis) does not have to
+// include and link with the libtipo.a archive containing class Cilkifier
+// and the rest of the automatic parallelization code.
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_CILKIFIER_H
+#define LLVM_SUPPORT_CILKIFIER_H
+
+#include <string>
+class Function;
+class CallInst;
+
+
+//----------------------------------------------------------------------------
+// Global constants used in marking Cilk functions and function calls.
+// These should be used only by the auto-parallelization pass.
+//----------------------------------------------------------------------------
+
+extern const std::string CilkSuffix;
+extern const std::string DummySyncFuncName;
+
+//----------------------------------------------------------------------------
+// Routines to identify Cilk functions, calls to Cilk functions, and syncs.
+//----------------------------------------------------------------------------
+
+extern bool isCilk (const Function& F);
+extern bool isCilkMain (const Function& F);
+extern bool isCilk (const CallInst& CI);
+extern bool isSync (const CallInst& CI);
+
+//===----------------------------------------------------------------------===//
+
+#endif
OpenPOWER on IntegriCloud