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.

165 lines
5.7 KiB

  1. //===-- llvm/Target/TargetCallingConv.h - Calling Convention ----*- 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 types for working with calling-convention information.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_TARGET_TARGETCALLINGCONV_H
  14. #define LLVM_TARGET_TARGETCALLINGCONV_H
  15. #include "llvm/Support/DataTypes.h"
  16. #include "llvm/Support/MathExtras.h"
  17. #include <string>
  18. namespace llvm {
  19. namespace ISD {
  20. struct ArgFlagsTy {
  21. private:
  22. static const uint64_t NoFlagSet = 0ULL;
  23. static const uint64_t ZExt = 1ULL<<0; ///< Zero extended
  24. static const uint64_t ZExtOffs = 0;
  25. static const uint64_t SExt = 1ULL<<1; ///< Sign extended
  26. static const uint64_t SExtOffs = 1;
  27. static const uint64_t InReg = 1ULL<<2; ///< Passed in register
  28. static const uint64_t InRegOffs = 2;
  29. static const uint64_t SRet = 1ULL<<3; ///< Hidden struct-ret ptr
  30. static const uint64_t SRetOffs = 3;
  31. static const uint64_t ByVal = 1ULL<<4; ///< Struct passed by value
  32. static const uint64_t ByValOffs = 4;
  33. static const uint64_t Nest = 1ULL<<5; ///< Nested fn static chain
  34. static const uint64_t NestOffs = 5;
  35. static const uint64_t Returned = 1ULL<<6; ///< Always returned
  36. static const uint64_t ReturnedOffs = 6;
  37. static const uint64_t ByValAlign = 0xFULL<<7; ///< Struct alignment
  38. static const uint64_t ByValAlignOffs = 7;
  39. static const uint64_t Split = 1ULL<<11;
  40. static const uint64_t SplitOffs = 11;
  41. static const uint64_t OrigAlign = 0x1FULL<<27;
  42. static const uint64_t OrigAlignOffs = 27;
  43. static const uint64_t ByValSize = 0xffffffffULL<<32; ///< Struct size
  44. static const uint64_t ByValSizeOffs = 32;
  45. static const uint64_t One = 1ULL; ///< 1 of this type, for shifts
  46. uint64_t Flags;
  47. public:
  48. ArgFlagsTy() : Flags(0) { }
  49. bool isZExt() const { return Flags & ZExt; }
  50. void setZExt() { Flags |= One << ZExtOffs; }
  51. bool isSExt() const { return Flags & SExt; }
  52. void setSExt() { Flags |= One << SExtOffs; }
  53. bool isInReg() const { return Flags & InReg; }
  54. void setInReg() { Flags |= One << InRegOffs; }
  55. bool isSRet() const { return Flags & SRet; }
  56. void setSRet() { Flags |= One << SRetOffs; }
  57. bool isByVal() const { return Flags & ByVal; }
  58. void setByVal() { Flags |= One << ByValOffs; }
  59. bool isNest() const { return Flags & Nest; }
  60. void setNest() { Flags |= One << NestOffs; }
  61. bool isReturned() const { return Flags & Returned; }
  62. void setReturned() { Flags |= One << ReturnedOffs; }
  63. unsigned getByValAlign() const {
  64. return (unsigned)
  65. ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
  66. }
  67. void setByValAlign(unsigned A) {
  68. Flags = (Flags & ~ByValAlign) |
  69. (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
  70. }
  71. bool isSplit() const { return Flags & Split; }
  72. void setSplit() { Flags |= One << SplitOffs; }
  73. unsigned getOrigAlign() const {
  74. return (unsigned)
  75. ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
  76. }
  77. void setOrigAlign(unsigned A) {
  78. Flags = (Flags & ~OrigAlign) |
  79. (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
  80. }
  81. unsigned getByValSize() const {
  82. return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
  83. }
  84. void setByValSize(unsigned S) {
  85. Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
  86. }
  87. /// getRawBits - Represent the flags as a bunch of bits.
  88. uint64_t getRawBits() const { return Flags; }
  89. };
  90. /// InputArg - This struct carries flags and type information about a
  91. /// single incoming (formal) argument or incoming (from the perspective
  92. /// of the caller) return value virtual register.
  93. ///
  94. struct InputArg {
  95. ArgFlagsTy Flags;
  96. MVT VT;
  97. bool Used;
  98. /// Index original Function's argument.
  99. unsigned OrigArgIndex;
  100. /// Offset in bytes of current input value relative to the beginning of
  101. /// original argument. E.g. if argument was splitted into four 32 bit
  102. /// registers, we got 4 InputArgs with PartOffsets 0, 4, 8 and 12.
  103. unsigned PartOffset;
  104. InputArg() : VT(MVT::Other), Used(false) {}
  105. InputArg(ArgFlagsTy flags, EVT vt, bool used,
  106. unsigned origIdx, unsigned partOffs)
  107. : Flags(flags), Used(used), OrigArgIndex(origIdx), PartOffset(partOffs) {
  108. VT = vt.getSimpleVT();
  109. }
  110. };
  111. /// OutputArg - This struct carries flags and a value for a
  112. /// single outgoing (actual) argument or outgoing (from the perspective
  113. /// of the caller) return value virtual register.
  114. ///
  115. struct OutputArg {
  116. ArgFlagsTy Flags;
  117. MVT VT;
  118. /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
  119. bool IsFixed;
  120. /// Index original Function's argument.
  121. unsigned OrigArgIndex;
  122. /// Offset in bytes of current output value relative to the beginning of
  123. /// original argument. E.g. if argument was splitted into four 32 bit
  124. /// registers, we got 4 OutputArgs with PartOffsets 0, 4, 8 and 12.
  125. unsigned PartOffset;
  126. OutputArg() : IsFixed(false) {}
  127. OutputArg(ArgFlagsTy flags, EVT vt, bool isfixed,
  128. unsigned origIdx, unsigned partOffs)
  129. : Flags(flags), IsFixed(isfixed), OrigArgIndex(origIdx),
  130. PartOffset(partOffs) {
  131. VT = vt.getSimpleVT();
  132. }
  133. };
  134. }
  135. } // end llvm namespace
  136. #endif