]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/blob - lib/IR/Statepoint.cpp
a04f6738dcb2420397eadaad9ed570483690484f
[opencl/llvm.git] / lib / IR / Statepoint.cpp
1 //===-- IR/Statepoint.cpp -- gc.statepoint utilities ---  -----------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // 
11 //===----------------------------------------------------------------------===//
13 #include "llvm/IR/Function.h"
14 #include "llvm/IR/Constant.h"
15 #include "llvm/IR/Constants.h"
16 #include "llvm/Support/CommandLine.h"
18 #include "llvm/IR/Statepoint.h"
20 using namespace std;
21 using namespace llvm;
23 bool llvm::isStatepoint(const ImmutableCallSite &CS) {
24   const Function *F = CS.getCalledFunction();
25   return (F && F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint);
26 }
27 bool llvm::isStatepoint(const Instruction *inst) {
28   if (isa<InvokeInst>(inst) || isa<CallInst>(inst)) {
29     ImmutableCallSite CS(inst);
30     return isStatepoint(CS);
31   }
32   return false;
33 }
34 bool llvm::isStatepoint(const Instruction &inst) {
35   return isStatepoint(&inst);
36 }
38 bool llvm::isGCRelocate(const ImmutableCallSite &CS) {
39   return isGCRelocate(CS.getInstruction());
40 }
41 bool llvm::isGCRelocate(const Instruction *inst) {
42   if (const CallInst *call = dyn_cast<CallInst>(inst)) {
43     if (const Function *F = call->getCalledFunction()) {
44       return F->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
45     }
46   }
47   return false;
48 }
50 bool llvm::isGCResult(const ImmutableCallSite &CS) {
51   return isGCResult(CS.getInstruction());
52 }
53 bool llvm::isGCResult(const Instruction *inst) {
54   if (const CallInst *call = dyn_cast<CallInst>(inst)) {
55     if (Function *F = call->getCalledFunction()) {
56       return (F->getIntrinsicID() == Intrinsic::experimental_gc_result_int ||
57               F->getIntrinsicID() == Intrinsic::experimental_gc_result_float ||
58               F->getIntrinsicID() == Intrinsic::experimental_gc_result_ptr);
59     }
60   }
61   return false;
62 }