@@ -331,6 +331,27 @@ class SelectionDAG {
331
331
virtual void anchor ();
332
332
};
333
333
334
+ // / Help to insert SDNodeFlags automatically in transforming. Use
335
+ // / RAII to save and resume flags in current scope.
336
+ class FlagInserter {
337
+ SelectionDAG &DAG;
338
+ SDNodeFlags Flags;
339
+ FlagInserter *LastInserter;
340
+
341
+ public:
342
+ FlagInserter (SelectionDAG &SDAG, SDNode *N)
343
+ : DAG(SDAG), Flags(N->getFlags ()),
344
+ LastInserter(SDAG.getFlagInserter()) {
345
+ SDAG.setFlagInserter (this );
346
+ }
347
+
348
+ FlagInserter (const FlagInserter &) = delete;
349
+ FlagInserter &operator =(const FlagInserter &) = delete ;
350
+ ~FlagInserter () { DAG.setFlagInserter (LastInserter); }
351
+
352
+ const SDNodeFlags getFlags () const { return Flags; }
353
+ };
354
+
334
355
// / When true, additional steps are taken to
335
356
// / ensure that getConstant() and similar functions return DAG nodes that
336
357
// / have legal types. This is important after type legalization since
@@ -433,6 +454,9 @@ class SelectionDAG {
433
454
ProfileSummaryInfo *getPSI () const { return PSI; }
434
455
BlockFrequencyInfo *getBFI () const { return BFI; }
435
456
457
+ FlagInserter *getFlagInserter () { return Inserter; }
458
+ void setFlagInserter (FlagInserter *FI) { Inserter = FI; }
459
+
436
460
// / Just dump dot graph to a user-provided path and title.
437
461
// / This doesn't open the dot viewer program and
438
462
// / helps visualization when outside debugging session.
@@ -945,21 +969,31 @@ class SelectionDAG {
945
969
SDValue getNode (unsigned Opcode, const SDLoc &DL, EVT VT,
946
970
ArrayRef<SDUse> Ops);
947
971
SDValue getNode (unsigned Opcode, const SDLoc &DL, EVT VT,
948
- ArrayRef<SDValue> Ops, const SDNodeFlags Flags = SDNodeFlags() );
972
+ ArrayRef<SDValue> Ops, const SDNodeFlags Flags);
949
973
SDValue getNode (unsigned Opcode, const SDLoc &DL, ArrayRef<EVT> ResultTys,
950
974
ArrayRef<SDValue> Ops);
951
975
SDValue getNode (unsigned Opcode, const SDLoc &DL, SDVTList VTList,
952
- ArrayRef<SDValue> Ops, const SDNodeFlags Flags = SDNodeFlags());
976
+ ArrayRef<SDValue> Ops, const SDNodeFlags Flags);
977
+
978
+ // Use flags from current flag inserter.
979
+ SDValue getNode (unsigned Opcode, const SDLoc &DL, EVT VT,
980
+ ArrayRef<SDValue> Ops);
981
+ SDValue getNode (unsigned Opcode, const SDLoc &DL, SDVTList VTList,
982
+ ArrayRef<SDValue> Ops);
983
+ SDValue getNode (unsigned Opcode, const SDLoc &DL, EVT VT, SDValue Operand);
984
+ SDValue getNode (unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
985
+ SDValue N2);
986
+ SDValue getNode (unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
987
+ SDValue N2, SDValue N3);
953
988
954
989
// Specialize based on number of operands.
955
990
SDValue getNode (unsigned Opcode, const SDLoc &DL, EVT VT);
956
991
SDValue getNode (unsigned Opcode, const SDLoc &DL, EVT VT, SDValue Operand,
957
- const SDNodeFlags Flags = SDNodeFlags() );
992
+ const SDNodeFlags Flags);
958
993
SDValue getNode (unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
959
- SDValue N2, const SDNodeFlags Flags = SDNodeFlags() );
994
+ SDValue N2, const SDNodeFlags Flags);
960
995
SDValue getNode (unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
961
- SDValue N2, SDValue N3,
962
- const SDNodeFlags Flags = SDNodeFlags());
996
+ SDValue N2, SDValue N3, const SDNodeFlags Flags);
963
997
SDValue getNode (unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
964
998
SDValue N2, SDValue N3, SDValue N4);
965
999
SDValue getNode (unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
@@ -1469,8 +1503,10 @@ class SelectionDAG {
1469
1503
SDValue Operand, SDValue Subreg);
1470
1504
1471
1505
// / Get the specified node if it's already available, or else return NULL.
1472
- SDNode *getNodeIfExists (unsigned Opcode, SDVTList VTList, ArrayRef<SDValue> Ops,
1473
- const SDNodeFlags Flags = SDNodeFlags());
1506
+ SDNode *getNodeIfExists (unsigned Opcode, SDVTList VTList,
1507
+ ArrayRef<SDValue> Ops, const SDNodeFlags Flags);
1508
+ SDNode *getNodeIfExists (unsigned Opcode, SDVTList VTList,
1509
+ ArrayRef<SDValue> Ops);
1474
1510
1475
1511
// / Creates a SDDbgValue node.
1476
1512
SDDbgValue *getDbgValue (DIVariable *Var, DIExpression *Expr, SDNode *N,
@@ -1999,6 +2035,8 @@ class SelectionDAG {
1999
2035
2000
2036
std::map<std::pair<std::string, unsigned >, SDNode *> TargetExternalSymbols;
2001
2037
DenseMap<MCSymbol *, SDNode *> MCSymbols;
2038
+
2039
+ FlagInserter *Inserter = nullptr ;
2002
2040
};
2003
2041
2004
2042
template <> struct GraphTraits <SelectionDAG*> : public GraphTraits<SDNode*> {
0 commit comments