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

Generated by: LCOV version 1.13