LCOV - code coverage report
Current view: top level - lib/CodeGen/SelectionDAG - SelectionDAGDumper.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 110 484 22.7 %
Date: 2017-09-14 15:23:50 Functions: 12 12 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- SelectionDAGDumper.cpp - Implement SelectionDAG::dump() -----------===//
       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 implements the SelectionDAG::dump method and friends.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "ScheduleDAGSDNodes.h"
      15             : #include "llvm/ADT/StringExtras.h"
      16             : #include "llvm/CodeGen/MachineConstantPool.h"
      17             : #include "llvm/CodeGen/MachineFunction.h"
      18             : #include "llvm/CodeGen/MachineModuleInfo.h"
      19             : #include "llvm/CodeGen/SelectionDAG.h"
      20             : #include "llvm/IR/DebugInfo.h"
      21             : #include "llvm/IR/Function.h"
      22             : #include "llvm/IR/Intrinsics.h"
      23             : #include "llvm/Support/Debug.h"
      24             : #include "llvm/Support/GraphWriter.h"
      25             : #include "llvm/Support/Printable.h"
      26             : #include "llvm/Support/raw_ostream.h"
      27             : #include "llvm/Target/TargetInstrInfo.h"
      28             : #include "llvm/Target/TargetIntrinsicInfo.h"
      29             : #include "llvm/Target/TargetMachine.h"
      30             : #include "llvm/Target/TargetRegisterInfo.h"
      31             : #include "llvm/Target/TargetSubtargetInfo.h"
      32             : using namespace llvm;
      33             : 
      34             : static cl::opt<bool>
      35       72306 : VerboseDAGDumping("dag-dump-verbose", cl::Hidden,
      36      216918 :                   cl::desc("Display more information when dumping selection "
      37       72306 :                            "DAG nodes."));
      38             : 
      39          43 : std::string SDNode::getOperationName(const SelectionDAG *G) const {
      40          86 :   switch (getOpcode()) {
      41           0 :   default:
      42           0 :     if (getOpcode() < ISD::BUILTIN_OP_END)
      43           0 :       return "<<Unknown DAG Node>>";
      44           0 :     if (isMachineOpcode()) {
      45           0 :       if (G)
      46           0 :         if (const TargetInstrInfo *TII = G->getSubtarget().getInstrInfo())
      47           0 :           if (getMachineOpcode() < TII->getNumOpcodes())
      48           0 :             return TII->getName(getMachineOpcode());
      49           0 :       return "<<Unknown Machine Node #" + utostr(getOpcode()) + ">>";
      50           0 :     }
      51           0 :     if (G) {
      52           0 :       const TargetLowering &TLI = G->getTargetLoweringInfo();
      53           0 :       const char *Name = TLI.getTargetNodeName(getOpcode());
      54           0 :       if (Name) return Name;
      55           0 :       return "<<Unknown Target Node #" + utostr(getOpcode()) + ">>";
      56           0 :     }
      57           0 :     return "<<Unknown Node #" + utostr(getOpcode()) + ">>";
      58             : 
      59             : #ifndef NDEBUG
      60             :   case ISD::DELETED_NODE:               return "<<Deleted Node!>>";
      61             : #endif
      62           2 :   case ISD::PREFETCH:                   return "Prefetch";
      63           0 :   case ISD::ATOMIC_FENCE:               return "AtomicFence";
      64           0 :   case ISD::ATOMIC_CMP_SWAP:            return "AtomicCmpSwap";
      65           0 :   case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS: return "AtomicCmpSwapWithSuccess";
      66           0 :   case ISD::ATOMIC_SWAP:                return "AtomicSwap";
      67           0 :   case ISD::ATOMIC_LOAD_ADD:            return "AtomicLoadAdd";
      68           0 :   case ISD::ATOMIC_LOAD_SUB:            return "AtomicLoadSub";
      69           0 :   case ISD::ATOMIC_LOAD_AND:            return "AtomicLoadAnd";
      70           0 :   case ISD::ATOMIC_LOAD_OR:             return "AtomicLoadOr";
      71           0 :   case ISD::ATOMIC_LOAD_XOR:            return "AtomicLoadXor";
      72           0 :   case ISD::ATOMIC_LOAD_NAND:           return "AtomicLoadNand";
      73           0 :   case ISD::ATOMIC_LOAD_MIN:            return "AtomicLoadMin";
      74           0 :   case ISD::ATOMIC_LOAD_MAX:            return "AtomicLoadMax";
      75           0 :   case ISD::ATOMIC_LOAD_UMIN:           return "AtomicLoadUMin";
      76           0 :   case ISD::ATOMIC_LOAD_UMAX:           return "AtomicLoadUMax";
      77           0 :   case ISD::ATOMIC_LOAD:                return "AtomicLoad";
      78           0 :   case ISD::ATOMIC_STORE:               return "AtomicStore";
      79           0 :   case ISD::PCMARKER:                   return "PCMarker";
      80           0 :   case ISD::READCYCLECOUNTER:           return "ReadCycleCounter";
      81           0 :   case ISD::SRCVALUE:                   return "SrcValue";
      82           0 :   case ISD::MDNODE_SDNODE:              return "MDNode";
      83           0 :   case ISD::EntryToken:                 return "EntryToken";
      84           0 :   case ISD::TokenFactor:                return "TokenFactor";
      85           0 :   case ISD::AssertSext:                 return "AssertSext";
      86           0 :   case ISD::AssertZext:                 return "AssertZext";
      87             : 
      88           0 :   case ISD::BasicBlock:                 return "BasicBlock";
      89           0 :   case ISD::VALUETYPE:                  return "ValueType";
      90           8 :   case ISD::Register:                   return "Register";
      91           0 :   case ISD::RegisterMask:               return "RegisterMask";
      92          13 :   case ISD::Constant:
      93          26 :     if (cast<ConstantSDNode>(this)->isOpaque())
      94           0 :       return "OpaqueConstant";
      95          26 :     return "Constant";
      96           0 :   case ISD::ConstantFP:                 return "ConstantFP";
      97          12 :   case ISD::GlobalAddress:              return "GlobalAddress";
      98           0 :   case ISD::GlobalTLSAddress:           return "GlobalTLSAddress";
      99           0 :   case ISD::FrameIndex:                 return "FrameIndex";
     100           0 :   case ISD::JumpTable:                  return "JumpTable";
     101           0 :   case ISD::GLOBAL_OFFSET_TABLE:        return "GLOBAL_OFFSET_TABLE";
     102           0 :   case ISD::RETURNADDR:                 return "RETURNADDR";
     103           0 :   case ISD::ADDROFRETURNADDR:           return "ADDROFRETURNADDR";
     104           0 :   case ISD::FRAMEADDR:                  return "FRAMEADDR";
     105           0 :   case ISD::LOCAL_RECOVER:              return "LOCAL_RECOVER";
     106           0 :   case ISD::READ_REGISTER:              return "READ_REGISTER";
     107           0 :   case ISD::WRITE_REGISTER:             return "WRITE_REGISTER";
     108           0 :   case ISD::FRAME_TO_ARGS_OFFSET:       return "FRAME_TO_ARGS_OFFSET";
     109           0 :   case ISD::EH_DWARF_CFA:               return "EH_DWARF_CFA";
     110           0 :   case ISD::EH_RETURN:                  return "EH_RETURN";
     111           0 :   case ISD::EH_SJLJ_SETJMP:             return "EH_SJLJ_SETJMP";
     112           0 :   case ISD::EH_SJLJ_LONGJMP:            return "EH_SJLJ_LONGJMP";
     113           0 :   case ISD::EH_SJLJ_SETUP_DISPATCH:     return "EH_SJLJ_SETUP_DISPATCH";
     114           0 :   case ISD::ConstantPool:               return "ConstantPool";
     115           0 :   case ISD::TargetIndex:                return "TargetIndex";
     116           2 :   case ISD::ExternalSymbol:             return "ExternalSymbol";
     117           0 :   case ISD::BlockAddress:               return "BlockAddress";
     118           0 :   case ISD::INTRINSIC_WO_CHAIN:
     119             :   case ISD::INTRINSIC_VOID:
     120             :   case ISD::INTRINSIC_W_CHAIN: {
     121           0 :     unsigned OpNo = getOpcode() == ISD::INTRINSIC_WO_CHAIN ? 0 : 1;
     122           0 :     unsigned IID = cast<ConstantSDNode>(getOperand(OpNo))->getZExtValue();
     123           0 :     if (IID < Intrinsic::num_intrinsics)
     124           0 :       return Intrinsic::getName((Intrinsic::ID)IID, None);
     125           0 :     else if (const TargetIntrinsicInfo *TII = G->getTarget().getIntrinsicInfo())
     126           0 :       return TII->getName(IID);
     127           0 :     llvm_unreachable("Invalid intrinsic ID");
     128             :   }
     129             : 
     130           0 :   case ISD::BUILD_VECTOR:               return "BUILD_VECTOR";
     131           0 :   case ISD::TargetConstant:
     132           0 :     if (cast<ConstantSDNode>(this)->isOpaque())
     133           0 :       return "OpaqueTargetConstant";
     134           0 :     return "TargetConstant";
     135           0 :   case ISD::TargetConstantFP:           return "TargetConstantFP";
     136           0 :   case ISD::TargetGlobalAddress:        return "TargetGlobalAddress";
     137           0 :   case ISD::TargetGlobalTLSAddress:     return "TargetGlobalTLSAddress";
     138           0 :   case ISD::TargetFrameIndex:           return "TargetFrameIndex";
     139           0 :   case ISD::TargetJumpTable:            return "TargetJumpTable";
     140           0 :   case ISD::TargetConstantPool:         return "TargetConstantPool";
     141           8 :   case ISD::TargetExternalSymbol:       return "TargetExternalSymbol";
     142           0 :   case ISD::MCSymbol:                   return "MCSymbol";
     143           0 :   case ISD::TargetBlockAddress:         return "TargetBlockAddress";
     144             : 
     145           0 :   case ISD::CopyToReg:                  return "CopyToReg";
     146           4 :   case ISD::CopyFromReg:                return "CopyFromReg";
     147           8 :   case ISD::UNDEF:                      return "undef";
     148           0 :   case ISD::MERGE_VALUES:               return "merge_values";
     149           0 :   case ISD::INLINEASM:                  return "inlineasm";
     150           0 :   case ISD::EH_LABEL:                   return "eh_label";
     151           0 :   case ISD::HANDLENODE:                 return "handlenode";
     152             : 
     153             :   // Unary operators
     154           0 :   case ISD::FABS:                       return "fabs";
     155           0 :   case ISD::FMINNUM:                    return "fminnum";
     156           0 :   case ISD::FMAXNUM:                    return "fmaxnum";
     157           0 :   case ISD::FMINNAN:                    return "fminnan";
     158           0 :   case ISD::FMAXNAN:                    return "fmaxnan";
     159           0 :   case ISD::FNEG:                       return "fneg";
     160           0 :   case ISD::FSQRT:                      return "fsqrt";
     161           2 :   case ISD::FSIN:                       return "fsin";
     162           2 :   case ISD::FCOS:                       return "fcos";
     163           0 :   case ISD::FSINCOS:                    return "fsincos";
     164           0 :   case ISD::FTRUNC:                     return "ftrunc";
     165           0 :   case ISD::FFLOOR:                     return "ffloor";
     166           0 :   case ISD::FCEIL:                      return "fceil";
     167           0 :   case ISD::FRINT:                      return "frint";
     168           0 :   case ISD::FNEARBYINT:                 return "fnearbyint";
     169           0 :   case ISD::FROUND:                     return "fround";
     170           0 :   case ISD::FEXP:                       return "fexp";
     171           0 :   case ISD::FEXP2:                      return "fexp2";
     172           0 :   case ISD::FLOG:                       return "flog";
     173           0 :   case ISD::FLOG2:                      return "flog2";
     174           0 :   case ISD::FLOG10:                     return "flog10";
     175             : 
     176             :   // Binary operators
     177           0 :   case ISD::ADD:                        return "add";
     178           0 :   case ISD::SUB:                        return "sub";
     179           0 :   case ISD::MUL:                        return "mul";
     180           0 :   case ISD::MULHU:                      return "mulhu";
     181           0 :   case ISD::MULHS:                      return "mulhs";
     182           4 :   case ISD::SDIV:                       return "sdiv";
     183           0 :   case ISD::UDIV:                       return "udiv";
     184           0 :   case ISD::SREM:                       return "srem";
     185           0 :   case ISD::UREM:                       return "urem";
     186           0 :   case ISD::SMUL_LOHI:                  return "smul_lohi";
     187           0 :   case ISD::UMUL_LOHI:                  return "umul_lohi";
     188           0 :   case ISD::SDIVREM:                    return "sdivrem";
     189           0 :   case ISD::UDIVREM:                    return "udivrem";
     190           0 :   case ISD::AND:                        return "and";
     191           0 :   case ISD::OR:                         return "or";
     192           0 :   case ISD::XOR:                        return "xor";
     193           2 :   case ISD::SHL:                        return "shl";
     194           2 :   case ISD::SRA:                        return "sra";
     195           0 :   case ISD::SRL:                        return "srl";
     196           0 :   case ISD::ROTL:                       return "rotl";
     197           0 :   case ISD::ROTR:                       return "rotr";
     198           0 :   case ISD::FADD:                       return "fadd";
     199           0 :   case ISD::FSUB:                       return "fsub";
     200           0 :   case ISD::FMUL:                       return "fmul";
     201           0 :   case ISD::FDIV:                       return "fdiv";
     202           0 :   case ISD::FMA:                        return "fma";
     203           0 :   case ISD::FMAD:                       return "fmad";
     204           0 :   case ISD::FREM:                       return "frem";
     205           0 :   case ISD::FCOPYSIGN:                  return "fcopysign";
     206           0 :   case ISD::FGETSIGN:                   return "fgetsign";
     207           0 :   case ISD::FCANONICALIZE:              return "fcanonicalize";
     208           0 :   case ISD::FPOW:                       return "fpow";
     209           0 :   case ISD::SMIN:                       return "smin";
     210           0 :   case ISD::SMAX:                       return "smax";
     211           0 :   case ISD::UMIN:                       return "umin";
     212           0 :   case ISD::UMAX:                       return "umax";
     213             : 
     214           0 :   case ISD::FPOWI:                      return "fpowi";
     215           0 :   case ISD::SETCC:                      return "setcc";
     216           0 :   case ISD::SETCCE:                     return "setcce";
     217           0 :   case ISD::SETCCCARRY:                 return "setcccarry";
     218           0 :   case ISD::SELECT:                     return "select";
     219           0 :   case ISD::VSELECT:                    return "vselect";
     220           0 :   case ISD::SELECT_CC:                  return "select_cc";
     221           0 :   case ISD::INSERT_VECTOR_ELT:          return "insert_vector_elt";
     222           0 :   case ISD::EXTRACT_VECTOR_ELT:         return "extract_vector_elt";
     223           0 :   case ISD::CONCAT_VECTORS:             return "concat_vectors";
     224           0 :   case ISD::INSERT_SUBVECTOR:           return "insert_subvector";
     225           0 :   case ISD::EXTRACT_SUBVECTOR:          return "extract_subvector";
     226           0 :   case ISD::SCALAR_TO_VECTOR:           return "scalar_to_vector";
     227           0 :   case ISD::VECTOR_SHUFFLE:             return "vector_shuffle";
     228           0 :   case ISD::CARRY_FALSE:                return "carry_false";
     229           0 :   case ISD::ADDC:                       return "addc";
     230           0 :   case ISD::ADDE:                       return "adde";
     231           0 :   case ISD::ADDCARRY:                   return "addcarry";
     232           0 :   case ISD::SADDO:                      return "saddo";
     233           0 :   case ISD::UADDO:                      return "uaddo";
     234           0 :   case ISD::SSUBO:                      return "ssubo";
     235           0 :   case ISD::USUBO:                      return "usubo";
     236           0 :   case ISD::SMULO:                      return "smulo";
     237           0 :   case ISD::UMULO:                      return "umulo";
     238           0 :   case ISD::SUBC:                       return "subc";
     239           0 :   case ISD::SUBE:                       return "sube";
     240           0 :   case ISD::SUBCARRY:                   return "subcarry";
     241           0 :   case ISD::SHL_PARTS:                  return "shl_parts";
     242           0 :   case ISD::SRA_PARTS:                  return "sra_parts";
     243           0 :   case ISD::SRL_PARTS:                  return "srl_parts";
     244             : 
     245             :   // Conversion operators.
     246           0 :   case ISD::SIGN_EXTEND:                return "sign_extend";
     247           0 :   case ISD::ZERO_EXTEND:                return "zero_extend";
     248           0 :   case ISD::ANY_EXTEND:                 return "any_extend";
     249           0 :   case ISD::SIGN_EXTEND_INREG:          return "sign_extend_inreg";
     250           0 :   case ISD::ANY_EXTEND_VECTOR_INREG:    return "any_extend_vector_inreg";
     251           0 :   case ISD::SIGN_EXTEND_VECTOR_INREG:   return "sign_extend_vector_inreg";
     252           0 :   case ISD::ZERO_EXTEND_VECTOR_INREG:   return "zero_extend_vector_inreg";
     253           0 :   case ISD::TRUNCATE:                   return "truncate";
     254           0 :   case ISD::FP_ROUND:                   return "fp_round";
     255           0 :   case ISD::FLT_ROUNDS_:                return "flt_rounds";
     256           0 :   case ISD::FP_ROUND_INREG:             return "fp_round_inreg";
     257           0 :   case ISD::FP_EXTEND:                  return "fp_extend";
     258             : 
     259           0 :   case ISD::SINT_TO_FP:                 return "sint_to_fp";
     260           0 :   case ISD::UINT_TO_FP:                 return "uint_to_fp";
     261           0 :   case ISD::FP_TO_SINT:                 return "fp_to_sint";
     262           0 :   case ISD::FP_TO_UINT:                 return "fp_to_uint";
     263           0 :   case ISD::BITCAST:                    return "bitcast";
     264           0 :   case ISD::ADDRSPACECAST:              return "addrspacecast";
     265           0 :   case ISD::FP16_TO_FP:                 return "fp16_to_fp";
     266           0 :   case ISD::FP_TO_FP16:                 return "fp_to_fp16";
     267             : 
     268             :     // Control flow instructions
     269           0 :   case ISD::BR:                         return "br";
     270           0 :   case ISD::BRIND:                      return "brind";
     271           0 :   case ISD::BR_JT:                      return "br_jt";
     272           0 :   case ISD::BRCOND:                     return "brcond";
     273           0 :   case ISD::BR_CC:                      return "br_cc";
     274           0 :   case ISD::CALLSEQ_START:              return "callseq_start";
     275           0 :   case ISD::CALLSEQ_END:                return "callseq_end";
     276             : 
     277             :     // EH instructions
     278           0 :   case ISD::CATCHRET:                   return "catchret";
     279           0 :   case ISD::CLEANUPRET:                 return "cleanupret";
     280             : 
     281             :     // Other operators
     282           4 :   case ISD::LOAD:                       return "load";
     283           0 :   case ISD::STORE:                      return "store";
     284           0 :   case ISD::MLOAD:                      return "masked_load";
     285           0 :   case ISD::MSTORE:                     return "masked_store";
     286           0 :   case ISD::MGATHER:                    return "masked_gather";
     287           0 :   case ISD::MSCATTER:                   return "masked_scatter";
     288           0 :   case ISD::VAARG:                      return "vaarg";
     289           0 :   case ISD::VACOPY:                     return "vacopy";
     290           0 :   case ISD::VAEND:                      return "vaend";
     291           0 :   case ISD::VASTART:                    return "vastart";
     292           0 :   case ISD::DYNAMIC_STACKALLOC:         return "dynamic_stackalloc";
     293           0 :   case ISD::EXTRACT_ELEMENT:            return "extract_element";
     294           0 :   case ISD::BUILD_PAIR:                 return "build_pair";
     295           0 :   case ISD::STACKSAVE:                  return "stacksave";
     296           0 :   case ISD::STACKRESTORE:               return "stackrestore";
     297           0 :   case ISD::TRAP:                       return "trap";
     298           0 :   case ISD::DEBUGTRAP:                  return "debugtrap";
     299           0 :   case ISD::LIFETIME_START:             return "lifetime.start";
     300           0 :   case ISD::LIFETIME_END:               return "lifetime.end";
     301           0 :   case ISD::GC_TRANSITION_START:        return "gc_transition.start";
     302           0 :   case ISD::GC_TRANSITION_END:          return "gc_transition.end";
     303           0 :   case ISD::GET_DYNAMIC_AREA_OFFSET:    return "get.dynamic.area.offset";
     304             : 
     305             :   // Bit manipulation
     306           0 :   case ISD::ABS:                        return "abs";
     307           0 :   case ISD::BITREVERSE:                 return "bitreverse";
     308           0 :   case ISD::BSWAP:                      return "bswap";
     309           0 :   case ISD::CTPOP:                      return "ctpop";
     310           0 :   case ISD::CTTZ:                       return "cttz";
     311           0 :   case ISD::CTTZ_ZERO_UNDEF:            return "cttz_zero_undef";
     312           0 :   case ISD::CTLZ:                       return "ctlz";
     313           0 :   case ISD::CTLZ_ZERO_UNDEF:            return "ctlz_zero_undef";
     314             : 
     315             :   // Trampolines
     316           0 :   case ISD::INIT_TRAMPOLINE:            return "init_trampoline";
     317           0 :   case ISD::ADJUST_TRAMPOLINE:          return "adjust_trampoline";
     318             : 
     319           0 :   case ISD::CONDCODE:
     320           0 :     switch (cast<CondCodeSDNode>(this)->get()) {
     321           0 :     default: llvm_unreachable("Unknown setcc condition!");
     322           0 :     case ISD::SETOEQ:                   return "setoeq";
     323           0 :     case ISD::SETOGT:                   return "setogt";
     324           0 :     case ISD::SETOGE:                   return "setoge";
     325           0 :     case ISD::SETOLT:                   return "setolt";
     326           0 :     case ISD::SETOLE:                   return "setole";
     327           0 :     case ISD::SETONE:                   return "setone";
     328             : 
     329           0 :     case ISD::SETO:                     return "seto";
     330           0 :     case ISD::SETUO:                    return "setuo";
     331           0 :     case ISD::SETUEQ:                   return "setueq";
     332           0 :     case ISD::SETUGT:                   return "setugt";
     333           0 :     case ISD::SETUGE:                   return "setuge";
     334           0 :     case ISD::SETULT:                   return "setult";
     335           0 :     case ISD::SETULE:                   return "setule";
     336           0 :     case ISD::SETUNE:                   return "setune";
     337             : 
     338           0 :     case ISD::SETEQ:                    return "seteq";
     339           0 :     case ISD::SETGT:                    return "setgt";
     340           0 :     case ISD::SETGE:                    return "setge";
     341           0 :     case ISD::SETLT:                    return "setlt";
     342           0 :     case ISD::SETLE:                    return "setle";
     343           0 :     case ISD::SETNE:                    return "setne";
     344             : 
     345           0 :     case ISD::SETTRUE:                  return "settrue";
     346           0 :     case ISD::SETTRUE2:                 return "settrue2";
     347           0 :     case ISD::SETFALSE:                 return "setfalse";
     348           0 :     case ISD::SETFALSE2:                return "setfalse2";
     349             :     }
     350           0 :   case ISD::VECREDUCE_FADD:             return "vecreduce_fadd";
     351           0 :   case ISD::VECREDUCE_FMUL:             return "vecreduce_fmul";
     352           0 :   case ISD::VECREDUCE_ADD:              return "vecreduce_add";
     353           0 :   case ISD::VECREDUCE_MUL:              return "vecreduce_mul";
     354           0 :   case ISD::VECREDUCE_AND:              return "vecreduce_and";
     355           0 :   case ISD::VECREDUCE_OR:               return "vecreduce_or";
     356           0 :   case ISD::VECREDUCE_XOR:              return "vecreduce_xor";
     357           0 :   case ISD::VECREDUCE_SMAX:             return "vecreduce_smax";
     358           0 :   case ISD::VECREDUCE_SMIN:             return "vecreduce_smin";
     359           0 :   case ISD::VECREDUCE_UMAX:             return "vecreduce_umax";
     360           0 :   case ISD::VECREDUCE_UMIN:             return "vecreduce_umin";
     361           0 :   case ISD::VECREDUCE_FMAX:             return "vecreduce_fmax";
     362           0 :   case ISD::VECREDUCE_FMIN:             return "vecreduce_fmin";
     363             :   }
     364             : }
     365             : 
     366           2 : const char *SDNode::getIndexedModeName(ISD::MemIndexedMode AM) {
     367           2 :   switch (AM) {
     368             :   default:              return "";
     369           0 :   case ISD::PRE_INC:    return "<pre-inc>";
     370           0 :   case ISD::PRE_DEC:    return "<pre-dec>";
     371           0 :   case ISD::POST_INC:   return "<post-inc>";
     372           0 :   case ISD::POST_DEC:   return "<post-dec>";
     373             :   }
     374             : }
     375             : 
     376             : static Printable PrintNodeId(const SDNode &Node) {
     377          42 :   return Printable([&Node](raw_ostream &OS) {
     378             : #ifndef NDEBUG
     379             :     OS << 't' << Node.PersistentId;
     380             : #else
     381          42 :     OS << (const void*)&Node;
     382             : #endif
     383         168 :   });
     384             : }
     385             : 
     386             : #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
     387             : LLVM_DUMP_METHOD void SDNode::dump() const { dump(nullptr); }
     388             : LLVM_DUMP_METHOD void SDNode::dump(const SelectionDAG *G) const {
     389             :   print(dbgs(), G);
     390             :   dbgs() << '\n';
     391             : }
     392             : #endif
     393             : 
     394          43 : void SDNode::print_types(raw_ostream &OS, const SelectionDAG *G) const {
     395         133 :   for (unsigned i = 0, e = getNumValues(); i != e; ++i) {
     396          47 :     if (i) OS << ",";
     397         141 :     if (getValueType(i) == MVT::Other)
     398           5 :       OS << "ch";
     399             :     else
     400         168 :       OS << getValueType(i).getEVTString();
     401             :   }
     402          43 : }
     403             : 
     404          43 : void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const {
     405          43 :   if (const MachineSDNode *MN = dyn_cast<MachineSDNode>(this)) {
     406           0 :     if (!MN->memoperands_empty()) {
     407           0 :       OS << "<";
     408           0 :       OS << "Mem:";
     409           0 :       for (MachineSDNode::mmo_iterator i = MN->memoperands_begin(),
     410           0 :            e = MN->memoperands_end(); i != e; ++i) {
     411           0 :         OS << **i;
     412           0 :         if (std::next(i) != e)
     413           0 :           OS << " ";
     414             :       }
     415           0 :       OS << ">";
     416             :     }
     417             :   } else if (const ShuffleVectorSDNode *SVN =
     418          43 :                dyn_cast<ShuffleVectorSDNode>(this)) {
     419           0 :     OS << "<";
     420           0 :     for (unsigned i = 0, e = ValueList[0].getVectorNumElements(); i != e; ++i) {
     421           0 :       int Idx = SVN->getMaskElt(i);
     422           0 :       if (i) OS << ",";
     423           0 :       if (Idx < 0)
     424           0 :         OS << "u";
     425             :       else
     426             :         OS << Idx;
     427             :     }
     428           0 :     OS << ">";
     429          43 :   } else if (const ConstantSDNode *CSDN = dyn_cast<ConstantSDNode>(this)) {
     430          39 :     OS << '<' << CSDN->getAPIntValue() << '>';
     431          30 :   } else if (const ConstantFPSDNode *CSDN = dyn_cast<ConstantFPSDNode>(this)) {
     432           0 :     if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEsingle())
     433           0 :       OS << '<' << CSDN->getValueAPF().convertToFloat() << '>';
     434           0 :     else if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEdouble())
     435           0 :       OS << '<' << CSDN->getValueAPF().convertToDouble() << '>';
     436             :     else {
     437           0 :       OS << "<APFloat(";
     438           0 :       CSDN->getValueAPF().bitcastToAPInt().print(OS, false);
     439           0 :       OS << ")>";
     440             :     }
     441             :   } else if (const GlobalAddressSDNode *GADN =
     442          30 :              dyn_cast<GlobalAddressSDNode>(this)) {
     443           6 :     int64_t offset = GADN->getOffset();
     444           6 :     OS << '<';
     445           6 :     GADN->getGlobal()->printAsOperand(OS);
     446           6 :     OS << '>';
     447           6 :     if (offset > 0)
     448           0 :       OS << " + " << offset;
     449             :     else
     450           6 :       OS << " " << offset;
     451           6 :     if (unsigned int TF = GADN->getTargetFlags())
     452           0 :       OS << " [TF=" << TF << ']';
     453          24 :   } else if (const FrameIndexSDNode *FIDN = dyn_cast<FrameIndexSDNode>(this)) {
     454           0 :     OS << "<" << FIDN->getIndex() << ">";
     455          24 :   } else if (const JumpTableSDNode *JTDN = dyn_cast<JumpTableSDNode>(this)) {
     456           0 :     OS << "<" << JTDN->getIndex() << ">";
     457           0 :     if (unsigned int TF = JTDN->getTargetFlags())
     458           0 :       OS << " [TF=" << TF << ']';
     459          24 :   } else if (const ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(this)){
     460           0 :     int offset = CP->getOffset();
     461           0 :     if (CP->isMachineConstantPoolEntry())
     462           0 :       OS << "<" << *CP->getMachineCPVal() << ">";
     463             :     else
     464           0 :       OS << "<" << *CP->getConstVal() << ">";
     465           0 :     if (offset > 0)
     466           0 :       OS << " + " << offset;
     467             :     else
     468           0 :       OS << " " << offset;
     469           0 :     if (unsigned int TF = CP->getTargetFlags())
     470           0 :       OS << " [TF=" << TF << ']';
     471          24 :   } else if (const TargetIndexSDNode *TI = dyn_cast<TargetIndexSDNode>(this)) {
     472           0 :     OS << "<" << TI->getIndex() << '+' << TI->getOffset() << ">";
     473           0 :     if (unsigned TF = TI->getTargetFlags())
     474           0 :       OS << " [TF=" << TF << ']';
     475          24 :   } else if (const BasicBlockSDNode *BBDN = dyn_cast<BasicBlockSDNode>(this)) {
     476           0 :     OS << "<";
     477           0 :     const Value *LBB = (const Value*)BBDN->getBasicBlock()->getBasicBlock();
     478           0 :     if (LBB)
     479           0 :       OS << LBB->getName() << " ";
     480           0 :     OS << (const void*)BBDN->getBasicBlock() << ">";
     481          24 :   } else if (const RegisterSDNode *R = dyn_cast<RegisterSDNode>(this)) {
     482          16 :     OS << ' ' << PrintReg(R->getReg(),
     483          12 :                           G ? G->getSubtarget().getRegisterInfo() : nullptr);
     484             :   } else if (const ExternalSymbolSDNode *ES =
     485          20 :              dyn_cast<ExternalSymbolSDNode>(this)) {
     486           5 :     OS << "'" << ES->getSymbol() << "'";
     487           5 :     if (unsigned int TF = ES->getTargetFlags())
     488           0 :       OS << " [TF=" << TF << ']';
     489          15 :   } else if (const SrcValueSDNode *M = dyn_cast<SrcValueSDNode>(this)) {
     490           0 :     if (M->getValue())
     491           0 :       OS << "<" << M->getValue() << ">";
     492             :     else
     493           0 :       OS << "<null>";
     494          15 :   } else if (const MDNodeSDNode *MD = dyn_cast<MDNodeSDNode>(this)) {
     495           0 :     if (MD->getMD())
     496           0 :       OS << "<" << MD->getMD() << ">";
     497             :     else
     498           0 :       OS << "<null>";
     499          15 :   } else if (const VTSDNode *N = dyn_cast<VTSDNode>(this)) {
     500           0 :     OS << ":" << N->getVT().getEVTString();
     501             :   }
     502          15 :   else if (const LoadSDNode *LD = dyn_cast<LoadSDNode>(this)) {
     503           4 :     OS << "<" << *LD->getMemOperand();
     504             : 
     505           2 :     bool doExt = true;
     506           2 :     switch (LD->getExtensionType()) {
     507             :     default: doExt = false; break;
     508           0 :     case ISD::EXTLOAD:  OS << ", anyext"; break;
     509           0 :     case ISD::SEXTLOAD: OS << ", sext"; break;
     510           0 :     case ISD::ZEXTLOAD: OS << ", zext"; break;
     511             :     }
     512             :     if (doExt)
     513           0 :       OS << " from " << LD->getMemoryVT().getEVTString();
     514             : 
     515           4 :     const char *AM = getIndexedModeName(LD->getAddressingMode());
     516           2 :     if (*AM)
     517           0 :       OS << ", " << AM;
     518             : 
     519           2 :     OS << ">";
     520          13 :   } else if (const StoreSDNode *ST = dyn_cast<StoreSDNode>(this)) {
     521           0 :     OS << "<" << *ST->getMemOperand();
     522             : 
     523           0 :     if (ST->isTruncatingStore())
     524           0 :       OS << ", trunc to " << ST->getMemoryVT().getEVTString();
     525             : 
     526           0 :     const char *AM = getIndexedModeName(ST->getAddressingMode());
     527           0 :     if (*AM)
     528           0 :       OS << ", " << AM;
     529             : 
     530           0 :     OS << ">";
     531          13 :   } else if (const MemSDNode* M = dyn_cast<MemSDNode>(this)) {
     532           2 :     OS << "<" << *M->getMemOperand() << ">";
     533             :   } else if (const BlockAddressSDNode *BA =
     534          12 :                dyn_cast<BlockAddressSDNode>(this)) {
     535           0 :     int64_t offset = BA->getOffset();
     536           0 :     OS << "<";
     537           0 :     BA->getBlockAddress()->getFunction()->printAsOperand(OS, false);
     538           0 :     OS << ", ";
     539           0 :     BA->getBlockAddress()->getBasicBlock()->printAsOperand(OS, false);
     540           0 :     OS << ">";
     541           0 :     if (offset > 0)
     542           0 :       OS << " + " << offset;
     543             :     else
     544           0 :       OS << " " << offset;
     545           0 :     if (unsigned int TF = BA->getTargetFlags())
     546           0 :       OS << " [TF=" << TF << ']';
     547             :   } else if (const AddrSpaceCastSDNode *ASC =
     548           0 :                dyn_cast<AddrSpaceCastSDNode>(this)) {
     549           0 :     OS << '['
     550           0 :        << ASC->getSrcAddressSpace()
     551           0 :        << " -> "
     552           0 :        << ASC->getDestAddressSpace()
     553             :        << ']';
     554             :   }
     555             : 
     556          43 :   if (VerboseDAGDumping) {
     557           0 :     if (unsigned Order = getIROrder())
     558           0 :         OS << " [ORD=" << Order << ']';
     559             : 
     560           0 :     if (getNodeId() != -1)
     561           0 :       OS << " [ID=" << getNodeId() << ']';
     562             : 
     563           0 :     if (!G)
     564             :       return;
     565             : 
     566           0 :     DILocation *L = getDebugLoc();
     567           0 :     if (!L)
     568             :       return;
     569             : 
     570           0 :     if (auto *Scope = L->getScope())
     571           0 :       OS << Scope->getFilename();
     572             :     else
     573           0 :       OS << "<unknown>";
     574           0 :     OS << ':' << L->getLine();
     575           0 :     if (unsigned C = L->getColumn())
     576           0 :       OS << ':' << C;
     577             :   }
     578             : }
     579             : 
     580             : /// Return true if this node is so simple that we should just print it inline
     581             : /// if it appears as an operand.
     582             : static bool shouldPrintInline(const SDNode &Node) {
     583          25 :   if (Node.getOpcode() == ISD::EntryToken)
     584             :     return false;
     585          21 :   return Node.getNumOperands() == 0;
     586             : }
     587             : 
     588             : #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
     589             : static void DumpNodes(const SDNode *N, unsigned indent, const SelectionDAG *G) {
     590             :   for (const SDValue &Op : N->op_values()) {
     591             :     if (shouldPrintInline(*Op.getNode()))
     592             :       continue;
     593             :     if (Op.getNode()->hasOneUse())
     594             :       DumpNodes(Op.getNode(), indent+2, G);
     595             :   }
     596             : 
     597             :   dbgs().indent(indent);
     598             :   N->dump(G);
     599             : }
     600             : 
     601             : LLVM_DUMP_METHOD void SelectionDAG::dump() const {
     602             :   dbgs() << "SelectionDAG has " << AllNodes.size() << " nodes:\n";
     603             : 
     604             :   for (allnodes_const_iterator I = allnodes_begin(), E = allnodes_end();
     605             :        I != E; ++I) {
     606             :     const SDNode *N = &*I;
     607             :     if (!N->hasOneUse() && N != getRoot().getNode() &&
     608             :         (!shouldPrintInline(*N) || N->use_empty()))
     609             :       DumpNodes(N, 2, this);
     610             :   }
     611             : 
     612             :   if (getRoot().getNode()) DumpNodes(getRoot().getNode(), 2, this);
     613             :   dbgs() << "\n\n";
     614             : }
     615             : #endif
     616             : 
     617          30 : void SDNode::printr(raw_ostream &OS, const SelectionDAG *G) const {
     618          90 :   OS << PrintNodeId(*this) << ": ";
     619          30 :   print_types(OS, G);
     620          60 :   OS << " = " << getOperationName(G);
     621          30 :   print_details(OS, G);
     622          30 : }
     623             : 
     624          25 : static bool printOperand(raw_ostream &OS, const SelectionDAG *G,
     625             :                          const SDValue Value) {
     626          25 :   if (!Value.getNode()) {
     627           0 :     OS << "<null>";
     628             :     return false;
     629          46 :   } else if (shouldPrintInline(*Value.getNode())) {
     630          52 :     OS << Value->getOperationName(G) << ':';
     631          13 :     Value->print_types(OS, G);
     632          13 :     Value->print_details(OS, G);
     633             :     return true;
     634             :   } else {
     635          48 :     OS << PrintNodeId(*Value.getNode());
     636          12 :     if (unsigned RN = Value.getResNo())
     637           0 :       OS << ':' << RN;
     638             :     return false;
     639             :   }
     640             : }
     641             : 
     642             : #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
     643             : typedef SmallPtrSet<const SDNode *, 32> VisitedSDNodeSet;
     644             : static void DumpNodesr(raw_ostream &OS, const SDNode *N, unsigned indent,
     645             :                        const SelectionDAG *G, VisitedSDNodeSet &once) {
     646             :   if (!once.insert(N).second) // If we've been here before, return now.
     647             :     return;
     648             : 
     649             :   // Dump the current SDNode, but don't end the line yet.
     650             :   OS.indent(indent);
     651             :   N->printr(OS, G);
     652             : 
     653             :   // Having printed this SDNode, walk the children:
     654             :   for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
     655             :     if (i) OS << ",";
     656             :     OS << " ";
     657             : 
     658             :     const SDValue Op = N->getOperand(i);
     659             :     bool printedInline = printOperand(OS, G, Op);
     660             :     if (printedInline)
     661             :       once.insert(Op.getNode());
     662             :   }
     663             : 
     664             :   OS << "\n";
     665             : 
     666             :   // Dump children that have grandchildren on their own line(s).
     667             :   for (const SDValue &Op : N->op_values())
     668             :     DumpNodesr(OS, Op.getNode(), indent+2, G, once);
     669             : }
     670             : 
     671             : LLVM_DUMP_METHOD void SDNode::dumpr() const {
     672             :   VisitedSDNodeSet once;
     673             :   DumpNodesr(dbgs(), this, 0, nullptr, once);
     674             : }
     675             : 
     676             : LLVM_DUMP_METHOD void SDNode::dumpr(const SelectionDAG *G) const {
     677             :   VisitedSDNodeSet once;
     678             :   DumpNodesr(dbgs(), this, 0, G, once);
     679             : }
     680             : #endif
     681             : 
     682          27 : static void printrWithDepthHelper(raw_ostream &OS, const SDNode *N,
     683             :                                   const SelectionDAG *G, unsigned depth,
     684             :                                   unsigned indent) {
     685          27 :   if (depth == 0)
     686             :     return;
     687             : 
     688          27 :   OS.indent(indent);
     689             : 
     690          27 :   N->print(OS, G);
     691             : 
     692             :   if (depth < 1)
     693             :     return;
     694             : 
     695         100 :   for (const SDValue &Op : N->op_values()) {
     696             :     // Don't follow chain operands.
     697          69 :     if (Op.getValueType() == MVT::Other)
     698           5 :       continue;
     699          18 :     OS << '\n';
     700          18 :     printrWithDepthHelper(OS, Op.getNode(), G, depth-1, indent+2);
     701             :   }
     702             : }
     703             : 
     704           9 : void SDNode::printrWithDepth(raw_ostream &OS, const SelectionDAG *G,
     705             :                             unsigned depth) const {
     706           9 :   printrWithDepthHelper(OS, this, G, depth, 0);
     707           9 : }
     708             : 
     709           9 : void SDNode::printrFull(raw_ostream &OS, const SelectionDAG *G) const {
     710             :   // Don't print impossibly deep things.
     711           9 :   printrWithDepth(OS, G, 10);
     712           9 : }
     713             : 
     714             : #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
     715             : LLVM_DUMP_METHOD
     716             : void SDNode::dumprWithDepth(const SelectionDAG *G, unsigned depth) const {
     717             :   printrWithDepth(dbgs(), G, depth);
     718             : }
     719             : 
     720             : LLVM_DUMP_METHOD void SDNode::dumprFull(const SelectionDAG *G) const {
     721             :   // Don't print impossibly deep things.
     722             :   dumprWithDepth(G, 10);
     723             : }
     724             : #endif
     725             : 
     726          30 : void SDNode::print(raw_ostream &OS, const SelectionDAG *G) const {
     727          30 :   printr(OS, G);
     728          85 :   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
     729          25 :     if (i) OS << ", "; else OS << " ";
     730          50 :     printOperand(OS, G, getOperand(i));
     731             :   }
     732      216948 : }

Generated by: LCOV version 1.13