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

Generated by: LCOV version 1.13