TargetIntrinsicInfo.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- llvm/Target/TargetIntrinsicInfo.h - Instruction Info ----*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file describes the target intrinsic instructions to the code generator.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_TARGET_TARGETINTRINSICINFO_H
  18. #define LLVM_TARGET_TARGETINTRINSICINFO_H
  19. #include "llvm/ADT/StringRef.h"
  20. #include <string>
  21. namespace llvm {
  22. class Function;
  23. class Module;
  24. class Type;
  25. //---------------------------------------------------------------------------
  26. ///
  27. /// TargetIntrinsicInfo - Interface to description of machine instruction set
  28. ///
  29. class TargetIntrinsicInfo {
  30. TargetIntrinsicInfo(const TargetIntrinsicInfo &) = delete;
  31. void operator=(const TargetIntrinsicInfo &) = delete;
  32. public:
  33. TargetIntrinsicInfo();
  34. virtual ~TargetIntrinsicInfo();
  35. /// Return the name of a target intrinsic, e.g. "llvm.bfin.ssync".
  36. /// The Tys and numTys parameters are for intrinsics with overloaded types
  37. /// (e.g., those using iAny or fAny). For a declaration for an overloaded
  38. /// intrinsic, Tys should point to an array of numTys pointers to Type,
  39. /// and must provide exactly one type for each overloaded type in the
  40. /// intrinsic.
  41. virtual std::string getName(unsigned IID, Type **Tys = nullptr,
  42. unsigned numTys = 0) const = 0;
  43. /// Look up target intrinsic by name. Return intrinsic ID or 0 for unknown
  44. /// names.
  45. virtual unsigned lookupName(const char *Name, unsigned Len) const =0;
  46. unsigned lookupName(StringRef Name) const {
  47. return lookupName(Name.data(), Name.size());
  48. }
  49. /// Return the target intrinsic ID of a function, or 0.
  50. virtual unsigned getIntrinsicID(const Function *F) const;
  51. /// Returns true if the intrinsic can be overloaded.
  52. virtual bool isOverloaded(unsigned IID) const = 0;
  53. /// Create or insert an LLVM Function declaration for an intrinsic,
  54. /// and return it. The Tys and numTys are for intrinsics with overloaded
  55. /// types. See above for more information.
  56. virtual Function *getDeclaration(Module *M, unsigned ID, Type **Tys = nullptr,
  57. unsigned numTys = 0) const = 0;
  58. };
  59. } // End llvm namespace
  60. #endif
  61. #ifdef __GNUC__
  62. #pragma GCC diagnostic pop
  63. #endif