11a1bdb22SPhilip Reames //===-- IR/Statepoint.cpp -- gc.statepoint utilities --- -----------------===// 21a1bdb22SPhilip Reames // 32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 61a1bdb22SPhilip Reames // 71a1bdb22SPhilip Reames //===----------------------------------------------------------------------===// 81a1bdb22SPhilip Reames // 9d6fc46eaSSanjoy Das // This file contains some utility functions to help recognize gc.statepoint 10d6fc46eaSSanjoy Das // intrinsics. 111a1bdb22SPhilip Reames // 121a1bdb22SPhilip Reames //===----------------------------------------------------------------------===// 131a1bdb22SPhilip Reames 141a1bdb22SPhilip Reames #include "llvm/IR/Statepoint.h" 151a1bdb22SPhilip Reames 161a1bdb22SPhilip Reames using namespace llvm; 171a1bdb22SPhilip Reames isStatepointDirectiveAttr(Attribute Attr)1831203887SSanjoy Dasbool llvm::isStatepointDirectiveAttr(Attribute Attr) { 1931203887SSanjoy Das return Attr.hasAttribute("statepoint-id") || 2031203887SSanjoy Das Attr.hasAttribute("statepoint-num-patch-bytes"); 2131203887SSanjoy Das } 2231203887SSanjoy Das 23b518054bSReid Kleckner StatepointDirectives parseStatepointDirectivesFromAttrs(AttributeList AS)24b518054bSReid Klecknerllvm::parseStatepointDirectivesFromAttrs(AttributeList AS) { 2531203887SSanjoy Das StatepointDirectives Result; 2631203887SSanjoy Das 27*d5ff5ef6SArthur Eubanks Attribute AttrID = AS.getFnAttr("statepoint-id"); 2831203887SSanjoy Das uint64_t StatepointID; 2931203887SSanjoy Das if (AttrID.isStringAttribute()) 3031203887SSanjoy Das if (!AttrID.getValueAsString().getAsInteger(10, StatepointID)) 3131203887SSanjoy Das Result.StatepointID = StatepointID; 3231203887SSanjoy Das 3331203887SSanjoy Das uint32_t NumPatchBytes; 34*d5ff5ef6SArthur Eubanks Attribute AttrNumPatchBytes = AS.getFnAttr("statepoint-num-patch-bytes"); 3531203887SSanjoy Das if (AttrNumPatchBytes.isStringAttribute()) 3631203887SSanjoy Das if (!AttrNumPatchBytes.getValueAsString().getAsInteger(10, NumPatchBytes)) 3731203887SSanjoy Das Result.NumPatchBytes = NumPatchBytes; 3831203887SSanjoy Das 3931203887SSanjoy Das return Result; 4031203887SSanjoy Das } 41