]> git.proxmox.com Git - rustc.git/blame - src/llvm/lib/IR/Statepoint.cpp
Imported Upstream version 1.0.0+dfsg1
[rustc.git] / src / llvm / lib / IR / Statepoint.cpp
CommitLineData
85aaf69f
SL
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//===----------------------------------------------------------------------===//
12
13#include "llvm/IR/Function.h"
14#include "llvm/IR/Constant.h"
15#include "llvm/IR/Constants.h"
16#include "llvm/IR/Statepoint.h"
17#include "llvm/Support/CommandLine.h"
18
19using namespace std;
20using namespace llvm;
21
22bool llvm::isStatepoint(const ImmutableCallSite &CS) {
23 const Function *F = CS.getCalledFunction();
24 return (F && F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint);
25}
26bool llvm::isStatepoint(const Instruction *inst) {
27 if (isa<InvokeInst>(inst) || isa<CallInst>(inst)) {
28 ImmutableCallSite CS(inst);
29 return isStatepoint(CS);
30 }
31 return false;
32}
33bool llvm::isStatepoint(const Instruction &inst) {
34 return isStatepoint(&inst);
35}
36
37bool llvm::isGCRelocate(const ImmutableCallSite &CS) {
38 return isGCRelocate(CS.getInstruction());
39}
40bool llvm::isGCRelocate(const Instruction *inst) {
41 if (const CallInst *call = dyn_cast<CallInst>(inst)) {
42 if (const Function *F = call->getCalledFunction()) {
43 return F->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
44 }
45 }
46 return false;
47}
48
49bool llvm::isGCResult(const ImmutableCallSite &CS) {
50 return isGCResult(CS.getInstruction());
51}
52bool llvm::isGCResult(const Instruction *inst) {
53 if (const CallInst *call = dyn_cast<CallInst>(inst)) {
54 if (Function *F = call->getCalledFunction()) {
55 return (F->getIntrinsicID() == Intrinsic::experimental_gc_result_int ||
56 F->getIntrinsicID() == Intrinsic::experimental_gc_result_float ||
57 F->getIntrinsicID() == Intrinsic::experimental_gc_result_ptr);
58 }
59 }
60 return false;
61}