Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 1
//===- llvm/CodeGen/GlobalISel/CombinerInfo.h ------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
/// \file
9
/// Interface for Targets to specify which operations are combined how and when.
10
///
11
//===----------------------------------------------------------------------===//
12
 
13
#ifndef LLVM_CODEGEN_GLOBALISEL_COMBINERINFO_H
14
#define LLVM_CODEGEN_GLOBALISEL_COMBINERINFO_H
15
 
16
#include <cassert>
17
namespace llvm {
18
 
19
class GISelChangeObserver;
20
class LegalizerInfo;
21
class MachineInstr;
22
class MachineIRBuilder;
23
 
24
// Contains information relevant to enabling/disabling various combines for a
25
// pass.
26
class CombinerInfo {
27
public:
28
  CombinerInfo(bool AllowIllegalOps, bool ShouldLegalizeIllegal,
29
               const LegalizerInfo *LInfo, bool OptEnabled, bool OptSize,
30
               bool MinSize)
31
      : IllegalOpsAllowed(AllowIllegalOps),
32
        LegalizeIllegalOps(ShouldLegalizeIllegal), LInfo(LInfo),
33
        EnableOpt(OptEnabled), EnableOptSize(OptSize), EnableMinSize(MinSize) {
34
    assert(((AllowIllegalOps || !LegalizeIllegalOps) || LInfo) &&
35
           "Expecting legalizerInfo when illegalops not allowed");
36
  }
37
  virtual ~CombinerInfo() = default;
38
  /// If \p IllegalOpsAllowed is false, the CombinerHelper will make use of
39
  /// the legalizerInfo to check for legality before each transformation.
40
  bool IllegalOpsAllowed; // TODO: Make use of this.
41
 
42
  /// If \p LegalizeIllegalOps is true, the Combiner will also legalize the
43
  /// illegal ops that are created.
44
  bool LegalizeIllegalOps; // TODO: Make use of this.
45
  const LegalizerInfo *LInfo;
46
 
47
  /// Whether optimizations should be enabled. This is to distinguish between
48
  /// uses of the combiner unconditionally and only when optimizations are
49
  /// specifically enabled/
50
  bool EnableOpt;
51
  /// Whether we're optimizing for size.
52
  bool EnableOptSize;
53
  /// Whether we're optimizing for minsize (-Oz).
54
  bool EnableMinSize;
55
 
56
  /// Attempt to combine instructions using MI as the root.
57
  ///
58
  /// Use Observer to report the creation, modification, and erasure of
59
  /// instructions. GISelChangeObserver will automatically report certain
60
  /// kinds of operations. These operations are:
61
  /// * Instructions that are newly inserted into the MachineFunction
62
  /// * Instructions that are erased from the MachineFunction.
63
  ///
64
  /// However, it is important to report instruction modification and this is
65
  /// not automatic.
66
  virtual bool combine(GISelChangeObserver &Observer, MachineInstr &MI,
67
                       MachineIRBuilder &B) const = 0;
68
};
69
} // namespace llvm
70
 
71
#endif