TargetCallingConv.td 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. //===- TargetCallingConv.td - Target Calling Conventions ---*- tablegen -*-===//
  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 the target-independent interfaces with which targets
  11. // describe their calling conventions.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. class CCAction;
  15. class CallingConv;
  16. /// CCCustom - Calls a custom arg handling function.
  17. class CCCustom<string fn> : CCAction {
  18. string FuncName = fn;
  19. }
  20. /// CCPredicateAction - Instances of this class check some predicate, then
  21. /// delegate to another action if the predicate is true.
  22. class CCPredicateAction<CCAction A> : CCAction {
  23. CCAction SubAction = A;
  24. }
  25. /// CCIfType - If the current argument is one of the specified types, apply
  26. /// Action A.
  27. class CCIfType<list<ValueType> vts, CCAction A> : CCPredicateAction<A> {
  28. list<ValueType> VTs = vts;
  29. }
  30. /// CCIf - If the predicate matches, apply A.
  31. class CCIf<string predicate, CCAction A> : CCPredicateAction<A> {
  32. string Predicate = predicate;
  33. }
  34. /// CCIfByVal - If the current argument has ByVal parameter attribute, apply
  35. /// Action A.
  36. class CCIfByVal<CCAction A> : CCIf<"ArgFlags.isByVal()", A> {
  37. }
  38. /// CCIfConsecutiveRegs - If the current argument has InConsecutiveRegs
  39. /// parameter attribute, apply Action A.
  40. class CCIfConsecutiveRegs<CCAction A> : CCIf<"ArgFlags.isInConsecutiveRegs()", A> {
  41. }
  42. /// CCIfCC - Match if the current calling convention is 'CC'.
  43. class CCIfCC<string CC, CCAction A>
  44. : CCIf<!strconcat("State.getCallingConv() == ", CC), A> {}
  45. /// CCIfInReg - If this argument is marked with the 'inreg' attribute, apply
  46. /// the specified action.
  47. class CCIfInReg<CCAction A> : CCIf<"ArgFlags.isInReg()", A> {}
  48. /// CCIfNest - If this argument is marked with the 'nest' attribute, apply
  49. /// the specified action.
  50. class CCIfNest<CCAction A> : CCIf<"ArgFlags.isNest()", A> {}
  51. /// CCIfSplit - If this argument is marked with the 'split' attribute, apply
  52. /// the specified action.
  53. class CCIfSplit<CCAction A> : CCIf<"ArgFlags.isSplit()", A> {}
  54. /// CCIfSRet - If this argument is marked with the 'sret' attribute, apply
  55. /// the specified action.
  56. class CCIfSRet<CCAction A> : CCIf<"ArgFlags.isSRet()", A> {}
  57. /// CCIfVarArg - If the current function is vararg - apply the action
  58. class CCIfVarArg<CCAction A> : CCIf<"State.isVarArg()", A> {}
  59. /// CCIfNotVarArg - If the current function is not vararg - apply the action
  60. class CCIfNotVarArg<CCAction A> : CCIf<"!State.isVarArg()", A> {}
  61. /// CCAssignToReg - This action matches if there is a register in the specified
  62. /// list that is still available. If so, it assigns the value to the first
  63. /// available register and succeeds.
  64. class CCAssignToReg<list<Register> regList> : CCAction {
  65. list<Register> RegList = regList;
  66. }
  67. /// CCAssignToRegWithShadow - Same as CCAssignToReg, but with list of registers
  68. /// which became shadowed, when some register is used.
  69. class CCAssignToRegWithShadow<list<Register> regList,
  70. list<Register> shadowList> : CCAction {
  71. list<Register> RegList = regList;
  72. list<Register> ShadowRegList = shadowList;
  73. }
  74. /// CCAssignToStack - This action always matches: it assigns the value to a
  75. /// stack slot of the specified size and alignment on the stack. If size is
  76. /// zero then the ABI size is used; if align is zero then the ABI alignment
  77. /// is used - these may depend on the target or subtarget.
  78. class CCAssignToStack<int size, int align> : CCAction {
  79. int Size = size;
  80. int Align = align;
  81. }
  82. /// CCAssignToStackWithShadow - Same as CCAssignToStack, but with a list of
  83. /// registers to be shadowed. Note that, unlike CCAssignToRegWithShadow, this
  84. /// shadows ALL of the registers in shadowList.
  85. class CCAssignToStackWithShadow<int size,
  86. int align,
  87. list<Register> shadowList> : CCAction {
  88. int Size = size;
  89. int Align = align;
  90. list<Register> ShadowRegList = shadowList;
  91. }
  92. /// CCPassByVal - This action always matches: it assigns the value to a stack
  93. /// slot to implement ByVal aggregate parameter passing. Size and alignment
  94. /// specify the minimum size and alignment for the stack slot.
  95. class CCPassByVal<int size, int align> : CCAction {
  96. int Size = size;
  97. int Align = align;
  98. }
  99. /// CCPromoteToType - If applied, this promotes the specified current value to
  100. /// the specified type.
  101. class CCPromoteToType<ValueType destTy> : CCAction {
  102. ValueType DestTy = destTy;
  103. }
  104. /// CCPromoteToUpperBitsInType - If applied, this promotes the specified current
  105. /// value to the specified type and shifts the value into the upper bits.
  106. class CCPromoteToUpperBitsInType<ValueType destTy> : CCAction {
  107. ValueType DestTy = destTy;
  108. }
  109. /// CCBitConvertToType - If applied, this bitconverts the specified current
  110. /// value to the specified type.
  111. class CCBitConvertToType<ValueType destTy> : CCAction {
  112. ValueType DestTy = destTy;
  113. }
  114. /// CCPassIndirect - If applied, this stores the value to stack and passes the pointer
  115. /// as normal argument.
  116. class CCPassIndirect<ValueType destTy> : CCAction {
  117. ValueType DestTy = destTy;
  118. }
  119. /// CCDelegateTo - This action invokes the specified sub-calling-convention. It
  120. /// is successful if the specified CC matches.
  121. class CCDelegateTo<CallingConv cc> : CCAction {
  122. CallingConv CC = cc;
  123. }
  124. /// CallingConv - An instance of this is used to define each calling convention
  125. /// that the target supports.
  126. class CallingConv<list<CCAction> actions> {
  127. list<CCAction> Actions = actions;
  128. bit Custom = 0;
  129. }
  130. /// CustomCallingConv - An instance of this is used to declare calling
  131. /// conventions that are implemented using a custom function of the same name.
  132. class CustomCallingConv : CallingConv<[]> {
  133. let Custom = 1;
  134. }
  135. /// CalleeSavedRegs - A list of callee saved registers for a given calling
  136. /// convention. The order of registers is used by PrologEpilogInsertion when
  137. /// allocation stack slots for saved registers.
  138. ///
  139. /// For each CalleeSavedRegs def, TableGen will emit a FOO_SaveList array for
  140. /// returning from getCalleeSavedRegs(), and a FOO_RegMask bit mask suitable for
  141. /// returning from getCallPreservedMask().
  142. class CalleeSavedRegs<dag saves> {
  143. dag SaveList = saves;
  144. // Registers that are also preserved across function calls, but should not be
  145. // included in the generated FOO_SaveList array. These registers will be
  146. // included in the FOO_RegMask bit mask. This can be used for registers that
  147. // are saved automatically, like the SPARC register windows.
  148. dag OtherPreserved;
  149. }