2
0

LegalizeTypes.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. //===-- LegalizeTypes.h - DAG Type Legalizer class definition ---*- 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 the DAGTypeLegalizer class. This is a private interface
  11. // shared between the code that implements the SelectionDAG::LegalizeTypes
  12. // method.
  13. //
  14. //===----------------------------------------------------------------------===//
  15. #ifndef LLVM_LIB_CODEGEN_SELECTIONDAG_LEGALIZETYPES_H
  16. #define LLVM_LIB_CODEGEN_SELECTIONDAG_LEGALIZETYPES_H
  17. #include "llvm/ADT/DenseMap.h"
  18. #include "llvm/ADT/DenseSet.h"
  19. #include "llvm/CodeGen/SelectionDAG.h"
  20. #include "llvm/Support/Compiler.h"
  21. #include "llvm/Support/Debug.h"
  22. #include "llvm/Target/TargetLowering.h"
  23. namespace llvm {
  24. // //
  25. ///////////////////////////////////////////////////////////////////////////////
  26. /// DAGTypeLegalizer - This takes an arbitrary SelectionDAG as input and hacks
  27. /// on it until only value types the target machine can handle are left. This
  28. /// involves promoting small sizes to large sizes or splitting up large values
  29. /// into small values.
  30. ///
  31. class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
  32. const TargetLowering &TLI;
  33. SelectionDAG &DAG;
  34. public:
  35. // NodeIdFlags - This pass uses the NodeId on the SDNodes to hold information
  36. // about the state of the node. The enum has all the values.
  37. enum NodeIdFlags {
  38. /// ReadyToProcess - All operands have been processed, so this node is ready
  39. /// to be handled.
  40. ReadyToProcess = 0,
  41. /// NewNode - This is a new node, not before seen, that was created in the
  42. /// process of legalizing some other node.
  43. NewNode = -1,
  44. /// Unanalyzed - This node's ID needs to be set to the number of its
  45. /// unprocessed operands.
  46. Unanalyzed = -2,
  47. /// Processed - This is a node that has already been processed.
  48. Processed = -3
  49. // 1+ - This is a node which has this many unprocessed operands.
  50. };
  51. private:
  52. /// ValueTypeActions - This is a bitvector that contains two bits for each
  53. /// simple value type, where the two bits correspond to the LegalizeAction
  54. /// enum from TargetLowering. This can be queried with "getTypeAction(VT)".
  55. TargetLowering::ValueTypeActionImpl ValueTypeActions;
  56. /// getTypeAction - Return how we should legalize values of this type.
  57. TargetLowering::LegalizeTypeAction getTypeAction(EVT VT) const {
  58. return TLI.getTypeAction(*DAG.getContext(), VT);
  59. }
  60. /// isTypeLegal - Return true if this type is legal on this target.
  61. bool isTypeLegal(EVT VT) const {
  62. return TLI.getTypeAction(*DAG.getContext(), VT) == TargetLowering::TypeLegal;
  63. }
  64. EVT getSetCCResultType(EVT VT) const {
  65. return TLI.getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
  66. }
  67. /// IgnoreNodeResults - Pretend all of this node's results are legal.
  68. bool IgnoreNodeResults(SDNode *N) const {
  69. return N->getOpcode() == ISD::TargetConstant;
  70. }
  71. /// PromotedIntegers - For integer nodes that are below legal width, this map
  72. /// indicates what promoted value to use.
  73. SmallDenseMap<SDValue, SDValue, 8> PromotedIntegers;
  74. /// ExpandedIntegers - For integer nodes that need to be expanded this map
  75. /// indicates which operands are the expanded version of the input.
  76. SmallDenseMap<SDValue, std::pair<SDValue, SDValue>, 8> ExpandedIntegers;
  77. /// SoftenedFloats - For floating point nodes converted to integers of
  78. /// the same size, this map indicates the converted value to use.
  79. SmallDenseMap<SDValue, SDValue, 8> SoftenedFloats;
  80. /// PromotedFloats - For floating point nodes that have a smaller precision
  81. /// than the smallest supported precision, this map indicates what promoted
  82. /// value to use.
  83. SmallDenseMap<SDValue, SDValue, 8> PromotedFloats;
  84. /// ExpandedFloats - For float nodes that need to be expanded this map
  85. /// indicates which operands are the expanded version of the input.
  86. SmallDenseMap<SDValue, std::pair<SDValue, SDValue>, 8> ExpandedFloats;
  87. /// ScalarizedVectors - For nodes that are <1 x ty>, this map indicates the
  88. /// scalar value of type 'ty' to use.
  89. SmallDenseMap<SDValue, SDValue, 8> ScalarizedVectors;
  90. /// SplitVectors - For nodes that need to be split this map indicates
  91. /// which operands are the expanded version of the input.
  92. SmallDenseMap<SDValue, std::pair<SDValue, SDValue>, 8> SplitVectors;
  93. /// WidenedVectors - For vector nodes that need to be widened, indicates
  94. /// the widened value to use.
  95. SmallDenseMap<SDValue, SDValue, 8> WidenedVectors;
  96. /// ReplacedValues - For values that have been replaced with another,
  97. /// indicates the replacement value to use.
  98. SmallDenseMap<SDValue, SDValue, 8> ReplacedValues;
  99. /// Worklist - This defines a worklist of nodes to process. In order to be
  100. /// pushed onto this worklist, all operands of a node must have already been
  101. /// processed.
  102. SmallVector<SDNode*, 128> Worklist;
  103. public:
  104. explicit DAGTypeLegalizer(SelectionDAG &dag)
  105. : TLI(dag.getTargetLoweringInfo()), DAG(dag),
  106. ValueTypeActions(TLI.getValueTypeActions()) {
  107. static_assert(MVT::LAST_VALUETYPE <= MVT::MAX_ALLOWED_VALUETYPE,
  108. "Too many value types for ValueTypeActions to hold!");
  109. }
  110. /// run - This is the main entry point for the type legalizer. This does a
  111. /// top-down traversal of the dag, legalizing types as it goes. Returns
  112. /// "true" if it made any changes.
  113. bool run();
  114. void NoteDeletion(SDNode *Old, SDNode *New) {
  115. ExpungeNode(Old);
  116. ExpungeNode(New);
  117. for (unsigned i = 0, e = Old->getNumValues(); i != e; ++i)
  118. ReplacedValues[SDValue(Old, i)] = SDValue(New, i);
  119. }
  120. SelectionDAG &getDAG() const { return DAG; }
  121. private:
  122. SDNode *AnalyzeNewNode(SDNode *N);
  123. void AnalyzeNewValue(SDValue &Val);
  124. void ExpungeNode(SDNode *N);
  125. void PerformExpensiveChecks();
  126. void RemapValue(SDValue &N);
  127. // Common routines.
  128. SDValue BitConvertToInteger(SDValue Op);
  129. SDValue BitConvertVectorToIntegerVector(SDValue Op);
  130. SDValue CreateStackStoreLoad(SDValue Op, EVT DestVT);
  131. bool CustomLowerNode(SDNode *N, EVT VT, bool LegalizeResult);
  132. bool CustomWidenLowerNode(SDNode *N, EVT VT);
  133. /// DisintegrateMERGE_VALUES - Replace each result of the given MERGE_VALUES
  134. /// node with the corresponding input operand, except for the result 'ResNo',
  135. /// for which the corresponding input operand is returned.
  136. SDValue DisintegrateMERGE_VALUES(SDNode *N, unsigned ResNo);
  137. SDValue GetVectorElementPointer(SDValue VecPtr, EVT EltVT, SDValue Index);
  138. SDValue JoinIntegers(SDValue Lo, SDValue Hi);
  139. SDValue LibCallify(RTLIB::Libcall LC, SDNode *N, bool isSigned);
  140. std::pair<SDValue, SDValue> ExpandChainLibCall(RTLIB::Libcall LC,
  141. SDNode *Node, bool isSigned);
  142. std::pair<SDValue, SDValue> ExpandAtomic(SDNode *Node);
  143. SDValue PromoteTargetBoolean(SDValue Bool, EVT ValVT);
  144. void ReplaceValueWith(SDValue From, SDValue To);
  145. void SplitInteger(SDValue Op, SDValue &Lo, SDValue &Hi);
  146. void SplitInteger(SDValue Op, EVT LoVT, EVT HiVT,
  147. SDValue &Lo, SDValue &Hi);
  148. //===--------------------------------------------------------------------===//
  149. // Integer Promotion Support: LegalizeIntegerTypes.cpp
  150. //===--------------------------------------------------------------------===//
  151. /// GetPromotedInteger - Given a processed operand Op which was promoted to a
  152. /// larger integer type, this returns the promoted value. The low bits of the
  153. /// promoted value corresponding to the original type are exactly equal to Op.
  154. /// The extra bits contain rubbish, so the promoted value may need to be zero-
  155. /// or sign-extended from the original type before it is usable (the helpers
  156. /// SExtPromotedInteger and ZExtPromotedInteger can do this for you).
  157. /// For example, if Op is an i16 and was promoted to an i32, then this method
  158. /// returns an i32, the lower 16 bits of which coincide with Op, and the upper
  159. /// 16 bits of which contain rubbish.
  160. SDValue GetPromotedInteger(SDValue Op) {
  161. SDValue &PromotedOp = PromotedIntegers[Op];
  162. RemapValue(PromotedOp);
  163. assert(PromotedOp.getNode() && "Operand wasn't promoted?");
  164. return PromotedOp;
  165. }
  166. void SetPromotedInteger(SDValue Op, SDValue Result);
  167. /// SExtPromotedInteger - Get a promoted operand and sign extend it to the
  168. /// final size.
  169. SDValue SExtPromotedInteger(SDValue Op) {
  170. EVT OldVT = Op.getValueType();
  171. SDLoc dl(Op);
  172. Op = GetPromotedInteger(Op);
  173. return DAG.getNode(ISD::SIGN_EXTEND_INREG, dl, Op.getValueType(), Op,
  174. DAG.getValueType(OldVT));
  175. }
  176. /// ZExtPromotedInteger - Get a promoted operand and zero extend it to the
  177. /// final size.
  178. SDValue ZExtPromotedInteger(SDValue Op) {
  179. EVT OldVT = Op.getValueType();
  180. SDLoc dl(Op);
  181. Op = GetPromotedInteger(Op);
  182. return DAG.getZeroExtendInReg(Op, dl, OldVT.getScalarType());
  183. }
  184. // Integer Result Promotion.
  185. void PromoteIntegerResult(SDNode *N, unsigned ResNo);
  186. SDValue PromoteIntRes_MERGE_VALUES(SDNode *N, unsigned ResNo);
  187. SDValue PromoteIntRes_AssertSext(SDNode *N);
  188. SDValue PromoteIntRes_AssertZext(SDNode *N);
  189. SDValue PromoteIntRes_Atomic0(AtomicSDNode *N);
  190. SDValue PromoteIntRes_Atomic1(AtomicSDNode *N);
  191. SDValue PromoteIntRes_AtomicCmpSwap(AtomicSDNode *N, unsigned ResNo);
  192. SDValue PromoteIntRes_EXTRACT_SUBVECTOR(SDNode *N);
  193. SDValue PromoteIntRes_VECTOR_SHUFFLE(SDNode *N);
  194. SDValue PromoteIntRes_BUILD_VECTOR(SDNode *N);
  195. SDValue PromoteIntRes_SCALAR_TO_VECTOR(SDNode *N);
  196. SDValue PromoteIntRes_INSERT_VECTOR_ELT(SDNode *N);
  197. SDValue PromoteIntRes_CONCAT_VECTORS(SDNode *N);
  198. SDValue PromoteIntRes_BITCAST(SDNode *N);
  199. SDValue PromoteIntRes_BSWAP(SDNode *N);
  200. SDValue PromoteIntRes_BUILD_PAIR(SDNode *N);
  201. SDValue PromoteIntRes_Constant(SDNode *N);
  202. SDValue PromoteIntRes_CONVERT_RNDSAT(SDNode *N);
  203. SDValue PromoteIntRes_CTLZ(SDNode *N);
  204. SDValue PromoteIntRes_CTPOP(SDNode *N);
  205. SDValue PromoteIntRes_CTTZ(SDNode *N);
  206. SDValue PromoteIntRes_EXTRACT_VECTOR_ELT(SDNode *N);
  207. SDValue PromoteIntRes_FP_TO_XINT(SDNode *N);
  208. SDValue PromoteIntRes_FP_TO_FP16(SDNode *N);
  209. SDValue PromoteIntRes_INT_EXTEND(SDNode *N);
  210. SDValue PromoteIntRes_LOAD(LoadSDNode *N);
  211. SDValue PromoteIntRes_MLOAD(MaskedLoadSDNode *N);
  212. SDValue PromoteIntRes_Overflow(SDNode *N);
  213. SDValue PromoteIntRes_SADDSUBO(SDNode *N, unsigned ResNo);
  214. SDValue PromoteIntRes_SDIV(SDNode *N);
  215. SDValue PromoteIntRes_SELECT(SDNode *N);
  216. SDValue PromoteIntRes_VSELECT(SDNode *N);
  217. SDValue PromoteIntRes_SELECT_CC(SDNode *N);
  218. SDValue PromoteIntRes_SETCC(SDNode *N);
  219. SDValue PromoteIntRes_SHL(SDNode *N);
  220. SDValue PromoteIntRes_SimpleIntBinOp(SDNode *N);
  221. SDValue PromoteIntRes_SIGN_EXTEND_INREG(SDNode *N);
  222. SDValue PromoteIntRes_SRA(SDNode *N);
  223. SDValue PromoteIntRes_SRL(SDNode *N);
  224. SDValue PromoteIntRes_TRUNCATE(SDNode *N);
  225. SDValue PromoteIntRes_UADDSUBO(SDNode *N, unsigned ResNo);
  226. SDValue PromoteIntRes_UDIV(SDNode *N);
  227. SDValue PromoteIntRes_UNDEF(SDNode *N);
  228. SDValue PromoteIntRes_VAARG(SDNode *N);
  229. SDValue PromoteIntRes_XMULO(SDNode *N, unsigned ResNo);
  230. // Integer Operand Promotion.
  231. bool PromoteIntegerOperand(SDNode *N, unsigned OperandNo);
  232. SDValue PromoteIntOp_ANY_EXTEND(SDNode *N);
  233. SDValue PromoteIntOp_ATOMIC_STORE(AtomicSDNode *N);
  234. SDValue PromoteIntOp_BITCAST(SDNode *N);
  235. SDValue PromoteIntOp_BUILD_PAIR(SDNode *N);
  236. SDValue PromoteIntOp_BR_CC(SDNode *N, unsigned OpNo);
  237. SDValue PromoteIntOp_BRCOND(SDNode *N, unsigned OpNo);
  238. SDValue PromoteIntOp_BUILD_VECTOR(SDNode *N);
  239. SDValue PromoteIntOp_CONVERT_RNDSAT(SDNode *N);
  240. SDValue PromoteIntOp_INSERT_VECTOR_ELT(SDNode *N, unsigned OpNo);
  241. SDValue PromoteIntOp_EXTRACT_ELEMENT(SDNode *N);
  242. SDValue PromoteIntOp_EXTRACT_VECTOR_ELT(SDNode *N);
  243. SDValue PromoteIntOp_EXTRACT_SUBVECTOR(SDNode *N);
  244. SDValue PromoteIntOp_CONCAT_VECTORS(SDNode *N);
  245. SDValue PromoteIntOp_SCALAR_TO_VECTOR(SDNode *N);
  246. SDValue PromoteIntOp_SELECT(SDNode *N, unsigned OpNo);
  247. SDValue PromoteIntOp_SELECT_CC(SDNode *N, unsigned OpNo);
  248. SDValue PromoteIntOp_SETCC(SDNode *N, unsigned OpNo);
  249. SDValue PromoteIntOp_VSETCC(SDNode *N, unsigned OpNo);
  250. SDValue PromoteIntOp_Shift(SDNode *N);
  251. SDValue PromoteIntOp_SIGN_EXTEND(SDNode *N);
  252. SDValue PromoteIntOp_SINT_TO_FP(SDNode *N);
  253. SDValue PromoteIntOp_STORE(StoreSDNode *N, unsigned OpNo);
  254. SDValue PromoteIntOp_TRUNCATE(SDNode *N);
  255. SDValue PromoteIntOp_UINT_TO_FP(SDNode *N);
  256. SDValue PromoteIntOp_ZERO_EXTEND(SDNode *N);
  257. SDValue PromoteIntOp_MSTORE(MaskedStoreSDNode *N, unsigned OpNo);
  258. SDValue PromoteIntOp_MLOAD(MaskedLoadSDNode *N, unsigned OpNo);
  259. void PromoteSetCCOperands(SDValue &LHS,SDValue &RHS, ISD::CondCode Code);
  260. //===--------------------------------------------------------------------===//
  261. // Integer Expansion Support: LegalizeIntegerTypes.cpp
  262. //===--------------------------------------------------------------------===//
  263. /// GetExpandedInteger - Given a processed operand Op which was expanded into
  264. /// two integers of half the size, this returns the two halves. The low bits
  265. /// of Op are exactly equal to the bits of Lo; the high bits exactly equal Hi.
  266. /// For example, if Op is an i64 which was expanded into two i32's, then this
  267. /// method returns the two i32's, with Lo being equal to the lower 32 bits of
  268. /// Op, and Hi being equal to the upper 32 bits.
  269. void GetExpandedInteger(SDValue Op, SDValue &Lo, SDValue &Hi);
  270. void SetExpandedInteger(SDValue Op, SDValue Lo, SDValue Hi);
  271. // Integer Result Expansion.
  272. void ExpandIntegerResult(SDNode *N, unsigned ResNo);
  273. void ExpandIntRes_MERGE_VALUES (SDNode *N, unsigned ResNo,
  274. SDValue &Lo, SDValue &Hi);
  275. void ExpandIntRes_ANY_EXTEND (SDNode *N, SDValue &Lo, SDValue &Hi);
  276. void ExpandIntRes_AssertSext (SDNode *N, SDValue &Lo, SDValue &Hi);
  277. void ExpandIntRes_AssertZext (SDNode *N, SDValue &Lo, SDValue &Hi);
  278. void ExpandIntRes_Constant (SDNode *N, SDValue &Lo, SDValue &Hi);
  279. void ExpandIntRes_CTLZ (SDNode *N, SDValue &Lo, SDValue &Hi);
  280. void ExpandIntRes_CTPOP (SDNode *N, SDValue &Lo, SDValue &Hi);
  281. void ExpandIntRes_CTTZ (SDNode *N, SDValue &Lo, SDValue &Hi);
  282. void ExpandIntRes_LOAD (LoadSDNode *N, SDValue &Lo, SDValue &Hi);
  283. void ExpandIntRes_SIGN_EXTEND (SDNode *N, SDValue &Lo, SDValue &Hi);
  284. void ExpandIntRes_SIGN_EXTEND_INREG (SDNode *N, SDValue &Lo, SDValue &Hi);
  285. void ExpandIntRes_TRUNCATE (SDNode *N, SDValue &Lo, SDValue &Hi);
  286. void ExpandIntRes_ZERO_EXTEND (SDNode *N, SDValue &Lo, SDValue &Hi);
  287. void ExpandIntRes_FP_TO_SINT (SDNode *N, SDValue &Lo, SDValue &Hi);
  288. void ExpandIntRes_FP_TO_UINT (SDNode *N, SDValue &Lo, SDValue &Hi);
  289. void ExpandIntRes_Logical (SDNode *N, SDValue &Lo, SDValue &Hi);
  290. void ExpandIntRes_ADDSUB (SDNode *N, SDValue &Lo, SDValue &Hi);
  291. void ExpandIntRes_ADDSUBC (SDNode *N, SDValue &Lo, SDValue &Hi);
  292. void ExpandIntRes_ADDSUBE (SDNode *N, SDValue &Lo, SDValue &Hi);
  293. void ExpandIntRes_BSWAP (SDNode *N, SDValue &Lo, SDValue &Hi);
  294. void ExpandIntRes_MUL (SDNode *N, SDValue &Lo, SDValue &Hi);
  295. void ExpandIntRes_SDIV (SDNode *N, SDValue &Lo, SDValue &Hi);
  296. void ExpandIntRes_SREM (SDNode *N, SDValue &Lo, SDValue &Hi);
  297. void ExpandIntRes_UDIV (SDNode *N, SDValue &Lo, SDValue &Hi);
  298. void ExpandIntRes_UREM (SDNode *N, SDValue &Lo, SDValue &Hi);
  299. void ExpandIntRes_Shift (SDNode *N, SDValue &Lo, SDValue &Hi);
  300. void ExpandIntRes_SADDSUBO (SDNode *N, SDValue &Lo, SDValue &Hi);
  301. void ExpandIntRes_UADDSUBO (SDNode *N, SDValue &Lo, SDValue &Hi);
  302. void ExpandIntRes_XMULO (SDNode *N, SDValue &Lo, SDValue &Hi);
  303. void ExpandIntRes_ATOMIC_LOAD (SDNode *N, SDValue &Lo, SDValue &Hi);
  304. void ExpandShiftByConstant(SDNode *N, const APInt &Amt,
  305. SDValue &Lo, SDValue &Hi);
  306. bool ExpandShiftWithKnownAmountBit(SDNode *N, SDValue &Lo, SDValue &Hi);
  307. bool ExpandShiftWithUnknownAmountBit(SDNode *N, SDValue &Lo, SDValue &Hi);
  308. // Integer Operand Expansion.
  309. bool ExpandIntegerOperand(SDNode *N, unsigned OperandNo);
  310. SDValue ExpandIntOp_BITCAST(SDNode *N);
  311. SDValue ExpandIntOp_BR_CC(SDNode *N);
  312. SDValue ExpandIntOp_BUILD_VECTOR(SDNode *N);
  313. SDValue ExpandIntOp_EXTRACT_ELEMENT(SDNode *N);
  314. SDValue ExpandIntOp_SELECT_CC(SDNode *N);
  315. SDValue ExpandIntOp_SETCC(SDNode *N);
  316. SDValue ExpandIntOp_Shift(SDNode *N);
  317. SDValue ExpandIntOp_SINT_TO_FP(SDNode *N);
  318. SDValue ExpandIntOp_STORE(StoreSDNode *N, unsigned OpNo);
  319. SDValue ExpandIntOp_TRUNCATE(SDNode *N);
  320. SDValue ExpandIntOp_UINT_TO_FP(SDNode *N);
  321. SDValue ExpandIntOp_RETURNADDR(SDNode *N);
  322. SDValue ExpandIntOp_ATOMIC_STORE(SDNode *N);
  323. void IntegerExpandSetCCOperands(SDValue &NewLHS, SDValue &NewRHS,
  324. ISD::CondCode &CCCode, SDLoc dl);
  325. //===--------------------------------------------------------------------===//
  326. // Float to Integer Conversion Support: LegalizeFloatTypes.cpp
  327. //===--------------------------------------------------------------------===//
  328. /// GetSoftenedFloat - Given a processed operand Op which was converted to an
  329. /// integer of the same size, this returns the integer. The integer contains
  330. /// exactly the same bits as Op - only the type changed. For example, if Op
  331. /// is an f32 which was softened to an i32, then this method returns an i32,
  332. /// the bits of which coincide with those of Op.
  333. SDValue GetSoftenedFloat(SDValue Op) {
  334. SDValue &SoftenedOp = SoftenedFloats[Op];
  335. RemapValue(SoftenedOp);
  336. assert(SoftenedOp.getNode() && "Operand wasn't converted to integer?");
  337. return SoftenedOp;
  338. }
  339. void SetSoftenedFloat(SDValue Op, SDValue Result);
  340. // Result Float to Integer Conversion.
  341. void SoftenFloatResult(SDNode *N, unsigned OpNo);
  342. SDValue SoftenFloatRes_MERGE_VALUES(SDNode *N, unsigned ResNo);
  343. SDValue SoftenFloatRes_BITCAST(SDNode *N);
  344. SDValue SoftenFloatRes_BUILD_PAIR(SDNode *N);
  345. SDValue SoftenFloatRes_ConstantFP(ConstantFPSDNode *N);
  346. SDValue SoftenFloatRes_EXTRACT_VECTOR_ELT(SDNode *N);
  347. SDValue SoftenFloatRes_FABS(SDNode *N);
  348. SDValue SoftenFloatRes_FMINNUM(SDNode *N);
  349. SDValue SoftenFloatRes_FMAXNUM(SDNode *N);
  350. SDValue SoftenFloatRes_FADD(SDNode *N);
  351. SDValue SoftenFloatRes_FCEIL(SDNode *N);
  352. SDValue SoftenFloatRes_FCOPYSIGN(SDNode *N);
  353. SDValue SoftenFloatRes_FCOS(SDNode *N);
  354. SDValue SoftenFloatRes_FDIV(SDNode *N);
  355. SDValue SoftenFloatRes_FEXP(SDNode *N);
  356. SDValue SoftenFloatRes_FEXP2(SDNode *N);
  357. SDValue SoftenFloatRes_FFLOOR(SDNode *N);
  358. SDValue SoftenFloatRes_FLOG(SDNode *N);
  359. SDValue SoftenFloatRes_FLOG2(SDNode *N);
  360. SDValue SoftenFloatRes_FLOG10(SDNode *N);
  361. SDValue SoftenFloatRes_FMA(SDNode *N);
  362. SDValue SoftenFloatRes_FMUL(SDNode *N);
  363. SDValue SoftenFloatRes_FNEARBYINT(SDNode *N);
  364. SDValue SoftenFloatRes_FNEG(SDNode *N);
  365. SDValue SoftenFloatRes_FP_EXTEND(SDNode *N);
  366. SDValue SoftenFloatRes_FP16_TO_FP(SDNode *N);
  367. SDValue SoftenFloatRes_FP_ROUND(SDNode *N);
  368. SDValue SoftenFloatRes_FPOW(SDNode *N);
  369. SDValue SoftenFloatRes_FPOWI(SDNode *N);
  370. SDValue SoftenFloatRes_FREM(SDNode *N);
  371. SDValue SoftenFloatRes_FRINT(SDNode *N);
  372. SDValue SoftenFloatRes_FROUND(SDNode *N);
  373. SDValue SoftenFloatRes_FSIN(SDNode *N);
  374. SDValue SoftenFloatRes_FSQRT(SDNode *N);
  375. SDValue SoftenFloatRes_FSUB(SDNode *N);
  376. SDValue SoftenFloatRes_FTRUNC(SDNode *N);
  377. SDValue SoftenFloatRes_LOAD(SDNode *N);
  378. SDValue SoftenFloatRes_SELECT(SDNode *N);
  379. SDValue SoftenFloatRes_SELECT_CC(SDNode *N);
  380. SDValue SoftenFloatRes_UNDEF(SDNode *N);
  381. SDValue SoftenFloatRes_VAARG(SDNode *N);
  382. SDValue SoftenFloatRes_XINT_TO_FP(SDNode *N);
  383. // Operand Float to Integer Conversion.
  384. bool SoftenFloatOperand(SDNode *N, unsigned OpNo);
  385. SDValue SoftenFloatOp_BITCAST(SDNode *N);
  386. SDValue SoftenFloatOp_BR_CC(SDNode *N);
  387. SDValue SoftenFloatOp_FP_EXTEND(SDNode *N);
  388. SDValue SoftenFloatOp_FP_ROUND(SDNode *N);
  389. SDValue SoftenFloatOp_FP_TO_SINT(SDNode *N);
  390. SDValue SoftenFloatOp_FP_TO_UINT(SDNode *N);
  391. SDValue SoftenFloatOp_SELECT_CC(SDNode *N);
  392. SDValue SoftenFloatOp_SETCC(SDNode *N);
  393. SDValue SoftenFloatOp_STORE(SDNode *N, unsigned OpNo);
  394. //===--------------------------------------------------------------------===//
  395. // Float Expansion Support: LegalizeFloatTypes.cpp
  396. //===--------------------------------------------------------------------===//
  397. /// GetExpandedFloat - Given a processed operand Op which was expanded into
  398. /// two floating point values of half the size, this returns the two halves.
  399. /// The low bits of Op are exactly equal to the bits of Lo; the high bits
  400. /// exactly equal Hi. For example, if Op is a ppcf128 which was expanded
  401. /// into two f64's, then this method returns the two f64's, with Lo being
  402. /// equal to the lower 64 bits of Op, and Hi to the upper 64 bits.
  403. void GetExpandedFloat(SDValue Op, SDValue &Lo, SDValue &Hi);
  404. void SetExpandedFloat(SDValue Op, SDValue Lo, SDValue Hi);
  405. // Float Result Expansion.
  406. void ExpandFloatResult(SDNode *N, unsigned ResNo);
  407. void ExpandFloatRes_ConstantFP(SDNode *N, SDValue &Lo, SDValue &Hi);
  408. void ExpandFloatRes_FABS (SDNode *N, SDValue &Lo, SDValue &Hi);
  409. void ExpandFloatRes_FMINNUM (SDNode *N, SDValue &Lo, SDValue &Hi);
  410. void ExpandFloatRes_FMAXNUM (SDNode *N, SDValue &Lo, SDValue &Hi);
  411. void ExpandFloatRes_FADD (SDNode *N, SDValue &Lo, SDValue &Hi);
  412. void ExpandFloatRes_FCEIL (SDNode *N, SDValue &Lo, SDValue &Hi);
  413. void ExpandFloatRes_FCOPYSIGN (SDNode *N, SDValue &Lo, SDValue &Hi);
  414. void ExpandFloatRes_FCOS (SDNode *N, SDValue &Lo, SDValue &Hi);
  415. void ExpandFloatRes_FDIV (SDNode *N, SDValue &Lo, SDValue &Hi);
  416. void ExpandFloatRes_FEXP (SDNode *N, SDValue &Lo, SDValue &Hi);
  417. void ExpandFloatRes_FEXP2 (SDNode *N, SDValue &Lo, SDValue &Hi);
  418. void ExpandFloatRes_FFLOOR (SDNode *N, SDValue &Lo, SDValue &Hi);
  419. void ExpandFloatRes_FLOG (SDNode *N, SDValue &Lo, SDValue &Hi);
  420. void ExpandFloatRes_FLOG2 (SDNode *N, SDValue &Lo, SDValue &Hi);
  421. void ExpandFloatRes_FLOG10 (SDNode *N, SDValue &Lo, SDValue &Hi);
  422. void ExpandFloatRes_FMA (SDNode *N, SDValue &Lo, SDValue &Hi);
  423. void ExpandFloatRes_FMUL (SDNode *N, SDValue &Lo, SDValue &Hi);
  424. void ExpandFloatRes_FNEARBYINT(SDNode *N, SDValue &Lo, SDValue &Hi);
  425. void ExpandFloatRes_FNEG (SDNode *N, SDValue &Lo, SDValue &Hi);
  426. void ExpandFloatRes_FP_EXTEND (SDNode *N, SDValue &Lo, SDValue &Hi);
  427. void ExpandFloatRes_FPOW (SDNode *N, SDValue &Lo, SDValue &Hi);
  428. void ExpandFloatRes_FPOWI (SDNode *N, SDValue &Lo, SDValue &Hi);
  429. void ExpandFloatRes_FREM (SDNode *N, SDValue &Lo, SDValue &Hi);
  430. void ExpandFloatRes_FRINT (SDNode *N, SDValue &Lo, SDValue &Hi);
  431. void ExpandFloatRes_FROUND (SDNode *N, SDValue &Lo, SDValue &Hi);
  432. void ExpandFloatRes_FSIN (SDNode *N, SDValue &Lo, SDValue &Hi);
  433. void ExpandFloatRes_FSQRT (SDNode *N, SDValue &Lo, SDValue &Hi);
  434. void ExpandFloatRes_FSUB (SDNode *N, SDValue &Lo, SDValue &Hi);
  435. void ExpandFloatRes_FTRUNC (SDNode *N, SDValue &Lo, SDValue &Hi);
  436. void ExpandFloatRes_LOAD (SDNode *N, SDValue &Lo, SDValue &Hi);
  437. void ExpandFloatRes_XINT_TO_FP(SDNode *N, SDValue &Lo, SDValue &Hi);
  438. // Float Operand Expansion.
  439. bool ExpandFloatOperand(SDNode *N, unsigned OperandNo);
  440. SDValue ExpandFloatOp_BR_CC(SDNode *N);
  441. SDValue ExpandFloatOp_FCOPYSIGN(SDNode *N);
  442. SDValue ExpandFloatOp_FP_ROUND(SDNode *N);
  443. SDValue ExpandFloatOp_FP_TO_SINT(SDNode *N);
  444. SDValue ExpandFloatOp_FP_TO_UINT(SDNode *N);
  445. SDValue ExpandFloatOp_SELECT_CC(SDNode *N);
  446. SDValue ExpandFloatOp_SETCC(SDNode *N);
  447. SDValue ExpandFloatOp_STORE(SDNode *N, unsigned OpNo);
  448. void FloatExpandSetCCOperands(SDValue &NewLHS, SDValue &NewRHS,
  449. ISD::CondCode &CCCode, SDLoc dl);
  450. //===--------------------------------------------------------------------===//
  451. // Float promotion support: LegalizeFloatTypes.cpp
  452. //===--------------------------------------------------------------------===//
  453. SDValue GetPromotedFloat(SDValue Op) {
  454. SDValue &PromotedOp = PromotedFloats[Op];
  455. RemapValue(PromotedOp);
  456. assert(PromotedOp.getNode() && "Operand wasn't promoted?");
  457. return PromotedOp;
  458. }
  459. void SetPromotedFloat(SDValue Op, SDValue Result);
  460. void PromoteFloatResult(SDNode *N, unsigned ResNo);
  461. SDValue PromoteFloatRes_BITCAST(SDNode *N);
  462. SDValue PromoteFloatRes_BinOp(SDNode *N);
  463. SDValue PromoteFloatRes_ConstantFP(SDNode *N);
  464. SDValue PromoteFloatRes_EXTRACT_VECTOR_ELT(SDNode *N);
  465. SDValue PromoteFloatRes_FCOPYSIGN(SDNode *N);
  466. SDValue PromoteFloatRes_FMAD(SDNode *N);
  467. SDValue PromoteFloatRes_FPOWI(SDNode *N);
  468. SDValue PromoteFloatRes_FP_ROUND(SDNode *N);
  469. SDValue PromoteFloatRes_LOAD(SDNode *N);
  470. SDValue PromoteFloatRes_SELECT(SDNode *N);
  471. SDValue PromoteFloatRes_SELECT_CC(SDNode *N);
  472. SDValue PromoteFloatRes_UnaryOp(SDNode *N);
  473. SDValue PromoteFloatRes_UNDEF(SDNode *N);
  474. SDValue PromoteFloatRes_XINT_TO_FP(SDNode *N);
  475. bool PromoteFloatOperand(SDNode *N, unsigned ResNo);
  476. SDValue PromoteFloatOp_BITCAST(SDNode *N, unsigned OpNo);
  477. SDValue PromoteFloatOp_FCOPYSIGN(SDNode *N, unsigned OpNo);
  478. SDValue PromoteFloatOp_FP_EXTEND(SDNode *N, unsigned OpNo);
  479. SDValue PromoteFloatOp_FP_TO_XINT(SDNode *N, unsigned OpNo);
  480. SDValue PromoteFloatOp_STORE(SDNode *N, unsigned OpNo);
  481. SDValue PromoteFloatOp_SELECT_CC(SDNode *N, unsigned OpNo);
  482. SDValue PromoteFloatOp_SETCC(SDNode *N, unsigned OpNo);
  483. //===--------------------------------------------------------------------===//
  484. // Scalarization Support: LegalizeVectorTypes.cpp
  485. //===--------------------------------------------------------------------===//
  486. /// GetScalarizedVector - Given a processed one-element vector Op which was
  487. /// scalarized to its element type, this returns the element. For example,
  488. /// if Op is a v1i32, Op = < i32 val >, this method returns val, an i32.
  489. SDValue GetScalarizedVector(SDValue Op) {
  490. SDValue &ScalarizedOp = ScalarizedVectors[Op];
  491. RemapValue(ScalarizedOp);
  492. assert(ScalarizedOp.getNode() && "Operand wasn't scalarized?");
  493. return ScalarizedOp;
  494. }
  495. void SetScalarizedVector(SDValue Op, SDValue Result);
  496. // Vector Result Scalarization: <1 x ty> -> ty.
  497. void ScalarizeVectorResult(SDNode *N, unsigned OpNo);
  498. SDValue ScalarizeVecRes_MERGE_VALUES(SDNode *N, unsigned ResNo);
  499. SDValue ScalarizeVecRes_BinOp(SDNode *N);
  500. SDValue ScalarizeVecRes_TernaryOp(SDNode *N);
  501. SDValue ScalarizeVecRes_UnaryOp(SDNode *N);
  502. SDValue ScalarizeVecRes_InregOp(SDNode *N);
  503. SDValue ScalarizeVecRes_BITCAST(SDNode *N);
  504. SDValue ScalarizeVecRes_BUILD_VECTOR(SDNode *N);
  505. SDValue ScalarizeVecRes_CONVERT_RNDSAT(SDNode *N);
  506. SDValue ScalarizeVecRes_EXTRACT_SUBVECTOR(SDNode *N);
  507. SDValue ScalarizeVecRes_FP_ROUND(SDNode *N);
  508. SDValue ScalarizeVecRes_FPOWI(SDNode *N);
  509. SDValue ScalarizeVecRes_INSERT_VECTOR_ELT(SDNode *N);
  510. SDValue ScalarizeVecRes_LOAD(LoadSDNode *N);
  511. SDValue ScalarizeVecRes_SCALAR_TO_VECTOR(SDNode *N);
  512. SDValue ScalarizeVecRes_SIGN_EXTEND_INREG(SDNode *N);
  513. SDValue ScalarizeVecRes_VSELECT(SDNode *N);
  514. SDValue ScalarizeVecRes_SELECT(SDNode *N);
  515. SDValue ScalarizeVecRes_SELECT_CC(SDNode *N);
  516. SDValue ScalarizeVecRes_SETCC(SDNode *N);
  517. SDValue ScalarizeVecRes_UNDEF(SDNode *N);
  518. SDValue ScalarizeVecRes_VECTOR_SHUFFLE(SDNode *N);
  519. SDValue ScalarizeVecRes_VSETCC(SDNode *N);
  520. // Vector Operand Scalarization: <1 x ty> -> ty.
  521. bool ScalarizeVectorOperand(SDNode *N, unsigned OpNo);
  522. SDValue ScalarizeVecOp_BITCAST(SDNode *N);
  523. SDValue ScalarizeVecOp_UnaryOp(SDNode *N);
  524. SDValue ScalarizeVecOp_CONCAT_VECTORS(SDNode *N);
  525. SDValue ScalarizeVecOp_EXTRACT_VECTOR_ELT(SDNode *N);
  526. SDValue ScalarizeVecOp_VSELECT(SDNode *N);
  527. SDValue ScalarizeVecOp_STORE(StoreSDNode *N, unsigned OpNo);
  528. SDValue ScalarizeVecOp_FP_ROUND(SDNode *N, unsigned OpNo);
  529. //===--------------------------------------------------------------------===//
  530. // Vector Splitting Support: LegalizeVectorTypes.cpp
  531. //===--------------------------------------------------------------------===//
  532. /// GetSplitVector - Given a processed vector Op which was split into vectors
  533. /// of half the size, this method returns the halves. The first elements of
  534. /// Op coincide with the elements of Lo; the remaining elements of Op coincide
  535. /// with the elements of Hi: Op is what you would get by concatenating Lo and
  536. /// Hi. For example, if Op is a v8i32 that was split into two v4i32's, then
  537. /// this method returns the two v4i32's, with Lo corresponding to the first 4
  538. /// elements of Op, and Hi to the last 4 elements.
  539. void GetSplitVector(SDValue Op, SDValue &Lo, SDValue &Hi);
  540. void SetSplitVector(SDValue Op, SDValue Lo, SDValue Hi);
  541. // Vector Result Splitting: <128 x ty> -> 2 x <64 x ty>.
  542. void SplitVectorResult(SDNode *N, unsigned OpNo);
  543. void SplitVecRes_BinOp(SDNode *N, SDValue &Lo, SDValue &Hi);
  544. void SplitVecRes_TernaryOp(SDNode *N, SDValue &Lo, SDValue &Hi);
  545. void SplitVecRes_UnaryOp(SDNode *N, SDValue &Lo, SDValue &Hi);
  546. void SplitVecRes_ExtendOp(SDNode *N, SDValue &Lo, SDValue &Hi);
  547. void SplitVecRes_InregOp(SDNode *N, SDValue &Lo, SDValue &Hi);
  548. void SplitVecRes_BITCAST(SDNode *N, SDValue &Lo, SDValue &Hi);
  549. void SplitVecRes_BUILD_PAIR(SDNode *N, SDValue &Lo, SDValue &Hi);
  550. void SplitVecRes_BUILD_VECTOR(SDNode *N, SDValue &Lo, SDValue &Hi);
  551. void SplitVecRes_CONCAT_VECTORS(SDNode *N, SDValue &Lo, SDValue &Hi);
  552. void SplitVecRes_EXTRACT_SUBVECTOR(SDNode *N, SDValue &Lo, SDValue &Hi);
  553. void SplitVecRes_INSERT_SUBVECTOR(SDNode *N, SDValue &Lo, SDValue &Hi);
  554. void SplitVecRes_FPOWI(SDNode *N, SDValue &Lo, SDValue &Hi);
  555. void SplitVecRes_INSERT_VECTOR_ELT(SDNode *N, SDValue &Lo, SDValue &Hi);
  556. void SplitVecRes_LOAD(LoadSDNode *N, SDValue &Lo, SDValue &Hi);
  557. void SplitVecRes_MLOAD(MaskedLoadSDNode *N, SDValue &Lo, SDValue &Hi);
  558. void SplitVecRes_MGATHER(MaskedGatherSDNode *N, SDValue &Lo, SDValue &Hi);
  559. void SplitVecRes_SCALAR_TO_VECTOR(SDNode *N, SDValue &Lo, SDValue &Hi);
  560. void SplitVecRes_SIGN_EXTEND_INREG(SDNode *N, SDValue &Lo, SDValue &Hi);
  561. void SplitVecRes_SETCC(SDNode *N, SDValue &Lo, SDValue &Hi);
  562. void SplitVecRes_UNDEF(SDNode *N, SDValue &Lo, SDValue &Hi);
  563. void SplitVecRes_VECTOR_SHUFFLE(ShuffleVectorSDNode *N, SDValue &Lo,
  564. SDValue &Hi);
  565. // Vector Operand Splitting: <128 x ty> -> 2 x <64 x ty>.
  566. bool SplitVectorOperand(SDNode *N, unsigned OpNo);
  567. SDValue SplitVecOp_VSELECT(SDNode *N, unsigned OpNo);
  568. SDValue SplitVecOp_UnaryOp(SDNode *N);
  569. SDValue SplitVecOp_TruncateHelper(SDNode *N);
  570. SDValue SplitVecOp_BITCAST(SDNode *N);
  571. SDValue SplitVecOp_EXTRACT_SUBVECTOR(SDNode *N);
  572. SDValue SplitVecOp_EXTRACT_VECTOR_ELT(SDNode *N);
  573. SDValue SplitVecOp_STORE(StoreSDNode *N, unsigned OpNo);
  574. SDValue SplitVecOp_MSTORE(MaskedStoreSDNode *N, unsigned OpNo);
  575. SDValue SplitVecOp_MSCATTER(MaskedScatterSDNode *N, unsigned OpNo);
  576. SDValue SplitVecOp_MGATHER(MaskedGatherSDNode *N, unsigned OpNo);
  577. SDValue SplitVecOp_CONCAT_VECTORS(SDNode *N);
  578. SDValue SplitVecOp_VSETCC(SDNode *N);
  579. SDValue SplitVecOp_FP_ROUND(SDNode *N);
  580. //===--------------------------------------------------------------------===//
  581. // Vector Widening Support: LegalizeVectorTypes.cpp
  582. //===--------------------------------------------------------------------===//
  583. /// GetWidenedVector - Given a processed vector Op which was widened into a
  584. /// larger vector, this method returns the larger vector. The elements of
  585. /// the returned vector consist of the elements of Op followed by elements
  586. /// containing rubbish. For example, if Op is a v2i32 that was widened to a
  587. /// v4i32, then this method returns a v4i32 for which the first two elements
  588. /// are the same as those of Op, while the last two elements contain rubbish.
  589. SDValue GetWidenedVector(SDValue Op) {
  590. SDValue &WidenedOp = WidenedVectors[Op];
  591. RemapValue(WidenedOp);
  592. assert(WidenedOp.getNode() && "Operand wasn't widened?");
  593. return WidenedOp;
  594. }
  595. void SetWidenedVector(SDValue Op, SDValue Result);
  596. // Widen Vector Result Promotion.
  597. void WidenVectorResult(SDNode *N, unsigned ResNo);
  598. SDValue WidenVecRes_MERGE_VALUES(SDNode* N, unsigned ResNo);
  599. SDValue WidenVecRes_BITCAST(SDNode* N);
  600. SDValue WidenVecRes_BUILD_VECTOR(SDNode* N);
  601. SDValue WidenVecRes_CONCAT_VECTORS(SDNode* N);
  602. SDValue WidenVecRes_CONVERT_RNDSAT(SDNode* N);
  603. SDValue WidenVecRes_EXTRACT_SUBVECTOR(SDNode* N);
  604. SDValue WidenVecRes_INSERT_VECTOR_ELT(SDNode* N);
  605. SDValue WidenVecRes_LOAD(SDNode* N);
  606. SDValue WidenVecRes_MLOAD(MaskedLoadSDNode* N);
  607. SDValue WidenVecRes_SCALAR_TO_VECTOR(SDNode* N);
  608. SDValue WidenVecRes_SIGN_EXTEND_INREG(SDNode* N);
  609. SDValue WidenVecRes_SELECT(SDNode* N);
  610. SDValue WidenVecRes_SELECT_CC(SDNode* N);
  611. SDValue WidenVecRes_SETCC(SDNode* N);
  612. SDValue WidenVecRes_UNDEF(SDNode *N);
  613. SDValue WidenVecRes_VECTOR_SHUFFLE(ShuffleVectorSDNode *N);
  614. SDValue WidenVecRes_VSETCC(SDNode* N);
  615. SDValue WidenVecRes_Ternary(SDNode *N);
  616. SDValue WidenVecRes_Binary(SDNode *N);
  617. SDValue WidenVecRes_BinaryCanTrap(SDNode *N);
  618. SDValue WidenVecRes_Convert(SDNode *N);
  619. SDValue WidenVecRes_POWI(SDNode *N);
  620. SDValue WidenVecRes_Shift(SDNode *N);
  621. SDValue WidenVecRes_Unary(SDNode *N);
  622. SDValue WidenVecRes_InregOp(SDNode *N);
  623. // Widen Vector Operand.
  624. bool WidenVectorOperand(SDNode *N, unsigned OpNo);
  625. SDValue WidenVecOp_BITCAST(SDNode *N);
  626. SDValue WidenVecOp_CONCAT_VECTORS(SDNode *N);
  627. SDValue WidenVecOp_EXTEND(SDNode *N);
  628. SDValue WidenVecOp_EXTRACT_VECTOR_ELT(SDNode *N);
  629. SDValue WidenVecOp_EXTRACT_SUBVECTOR(SDNode *N);
  630. SDValue WidenVecOp_STORE(SDNode* N);
  631. SDValue WidenVecOp_MSTORE(SDNode* N, unsigned OpNo);
  632. SDValue WidenVecOp_SETCC(SDNode* N);
  633. SDValue WidenVecOp_Convert(SDNode *N);
  634. //===--------------------------------------------------------------------===//
  635. // Vector Widening Utilities Support: LegalizeVectorTypes.cpp
  636. //===--------------------------------------------------------------------===//
  637. /// Helper GenWidenVectorLoads - Helper function to generate a set of
  638. /// loads to load a vector with a resulting wider type. It takes
  639. /// LdChain: list of chains for the load to be generated.
  640. /// Ld: load to widen
  641. SDValue GenWidenVectorLoads(SmallVectorImpl<SDValue> &LdChain,
  642. LoadSDNode *LD);
  643. /// GenWidenVectorExtLoads - Helper function to generate a set of extension
  644. /// loads to load a ector with a resulting wider type. It takes
  645. /// LdChain: list of chains for the load to be generated.
  646. /// Ld: load to widen
  647. /// ExtType: extension element type
  648. SDValue GenWidenVectorExtLoads(SmallVectorImpl<SDValue> &LdChain,
  649. LoadSDNode *LD, ISD::LoadExtType ExtType);
  650. /// Helper genWidenVectorStores - Helper function to generate a set of
  651. /// stores to store a widen vector into non-widen memory
  652. /// StChain: list of chains for the stores we have generated
  653. /// ST: store of a widen value
  654. void GenWidenVectorStores(SmallVectorImpl<SDValue> &StChain, StoreSDNode *ST);
  655. /// Helper genWidenVectorTruncStores - Helper function to generate a set of
  656. /// stores to store a truncate widen vector into non-widen memory
  657. /// StChain: list of chains for the stores we have generated
  658. /// ST: store of a widen value
  659. void GenWidenVectorTruncStores(SmallVectorImpl<SDValue> &StChain,
  660. StoreSDNode *ST);
  661. /// Modifies a vector input (widen or narrows) to a vector of NVT. The
  662. /// input vector must have the same element type as NVT.
  663. SDValue ModifyToType(SDValue InOp, EVT WidenVT);
  664. //===--------------------------------------------------------------------===//
  665. // Generic Splitting: LegalizeTypesGeneric.cpp
  666. //===--------------------------------------------------------------------===//
  667. // Legalization methods which only use that the illegal type is split into two
  668. // not necessarily identical types. As such they can be used for splitting
  669. // vectors and expanding integers and floats.
  670. void GetSplitOp(SDValue Op, SDValue &Lo, SDValue &Hi) {
  671. if (Op.getValueType().isVector())
  672. GetSplitVector(Op, Lo, Hi);
  673. else if (Op.getValueType().isInteger())
  674. GetExpandedInteger(Op, Lo, Hi);
  675. else
  676. GetExpandedFloat(Op, Lo, Hi);
  677. }
  678. /// GetPairElements - Use ISD::EXTRACT_ELEMENT nodes to extract the low and
  679. /// high parts of the given value.
  680. void GetPairElements(SDValue Pair, SDValue &Lo, SDValue &Hi);
  681. // Generic Result Splitting.
  682. void SplitRes_MERGE_VALUES(SDNode *N, unsigned ResNo,
  683. SDValue &Lo, SDValue &Hi);
  684. void SplitRes_SELECT (SDNode *N, SDValue &Lo, SDValue &Hi);
  685. void SplitRes_SELECT_CC (SDNode *N, SDValue &Lo, SDValue &Hi);
  686. void SplitRes_UNDEF (SDNode *N, SDValue &Lo, SDValue &Hi);
  687. //===--------------------------------------------------------------------===//
  688. // Generic Expansion: LegalizeTypesGeneric.cpp
  689. //===--------------------------------------------------------------------===//
  690. // Legalization methods which only use that the illegal type is split into two
  691. // identical types of half the size, and that the Lo/Hi part is stored first
  692. // in memory on little/big-endian machines, followed by the Hi/Lo part. As
  693. // such they can be used for expanding integers and floats.
  694. void GetExpandedOp(SDValue Op, SDValue &Lo, SDValue &Hi) {
  695. if (Op.getValueType().isInteger())
  696. GetExpandedInteger(Op, Lo, Hi);
  697. else
  698. GetExpandedFloat(Op, Lo, Hi);
  699. }
  700. /// This function will split the integer \p Op into \p NumElements
  701. /// operations of type \p EltVT and store them in \p Ops.
  702. void IntegerToVector(SDValue Op, unsigned NumElements,
  703. SmallVectorImpl<SDValue> &Ops, EVT EltVT);
  704. // Generic Result Expansion.
  705. void ExpandRes_MERGE_VALUES (SDNode *N, unsigned ResNo,
  706. SDValue &Lo, SDValue &Hi);
  707. void ExpandRes_BITCAST (SDNode *N, SDValue &Lo, SDValue &Hi);
  708. void ExpandRes_BUILD_PAIR (SDNode *N, SDValue &Lo, SDValue &Hi);
  709. void ExpandRes_EXTRACT_ELEMENT (SDNode *N, SDValue &Lo, SDValue &Hi);
  710. void ExpandRes_EXTRACT_VECTOR_ELT(SDNode *N, SDValue &Lo, SDValue &Hi);
  711. void ExpandRes_NormalLoad (SDNode *N, SDValue &Lo, SDValue &Hi);
  712. void ExpandRes_VAARG (SDNode *N, SDValue &Lo, SDValue &Hi);
  713. // Generic Operand Expansion.
  714. SDValue ExpandOp_BITCAST (SDNode *N);
  715. SDValue ExpandOp_BUILD_VECTOR (SDNode *N);
  716. SDValue ExpandOp_EXTRACT_ELEMENT (SDNode *N);
  717. SDValue ExpandOp_INSERT_VECTOR_ELT(SDNode *N);
  718. SDValue ExpandOp_SCALAR_TO_VECTOR (SDNode *N);
  719. SDValue ExpandOp_NormalStore (SDNode *N, unsigned OpNo);
  720. };
  721. } // end namespace llvm.
  722. #endif