blob: a04f6738dcb2420397eadaad9ed570483690484f [file] [log] [blame]
Philip Reames1a1bdb22014-12-02 18:50:36 +00001//===-- 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//===----------------------------------------------------------------------===//
12
13#include "llvm/IR/Function.h"
14#include "llvm/IR/Constant.h"
15#include "llvm/IR/Constants.h"
16#include "llvm/Support/CommandLine.h"
17
18#include "llvm/IR/Statepoint.h"
19
20using namespace std;
21using namespace llvm;
22
23bool llvm::isStatepoint(const ImmutableCallSite &CS) {
24 const Function *F = CS.getCalledFunction();
25 return (F && F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint);
26}
27bool 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}
34bool llvm::isStatepoint(const Instruction &inst) {
35 return isStatepoint(&inst);
36}
37
38bool llvm::isGCRelocate(const ImmutableCallSite &CS) {
39 return isGCRelocate(CS.getInstruction());
40}
41bool 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}
49
50bool llvm::isGCResult(const ImmutableCallSite &CS) {
51 return isGCResult(CS.getInstruction());
52}
53bool llvm::isGCResult(const Instruction *inst) {
Philip Reameseafafa32014-12-04 17:27:58 +000054 if (const CallInst *call = dyn_cast<CallInst>(inst)) {
Philip Reames1a1bdb22014-12-02 18:50:36 +000055 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}