Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
4.0 KiB

  1. //===-- llvm/Instrinsics.h - LLVM Intrinsic Function Handling ---*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file defines a set of enums which allow processing of intrinsic
  11. // functions. Values of these enum types are returned by
  12. // Function::getIntrinsicID.
  13. //
  14. //===----------------------------------------------------------------------===//
  15. #ifndef LLVM_INTRINSICS_H
  16. #define LLVM_INTRINSICS_H
  17. #include "llvm/ADT/ArrayRef.h"
  18. #include <string>
  19. namespace llvm {
  20. class Type;
  21. class FunctionType;
  22. class Function;
  23. class LLVMContext;
  24. class Module;
  25. class AttrListPtr;
  26. /// Intrinsic Namespace - This namespace contains an enum with a value for
  27. /// every intrinsic/builtin function known by LLVM. These enum values are
  28. /// returned by Function::getIntrinsicID().
  29. ///
  30. namespace Intrinsic {
  31. enum ID {
  32. not_intrinsic = 0, // Must be zero
  33. // Get the intrinsic enums generated from Intrinsics.td
  34. #define GET_INTRINSIC_ENUM_VALUES
  35. #include "llvm/Intrinsics.gen"
  36. #undef GET_INTRINSIC_ENUM_VALUES
  37. , num_intrinsics
  38. };
  39. /// Intrinsic::getName(ID) - Return the LLVM name for an intrinsic, such as
  40. /// "llvm.ppc.altivec.lvx".
  41. std::string getName(ID id, ArrayRef<Type*> Tys = ArrayRef<Type*>());
  42. /// Intrinsic::getType(ID) - Return the function type for an intrinsic.
  43. ///
  44. FunctionType *getType(LLVMContext &Context, ID id,
  45. ArrayRef<Type*> Tys = ArrayRef<Type*>());
  46. /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be
  47. /// overloaded.
  48. bool isOverloaded(ID id);
  49. /// Intrinsic::getAttributes(ID) - Return the attributes for an intrinsic.
  50. ///
  51. AttrListPtr getAttributes(ID id);
  52. /// Intrinsic::getDeclaration(M, ID) - Create or insert an LLVM Function
  53. /// declaration for an intrinsic, and return it.
  54. ///
  55. /// The Tys and numTys parameters are for intrinsics with overloaded types
  56. /// (e.g., those using iAny, fAny, vAny, or iPTRAny). For a declaration for an
  57. /// overloaded intrinsic, Tys should point to an array of numTys pointers to
  58. /// Type, and must provide exactly one type for each overloaded type in the
  59. /// intrinsic.
  60. Function *getDeclaration(Module *M, ID id,
  61. ArrayRef<Type*> Tys = ArrayRef<Type*>());
  62. /// Map a GCC builtin name to an intrinsic ID.
  63. ID getIntrinsicForGCCBuiltin(const char *Prefix, const char *BuiltinName);
  64. /// IITDescriptor - This is a type descriptor which explains the type
  65. /// requirements of an intrinsic. This is returned by
  66. /// getIntrinsicInfoTableEntries.
  67. struct IITDescriptor {
  68. enum IITDescriptorKind {
  69. Void, MMX, Metadata, Float, Double,
  70. Integer, Vector, Pointer, Struct,
  71. Argument, ExtendVecArgument, TruncVecArgument
  72. } Kind;
  73. union {
  74. unsigned Integer_Width;
  75. unsigned Float_Width;
  76. unsigned Vector_Width;
  77. unsigned Pointer_AddressSpace;
  78. unsigned Struct_NumElements;
  79. unsigned Argument_Info;
  80. };
  81. enum ArgKind {
  82. AK_AnyInteger,
  83. AK_AnyFloat,
  84. AK_AnyVector,
  85. AK_AnyPointer
  86. };
  87. unsigned getArgumentNumber() const {
  88. assert(Kind == Argument || Kind == ExtendVecArgument ||
  89. Kind == TruncVecArgument);
  90. return Argument_Info >> 2;
  91. }
  92. ArgKind getArgumentKind() const {
  93. assert(Kind == Argument || Kind == ExtendVecArgument ||
  94. Kind == TruncVecArgument);
  95. return (ArgKind)(Argument_Info&3);
  96. }
  97. static IITDescriptor get(IITDescriptorKind K, unsigned Field) {
  98. IITDescriptor Result = { K, { Field } };
  99. return Result;
  100. }
  101. };
  102. /// getIntrinsicInfoTableEntries - Return the IIT table descriptor for the
  103. /// specified intrinsic into an array of IITDescriptors.
  104. ///
  105. void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl<IITDescriptor> &T);
  106. } // End Intrinsic namespace
  107. } // End llvm namespace
  108. #endif