//===-- SelectionDAG.cpp - Implement the SelectionDAG data structures -----===//// // The LLVM Compiler Infrastructure//// This file was developed by the LLVM research group and is distributed under// the University of Illinois Open Source License. See LICENSE.TXT for details.// //===----------------------------------------------------------------------===////// This implements the SelectionDAG class.////===----------------------------------------------------------------------===//#include"llvm/CodeGen/SelectionDAG.h"#include"llvm/Constants.h"#include"llvm/GlobalValue.h"#include"llvm/Assembly/Writer.h"#include"llvm/CodeGen/MachineBasicBlock.h"#include"llvm/Target/TargetLowering.h"#include<iostream>#include<set>#include<cmath>#include<algorithm>usingnamespacellvm;staticboolisCommutativeBinOp(unsignedOpcode){switch(Opcode){caseISD::ADD:caseISD::MUL:caseISD::AND:caseISD::OR:caseISD::XOR:returntrue;default:returnfalse;// FIXME: Need commutative info for user ops!}}staticboolisAssociativeBinOp(unsignedOpcode){switch(Opcode){caseISD::ADD:caseISD::MUL:caseISD::AND:caseISD::OR:caseISD::XOR:returntrue;default:returnfalse;// FIXME: Need associative info for user ops!}}staticunsignedExactLog2(uint64_tVal){unsignedCount=0;while(Val!=1){Val>>=1;++Count;}returnCount;}// isInvertibleForFree - Return true if there is no cost to emitting the logical// inverse of this node.staticboolisInvertibleForFree(SDOperandN){if(isa<ConstantSDNode>(N.Val))returntrue;if(isa<SetCCSDNode>(N.Val)&&N.Val->hasOneUse())returntrue;returnfalse;}/// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)/// when given the operation for (X op Y).ISD::CondCodeISD::getSetCCSwappedOperands(ISD::CondCodeOperation){// To perform this operation, we just need to swap the L and G bits of the// operation.unsignedOldL=(Operation>>2)&1;unsignedOldG=(Operation>>1)&1;returnISD::CondCode((Operation&~6)|