Statepoint.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include "llvm/IR/Statepoint.h"
  14. using namespace llvm;
  15. bool llvm::isStatepointDirectiveAttr(Attribute Attr) {
  16. return Attr.hasAttribute("statepoint-id") ||
  17. Attr.hasAttribute("statepoint-num-patch-bytes");
  18. }
  19. StatepointDirectives
  20. llvm::parseStatepointDirectivesFromAttrs(AttributeList AS) {
  21. StatepointDirectives Result;
  22. Attribute AttrID = AS.getFnAttr("statepoint-id");
  23. uint64_t StatepointID;
  24. if (AttrID.isStringAttribute())
  25. if (!AttrID.getValueAsString().getAsInteger(10, StatepointID))
  26. Result.StatepointID = StatepointID;
  27. uint32_t NumPatchBytes;
  28. Attribute AttrNumPatchBytes = AS.getFnAttr("statepoint-num-patch-bytes");
  29. if (AttrNumPatchBytes.isStringAttribute())
  30. if (!AttrNumPatchBytes.getValueAsString().getAsInteger(10, NumPatchBytes))
  31. Result.NumPatchBytes = NumPatchBytes;
  32. return Result;
  33. }