1//===-- IR/Statepoint.cpp -- gc.statepoint utilities --- -----------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains some utility functions to help recognize gc.statepoint
10// intrinsics.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/IR/Statepoint.h"
15
16using namespace llvm;
17
18bool llvm::isStatepointDirectiveAttr(Attribute Attr) {
19 return Attr.hasAttribute(Val: "statepoint-id") ||
20 Attr.hasAttribute(Val: "statepoint-num-patch-bytes");
21}
22
23StatepointDirectives
24llvm::parseStatepointDirectivesFromAttrs(AttributeList AS) {
25 StatepointDirectives Result;
26
27 Attribute AttrID = AS.getFnAttr(Kind: "statepoint-id");
28 uint64_t StatepointID;
29 if (AttrID.isStringAttribute())
30 if (!AttrID.getValueAsString().getAsInteger(Radix: 10, Result&: StatepointID))
31 Result.StatepointID = StatepointID;
32
33 uint32_t NumPatchBytes;
34 Attribute AttrNumPatchBytes = AS.getFnAttr(Kind: "statepoint-num-patch-bytes");
35 if (AttrNumPatchBytes.isStringAttribute())
36 if (!AttrNumPatchBytes.getValueAsString().getAsInteger(Radix: 10, Result&: NumPatchBytes))
37 Result.NumPatchBytes = NumPatchBytes;
38
39 return Result;
40}
41