-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathOpFoldResultUtils.h
More file actions
77 lines (60 loc) · 3.17 KB
/
Copy pathOpFoldResultUtils.h
File metadata and controls
77 lines (60 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//===----------------------------------------------------------------------===//
//
// Copyright (c) Microsoft Corporation, Meta Platforms.
// Licensed under the MIT license.
//
//===----------------------------------------------------------------------===//
#ifndef TRITON_ANALYSIS_OPFOLDRESULT_UTILS_H
#define TRITON_ANALYSIS_OPFOLDRESULT_UTILS_H
#include "mlir/IR/Location.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include <optional>
namespace mlir {
class OpBuilder;
Value materializeValue(OpBuilder &builder, Location loc, OpFoldResult ofr);
// Return integer if ofr is an IntegerAttr. Note that this function differs
// from getConstantIntValue, which returns an integer if ofr is the constant
// result of an operation too.
std::optional<int64_t> getIntAttr(const OpFoldResult ofr);
// Return if ofr contains a constant zero, either represented by an integer
// attribute or a constant value.
bool hasConstZero(const OpFoldResult ofr);
// Create a value of index type if necessary from an OpFoldResult.
Value ofrToIndexValue(const OpFoldResult ofr, const Location loc, OpBuilder &b);
// Create a vector of values of index type if necessary from an array of
// OpFoldResults.
SmallVector<Value> ofrsToIndexValues(ArrayRef<OpFoldResult> ofrs,
const Location loc, OpBuilder &b);
// Process addition of two OFRs. If both OFRs are Integer Attributes, result
// is an Integer Attribute. Otherwise, insert the arith.addi instruction if
// needed and use its result Value.
OpFoldResult addOFRs(const OpFoldResult lhs, const OpFoldResult rhs,
const Location loc, OpBuilder &b);
// Produce result = lhs - rhs. If both OFRs are Integer Attributes, result
// is an Integer Attribute. Otherwise, insert the arith.addi instruction if
// needed and use its result Value.
OpFoldResult subOFRs(const OpFoldResult lhs, const OpFoldResult rhs,
const Location loc, OpBuilder &b);
// Process multiplication of two OFRs. If both OFRs are Integer Attributes,
// result is an Integer Attribtue. Otherwise, insert the arith.muli
// instruction if needed and use its result Value.
OpFoldResult mulOFRValue(const OpFoldResult lhs, const Value rhs,
const Location loc, OpBuilder &b);
////////////ASCEND
OpFoldResult divOFRs(const OpFoldResult lhs, const OpFoldResult rhs,
const Location loc, OpBuilder &b);
OpFoldResult remOFRs(const OpFoldResult lhs, const OpFoldResult rhs,
const Location loc, OpBuilder &b);
OpFoldResult mulOFRs(const OpFoldResult lhs, const OpFoldResult rhs,
const Location loc, OpBuilder &b);
/////////////ASCEND
OpFoldResult minOFRs(const OpFoldResult lhs, const OpFoldResult rhs,
const Location loc, OpBuilder &b);
OpFoldResult maxOFRs(const OpFoldResult lhs, const OpFoldResult rhs,
const Location loc, OpBuilder &b);
OpFoldResult compareOFRs(const OpFoldResult lhs, const OpFoldResult rhs,
const arith::CmpIPredicate pred, const OpFoldResult trueVal,
const OpFoldResult falseVal, const Location loc, OpBuilder &b);
} // namespace mlir
#endif