MLIR: lib/IR/Types.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

11

12 using namespace mlir;

14

15

16

17

18

22 walkImmediateSubElementsFn(type, walkAttrsFn, walkTypesFn);

23 }

24

28 return replaceImmediateSubElementsFn(type, replAttrs, replTypes);

29 }

30

31

32

33

34

36

37 bool Type::isBF16() const { return llvm::isa(*this); }

38 bool Type::isF16() const { return llvm::isa(*this); }

39 bool Type::isTF32() const { return llvm::isa(*this); }

40 bool Type::isF32() const { return llvm::isa(*this); }

41 bool Type::isF64() const { return llvm::isa(*this); }

42 bool Type::isF80() const { return llvm::isa(*this); }

43 bool Type::isF128() const { return llvm::isa(*this); }

44

45 bool Type::isFloat() const { return llvm::isa(*this); }

46

47

49 if (auto fltTy = llvm::dyn_cast(*this))

50 return fltTy.getWidth() == width;

51 return false;

52 }

53

54 bool Type::isIndex() const { return llvm::isa(*this); }

55

56 bool Type::isInteger() const { return llvm::isa(*this); }

57

59 if (auto intTy = llvm::dyn_cast(*this))

60 return intTy.getWidth() == width;

61 return false;

62 }

63

65 if (auto intTy = llvm::dyn_cast(*this))

66 return intTy.isSignless();

67 return false;

68 }

69

71 if (auto intTy = llvm::dyn_cast(*this))

72 return intTy.isSignless() && intTy.getWidth() == width;

73 return false;

74 }

75

77 if (auto intTy = llvm::dyn_cast(*this))

78 return intTy.isSigned();

79 return false;

80 }

81

83 if (auto intTy = llvm::dyn_cast(*this))

84 return intTy.isSigned() && intTy.getWidth() == width;

85 return false;

86 }

87

89 if (auto intTy = llvm::dyn_cast(*this))

90 return intTy.isUnsigned();

91 return false;

92 }

93

95 if (auto intTy = llvm::dyn_cast(*this))

96 return intTy.isUnsigned() && intTy.getWidth() == width;

97 return false;

98 }

99

101 return isSignlessInteger() || llvm::isa(*this);

102 }

103

105 return isSignlessInteger() || llvm::isa<IndexType, FloatType>(*this);

106 }

107

109 return isSignlessInteger() || llvm::isa(*this);

110 }

111

113 return llvm::isa(*this) || isIndex();

114 }

115

117 return llvm::isa<IntegerType, FloatType>(*this);

118 }

119

121

123 assert(isIntOrFloat() && "only integers and floats have a bitwidth");

124 if (auto intType = llvm::dyn_cast(*this))

125 return intType.getWidth();

126 return llvm::cast(*this).getWidth();

127 }

Type replaceImmediateSubElements(Type type, ArrayRef< Attribute > replAttrs, ArrayRef< Type > replTypes) const

Replace the immediate sub-elements of the given type.

void walkImmediateSubElements(Type type, function_ref< void(Attribute)> walkAttrsFn, function_ref< void(Type)> walkTypesFn) const

Walk the immediate sub-elements of the given type.

Attributes are known-constant values of operations.

MLIRContext is the top-level object for a collection of MLIR operations.

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

bool isFloat() const

Return true if this is an float type (with the specified width).

bool isSignlessIntOrIndex() const

Return true if this is a signless integer or index type.

MLIRContext * getContext() const

Return the MLIRContext in which this type was uniqued.

bool isSignedInteger() const

Return true if this is a signed integer type (with the specified width).

bool isSignlessInteger() const

Return true if this is a signless integer type (with the specified width).

bool isIntOrIndexOrFloat() const

Return true if this is an integer (of any signedness), index, or float type.

bool isUnsignedInteger() const

Return true if this is an unsigned integer type (with the specified width).

bool isIntOrIndex() const

Return true if this is an integer (of any signedness) or an index type.

bool isInteger() const

Return true if this is an integer type (with the specified width).

bool isIntOrFloat() const

Return true if this is an integer (of any signedness) or a float type.

bool isSignlessIntOrFloat() const

Return true of this is a signless integer or a float type.

unsigned getIntOrFloatBitWidth() const

Return the bit width of an integer or a float type, assert failure on other types.

bool isSignlessIntOrIndexOrFloat() const

Return true if this is a signless integer, index, or float type.

Include the generated interface declarations.