Comb
comb
¶
The comb dialect provides a collection of operations that define a mid-level compiler IR for combinational logic. It is designed to be easy to analyze and transform, and be a flexible and extensible substrate that may be extended with higher level dialects mixed into it.
Up to date as of CIRCT commit 2e23cda6c2cbedb118b92fab755f1e36d80b13f5.
See external documentation.
ICMP_COMPARISON_OPERATIONS = ['eq', 'ne', 'slt', 'sle', 'sgt', 'sge', 'ult', 'ule', 'ugt', 'uge']
module-attribute
¶
Comb = Dialect('comb', [AddOp, MulOp, DivUOp, DivSOp, ModUOp, ModSOp, ShlOp, ShrUOp, ShrSOp, SubOp, AndOp, OrOp, XorOp, ICmpOp, ParityOp, ExtractOp, ConcatOp, ReplicateOp, MuxOp])
module-attribute
¶
TwoStateOperation
¶
Bases: IRDLOperation, ABC
"All operations are defined in the expected way for 2-state (binary) logic. However, comb is used for operations which have extended truth table for non-2-state logic for various target languages. The two_state variable describes if we are using 2-state (binary) logic or not."
Source code in xdsl/dialects/comb.py
two_state = opt_prop_def(UnitAttr, prop_name='twoState')
class-attribute
instance-attribute
¶
__init__(*, operands: Sequence[OperandArg | Sequence[OperandArg] | None] | None = None, result_types: Sequence[Attribute | Sequence[Attribute] | None] | None = None, attributes: Mapping[str, Attribute | None] | None = None, properties: Mapping[str, Attribute | None] | None = None, has_two_state_semantics: bool = False)
¶
Source code in xdsl/dialects/comb.py
print_optional_two_state_keyword(printer: Printer)
¶
BinCombOperation
¶
Bases: TwoStateOperation, ABC
A binary comb operation. It has two operands and one result, all of the same integer type.
Source code in xdsl/dialects/comb.py
T: ClassVar = VarConstraint.get('T', IntegerType)
class-attribute
instance-attribute
¶
lhs = operand_def(T)
class-attribute
instance-attribute
¶
rhs = operand_def(T)
class-attribute
instance-attribute
¶
result = result_def(T)
class-attribute
instance-attribute
¶
__init__(operand1: OperandArg, operand2: OperandArg, result_type: Attribute | None = None, has_two_state_semantics: bool = False, attr_dict: dict[str, Attribute] | None = None)
¶
Source code in xdsl/dialects/comb.py
parse(parser: Parser)
classmethod
¶
Source code in xdsl/dialects/comb.py
print(printer: Printer)
¶
Source code in xdsl/dialects/comb.py
VariadicCombOperation
¶
Bases: TwoStateOperation, ABC
A variadic comb operation. It has a variadic number of operands, and a single result, all of the same integer type.
Source code in xdsl/dialects/comb.py
T: ClassVar = VarConstraint.get('T', IntegerType)
class-attribute
instance-attribute
¶
inputs = var_operand_def(T)
class-attribute
instance-attribute
¶
result = result_def(T)
class-attribute
instance-attribute
¶
__init__(input_list: Sequence[OperandArg], result_type: Attribute | None = None, has_two_state_semantics: bool = False, attr_dict: dict[str, Attribute] | None = None)
¶
Source code in xdsl/dialects/comb.py
verify_() -> None
¶
parse(parser: Parser)
classmethod
¶
Source code in xdsl/dialects/comb.py
print(printer: Printer)
¶
Source code in xdsl/dialects/comb.py
AddOp
dataclass
¶
MulOp
dataclass
¶
DivUOp
dataclass
¶
DivSOp
dataclass
¶
ModUOp
dataclass
¶
ModSOp
dataclass
¶
ShlOp
dataclass
¶
ShrUOp
dataclass
¶
ShrSOp
dataclass
¶
SubOp
dataclass
¶
AndOp
dataclass
¶
OrOp
dataclass
¶
XorOp
dataclass
¶
ICmpOp
¶
Bases: TwoStateOperation, ABC
Integer comparison: A generic comparison operation, operation definitions inherit this class.
The first argument to these comparison operations is the type of comparison being performed, the following comparisons are supported:
- equal (mnemonic:
"eq"; integer value:0) - not equal (mnemonic:
"ne"; integer value:1) - signed less than (mnemonic:
"slt"; integer value:2) - signed less than or equal (mnemonic:
"sle"; integer value:3) - signed greater than (mnemonic:
"sgt"; integer value:4) - signed greater than or equal (mnemonic:
"sge"; integer value:5) - unsigned less than (mnemonic:
"ult"; integer value:6) - unsigned less than or equal (mnemonic:
"ule"; integer value:7) - unsigned greater than (mnemonic:
"ugt"; integer value:8) - unsigned greater than or equal (mnemonic:
"uge"; integer value:9)
Source code in xdsl/dialects/comb.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | |
name = 'comb.icmp'
class-attribute
instance-attribute
¶
T: ClassVar = VarConstraint.get('T', IntegerType)
class-attribute
instance-attribute
¶
predicate = prop_def(IntegerAttr[I64])
class-attribute
instance-attribute
¶
lhs = operand_def(T)
class-attribute
instance-attribute
¶
rhs = operand_def(T)
class-attribute
instance-attribute
¶
result = result_def(IntegerType(1))
class-attribute
instance-attribute
¶
__init__(operand1: OperandArg, operand2: OperandArg, arg: int | str | IntegerAttr[IntegerType], has_two_state_semantics: bool = False, attr_dict: dict[str, Attribute] | None = None)
¶
Source code in xdsl/dialects/comb.py
parse(parser: Parser)
classmethod
¶
Source code in xdsl/dialects/comb.py
print(printer: Printer)
¶
Source code in xdsl/dialects/comb.py
ParityOp
¶
Bases: TwoStateOperation
Parity
Source code in xdsl/dialects/comb.py
name = 'comb.parity'
class-attribute
instance-attribute
¶
input = operand_def(IntegerType)
class-attribute
instance-attribute
¶
result = result_def(IntegerType(1))
class-attribute
instance-attribute
¶
__init__(operand: OperandArg, has_two_state_semantics: bool = False, attr_dict: dict[str, Attribute] | None = None)
¶
Source code in xdsl/dialects/comb.py
parse(parser: Parser)
classmethod
¶
Source code in xdsl/dialects/comb.py
print(printer: Printer)
¶
Source code in xdsl/dialects/comb.py
ExtractOp
¶
Bases: IRDLOperation
Extract a range of bits into a smaller value, low_bit specifies the lowest bit included. Result is the size of the value to extract.
|-----------------| input l low bit <--------> result
Source code in xdsl/dialects/comb.py
name = 'comb.extract'
class-attribute
instance-attribute
¶
input = operand_def(IntegerType)
class-attribute
instance-attribute
¶
low_bit = prop_def(IntegerAttr[I32], prop_name='lowBit')
class-attribute
instance-attribute
¶
result = result_def(IntegerType)
class-attribute
instance-attribute
¶
__init__(operand: OperandArg, low_bit: IntegerAttr[IntegerType], result_type: IntegerType, attr_dict: dict[str, Attribute] | None = None)
¶
Source code in xdsl/dialects/comb.py
verify_() -> None
¶
Source code in xdsl/dialects/comb.py
parse(parser: Parser)
classmethod
¶
Source code in xdsl/dialects/comb.py
print(printer: Printer)
¶
Source code in xdsl/dialects/comb.py
ConcatOp
¶
Bases: IRDLOperation
Concatenate a variadic list of operands together.
Source code in xdsl/dialects/comb.py
name = 'comb.concat'
class-attribute
instance-attribute
¶
inputs = var_operand_def(IntegerType)
class-attribute
instance-attribute
¶
result = result_def(IntegerType)
class-attribute
instance-attribute
¶
__init__(ops: Sequence[OperandArg], target_type: IntegerType, attr_dict: dict[str, Attribute] | None = None)
¶
from_int_values(inputs: Sequence[SSAValue]) -> ConcatOp | None
staticmethod
¶
Concatenates the provided values, in order. Returns None if the provided values are not integers.
Source code in xdsl/dialects/comb.py
verify_() -> None
¶
Source code in xdsl/dialects/comb.py
parse(parser: Parser)
classmethod
¶
Source code in xdsl/dialects/comb.py
print(printer: Printer)
¶
Source code in xdsl/dialects/comb.py
ReplicateOp
¶
Bases: IRDLOperation
Concatenate the operand a constant number of times.
Source code in xdsl/dialects/comb.py
name = 'comb.replicate'
class-attribute
instance-attribute
¶
input = operand_def(IntegerType)
class-attribute
instance-attribute
¶
result = result_def(IntegerType)
class-attribute
instance-attribute
¶
__init__(op: OperandArg, target_type: IntegerType, attr_dict: dict[str, Attribute] | None = None)
¶
parse(parser: Parser)
classmethod
¶
Source code in xdsl/dialects/comb.py
print(printer: Printer)
¶
MuxOp
¶
Bases: TwoStateOperation
Select between two values based on a condition.