Statepoint.cpp 1.5 KB

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