LegalizeTypes.h revision 38a9de35d55d7a5a3224cea99528fae4067bdc2b
1//===-- LegalizeTypes.h - Definition of the DAG Type Legalizer class ------===// 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 16#ifndef SELECTIONDAG_LEGALIZETYPES_H 17#define SELECTIONDAG_LEGALIZETYPES_H 18 19#define DEBUG_TYPE "legalize-types" 20#include "llvm/CodeGen/SelectionDAG.h" 21#include "llvm/Target/TargetLowering.h" 22#include "llvm/ADT/DenseMap.h" 23#include "llvm/Support/Compiler.h" 24#include "llvm/Support/Debug.h" 25 26namespace llvm { 27 28//===----------------------------------------------------------------------===// 29/// DAGTypeLegalizer - This takes an arbitrary SelectionDAG as input and hacks 30/// on it until only value types the target machine can handle are left. This 31/// involves promoting small sizes to large sizes or splitting up large values 32/// into small values. 33/// 34class VISIBILITY_HIDDEN DAGTypeLegalizer { 35 TargetLowering &TLI; 36 SelectionDAG &DAG; 37public: 38 // NodeIDFlags - This pass uses the NodeID on the SDNodes to hold information 39 // about the state of the node. The enum has all the values. 40 enum NodeIDFlags { 41 /// ReadyToProcess - All operands have been processed, so this node is ready 42 /// to be handled. 43 ReadyToProcess = 0, 44 45 /// NewNode - This is a new node that was created in the process of 46 /// legalizing some other node. 47 NewNode = -1, 48 49 /// Processed - This is a node that has already been processed. 50 Processed = -2 51 52 // 1+ - This is a node which has this many unlegalized operands. 53 }; 54private: 55 enum LegalizeAction { 56 Legal, // The target natively supports this type. 57 PromoteInteger, // Replace this integer type with a larger one. 58 ExpandInteger, // Split this integer type into two of half the size. 59 SoftenFloat, // Convert this float type to a same size integer type. 60 ExpandFloat, // Split this float type into two of half the size. 61 ScalarizeVector, // Replace this one-element vector with its element type. 62 SplitVector // This vector type should be split into smaller vectors. 63 }; 64 65 /// ValueTypeActions - This is a bitvector that contains two bits for each 66 /// simple value type, where the two bits correspond to the LegalizeAction 67 /// enum from TargetLowering. This can be queried with "getTypeAction(VT)". 68 TargetLowering::ValueTypeActionImpl ValueTypeActions; 69 70 /// getTypeAction - Return how we should legalize values of this type, either 71 /// it is already legal, or we need to promote it to a larger integer type, or 72 /// we need to expand it into multiple registers of a smaller integer type, or 73 /// we need to split a vector type into smaller vector types, or we need to 74 /// convert it to a different type of the same size. 75 LegalizeAction getTypeAction(MVT VT) const { 76 switch (ValueTypeActions.getTypeAction(VT)) { 77 default: 78 assert(false && "Unknown legalize action!"); 79 case TargetLowering::Legal: 80 return Legal; 81 case TargetLowering::Promote: 82 return PromoteInteger; 83 case TargetLowering::Expand: 84 // Expand can mean 85 // 1) split scalar in half, 2) convert a float to an integer, 86 // 3) scalarize a single-element vector, 4) split a vector in two. 87 if (!VT.isVector()) { 88 if (VT.isInteger()) 89 return ExpandInteger; 90 else if (VT.getSizeInBits() == 91 TLI.getTypeToTransformTo(VT).getSizeInBits()) 92 return SoftenFloat; 93 else 94 return ExpandFloat; 95 } else if (VT.getVectorNumElements() == 1) { 96 return ScalarizeVector; 97 } else { 98 return SplitVector; 99 } 100 } 101 } 102 103 /// isTypeLegal - Return true if this type is legal on this target. 104 bool isTypeLegal(MVT VT) const { 105 return ValueTypeActions.getTypeAction(VT) == TargetLowering::Legal; 106 } 107 108 /// IgnoreNodeResults - Pretend all of this node's results are legal. 109 bool IgnoreNodeResults(SDNode *N) const { 110 return N->getOpcode() == ISD::TargetConstant; 111 } 112 113 /// PromotedIntegers - For integer nodes that are below legal width, this map 114 /// indicates what promoted value to use. 115 DenseMap<SDOperand, SDOperand> PromotedIntegers; 116 117 /// ExpandedIntegers - For integer nodes that need to be expanded this map 118 /// indicates which operands are the expanded version of the input. 119 DenseMap<SDOperand, std::pair<SDOperand, SDOperand> > ExpandedIntegers; 120 121 /// SoftenedFloats - For floating point nodes converted to integers of 122 /// the same size, this map indicates the converted value to use. 123 DenseMap<SDOperand, SDOperand> SoftenedFloats; 124 125 /// ExpandedFloats - For float nodes that need to be expanded this map 126 /// indicates which operands are the expanded version of the input. 127 DenseMap<SDOperand, std::pair<SDOperand, SDOperand> > ExpandedFloats; 128 129 /// ScalarizedVectors - For nodes that are <1 x ty>, this map indicates the 130 /// scalar value of type 'ty' to use. 131 DenseMap<SDOperand, SDOperand> ScalarizedVectors; 132 133 /// SplitVectors - For nodes that need to be split this map indicates 134 /// which operands are the expanded version of the input. 135 DenseMap<SDOperand, std::pair<SDOperand, SDOperand> > SplitVectors; 136 137 /// ReplacedNodes - For nodes that have been replaced with another, 138 /// indicates the replacement node to use. 139 DenseMap<SDOperand, SDOperand> ReplacedNodes; 140 141 /// Worklist - This defines a worklist of nodes to process. In order to be 142 /// pushed onto this worklist, all operands of a node must have already been 143 /// processed. 144 SmallVector<SDNode*, 128> Worklist; 145 146public: 147 explicit DAGTypeLegalizer(SelectionDAG &dag) 148 : TLI(dag.getTargetLoweringInfo()), DAG(dag), 149 ValueTypeActions(TLI.getValueTypeActions()) { 150 assert(MVT::LAST_VALUETYPE <= 32 && 151 "Too many value types for ValueTypeActions to hold!"); 152 } 153 154 void run(); 155 156 /// ReanalyzeNode - Recompute the NodeID and correct processed operands 157 /// for the specified node, adding it to the worklist if ready. 158 void ReanalyzeNode(SDNode *N) { 159 N->setNodeId(NewNode); 160 AnalyzeNewNode(N); 161 } 162 163 void NoteDeletion(SDNode *Old, SDNode *New) { 164 ExpungeNode(Old); 165 ExpungeNode(New); 166 for (unsigned i = 0, e = Old->getNumValues(); i != e; ++i) 167 ReplacedNodes[SDOperand(Old, i)] = SDOperand(New, i); 168 } 169 170private: 171 void AnalyzeNewNode(SDNode *&N); 172 173 void ReplaceValueWith(SDOperand From, SDOperand To); 174 void ReplaceNodeWith(SDNode *From, SDNode *To); 175 176 void RemapNode(SDOperand &N); 177 void ExpungeNode(SDNode *N); 178 179 // Common routines. 180 SDOperand CreateStackStoreLoad(SDOperand Op, MVT DestVT); 181 SDOperand MakeLibCall(RTLIB::Libcall LC, MVT RetVT, 182 const SDOperand *Ops, unsigned NumOps, bool isSigned); 183 184 SDOperand BitConvertToInteger(SDOperand Op); 185 SDOperand JoinIntegers(SDOperand Lo, SDOperand Hi); 186 void SplitInteger(SDOperand Op, SDOperand &Lo, SDOperand &Hi); 187 void SplitInteger(SDOperand Op, MVT LoVT, MVT HiVT, 188 SDOperand &Lo, SDOperand &Hi); 189 190 SDOperand GetVectorElementPointer(SDOperand VecPtr, MVT EltVT, 191 SDOperand Index); 192 193 //===--------------------------------------------------------------------===// 194 // Integer Promotion Support: LegalizeIntegerTypes.cpp 195 //===--------------------------------------------------------------------===// 196 197 SDOperand GetPromotedInteger(SDOperand Op) { 198 SDOperand &PromotedOp = PromotedIntegers[Op]; 199 RemapNode(PromotedOp); 200 assert(PromotedOp.Val && "Operand wasn't promoted?"); 201 return PromotedOp; 202 } 203 void SetPromotedInteger(SDOperand Op, SDOperand Result); 204 205 /// ZExtPromotedInteger - Get a promoted operand and zero extend it to the 206 /// final size. 207 SDOperand ZExtPromotedInteger(SDOperand Op) { 208 MVT OldVT = Op.getValueType(); 209 Op = GetPromotedInteger(Op); 210 return DAG.getZeroExtendInReg(Op, OldVT); 211 } 212 213 // Integer Result Promotion. 214 void PromoteIntegerResult(SDNode *N, unsigned ResNo); 215 SDOperand PromoteIntRes_AssertSext(SDNode *N); 216 SDOperand PromoteIntRes_AssertZext(SDNode *N); 217 SDOperand PromoteIntRes_BIT_CONVERT(SDNode *N); 218 SDOperand PromoteIntRes_BSWAP(SDNode *N); 219 SDOperand PromoteIntRes_BUILD_PAIR(SDNode *N); 220 SDOperand PromoteIntRes_Constant(SDNode *N); 221 SDOperand PromoteIntRes_CTLZ(SDNode *N); 222 SDOperand PromoteIntRes_CTPOP(SDNode *N); 223 SDOperand PromoteIntRes_CTTZ(SDNode *N); 224 SDOperand PromoteIntRes_EXTRACT_VECTOR_ELT(SDNode *N); 225 SDOperand PromoteIntRes_FP_TO_XINT(SDNode *N); 226 SDOperand PromoteIntRes_INT_EXTEND(SDNode *N); 227 SDOperand PromoteIntRes_LOAD(LoadSDNode *N); 228 SDOperand PromoteIntRes_SDIV(SDNode *N); 229 SDOperand PromoteIntRes_SELECT (SDNode *N); 230 SDOperand PromoteIntRes_SELECT_CC(SDNode *N); 231 SDOperand PromoteIntRes_SETCC(SDNode *N); 232 SDOperand PromoteIntRes_SHL(SDNode *N); 233 SDOperand PromoteIntRes_SimpleIntBinOp(SDNode *N); 234 SDOperand PromoteIntRes_SIGN_EXTEND_INREG(SDNode *N); 235 SDOperand PromoteIntRes_SRA(SDNode *N); 236 SDOperand PromoteIntRes_SRL(SDNode *N); 237 SDOperand PromoteIntRes_TRUNCATE(SDNode *N); 238 SDOperand PromoteIntRes_UDIV(SDNode *N); 239 SDOperand PromoteIntRes_UNDEF(SDNode *N); 240 SDOperand PromoteIntRes_VAARG(SDNode *N); 241 242 // Integer Operand Promotion. 243 bool PromoteIntegerOperand(SDNode *N, unsigned OperandNo); 244 SDOperand PromoteIntOp_ANY_EXTEND(SDNode *N); 245 SDOperand PromoteIntOp_BUILD_PAIR(SDNode *N); 246 SDOperand PromoteIntOp_BR_CC(SDNode *N, unsigned OpNo); 247 SDOperand PromoteIntOp_BRCOND(SDNode *N, unsigned OpNo); 248 SDOperand PromoteIntOp_BUILD_VECTOR(SDNode *N); 249 SDOperand PromoteIntOp_FP_EXTEND(SDNode *N); 250 SDOperand PromoteIntOp_FP_ROUND(SDNode *N); 251 SDOperand PromoteIntOp_INT_TO_FP(SDNode *N); 252 SDOperand PromoteIntOp_INSERT_VECTOR_ELT(SDNode *N, unsigned OpNo); 253 SDOperand PromoteIntOp_MEMBARRIER(SDNode *N); 254 SDOperand PromoteIntOp_SELECT(SDNode *N, unsigned OpNo); 255 SDOperand PromoteIntOp_SELECT_CC(SDNode *N, unsigned OpNo); 256 SDOperand PromoteIntOp_SETCC(SDNode *N, unsigned OpNo); 257 SDOperand PromoteIntOp_SIGN_EXTEND(SDNode *N); 258 SDOperand PromoteIntOp_STORE(StoreSDNode *N, unsigned OpNo); 259 SDOperand PromoteIntOp_TRUNCATE(SDNode *N); 260 SDOperand PromoteIntOp_ZERO_EXTEND(SDNode *N); 261 262 void PromoteSetCCOperands(SDOperand &LHS,SDOperand &RHS, ISD::CondCode Code); 263 264 //===--------------------------------------------------------------------===// 265 // Integer Expansion Support: LegalizeIntegerTypes.cpp 266 //===--------------------------------------------------------------------===// 267 268 void GetExpandedInteger(SDOperand Op, SDOperand &Lo, SDOperand &Hi); 269 void SetExpandedInteger(SDOperand Op, SDOperand Lo, SDOperand Hi); 270 271 // Integer Result Expansion. 272 void ExpandIntegerResult(SDNode *N, unsigned ResNo); 273 void ExpandIntRes_ANY_EXTEND (SDNode *N, SDOperand &Lo, SDOperand &Hi); 274 void ExpandIntRes_AssertSext (SDNode *N, SDOperand &Lo, SDOperand &Hi); 275 void ExpandIntRes_AssertZext (SDNode *N, SDOperand &Lo, SDOperand &Hi); 276 void ExpandIntRes_Constant (SDNode *N, SDOperand &Lo, SDOperand &Hi); 277 void ExpandIntRes_CTLZ (SDNode *N, SDOperand &Lo, SDOperand &Hi); 278 void ExpandIntRes_CTPOP (SDNode *N, SDOperand &Lo, SDOperand &Hi); 279 void ExpandIntRes_CTTZ (SDNode *N, SDOperand &Lo, SDOperand &Hi); 280 void ExpandIntRes_LOAD (LoadSDNode *N, SDOperand &Lo, SDOperand &Hi); 281 void ExpandIntRes_SIGN_EXTEND (SDNode *N, SDOperand &Lo, SDOperand &Hi); 282 void ExpandIntRes_SIGN_EXTEND_INREG (SDNode *N, SDOperand &Lo, SDOperand &Hi); 283 void ExpandIntRes_TRUNCATE (SDNode *N, SDOperand &Lo, SDOperand &Hi); 284 void ExpandIntRes_ZERO_EXTEND (SDNode *N, SDOperand &Lo, SDOperand &Hi); 285 void ExpandIntRes_FP_TO_SINT (SDNode *N, SDOperand &Lo, SDOperand &Hi); 286 void ExpandIntRes_FP_TO_UINT (SDNode *N, SDOperand &Lo, SDOperand &Hi); 287 288 void ExpandIntRes_Logical (SDNode *N, SDOperand &Lo, SDOperand &Hi); 289 void ExpandIntRes_ADDSUB (SDNode *N, SDOperand &Lo, SDOperand &Hi); 290 void ExpandIntRes_ADDSUBC (SDNode *N, SDOperand &Lo, SDOperand &Hi); 291 void ExpandIntRes_ADDSUBE (SDNode *N, SDOperand &Lo, SDOperand &Hi); 292 void ExpandIntRes_BSWAP (SDNode *N, SDOperand &Lo, SDOperand &Hi); 293 void ExpandIntRes_MUL (SDNode *N, SDOperand &Lo, SDOperand &Hi); 294 void ExpandIntRes_SDIV (SDNode *N, SDOperand &Lo, SDOperand &Hi); 295 void ExpandIntRes_SREM (SDNode *N, SDOperand &Lo, SDOperand &Hi); 296 void ExpandIntRes_UDIV (SDNode *N, SDOperand &Lo, SDOperand &Hi); 297 void ExpandIntRes_UREM (SDNode *N, SDOperand &Lo, SDOperand &Hi); 298 void ExpandIntRes_Shift (SDNode *N, SDOperand &Lo, SDOperand &Hi); 299 300 void ExpandShiftByConstant(SDNode *N, unsigned Amt, 301 SDOperand &Lo, SDOperand &Hi); 302 bool ExpandShiftWithKnownAmountBit(SDNode *N, SDOperand &Lo, SDOperand &Hi); 303 304 // Integer Operand Expansion. 305 bool ExpandIntegerOperand(SDNode *N, unsigned OperandNo); 306 SDOperand ExpandIntOp_BIT_CONVERT(SDNode *N); 307 SDOperand ExpandIntOp_BR_CC(SDNode *N); 308 SDOperand ExpandIntOp_BUILD_VECTOR(SDNode *N); 309 SDOperand ExpandIntOp_EXTRACT_ELEMENT(SDNode *N); 310 SDOperand ExpandIntOp_SELECT_CC(SDNode *N); 311 SDOperand ExpandIntOp_SETCC(SDNode *N); 312 SDOperand ExpandIntOp_SINT_TO_FP(SDNode *N); 313 SDOperand ExpandIntOp_STORE(StoreSDNode *N, unsigned OpNo); 314 SDOperand ExpandIntOp_TRUNCATE(SDNode *N); 315 SDOperand ExpandIntOp_UINT_TO_FP(SDNode *N); 316 317 void IntegerExpandSetCCOperands(SDOperand &NewLHS, SDOperand &NewRHS, 318 ISD::CondCode &CCCode); 319 320 //===--------------------------------------------------------------------===// 321 // Float to Integer Conversion Support: LegalizeFloatTypes.cpp 322 //===--------------------------------------------------------------------===// 323 324 SDOperand GetSoftenedFloat(SDOperand Op) { 325 SDOperand &SoftenedOp = SoftenedFloats[Op]; 326 RemapNode(SoftenedOp); 327 assert(SoftenedOp.Val && "Operand wasn't converted to integer?"); 328 return SoftenedOp; 329 } 330 void SetSoftenedFloat(SDOperand Op, SDOperand Result); 331 332 // Result Float to Integer Conversion. 333 void SoftenFloatResult(SDNode *N, unsigned OpNo); 334 SDOperand SoftenFloatRes_BIT_CONVERT(SDNode *N); 335 SDOperand SoftenFloatRes_BUILD_PAIR(SDNode *N); 336 SDOperand SoftenFloatRes_ConstantFP(ConstantFPSDNode *N); 337 SDOperand SoftenFloatRes_FADD(SDNode *N); 338 SDOperand SoftenFloatRes_FCOPYSIGN(SDNode *N); 339 SDOperand SoftenFloatRes_FMUL(SDNode *N); 340 SDOperand SoftenFloatRes_FP_EXTEND(SDNode *N); 341 SDOperand SoftenFloatRes_FP_ROUND(SDNode *N); 342 SDOperand SoftenFloatRes_FPOWI(SDNode *N); 343 SDOperand SoftenFloatRes_FSUB(SDNode *N); 344 SDOperand SoftenFloatRes_LOAD(SDNode *N); 345 SDOperand SoftenFloatRes_SELECT(SDNode *N); 346 SDOperand SoftenFloatRes_SELECT_CC(SDNode *N); 347 SDOperand SoftenFloatRes_SINT_TO_FP(SDNode *N); 348 SDOperand SoftenFloatRes_UINT_TO_FP(SDNode *N); 349 350 // Operand Float to Integer Conversion. 351 bool SoftenFloatOperand(SDNode *N, unsigned OpNo); 352 SDOperand SoftenFloatOp_BIT_CONVERT(SDNode *N); 353 SDOperand SoftenFloatOp_BR_CC(SDNode *N); 354 SDOperand SoftenFloatOp_FP_TO_SINT(SDNode *N); 355 SDOperand SoftenFloatOp_FP_TO_UINT(SDNode *N); 356 SDOperand SoftenFloatOp_SELECT_CC(SDNode *N); 357 SDOperand SoftenFloatOp_SETCC(SDNode *N); 358 SDOperand SoftenFloatOp_STORE(SDNode *N, unsigned OpNo); 359 360 void SoftenSetCCOperands(SDOperand &NewLHS, SDOperand &NewRHS, 361 ISD::CondCode &CCCode); 362 363 //===--------------------------------------------------------------------===// 364 // Float Expansion Support: LegalizeFloatTypes.cpp 365 //===--------------------------------------------------------------------===// 366 367 void GetExpandedFloat(SDOperand Op, SDOperand &Lo, SDOperand &Hi); 368 void SetExpandedFloat(SDOperand Op, SDOperand Lo, SDOperand Hi); 369 370 // Float Result Expansion. 371 void ExpandFloatResult(SDNode *N, unsigned ResNo); 372 void ExpandFloatRes_ConstantFP(SDNode *N, SDOperand &Lo, SDOperand &Hi); 373 void ExpandFloatRes_FABS (SDNode *N, SDOperand &Lo, SDOperand &Hi); 374 void ExpandFloatRes_FADD (SDNode *N, SDOperand &Lo, SDOperand &Hi); 375 void ExpandFloatRes_FDIV (SDNode *N, SDOperand &Lo, SDOperand &Hi); 376 void ExpandFloatRes_FMUL (SDNode *N, SDOperand &Lo, SDOperand &Hi); 377 void ExpandFloatRes_FNEG (SDNode *N, SDOperand &Lo, SDOperand &Hi); 378 void ExpandFloatRes_FP_EXTEND (SDNode *N, SDOperand &Lo, SDOperand &Hi); 379 void ExpandFloatRes_FSUB (SDNode *N, SDOperand &Lo, SDOperand &Hi); 380 void ExpandFloatRes_LOAD (SDNode *N, SDOperand &Lo, SDOperand &Hi); 381 void ExpandFloatRes_XINT_TO_FP(SDNode *N, SDOperand &Lo, SDOperand &Hi); 382 383 // Float Operand Expansion. 384 bool ExpandFloatOperand(SDNode *N, unsigned OperandNo); 385 SDOperand ExpandFloatOp_BR_CC(SDNode *N); 386 SDOperand ExpandFloatOp_FP_ROUND(SDNode *N); 387 SDOperand ExpandFloatOp_FP_TO_SINT(SDNode *N); 388 SDOperand ExpandFloatOp_FP_TO_UINT(SDNode *N); 389 SDOperand ExpandFloatOp_SELECT_CC(SDNode *N); 390 SDOperand ExpandFloatOp_SETCC(SDNode *N); 391 SDOperand ExpandFloatOp_STORE(SDNode *N, unsigned OpNo); 392 393 void FloatExpandSetCCOperands(SDOperand &NewLHS, SDOperand &NewRHS, 394 ISD::CondCode &CCCode); 395 396 //===--------------------------------------------------------------------===// 397 // Scalarization Support: LegalizeVectorTypes.cpp 398 //===--------------------------------------------------------------------===// 399 400 SDOperand GetScalarizedVector(SDOperand Op) { 401 SDOperand &ScalarizedOp = ScalarizedVectors[Op]; 402 RemapNode(ScalarizedOp); 403 assert(ScalarizedOp.Val && "Operand wasn't scalarized?"); 404 return ScalarizedOp; 405 } 406 void SetScalarizedVector(SDOperand Op, SDOperand Result); 407 408 // Vector Result Scalarization: <1 x ty> -> ty. 409 void ScalarizeVectorResult(SDNode *N, unsigned OpNo); 410 SDOperand ScalarizeVecRes_BinOp(SDNode *N); 411 SDOperand ScalarizeVecRes_UnaryOp(SDNode *N); 412 413 SDOperand ScalarizeVecRes_BIT_CONVERT(SDNode *N); 414 SDOperand ScalarizeVecRes_FPOWI(SDNode *N); 415 SDOperand ScalarizeVecRes_INSERT_VECTOR_ELT(SDNode *N); 416 SDOperand ScalarizeVecRes_LOAD(LoadSDNode *N); 417 SDOperand ScalarizeVecRes_SELECT(SDNode *N); 418 SDOperand ScalarizeVecRes_UNDEF(SDNode *N); 419 SDOperand ScalarizeVecRes_VECTOR_SHUFFLE(SDNode *N); 420 421 // Vector Operand Scalarization: <1 x ty> -> ty. 422 bool ScalarizeVectorOperand(SDNode *N, unsigned OpNo); 423 SDOperand ScalarizeVecOp_BIT_CONVERT(SDNode *N); 424 SDOperand ScalarizeVecOp_EXTRACT_VECTOR_ELT(SDNode *N); 425 SDOperand ScalarizeVecOp_STORE(StoreSDNode *N, unsigned OpNo); 426 427 //===--------------------------------------------------------------------===// 428 // Vector Splitting Support: LegalizeVectorTypes.cpp 429 //===--------------------------------------------------------------------===// 430 431 void GetSplitVector(SDOperand Op, SDOperand &Lo, SDOperand &Hi); 432 void SetSplitVector(SDOperand Op, SDOperand Lo, SDOperand Hi); 433 434 // Vector Result Splitting: <128 x ty> -> 2 x <64 x ty>. 435 void SplitVectorResult(SDNode *N, unsigned OpNo); 436 437 void SplitVecRes_UNDEF(SDNode *N, SDOperand &Lo, SDOperand &Hi); 438 void SplitVecRes_LOAD(LoadSDNode *N, SDOperand &Lo, SDOperand &Hi); 439 void SplitVecRes_BUILD_PAIR(SDNode *N, SDOperand &Lo, SDOperand &Hi); 440 void SplitVecRes_INSERT_VECTOR_ELT(SDNode *N, SDOperand &Lo, SDOperand &Hi); 441 void SplitVecRes_VECTOR_SHUFFLE(SDNode *N, SDOperand &Lo, SDOperand &Hi); 442 443 void SplitVecRes_BUILD_VECTOR(SDNode *N, SDOperand &Lo, SDOperand &Hi); 444 void SplitVecRes_CONCAT_VECTORS(SDNode *N, SDOperand &Lo, SDOperand &Hi); 445 void SplitVecRes_BIT_CONVERT(SDNode *N, SDOperand &Lo, SDOperand &Hi); 446 void SplitVecRes_UnOp(SDNode *N, SDOperand &Lo, SDOperand &Hi); 447 void SplitVecRes_BinOp(SDNode *N, SDOperand &Lo, SDOperand &Hi); 448 void SplitVecRes_FPOWI(SDNode *N, SDOperand &Lo, SDOperand &Hi); 449 450 // Vector Operand Splitting: <128 x ty> -> 2 x <64 x ty>. 451 bool SplitVectorOperand(SDNode *N, unsigned OpNo); 452 453 SDOperand SplitVecOp_BIT_CONVERT(SDNode *N); 454 SDOperand SplitVecOp_EXTRACT_SUBVECTOR(SDNode *N); 455 SDOperand SplitVecOp_EXTRACT_VECTOR_ELT(SDNode *N); 456 SDOperand SplitVecOp_STORE(StoreSDNode *N, unsigned OpNo); 457 SDOperand SplitVecOp_VECTOR_SHUFFLE(SDNode *N, unsigned OpNo); 458 459 //===--------------------------------------------------------------------===// 460 // Generic Splitting: LegalizeTypesGeneric.cpp 461 //===--------------------------------------------------------------------===// 462 463 // Legalization methods which only use that the illegal type is split into two 464 // not necessarily identical types. As such they can be used for splitting 465 // vectors and expanding integers and floats. 466 467 void GetSplitOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi) { 468 if (Op.getValueType().isVector()) 469 GetSplitVector(Op, Lo, Hi); 470 else if (Op.getValueType().isInteger()) 471 GetExpandedInteger(Op, Lo, Hi); 472 else 473 GetExpandedFloat(Op, Lo, Hi); 474 } 475 476 /// GetSplitDestVTs - Compute the VTs needed for the low/hi parts of a type 477 /// which is split (or expanded) into two not necessarily identical pieces. 478 void GetSplitDestVTs(MVT InVT, MVT &LoVT, MVT &HiVT); 479 480 // Generic Result Splitting. 481 void SplitRes_MERGE_VALUES(SDNode *N, SDOperand &Lo, SDOperand &Hi); 482 void SplitRes_SELECT (SDNode *N, SDOperand &Lo, SDOperand &Hi); 483 void SplitRes_SELECT_CC (SDNode *N, SDOperand &Lo, SDOperand &Hi); 484 void SplitRes_UNDEF (SDNode *N, SDOperand &Lo, SDOperand &Hi); 485 486 //===--------------------------------------------------------------------===// 487 // Generic Expansion: LegalizeTypesGeneric.cpp 488 //===--------------------------------------------------------------------===// 489 490 // Legalization methods which only use that the illegal type is split into two 491 // identical types of half the size, and that the Lo/Hi part is stored first 492 // in memory on little/big-endian machines, followed by the Hi/Lo part. As 493 // such they can be used for expanding integers and floats. 494 495 void GetExpandedOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi) { 496 if (Op.getValueType().isInteger()) 497 GetExpandedInteger(Op, Lo, Hi); 498 else 499 GetExpandedFloat(Op, Lo, Hi); 500 } 501 502 // Generic Result Expansion. 503 void ExpandRes_BIT_CONVERT (SDNode *N, SDOperand &Lo, SDOperand &Hi); 504 void ExpandRes_BUILD_PAIR (SDNode *N, SDOperand &Lo, SDOperand &Hi); 505 void ExpandRes_EXTRACT_ELEMENT (SDNode *N, SDOperand &Lo, SDOperand &Hi); 506 void ExpandRes_EXTRACT_VECTOR_ELT(SDNode *N, SDOperand &Lo, SDOperand &Hi); 507 void ExpandRes_NormalLoad (SDNode *N, SDOperand &Lo, SDOperand &Hi); 508 509 // Generic Operand Expansion. 510 SDOperand ExpandOp_BIT_CONVERT (SDNode *N); 511 SDOperand ExpandOp_BUILD_VECTOR (SDNode *N); 512 SDOperand ExpandOp_EXTRACT_ELEMENT(SDNode *N); 513 SDOperand ExpandOp_NormalStore (SDNode *N, unsigned OpNo); 514 515}; 516 517} // end namespace llvm. 518 519#endif 520