-
Notifications
You must be signed in to change notification settings - Fork 57
/
test_attribute_definition.py
763 lines (551 loc) · 22.2 KB
/
test_attribute_definition.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
"""
Test the definition of attributes and their constraints.
"""
from __future__ import annotations
from dataclasses import dataclass
from enum import auto
from io import StringIO
from typing import Annotated, Any, Generic, TypeAlias, TypeVar, cast
import pytest
from xdsl.dialects.builtin import IndexType, IntegerAttr, IntegerType, Signedness
from xdsl.ir import (
Attribute,
Data,
EnumAttribute,
OpaqueSyntaxAttribute,
ParametrizedAttribute,
StrEnum,
)
from xdsl.irdl import (
AnyAttr,
AttrConstraint,
BaseAttr,
ConstraintVar,
GenericData,
ParamAttrDef,
ParameterDef,
irdl_attr_definition,
irdl_to_attr_constraint,
)
from xdsl.parser import AttrParser
from xdsl.printer import Printer
from xdsl.utils.exceptions import PyRDLAttrDefinitionError, VerifyException
def test_wrong_attribute_type():
with pytest.raises(
TypeError,
match="Class AbstractAttribute should either be a subclass of 'Data' or 'ParametrizedAttribute'",
):
@irdl_attr_definition
class AbstractAttribute(Attribute): # pyright: ignore[reportUnusedClass]
name = "test.wrong"
pass
################################################################################
# Data attributes
################################################################################
@irdl_attr_definition
class BoolData(Data[bool]):
"""An attribute holding a boolean value."""
name = "test.bool"
@classmethod
def parse_parameter(cls, parser: AttrParser) -> bool:
with parser.in_angle_brackets():
if parser.parse_optional_keyword("True"):
return True
if parser.parse_optional_keyword("False"):
return False
parser.raise_error("Expected True or False literal")
def print_parameter(self, printer: Printer):
with printer.in_angle_brackets():
printer.print_string(str(self.data))
@irdl_attr_definition
class IntData(Data[int]):
"""An attribute holding an integer value."""
name = "test.int"
@classmethod
def parse_parameter(cls, parser: AttrParser) -> int:
with parser.in_angle_brackets():
return parser.parse_integer()
def print_parameter(self, printer: Printer):
with printer.in_angle_brackets():
printer.print_string(str(self.data))
@irdl_attr_definition
class StringData(Data[str]):
"""An attribute holding a string value."""
name = "test.str"
@classmethod
def parse_parameter(cls, parser: AttrParser) -> str:
with parser.in_angle_brackets():
return parser.parse_str_literal()
def print_parameter(self, printer: Printer):
with printer.in_angle_brackets():
printer.print_string(self.data)
def test_simple_data():
"""Test that the definition of a data with a class parameter."""
b = BoolData(True)
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(b)
assert stream.getvalue() == "#test.bool<True>"
@irdl_attr_definition
class IntListData(Data[list[int]]):
"""
An attribute holding a list of integers.
"""
name = "test.int_list"
@classmethod
def parse_parameter(cls, parser: AttrParser) -> list[int]:
raise NotImplementedError()
def print_parameter(self, printer: Printer) -> None:
with printer.in_angle_brackets():
printer.print_string("[")
printer.print_list(self.data, lambda x: printer.print_string(str(x)))
printer.print_string("]")
def test_non_class_data():
"""Test the definition of a Data with a non-class parameter."""
attr = IntListData([0, 1, 42])
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(attr)
assert stream.getvalue() == "#test.int_list<[0, 1, 42]>"
class TestEnum(StrEnum):
Yes = auto()
No = auto()
class TestNonIdentifierEnum(StrEnum):
"""
The value defined by this StrEnum is not parsable as an identifier, because of the
contained space.
While valid as a StrEnum, it is thus invalid to use it in an EnumAttribute.
"""
Spaced = "left right"
@irdl_attr_definition
class EnumData(EnumAttribute[TestEnum], OpaqueSyntaxAttribute):
name = "test.enum"
def test_enum_attribute():
"""Test the definition of an EnumAttribute."""
attr = EnumData(TestEnum.No)
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(attr)
assert stream.getvalue() == "#test<enum no>"
def test_indirect_enum_guard():
EnumType = TypeVar("EnumType", bound=StrEnum)
with pytest.raises(
TypeError, match="Only direct inheritance from EnumAttribute is allowed."
):
class IndirectEnumData( # pyright: ignore[reportUnusedClass]
EnumAttribute[EnumType]
):
name = "test.indirect_enum"
def test_identifier_enum_guard():
with pytest.raises(
ValueError,
match="All StrEnum values of an EnumAttribute must be parsable as an identifer.",
):
class IndirectEnumData( # pyright: ignore[reportUnusedClass]
EnumAttribute[TestNonIdentifierEnum]
):
name = "test.non_identifier_enum"
################################################################################
# IntegerAttr
################################################################################
def test_signed_integer_attr():
"""Test the verification of a signed integer attribute."""
with pytest.raises(VerifyException):
IntegerAttr(1 << 31, IntegerType(32, Signedness.SIGNED))
with pytest.raises(VerifyException):
IntegerAttr(-(1 << 31) - 1, IntegerType(32, Signedness.SIGNED))
IntegerAttr((1 << 31) - 1, IntegerType(32, Signedness.SIGNED))
IntegerAttr(-(1 << 31), IntegerType(32, Signedness.SIGNED))
def test_unsigned_integer_attr():
"""Test the verification of a unsigned integer attribute."""
with pytest.raises(VerifyException):
IntegerAttr(1 << 32, IntegerType(32, Signedness.UNSIGNED))
with pytest.raises(VerifyException):
IntegerAttr(-1, IntegerType(32, Signedness.UNSIGNED))
IntegerAttr((1 << 32) - 1, IntegerType(32, Signedness.UNSIGNED))
def test_signless_integer_attr():
"""Test the verification of a signless integer attribute."""
with pytest.raises(VerifyException):
IntegerAttr((1 << 32) + 1, IntegerType(32, Signedness.SIGNLESS))
with pytest.raises(VerifyException):
IntegerAttr(-(1 << 32) - 1, IntegerType(32, Signedness.SIGNLESS))
IntegerAttr(1 << 32, IntegerType(32, Signedness.SIGNLESS))
IntegerAttr(-(1 << 32), IntegerType(32, Signedness.SIGNLESS))
################################################################################
# PyRDL Base constraints
################################################################################
@irdl_attr_definition
class BoolWrapperAttr(ParametrizedAttribute):
name = "test.bool_wrapper"
param: ParameterDef[BoolData]
def test_bose_constraint():
"""Test the verifier of a base attribute type constraint."""
attr = BoolWrapperAttr([BoolData(True)])
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(attr)
assert stream.getvalue() == "#test.bool_wrapper<#test.bool<True>>"
def test_base_constraint_fail():
"""Test the verifier of a union constraint."""
with pytest.raises(Exception) as e:
BoolWrapperAttr([StringData("foo")])
assert e.value.args[0] == "#test.str<foo> should be of base attribute test.bool"
################################################################################
# PyRDL union constraints
################################################################################
@irdl_attr_definition
class BoolOrIntParamAttr(ParametrizedAttribute):
name = "test.bool_or_int"
param: ParameterDef[BoolData | IntData]
def test_union_constraint_left():
"""Test the verifier of a union constraint."""
attr = BoolOrIntParamAttr([BoolData(True)])
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(attr)
assert stream.getvalue() == "#test.bool_or_int<#test.bool<True>>"
def test_union_constraint_right():
"""Test the verifier of a union constraint."""
attr = BoolOrIntParamAttr([IntData(42)])
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(attr)
assert stream.getvalue() == "#test.bool_or_int<#test.int<42>>"
def test_union_constraint_fail():
"""Test the verifier of a union constraint."""
with pytest.raises(Exception) as e:
BoolOrIntParamAttr([StringData("foo")])
assert e.value.args[0] == "Unexpected attribute #test.str<foo>"
################################################################################
# PyRDL Annotated constraints
################################################################################
class PositiveIntConstr(AttrConstraint):
def verify(self, attr: Attribute, constraint_vars: dict[str, Attribute]) -> None:
if not isinstance(attr, IntData):
raise VerifyException(
f"Expected {IntData.name} attribute, but got {attr.name}."
)
if attr.data <= 0:
raise VerifyException(f"Expected positive integer, got {attr.data}.")
@irdl_attr_definition
class PositiveIntAttr(ParametrizedAttribute):
name = "test.positive_int"
param: ParameterDef[Annotated[IntData, PositiveIntConstr()]]
def test_annotated_constraint():
"""Test the verifier of an annotated constraint."""
attr = PositiveIntAttr([IntData(42)])
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(attr)
assert stream.getvalue() == "#test.positive_int<#test.int<42>>"
def test_annotated_constraint_fail():
"""Test that the verifier of an annotated constraint can fail."""
with pytest.raises(Exception) as e:
PositiveIntAttr([IntData(-42)])
assert e.value.args[0] == "Expected positive integer, got -42."
################################################################################
# PyRDL Generic constraints
################################################################################
_T = TypeVar("_T", bound=BoolData | IntData)
@irdl_attr_definition
class ParamWrapperAttr(Generic[_T], ParametrizedAttribute):
name = "test.int_or_bool_generic"
param: ParameterDef[_T]
def test_typevar_attribute_int():
"""Test the verifier of a generic attribute."""
attr = ParamWrapperAttr[IntData]([IntData(42)])
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(attr)
assert stream.getvalue() == "#test.int_or_bool_generic<#test.int<42>>"
def test_typevar_attribute_bool():
"""Test the verifier of a generic attribute."""
attr = ParamWrapperAttr[BoolData]([BoolData(True)])
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(attr)
assert stream.getvalue() == "#test.int_or_bool_generic<#test.bool<True>>"
def test_typevar_attribute_fail():
"""Test that the verifier of an generic attribute can fail."""
with pytest.raises(Exception) as e:
ParamWrapperAttr([StringData("foo")])
assert e.value.args[0] == "Unexpected attribute #test.str<foo>"
@irdl_attr_definition
class ParamConstrAttr(ParametrizedAttribute):
name = "test.param_constr"
param: ParameterDef[ParamWrapperAttr[IntData]]
def test_param_attr_constraint():
"""Test the verifier of an attribute with a parametric constraint."""
attr = ParamConstrAttr([ParamWrapperAttr([IntData(42)])])
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(attr)
assert (
stream.getvalue()
== "#test.param_constr<#test.int_or_bool_generic<#test.int<42>>>"
)
def test_param_attr_constraint_fail():
"""
Test that the verifier of an attribute with
a parametric constraint can fail.
"""
with pytest.raises(Exception) as e:
ParamConstrAttr([ParamWrapperAttr([BoolData(True)])])
assert e.value.args[0] == "#test.bool<True> should be of base attribute test.int"
_U = TypeVar("_U", bound=IntData)
@irdl_attr_definition
class NestedParamWrapperAttr(Generic[_U], ParametrizedAttribute):
name = "test.nested_param_wrapper"
param: ParameterDef[ParamWrapperAttr[_U]]
def test_nested_generic_constraint():
"""
Test the verifier of an attribute with a generic
constraint used in a parametric constraint.
"""
attr = NestedParamWrapperAttr[IntData]([ParamWrapperAttr([IntData(42)])])
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(attr)
assert (
stream.getvalue()
== "#test.nested_param_wrapper<#test.int_or_bool_generic<#test.int<42>>>"
)
def test_nested_generic_constraint_fail():
"""
Test that the verifier of an attribute with
a parametric constraint can fail.
"""
with pytest.raises(Exception) as e:
NestedParamWrapperAttr([ParamWrapperAttr([BoolData(True)])])
assert e.value.args[0] == "#test.bool<True> should be of base attribute test.int"
@irdl_attr_definition
class NestedParamConstrAttr(ParametrizedAttribute):
name = "test.nested_param_constr"
param: ParameterDef[NestedParamWrapperAttr[Annotated[IntData, PositiveIntConstr()]]]
def test_nested_param_attr_constraint():
"""
Test the verifier of a nested parametric constraint.
"""
attr = NestedParamConstrAttr(
[NestedParamWrapperAttr([ParamWrapperAttr([IntData(42)])])]
)
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(attr)
assert (
stream.getvalue()
== "#test.nested_param_constr<#test.nested_param_wrapper<#test.int_or_bool_generic<#test.int<42>>>>"
)
def test_nested_param_attr_constraint_fail():
"""
Test that the verifier of a nested parametric constraint can fail.
"""
with pytest.raises(Exception) as e:
NestedParamConstrAttr(
[NestedParamWrapperAttr([ParamWrapperAttr([IntData(-42)])])]
)
assert e.value.args[0] == "Expected positive integer, got -42."
################################################################################
# GenericData definition
################################################################################
_MissingGenericDataData = TypeVar("_MissingGenericDataData")
@irdl_attr_definition
class MissingGenericDataData(Data[_MissingGenericDataData]):
name = "test.missing_genericdata"
@classmethod
def parse_parameter(cls, parser: AttrParser) -> _MissingGenericDataData:
raise NotImplementedError()
def print_parameter(self, printer: Printer) -> None:
raise NotImplementedError()
def verify(self) -> None:
return
class MissingGenericDataDataWrapper(ParametrizedAttribute):
name = "test.missing_genericdata_wrapper"
param: ParameterDef[MissingGenericDataData[int]]
def test_data_with_generic_missing_generic_data_failure():
"""
Test error message when a generic data is used in constraints
without implementing GenericData.
"""
with pytest.raises(Exception) as e:
irdl_attr_definition(MissingGenericDataDataWrapper)
assert e.value.args[0] == (
"Generic `Data` type 'test.missing_genericdata' cannot be converted to "
"an attribute constraint. Consider making it inherit from "
"`GenericData` instead of `Data`."
)
A = TypeVar("A", bound=Attribute)
@dataclass
class DataListAttr(AttrConstraint):
"""
A constraint that enforces that the elements of a ListData all respect
a constraint.
"""
elem_constr: AttrConstraint
def verify(self, attr: Attribute, constraint_vars: dict[str, Attribute]) -> None:
attr = cast(ListData[Attribute], attr)
for e in attr.data:
self.elem_constr.verify(e, constraint_vars)
@irdl_attr_definition
class ListData(GenericData[list[A]]):
name = "test.list"
@classmethod
def parse_parameter(cls, parser: AttrParser) -> list[A]:
raise NotImplementedError()
def print_parameter(self, printer: Printer) -> None:
with printer.in_angle_brackets():
printer.print_string("[")
printer.print_list(self.data, printer.print_attribute)
printer.print_string("]")
@staticmethod
def generic_constraint_coercion(args: tuple[Any]) -> AttrConstraint:
assert len(args) == 1
return DataListAttr(irdl_to_attr_constraint(args[0]))
@staticmethod
def from_list(data: list[A]) -> ListData[A]:
return ListData(data)
def verify(self) -> None:
for idx, val in enumerate(self.data):
if not isinstance(val, Attribute):
raise VerifyException(
f"{self.name} data expects attribute list, but element "
f"{idx} is of type {type(val)}."
)
AnyListData: TypeAlias = ListData[Attribute]
class Test_generic_data_verifier:
def test_generic_data_verifier(self):
"""
Test that a GenericData can be created.
"""
attr = ListData([BoolData(True), ListData([BoolData(False)])])
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(attr)
assert (
stream.getvalue()
== "#test.list<[#test.bool<True>, #test.list<[#test.bool<False>]>]>"
)
@irdl_attr_definition
class ListDataWrapper(ParametrizedAttribute):
name = "test.list_wrapper"
val: ParameterDef[ListData[BoolData]]
def test_generic_data_wrapper_verifier():
"""
Test that a GenericData used in constraints pass the verifier when correct.
"""
attr = ListDataWrapper([ListData([BoolData(True), BoolData(False)])])
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(attr)
assert (
stream.getvalue()
== "#test.list_wrapper<#test.list<[#test.bool<True>, #test.bool<False>]>>"
)
def test_generic_data_wrapper_verifier_failure():
"""
Test that a GenericData used in constraints fails
the verifier when constraints are not satisfied.
"""
with pytest.raises(VerifyException) as e:
ListDataWrapper([ListData([BoolData(True), ListData([BoolData(False)])])])
assert (
e.value.args[0]
== "#test.list<[#test.bool<False>]> should be of base attribute test.bool"
)
assert (
e.value.args[0]
== "#test.list<[#test.bool<False>]> should be of base attribute test.bool"
)
@irdl_attr_definition
class ListDataNoGenericsWrapper(ParametrizedAttribute):
name = "test.list_no_generics_wrapper"
val: ParameterDef[AnyListData]
def test_generic_data_no_generics_wrapper_verifier():
"""
Test that GenericType can be used in constraints without a parameter.
"""
attr = ListDataNoGenericsWrapper(
[ListData([BoolData(True), ListData([BoolData(False)])])]
)
stream = StringIO()
p = Printer(stream=stream)
p.print_attribute(attr)
assert (
stream.getvalue()
== "#test.list_no_generics_wrapper<#test.list<[#test.bool<True>, #test.list<[#test.bool<False>]>]>>"
)
################################################################################
# Parametrized attribute definition
################################################################################
@irdl_attr_definition
class ParamAttrDefAttr(ParametrizedAttribute):
name = "test.param_attr_def_attr"
arg1: ParameterDef[Attribute]
arg2: ParameterDef[BoolData]
# Check that we can define methods in attribute definition
def test(self):
pass
def test_irdl_definition():
"""Test that we can get the IRDL definition of a parametrized attribute."""
assert ParamAttrDefAttr.get_irdl_definition() == ParamAttrDef(
"test.param_attr_def_attr", [("arg1", AnyAttr()), ("arg2", BaseAttr(BoolData))]
)
class InvalidTypedFieldTestAttr(ParametrizedAttribute):
name = "test.invalid_typed_field"
x: int
def test_invalid_typed_field():
"""Check that typed fields are not allowed."""
with pytest.raises(PyRDLAttrDefinitionError):
irdl_attr_definition(InvalidTypedFieldTestAttr)
class InvalidUntypedFieldTestAttr(ParametrizedAttribute):
name = "test.invalid_untyped_field"
x = 2
def test_invalid_field():
"""Check that untyped fields are not allowed."""
with pytest.raises(PyRDLAttrDefinitionError):
irdl_attr_definition(InvalidUntypedFieldTestAttr)
@irdl_attr_definition
class OveriddenInitAttr(ParametrizedAttribute):
name = "test.overidden_init"
param: ParameterDef[Attribute]
def __init__(self, param: int | str):
match param:
case int():
super().__init__([IntData(param)])
case str():
super().__init__([StringData(param)])
def test_generic_constructor():
"""Test the generic constructor of a ParametrizedAttribute."""
param = IntData(42)
attr = OveriddenInitAttr.new([param])
assert isinstance(attr, OveriddenInitAttr)
assert attr.param == param
def test_custom_constructor():
"""Test the use of custom constructors in ParametrizedAttribute."""
assert OveriddenInitAttr.new([IntData(42)]) == OveriddenInitAttr(42)
assert OveriddenInitAttr.new([StringData("17")]) == OveriddenInitAttr("17")
################################################################################
# ConstraintVar
################################################################################
@irdl_attr_definition
class ConstraintVarAttr(ParametrizedAttribute):
name = "test.constraint_var"
T = Annotated[IntegerType, ConstraintVar("T")]
param1: ParameterDef[IntegerAttr[T]]
param2: ParameterDef[IntegerAttr[T]]
def test_constraint_var():
"""Test that ConstraintVar can be used in attributes."""
ConstraintVarAttr.new([IntegerAttr(42, 32), IntegerAttr(17, 32)])
ConstraintVarAttr.new([IntegerAttr(42, 64), IntegerAttr(17, 64)])
def test_constraint_var_fail_non_equal():
"""Test that constraint variables must be equal."""
with pytest.raises(VerifyException):
ConstraintVarAttr.new([IntegerAttr(42, 32), IntegerAttr(42, 64)])
with pytest.raises(VerifyException):
ConstraintVarAttr.new([IntegerAttr(42, 64), IntegerAttr(42, 32)])
def test_constraint_var_fail_not_satisfy_constraint():
"""Test that constraint variables must satisfy the underlying constraint."""
with pytest.raises(VerifyException):
ConstraintVarAttr.new(
[IntegerAttr(42, IndexType()), IntegerAttr(17, IndexType())]
)