llvm.org GIT mirror llvm / 444b4bf
Refactor DAGCombinerInfo. Change the different booleans that indicate if we are before or after different runs of DAGCo, with the CombineLevel enum. Also, added a new API for checking if we are running before or after the LegalizeVectorOps phase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171142 91177308-0d34-0410-b5e6-96231b3b80d8 Nadav Rotem 7 years ago
5 changed file(s) with 39 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
0 //===-- llvm/CodeGen/DAGCombine.h ------- SelectionDAG Nodes ---*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9
10 #ifndef LLVM_CODEGEN_DAGCOMBINE_H
11 #define LLVM_CODEGEN_DAGCOMBINE_H
12
13 namespace llvm {
14
15 enum CombineLevel {
16 BeforeLegalizeTypes,
17 AfterLegalizeTypes,
18 AfterLegalizeVectorOps,
19 AfterLegalizeDAG
20 };
21
22 } // end llvm namespace
23
24 #endif
1717 #include "llvm/ADT/DenseSet.h"
1818 #include "llvm/ADT/StringMap.h"
1919 #include "llvm/ADT/ilist.h"
20 #include "llvm/CodeGen/DAGCombine.h"
2021 #include "llvm/CodeGen/SelectionDAGNodes.h"
2122 #include "llvm/Support/RecyclingAllocator.h"
2223 #include "llvm/Target/TargetMachine.h"
108109 DbgIterator DbgEnd() { return DbgValues.end(); }
109110 DbgIterator ByvalParmDbgBegin() { return ByvalParmDbgValues.begin(); }
110111 DbgIterator ByvalParmDbgEnd() { return ByvalParmDbgValues.end(); }
111 };
112
113 enum CombineLevel {
114 BeforeLegalizeTypes,
115 AfterLegalizeTypes,
116 AfterLegalizeVectorOps,
117 AfterLegalizeDAG
118112 };
119113
120114 class SelectionDAG;
2525 #include "llvm/AddressingMode.h"
2626 #include "llvm/Attributes.h"
2727 #include "llvm/CallingConv.h"
28 #include "llvm/CodeGen/DAGCombine.h"
2829 #include "llvm/CodeGen/RuntimeLibcalls.h"
2930 #include "llvm/CodeGen/SelectionDAGNodes.h"
3031 #include "llvm/InlineAsm.h"
962963
963964 struct DAGCombinerInfo {
964965 void *DC; // The DAG Combiner object.
965 bool BeforeLegalize;
966 bool BeforeLegalizeOps;
966 CombineLevel Level;
967967 bool CalledByLegalizer;
968968 public:
969969 SelectionDAG &DAG;
970970
971 DAGCombinerInfo(SelectionDAG &dag, bool bl, bool blo, bool cl, void *dc)
972 : DC(dc), BeforeLegalize(bl), BeforeLegalizeOps(blo),
973 CalledByLegalizer(cl), DAG(dag) {}
974
975 bool isBeforeLegalize() const { return BeforeLegalize; }
976 bool isBeforeLegalizeOps() const { return BeforeLegalizeOps; }
971 DAGCombinerInfo(SelectionDAG &dag, CombineLevel level, bool cl, void *dc)
972 : DC(dc), Level(level), CalledByLegalizer(cl), DAG(dag) {}
973
974 bool isBeforeLegalize() const { return Level == BeforeLegalizeTypes; }
975 bool isBeforeLegalizeOps() const { return Level < AfterLegalizeVectorOps; }
976 bool isAfterLegalizeVectorOps() const {
977 return Level == AfterLegalizeDAG;
978 }
977979 bool isCalledByLegalizer() const { return CalledByLegalizer; }
978980
979981 void AddToWorklist(SDNode *N);
11821182
11831183 // Expose the DAG combiner to the target combiner impls.
11841184 TargetLowering::DAGCombinerInfo
1185 DagCombineInfo(DAG, !LegalTypes, !LegalOperations, false, this);
1185 DagCombineInfo(DAG, Level, false, this);
11861186
11871187 RV = TLI.PerformDAGCombine(N, DagCombineInfo);
11881188 }
96469646 SDValue N1, ISD::CondCode Cond,
96479647 DebugLoc DL, bool foldBooleans) {
96489648 TargetLowering::DAGCombinerInfo
9649 DagCombineInfo(DAG, !LegalTypes, !LegalOperations, false, this);
9649 DagCombineInfo(DAG, Level, false, this);
96509650 return TLI.SimplifySetCC(VT, N0, N1, Cond, foldBooleans, DagCombineInfo, DL);
96519651 }
96529652
25482548
25492549 // NOTE: on targets without efficient SELECT of bools, we can always use
25502550 // this identity: (B1 ? B2 : B3) --> (B1 & B2)|(!B1&B3)
2551 TargetLowering::DAGCombinerInfo DagCombineInfo(DAG, false, true, true, NULL);
2551 TargetLowering::DAGCombinerInfo DagCombineInfo(DAG, AfterLegalizeTypes, true, NULL);
25522552 SDValue Tmp1, Tmp2;
25532553 Tmp1 = TLI.SimplifySetCC(TLI.getSetCCResultType(LHSLo.getValueType()),
25542554 LHSLo, RHSLo, LowCC, false, DagCombineInfo, dl);