CodeGenIntrinsics.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //===- CodeGenIntrinsic.h - Intrinsic Class Wrapper ------------*- 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 wrapper class for the 'Intrinsic' TableGen class.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_UTILS_TABLEGEN_CODEGENINTRINSICS_H
  14. #define LLVM_UTILS_TABLEGEN_CODEGENINTRINSICS_H
  15. #include "llvm/CodeGen/MachineValueType.h"
  16. #include <string>
  17. #include <vector>
  18. namespace llvm {
  19. class Record;
  20. class RecordKeeper;
  21. class CodeGenTarget;
  22. struct CodeGenIntrinsic {
  23. Record *TheDef; // The actual record defining this intrinsic.
  24. std::string Name; // The name of the LLVM function "llvm.bswap.i32"
  25. std::string EnumName; // The name of the enum "bswap_i32"
  26. std::string GCCBuiltinName;// Name of the corresponding GCC builtin, or "".
  27. std::string MSBuiltinName; // Name of the corresponding MS builtin, or "".
  28. std::string TargetPrefix; // Target prefix, e.g. "ppc" for t-s intrinsics.
  29. /// IntrinsicSignature - This structure holds the return values and
  30. /// parameter values of an intrinsic. If the number of return values is > 1,
  31. /// then the intrinsic implicitly returns a first-class aggregate. The
  32. /// numbering of the types starts at 0 with the first return value and
  33. /// continues from there through the parameter list. This is useful for
  34. /// "matching" types.
  35. struct IntrinsicSignature {
  36. /// RetVTs - The MVT::SimpleValueType for each return type. Note that this
  37. /// list is only populated when in the context of a target .td file. When
  38. /// building Intrinsics.td, this isn't available, because we don't know
  39. /// the target pointer size.
  40. std::vector<MVT::SimpleValueType> RetVTs;
  41. /// RetTypeDefs - The records for each return type.
  42. std::vector<Record*> RetTypeDefs;
  43. /// ParamVTs - The MVT::SimpleValueType for each parameter type. Note that
  44. /// this list is only populated when in the context of a target .td file.
  45. /// When building Intrinsics.td, this isn't available, because we don't
  46. /// know the target pointer size.
  47. std::vector<MVT::SimpleValueType> ParamVTs;
  48. /// ParamTypeDefs - The records for each parameter type.
  49. std::vector<Record*> ParamTypeDefs;
  50. };
  51. IntrinsicSignature IS;
  52. // Memory mod/ref behavior of this intrinsic.
  53. enum {
  54. NoMem, ReadArgMem, ReadMem, ReadWriteArgMem, ReadWriteMem
  55. } ModRef;
  56. /// This is set to true if the intrinsic is overloaded by its argument
  57. /// types.
  58. bool isOverloaded;
  59. /// isCommutative - True if the intrinsic is commutative.
  60. bool isCommutative;
  61. /// canThrow - True if the intrinsic can throw.
  62. bool canThrow;
  63. /// isNoDuplicate - True if the intrinsic is marked as noduplicate.
  64. bool isNoDuplicate;
  65. /// isNoReturn - True if the intrinsic is no-return.
  66. bool isNoReturn;
  67. /// isConvergent - True if the intrinsic is marked as convergent.
  68. bool isConvergent;
  69. enum ArgAttribute {
  70. NoCapture,
  71. ReadOnly,
  72. ReadNone
  73. };
  74. std::vector<std::pair<unsigned, ArgAttribute> > ArgumentAttributes;
  75. CodeGenIntrinsic(Record *R);
  76. };
  77. /// LoadIntrinsics - Read all of the intrinsics defined in the specified
  78. /// .td file.
  79. std::vector<CodeGenIntrinsic> LoadIntrinsics(const RecordKeeper &RC,
  80. bool TargetOnly);
  81. }
  82. #endif