MLIR: include/mlir/Interfaces/InferIntRangeInterface.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14 #ifndef MLIR_INTERFACES_INFERINTRANGEINTERFACE_H

15 #define MLIR_INTERFACES_INFERINTRANGEINTERFACE_H

16

18 #include

19

20 namespace mlir {

21

22

23

24

25

26

28 public:

29

30

32 const APInt &smax)

33 : uminVal(umin), umaxVal(umax), sminVal(smin), smaxVal(smax) {

34 assert(uminVal.getBitWidth() == umaxVal.getBitWidth() &&

35 umaxVal.getBitWidth() == sminVal.getBitWidth() &&

36 sminVal.getBitWidth() == smaxVal.getBitWidth() &&

37 "All bounds in the ranges must have the same bitwidth");

38 }

39

41

42

43 const APInt &umin() const;

44

45

46 const APInt &umax() const;

47

48

49 const APInt &smin() const;

50

51

52 const APInt &smax() const;

53

54

55

56

57

59

60

61

62

64

65

66

68

69

70

71

73 bool isSigned);

74

75

76

77

78

80

81

82

83

85

86

87

89

90

91

93

94

95

96

98

99 friend raw_ostream &operator<<(raw_ostream &os,

101

102 private:

103 APInt uminVal, umaxVal, sminVal, smaxVal;

104 };

105

107

108

110 public:

111

112

113

115

116

118

119

121 : value(std::move(value)) {}

122

123

124

126

127

130 return *value;

131 }

132

133

135 return value == rhs.value;

136 }

137

138

142 return rhs;

144 return lhs;

146 }

147

148

149 void print(raw_ostream &os) const { os << value; }

150

151 private:

152

153 std::optional value;

154 };

155

156 raw_ostream &operator<<(raw_ostream &, const IntegerValueRange &);

157

158

159

160

163

164

165

166

169

170 class InferIntRangeInterface;

171

172 namespace intrange::detail {

173

174

178

179

180

184 }

185 }

186

187 #include "mlir/Interfaces/InferIntRangeInterface.h.inc"

188

189 #endif

static Value max(ImplicitLocOpBuilder &builder, Value value, Value bound)

static Value min(ImplicitLocOpBuilder &builder, Value value, Value bound)

A set of arbitrary-precision integers representing bounds on a given integer value.

friend raw_ostream & operator<<(raw_ostream &os, const ConstantIntRanges &range)

static ConstantIntRanges maxRange(unsigned bitwidth)

Create a ConstantIntRanges with the maximum bounds for the width bitwidth, that is - [0,...

ConstantIntRanges(const APInt &umin, const APInt &umax, const APInt &smin, const APInt &smax)

Bound umin <= (unsigned)x <= umax and smin <= signed(x) <= smax.

const APInt & smax() const

The maximum value of an integer when it is interpreted as signed.

static ConstantIntRanges constant(const APInt &value)

Create a ConstantIntRanges with a constant value - that is, with the bounds [value,...

static ConstantIntRanges fromUnsigned(const APInt &umin, const APInt &umax)

Create an ConstantIntRanges with the unsigned minimum and maximum equal to umin and umax and the sign...

const APInt & smin() const

The minimum value of an integer when it is interpreted as signed.

static ConstantIntRanges range(const APInt &min, const APInt &max, bool isSigned)

Create a ConstantIntRanges whose minimum is min and maximum is max with isSigned specifying if the mi...

ConstantIntRanges intersection(const ConstantIntRanges &other) const

Returns the intersection (computed separately for signed and unsigned bounds) of this range and other...

static ConstantIntRanges fromSigned(const APInt &smin, const APInt &smax)

Create an ConstantIntRanges with the signed minimum and maximum equal to smin and smax,...

static unsigned getStorageBitwidth(Type type)

Return the bitwidth that should be used for integer ranges describing type.

std::optional< APInt > getConstantValue() const

If either the signed or unsigned interpretations of the range indicate that the value it bounds is a ...

const APInt & umax() const

The maximum value of an integer when it is interpreted as unsigned.

const APInt & umin() const

The minimum value of an integer when it is interpreted as unsigned.

ConstantIntRanges rangeUnion(const ConstantIntRanges &other) const

Returns the union (computed separately for signed and unsigned bounds) of this range and other.

bool operator==(const ConstantIntRanges &other) const

This lattice value represents the integer range of an SSA value.

IntegerValueRange(ConstantIntRanges value)

Create an integer value range lattice value.

void print(raw_ostream &os) const

Print the integer value range.

const ConstantIntRanges & getValue() const

Get the known integer value range.

IntegerValueRange(std::optional< ConstantIntRanges > value=std::nullopt)

Create an integer value range lattice value.

bool isUninitialized() const

Whether the range is uninitialized.

static IntegerValueRange getMaxRange(Value value)

Create a maximal range ([0, uint_max(t)] / [int_min(t), int_max(t)]) range that is used to mark the v...

bool operator==(const IntegerValueRange &rhs) const

Compare two ranges.

static IntegerValueRange join(const IntegerValueRange &lhs, const IntegerValueRange &rhs)

Compute the least upper bound of two ranges.

Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...

This class represents an instance of an SSA value in the MLIR system, representing a computable value...

void defaultInferResultRanges(InferIntRangeInterface interface, ArrayRef< IntegerValueRange > argRanges, SetIntLatticeFn setResultRanges)

Default implementation of inferResultRanges which dispatches to the inferResultRangesFromOptional.

void defaultInferResultRangesFromOptional(InferIntRangeInterface interface, ArrayRef< ConstantIntRanges > argRanges, SetIntRangeFn setResultRanges)

Default implementation of inferResultRangesFromOptional which dispatches to the inferResultRanges.

Include the generated interface declarations.

raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)