xref: /freebsd-src/contrib/llvm-project/llvm/lib/IR/Statepoint.cpp (revision 1fd87a682ad7442327078e1eeb63edc4258f9815)
10b57cec5SDimitry Andric //===-- IR/Statepoint.cpp -- gc.statepoint utilities ---  -----------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file contains some utility functions to help recognize gc.statepoint
100b57cec5SDimitry Andric // intrinsics.
110b57cec5SDimitry Andric //
120b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric #include "llvm/IR/Statepoint.h"
150b57cec5SDimitry Andric 
160b57cec5SDimitry Andric using namespace llvm;
170b57cec5SDimitry Andric 
isStatepointDirectiveAttr(Attribute Attr)180b57cec5SDimitry Andric bool llvm::isStatepointDirectiveAttr(Attribute Attr) {
190b57cec5SDimitry Andric   return Attr.hasAttribute("statepoint-id") ||
200b57cec5SDimitry Andric          Attr.hasAttribute("statepoint-num-patch-bytes");
210b57cec5SDimitry Andric }
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric StatepointDirectives
parseStatepointDirectivesFromAttrs(AttributeList AS)240b57cec5SDimitry Andric llvm::parseStatepointDirectivesFromAttrs(AttributeList AS) {
250b57cec5SDimitry Andric   StatepointDirectives Result;
260b57cec5SDimitry Andric 
27*349cc55cSDimitry Andric   Attribute AttrID = AS.getFnAttr("statepoint-id");
280b57cec5SDimitry Andric   uint64_t StatepointID;
290b57cec5SDimitry Andric   if (AttrID.isStringAttribute())
300b57cec5SDimitry Andric     if (!AttrID.getValueAsString().getAsInteger(10, StatepointID))
310b57cec5SDimitry Andric       Result.StatepointID = StatepointID;
320b57cec5SDimitry Andric 
330b57cec5SDimitry Andric   uint32_t NumPatchBytes;
34*349cc55cSDimitry Andric   Attribute AttrNumPatchBytes = AS.getFnAttr("statepoint-num-patch-bytes");
350b57cec5SDimitry Andric   if (AttrNumPatchBytes.isStringAttribute())
360b57cec5SDimitry Andric     if (!AttrNumPatchBytes.getValueAsString().getAsInteger(10, NumPatchBytes))
370b57cec5SDimitry Andric       Result.NumPatchBytes = NumPatchBytes;
380b57cec5SDimitry Andric 
390b57cec5SDimitry Andric   return Result;
400b57cec5SDimitry Andric }
41