CIRCT
20.0.0git
Loading...
Searching...
No Matches
lib
Bindings
Python
dialects
hwarith.py
Go to the documentation of this file.
1
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2
# See https://llvm.org/LICENSE.txt for license information.
3
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5
from
..dialects._ods_common
import
_cext
as
_ods_cext
6
from
..ir
import
IntegerAttr, IntegerType
7
from
..support
import
NamedValueOpView, get_value
8
from
._hwarith_ops_gen
import
*
9
from
._hwarith_ops_gen
import
_Dialect
10
11
12
class
BinaryOpBuilder
(NamedValueOpView):
13
14
def
operand_names
(self):
15
return
[
"lhs"
,
"rhs"
]
16
17
def
result_names
(self):
18
return
[
"result"
]
19
20
21
def
BinaryOp
(base):
22
23
class
_Class(base):
24
25
@classmethod
26
def
create(cls, lhs=None, rhs=None, result_type=None):
27
return
cls([get_value(lhs), get_value(rhs)])
28
29
return
_Class
30
31
32
@BinaryOp
33
@_ods_cext.register_operation(_Dialect, replace=True)
34
class
DivOp
(
DivOp
):
35
pass
36
37
38
@BinaryOp
39
@_ods_cext.register_operation(_Dialect, replace=True)
40
class
SubOp
(
SubOp
):
41
pass
42
43
44
@BinaryOp
45
@_ods_cext.register_operation(_Dialect, replace=True)
46
class
AddOp
(
AddOp
):
47
pass
48
49
50
@BinaryOp
51
@_ods_cext.register_operation(_Dialect, replace=True)
52
class
MulOp
(
MulOp
):
53
pass
54
55
56
@_ods_cext.register_operation(_Dialect, replace=
True
)
57
class
CastOp
(
CastOp
):
58
59
@classmethod
60
def
create
(cls, value, result_type):
61
return
cls(result_type, value)
62
63
64
@_ods_cext.register_operation(_Dialect, replace=True)
65
class
ICmpOp
(
ICmpOp
):
66
# Predicate constants.
67
68
# `==` and `!=`
69
PRED_EQ = 0b000
70
PRED_NE = 0b001
71
# `<` and `>=`
72
PRED_LT = 0b010
73
PRED_GE = 0b011
74
# `<=` and `>`
75
PRED_LE = 0b100
76
PRED_GT = 0b101
77
78
@classmethod
79
def
create
(cls, pred, a, b):
80
if
isinstance(pred, int):
81
pred = IntegerAttr.get(IntegerType.get_signless(64), pred)
82
return
cls(pred, a, b)
83
84
85
@_ods_cext.register_operation(_Dialect, replace=True)
86
class
ConstantOp
(
ConstantOp
):
87
88
@classmethod
89
def
create
(cls, data_type, value):
90
return
cls(IntegerAttr.get(data_type, value))
hwarith.AddOp
Definition
hwarith.py:46
hwarith.BinaryOpBuilder
Definition
hwarith.py:12
hwarith.BinaryOpBuilder.operand_names
operand_names(self)
Definition
hwarith.py:14
hwarith.BinaryOpBuilder.result_names
result_names(self)
Definition
hwarith.py:17
hwarith.CastOp
Definition
hwarith.py:57
hwarith.CastOp.create
create(cls, value, result_type)
Definition
hwarith.py:60
hwarith.ConstantOp
Definition
hwarith.py:86
hwarith.ConstantOp.create
create(cls, data_type, value)
Definition
hwarith.py:89
hwarith.DivOp
Definition
hwarith.py:34
hwarith.ICmpOp
Definition
hwarith.py:65
hwarith.ICmpOp.create
create(cls, pred, a, b)
Definition
hwarith.py:79
hwarith.MulOp
Definition
hwarith.py:52
hwarith.SubOp
Definition
hwarith.py:40
hwarith.BinaryOp
BinaryOp(base)
Definition
hwarith.py:21
Generated on Wed Jan 22 2025 00:10:06 for CIRCT by
1.9.8