1//===-- SPIRVLogicalOps.td - MLIR SPIR-V Logical Ops -------*- tablegen -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// This file contains arithmetic ops for the SPIR-V dialect. It corresponds 10// to "3.32.15. Relational and Logical Instructions" of the SPIR-V spec. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef SPIRV_LOGICAL_OPS 15#define SPIRV_LOGICAL_OPS 16 17include "mlir/Dialect/SPIRV/SPIRVBase.td" 18include "mlir/Interfaces/SideEffectInterfaces.td" 19 20class SPV_LogicalBinaryOp<string mnemonic, Type operandsType, 21 list<OpTrait> traits = []> : 22 // Result type is SPV_Bool. 23 SPV_BinaryOp<mnemonic, SPV_Bool, operandsType, 24 !listconcat(traits, 25 [NoSideEffect, SameTypeOperands, 26 SameOperandsAndResultShape])> { 27 let parser = [{ return ::parseLogicalBinaryOp(parser, result); }]; 28 let printer = [{ return ::printLogicalOp(getOperation(), p); }]; 29 30 let builders = [ 31 OpBuilderDAG<(ins "Value":$lhs, "Value":$rhs), 32 [{::buildLogicalBinaryOp($_builder, $_state, lhs, rhs);}]> 33 ]; 34} 35 36class SPV_LogicalUnaryOp<string mnemonic, Type operandType, 37 list<OpTrait> traits = []> : 38 // Result type is SPV_Bool. 39 SPV_UnaryOp<mnemonic, SPV_Bool, operandType, 40 !listconcat(traits, [NoSideEffect, SameTypeOperands, 41 SameOperandsAndResultShape])> { 42 let parser = [{ return ::parseLogicalUnaryOp(parser, result); }]; 43 let printer = [{ return ::printLogicalOp(getOperation(), p); }]; 44} 45 46// ----- 47 48def SPV_FOrdEqualOp : SPV_LogicalBinaryOp<"FOrdEqual", SPV_Float, [Commutative]> { 49 let summary = "Floating-point comparison for being ordered and equal."; 50 51 let description = [{ 52 Result Type must be a scalar or vector of Boolean type. 53 54 The type of Operand 1 and Operand 2 must be a scalar or vector of 55 floating-point type. They must have the same type, and they must have 56 the same number of components as Result Type. 57 58 Results are computed per component. 59 60 <!-- End of AutoGen section --> 61 62 ``` 63 float-scalar-vector-type ::= float-type | 64 `vector<` integer-literal `x` float-type `>` 65 fordequal-op ::= ssa-id `=` `spv.FOrdEqual` ssa-use, ssa-use 66 ``` 67 68 #### Example: 69 70 ```mlir 71 %4 = spv.FOrdEqual %0, %1 : f32 72 %5 = spv.FOrdEqual %2, %3 : vector<4xf32> 73 ``` 74 }]; 75} 76 77// ----- 78 79def SPV_FOrdGreaterThanOp : SPV_LogicalBinaryOp<"FOrdGreaterThan", SPV_Float, []> { 80 let summary = [{ 81 Floating-point comparison if operands are ordered and Operand 1 is 82 greater than Operand 2. 83 }]; 84 85 let description = [{ 86 Result Type must be a scalar or vector of Boolean type. 87 88 The type of Operand 1 and Operand 2 must be a scalar or vector of 89 floating-point type. They must have the same type, and they must have 90 the same number of components as Result Type. 91 92 Results are computed per component. 93 94 <!-- End of AutoGen section --> 95 96 ``` 97 float-scalar-vector-type ::= float-type | 98 `vector<` integer-literal `x` float-type `>` 99 fordgt-op ::= ssa-id `=` `spv.FOrdGreaterThan` ssa-use, ssa-use 100 ``` 101 102 #### Example: 103 104 ```mlir 105 %4 = spv.FOrdGreaterThan %0, %1 : f32 106 %5 = spv.FOrdGreaterThan %2, %3 : vector<4xf32> 107 ``` 108 }]; 109} 110 111// ----- 112 113def SPV_FOrdGreaterThanEqualOp : SPV_LogicalBinaryOp<"FOrdGreaterThanEqual", SPV_Float, []> { 114 let summary = [{ 115 Floating-point comparison if operands are ordered and Operand 1 is 116 greater than or equal to Operand 2. 117 }]; 118 119 let description = [{ 120 Result Type must be a scalar or vector of Boolean type. 121 122 The type of Operand 1 and Operand 2 must be a scalar or vector of 123 floating-point type. They must have the same type, and they must have 124 the same number of components as Result Type. 125 126 Results are computed per component. 127 128 <!-- End of AutoGen section --> 129 130 ``` 131 float-scalar-vector-type ::= float-type | 132 `vector<` integer-literal `x` float-type `>` 133 fordgte-op ::= ssa-id `=` `spv.FOrdGreaterThanEqual` ssa-use, ssa-use 134 ``` 135 136 #### Example: 137 138 ```mlir 139 %4 = spv.FOrdGreaterThanEqual %0, %1 : f32 140 %5 = spv.FOrdGreaterThanEqual %2, %3 : vector<4xf32> 141 ``` 142 }]; 143} 144 145// ----- 146 147def SPV_FOrdLessThanOp : SPV_LogicalBinaryOp<"FOrdLessThan", SPV_Float, []> { 148 let summary = [{ 149 Floating-point comparison if operands are ordered and Operand 1 is less 150 than Operand 2. 151 }]; 152 153 let description = [{ 154 Result Type must be a scalar or vector of Boolean type. 155 156 The type of Operand 1 and Operand 2 must be a scalar or vector of 157 floating-point type. They must have the same type, and they must have 158 the same number of components as Result Type. 159 160 Results are computed per component. 161 162 <!-- End of AutoGen section --> 163 164 ``` 165 float-scalar-vector-type ::= float-type | 166 `vector<` integer-literal `x` float-type `>` 167 fordlt-op ::= ssa-id `=` `spv.FOrdLessThan` ssa-use, ssa-use 168 ``` 169 170 #### Example: 171 172 ```mlir 173 %4 = spv.FOrdLessThan %0, %1 : f32 174 %5 = spv.FOrdLessThan %2, %3 : vector<4xf32> 175 ``` 176 }]; 177} 178 179// ----- 180 181def SPV_FOrdLessThanEqualOp : SPV_LogicalBinaryOp<"FOrdLessThanEqual", SPV_Float, []> { 182 let summary = [{ 183 Floating-point comparison if operands are ordered and Operand 1 is less 184 than or equal to Operand 2. 185 }]; 186 187 let description = [{ 188 Result Type must be a scalar or vector of Boolean type. 189 190 The type of Operand 1 and Operand 2 must be a scalar or vector of 191 floating-point type. They must have the same type, and they must have 192 the same number of components as Result Type. 193 194 Results are computed per component. 195 196 <!-- End of AutoGen section --> 197 198 ``` 199 float-scalar-vector-type ::= float-type | 200 `vector<` integer-literal `x` float-type `>` 201 fordlte-op ::= ssa-id `=` `spv.FOrdLessThanEqual` ssa-use, ssa-use 202 ``` 203 204 #### Example: 205 206 ```mlir 207 %4 = spv.FOrdLessThanEqual %0, %1 : f32 208 %5 = spv.FOrdLessThanEqual %2, %3 : vector<4xf32> 209 ``` 210 }]; 211} 212 213// ----- 214 215def SPV_FOrdNotEqualOp : SPV_LogicalBinaryOp<"FOrdNotEqual", SPV_Float, [Commutative]> { 216 let summary = "Floating-point comparison for being ordered and not equal."; 217 218 let description = [{ 219 Result Type must be a scalar or vector of Boolean type. 220 221 The type of Operand 1 and Operand 2 must be a scalar or vector of 222 floating-point type. They must have the same type, and they must have 223 the same number of components as Result Type. 224 225 Results are computed per component. 226 227 <!-- End of AutoGen section --> 228 229 ``` 230 float-scalar-vector-type ::= float-type | 231 `vector<` integer-literal `x` float-type `>` 232 fordneq-op ::= ssa-id `=` `spv.FOrdNotEqual` ssa-use, ssa-use 233 ``` 234 235 #### Example: 236 237 ```mlir 238 %4 = spv.FOrdNotEqual %0, %1 : f32 239 %5 = spv.FOrdNotEqual %2, %3 : vector<4xf32> 240 ``` 241 }]; 242} 243 244// ----- 245 246def SPV_FUnordEqualOp : SPV_LogicalBinaryOp<"FUnordEqual", SPV_Float, [Commutative]> { 247 let summary = "Floating-point comparison for being unordered or equal."; 248 249 let description = [{ 250 Result Type must be a scalar or vector of Boolean type. 251 252 The type of Operand 1 and Operand 2 must be a scalar or vector of 253 floating-point type. They must have the same type, and they must have 254 the same number of components as Result Type. 255 256 Results are computed per component. 257 258 <!-- End of AutoGen section --> 259 260 ``` 261 float-scalar-vector-type ::= float-type | 262 `vector<` integer-literal `x` float-type `>` 263 funordequal-op ::= ssa-id `=` `spv.FUnordEqual` ssa-use, ssa-use 264 ``` 265 266 #### Example: 267 268 ```mlir 269 %4 = spv.FUnordEqual %0, %1 : f32 270 %5 = spv.FUnordEqual %2, %3 : vector<4xf32> 271 ``` 272 }]; 273} 274 275// ----- 276 277def SPV_FUnordGreaterThanOp : SPV_LogicalBinaryOp<"FUnordGreaterThan", SPV_Float, []> { 278 let summary = [{ 279 Floating-point comparison if operands are unordered or Operand 1 is 280 greater than Operand 2. 281 }]; 282 283 let description = [{ 284 Result Type must be a scalar or vector of Boolean type. 285 286 The type of Operand 1 and Operand 2 must be a scalar or vector of 287 floating-point type. They must have the same type, and they must have 288 the same number of components as Result Type. 289 290 Results are computed per component. 291 292 <!-- End of AutoGen section --> 293 294 ``` 295 float-scalar-vector-type ::= float-type | 296 `vector<` integer-literal `x` float-type `>` 297 funordgt-op ::= ssa-id `=` `spv.FUnordGreaterThan` ssa-use, ssa-use 298 ``` 299 300 #### Example: 301 302 ```mlir 303 %4 = spv.FUnordGreaterThan %0, %1 : f32 304 %5 = spv.FUnordGreaterThan %2, %3 : vector<4xf32> 305 ``` 306 }]; 307} 308 309// ----- 310 311def SPV_FUnordGreaterThanEqualOp : SPV_LogicalBinaryOp<"FUnordGreaterThanEqual", SPV_Float, []> { 312 let summary = [{ 313 Floating-point comparison if operands are unordered or Operand 1 is 314 greater than or equal to Operand 2. 315 }]; 316 317 let description = [{ 318 Result Type must be a scalar or vector of Boolean type. 319 320 The type of Operand 1 and Operand 2 must be a scalar or vector of 321 floating-point type. They must have the same type, and they must have 322 the same number of components as Result Type. 323 324 Results are computed per component. 325 326 <!-- End of AutoGen section --> 327 328 ``` 329 float-scalar-vector-type ::= float-type | 330 `vector<` integer-literal `x` float-type `>` 331 funordgte-op ::= ssa-id `=` `spv.FUnordGreaterThanEqual` ssa-use, ssa-use 332 ``` 333 334 #### Example: 335 336 ```mlir 337 %4 = spv.FUnordGreaterThanEqual %0, %1 : f32 338 %5 = spv.FUnordGreaterThanEqual %2, %3 : vector<4xf32> 339 ``` 340 }]; 341} 342 343// ----- 344 345def SPV_FUnordLessThanOp : SPV_LogicalBinaryOp<"FUnordLessThan", SPV_Float, []> { 346 let summary = [{ 347 Floating-point comparison if operands are unordered or Operand 1 is less 348 than Operand 2. 349 }]; 350 351 let description = [{ 352 Result Type must be a scalar or vector of Boolean type. 353 354 The type of Operand 1 and Operand 2 must be a scalar or vector of 355 floating-point type. They must have the same type, and they must have 356 the same number of components as Result Type. 357 358 Results are computed per component. 359 360 <!-- End of AutoGen section --> 361 362 ``` 363 float-scalar-vector-type ::= float-type | 364 `vector<` integer-literal `x` float-type `>` 365 funordlt-op ::= ssa-id `=` `spv.FUnordLessThan` ssa-use, ssa-use 366 ``` 367 368 #### Example: 369 370 ```mlir 371 %4 = spv.FUnordLessThan %0, %1 : f32 372 %5 = spv.FUnordLessThan %2, %3 : vector<4xf32> 373 ``` 374 }]; 375} 376 377// ----- 378 379def SPV_FUnordLessThanEqualOp : SPV_LogicalBinaryOp<"FUnordLessThanEqual", SPV_Float, []> { 380 let summary = [{ 381 Floating-point comparison if operands are unordered or Operand 1 is less 382 than or equal to Operand 2. 383 }]; 384 385 let description = [{ 386 Result Type must be a scalar or vector of Boolean type. 387 388 The type of Operand 1 and Operand 2 must be a scalar or vector of 389 floating-point type. They must have the same type, and they must have 390 the same number of components as Result Type. 391 392 Results are computed per component. 393 394 <!-- End of AutoGen section --> 395 396 ``` 397 float-scalar-vector-type ::= float-type | 398 `vector<` integer-literal `x` float-type `>` 399 funordlte-op ::= ssa-id `=` `spv.FUnordLessThanEqual` ssa-use, ssa-use 400 ``` 401 402 #### Example: 403 404 ```mlir 405 %4 = spv.FUnordLessThanEqual %0, %1 : f32 406 %5 = spv.FUnordLessThanEqual %2, %3 : vector<4xf32> 407 ``` 408 }]; 409} 410 411// ----- 412 413def SPV_FUnordNotEqualOp : SPV_LogicalBinaryOp<"FUnordNotEqual", SPV_Float, [Commutative]> { 414 let summary = "Floating-point comparison for being unordered or not equal."; 415 416 let description = [{ 417 Result Type must be a scalar or vector of Boolean type. 418 419 The type of Operand 1 and Operand 2 must be a scalar or vector of 420 floating-point type. They must have the same type, and they must have 421 the same number of components as Result Type. 422 423 Results are computed per component. 424 425 <!-- End of AutoGen section --> 426 427 ``` 428 float-scalar-vector-type ::= float-type | 429 `vector<` integer-literal `x` float-type `>` 430 funordneq-op ::= ssa-id `=` `spv.FUnordNotEqual` ssa-use, ssa-use 431 ``` 432 433 #### Example: 434 435 ```mlir 436 %4 = spv.FUnordNotEqual %0, %1 : f32 437 %5 = spv.FUnordNotEqual %2, %3 : vector<4xf32> 438 ``` 439 }]; 440} 441 442// ----- 443 444def SPV_IEqualOp : SPV_LogicalBinaryOp<"IEqual", SPV_Integer, [Commutative]> { 445 let summary = "Integer comparison for equality."; 446 447 let description = [{ 448 Result Type must be a scalar or vector of Boolean type. 449 450 The type of Operand 1 and Operand 2 must be a scalar or vector of 451 integer type. They must have the same component width, and they must 452 have the same number of components as Result Type. 453 454 Results are computed per component. 455 456 <!-- End of AutoGen section --> 457 ``` 458 integer-scalar-vector-type ::= integer-type | 459 `vector<` integer-literal `x` integer-type `>` 460 iequal-op ::= ssa-id `=` `spv.IEqual` ssa-use, ssa-use 461 `:` integer-scalar-vector-type 462 ``` 463 #### Example: 464 465 ```mlir 466 %4 = spv.IEqual %0, %1 : i32 467 %5 = spv.IEqual %2, %3 : vector<4xi32> 468 469 ``` 470 }]; 471} 472 473// ----- 474 475def SPV_INotEqualOp : SPV_LogicalBinaryOp<"INotEqual", SPV_Integer, [Commutative]> { 476 let summary = "Integer comparison for inequality."; 477 478 let description = [{ 479 Result Type must be a scalar or vector of Boolean type. 480 481 The type of Operand 1 and Operand 2 must be a scalar or vector of 482 integer type. They must have the same component width, and they must 483 have the same number of components as Result Type. 484 485 Results are computed per component. 486 487 <!-- End of AutoGen section --> 488 ``` 489 integer-scalar-vector-type ::= integer-type | 490 `vector<` integer-literal `x` integer-type `>` 491 inot-equal-op ::= ssa-id `=` `spv.INotEqual` ssa-use, ssa-use 492 `:` integer-scalar-vector-type 493 ``` 494 #### Example: 495 496 ```mlir 497 %4 = spv.INotEqual %0, %1 : i32 498 %5 = spv.INotEqual %2, %3 : vector<4xi32> 499 500 ``` 501 }]; 502} 503 504// ----- 505 506def SPV_LogicalAndOp : SPV_LogicalBinaryOp<"LogicalAnd", SPV_Bool, [Commutative]> { 507 let summary = [{ 508 Result is true if both Operand 1 and Operand 2 are true. Result is false 509 if either Operand 1 or Operand 2 are false. 510 }]; 511 512 let description = [{ 513 Result Type must be a scalar or vector of Boolean type. 514 515 The type of Operand 1 must be the same as Result Type. 516 517 The type of Operand 2 must be the same as Result Type. 518 519 Results are computed per component. 520 521 <!-- End of AutoGen section --> 522 523 ``` 524 logical-and ::= `spv.LogicalAnd` ssa-use `,` ssa-use 525 `:` operand-type 526 ``` 527 528 #### Example: 529 530 ```mlir 531 %2 = spv.LogicalAnd %0, %1 : i1 532 %2 = spv.LogicalAnd %0, %1 : vector<4xi1> 533 ``` 534 }]; 535 536 let hasFolder = 1; 537} 538 539// ----- 540 541def SPV_LogicalEqualOp : SPV_LogicalBinaryOp<"LogicalEqual", SPV_Bool, [Commutative]> { 542 let summary = [{ 543 Result is true if Operand 1 and Operand 2 have the same value. Result is 544 false if Operand 1 and Operand 2 have different values. 545 }]; 546 547 let description = [{ 548 Result Type must be a scalar or vector of Boolean type. 549 550 The type of Operand 1 must be the same as Result Type. 551 552 The type of Operand 2 must be the same as Result Type. 553 554 Results are computed per component. 555 556 <!-- End of AutoGen section --> 557 558 ``` 559 logical-equal ::= `spv.LogicalEqual` ssa-use `,` ssa-use 560 `:` operand-type 561 ``` 562 563 #### Example: 564 565 ```mlir 566 %2 = spv.LogicalEqual %0, %1 : i1 567 %2 = spv.LogicalEqual %0, %1 : vector<4xi1> 568 ``` 569 }]; 570} 571 572// ----- 573 574def SPV_LogicalNotOp : SPV_LogicalUnaryOp<"LogicalNot", SPV_Bool, []> { 575 let summary = [{ 576 Result is true if Operand is false. Result is false if Operand is true. 577 }]; 578 579 let description = [{ 580 Result Type must be a scalar or vector of Boolean type. 581 582 The type of Operand must be the same as Result Type. 583 584 Results are computed per component. 585 586 <!-- End of AutoGen section --> 587 588 ``` 589 logical-not ::= `spv.LogicalNot` ssa-use `:` operand-type 590 ``` 591 592 #### Example: 593 594 ```mlir 595 %2 = spv.LogicalNot %0 : i1 596 %2 = spv.LogicalNot %0 : vector<4xi1> 597 ``` 598 }]; 599 600 let hasCanonicalizer = 1; 601} 602 603// ----- 604 605def SPV_LogicalNotEqualOp : SPV_LogicalBinaryOp<"LogicalNotEqual", SPV_Bool, [Commutative]> { 606 let summary = [{ 607 Result is true if Operand 1 and Operand 2 have different values. Result 608 is false if Operand 1 and Operand 2 have the same value. 609 }]; 610 611 let description = [{ 612 Result Type must be a scalar or vector of Boolean type. 613 614 The type of Operand 1 must be the same as Result Type. 615 616 The type of Operand 2 must be the same as Result Type. 617 618 Results are computed per component. 619 620 <!-- End of AutoGen section --> 621 622 ``` 623 logical-not-equal ::= `spv.LogicalNotEqual` ssa-use `,` ssa-use 624 `:` operand-type 625 ``` 626 627 #### Example: 628 629 ```mlir 630 %2 = spv.LogicalNotEqual %0, %1 : i1 631 %2 = spv.LogicalNotEqual %0, %1 : vector<4xi1> 632 ``` 633 }]; 634} 635 636// ----- 637 638def SPV_LogicalOrOp : SPV_LogicalBinaryOp<"LogicalOr", SPV_Bool, [Commutative]> { 639 let summary = [{ 640 Result is true if either Operand 1 or Operand 2 is true. Result is false 641 if both Operand 1 and Operand 2 are false. 642 }]; 643 644 let description = [{ 645 Result Type must be a scalar or vector of Boolean type. 646 647 The type of Operand 1 must be the same as Result Type. 648 649 The type of Operand 2 must be the same as Result Type. 650 651 Results are computed per component. 652 653 <!-- End of AutoGen section --> 654 655 ``` 656 logical-or ::= `spv.LogicalOr` ssa-use `,` ssa-use 657 `:` operand-type 658 ``` 659 660 #### Example: 661 662 ```mlir 663 %2 = spv.LogicalOr %0, %1 : i1 664 %2 = spv.LogicalOr %0, %1 : vector<4xi1> 665 ``` 666 }]; 667 668 let hasFolder = 1; 669} 670 671// ----- 672 673def SPV_SGreaterThanOp : SPV_LogicalBinaryOp<"SGreaterThan", SPV_Integer, []> { 674 let summary = [{ 675 Signed-integer comparison if Operand 1 is greater than Operand 2. 676 }]; 677 678 let description = [{ 679 Result Type must be a scalar or vector of Boolean type. 680 681 The type of Operand 1 and Operand 2 must be a scalar or vector of 682 integer type. They must have the same component width, and they must 683 have the same number of components as Result Type. 684 685 Results are computed per component. 686 687 <!-- End of AutoGen section --> 688 ``` 689 integer-scalar-vector-type ::= integer-type | 690 `vector<` integer-literal `x` integer-type `>` 691 sgreater-than-op ::= ssa-id `=` `spv.SGreaterThan` ssa-use, ssa-use 692 `:` integer-scalar-vector-type 693 ``` 694 #### Example: 695 696 ```mlir 697 %4 = spv.SGreaterThan %0, %1 : i32 698 %5 = spv.SGreaterThan %2, %3 : vector<4xi32> 699 700 ``` 701 }]; 702} 703 704// ----- 705 706def SPV_SGreaterThanEqualOp : SPV_LogicalBinaryOp<"SGreaterThanEqual", SPV_Integer, []> { 707 let summary = [{ 708 Signed-integer comparison if Operand 1 is greater than or equal to 709 Operand 2. 710 }]; 711 712 let description = [{ 713 Result Type must be a scalar or vector of Boolean type. 714 715 The type of Operand 1 and Operand 2 must be a scalar or vector of 716 integer type. They must have the same component width, and they must 717 have the same number of components as Result Type. 718 719 Results are computed per component. 720 721 <!-- End of AutoGen section --> 722 ``` 723 integer-scalar-vector-type ::= integer-type | 724 `vector<` integer-literal `x` integer-type `>` 725 sgreater-than-equal-op ::= ssa-id `=` `spv.SGreaterThanEqual` ssa-use, ssa-use 726 `:` integer-scalar-vector-type 727 ``` 728 #### Example: 729 730 ``` 731 %4 = spv.SGreaterThanEqual %0, %1 : i32 732 %5 = spv.SGreaterThanEqual %2, %3 : vector<4xi32> 733 734 ``` 735 }]; 736} 737 738// ----- 739 740def SPV_SLessThanOp : SPV_LogicalBinaryOp<"SLessThan", SPV_Integer, []> { 741 let summary = [{ 742 Signed-integer comparison if Operand 1 is less than Operand 2. 743 }]; 744 745 let description = [{ 746 Result Type must be a scalar or vector of Boolean type. 747 748 The type of Operand 1 and Operand 2 must be a scalar or vector of 749 integer type. They must have the same component width, and they must 750 have the same number of components as Result Type. 751 752 Results are computed per component. 753 754 <!-- End of AutoGen section --> 755 ``` 756 integer-scalar-vector-type ::= integer-type | 757 `vector<` integer-literal `x` integer-type `>` 758 sless-than-op ::= ssa-id `=` `spv.SLessThan` ssa-use, ssa-use 759 `:` integer-scalar-vector-type 760 ``` 761 #### Example: 762 763 ```mlir 764 %4 = spv.SLessThan %0, %1 : i32 765 %5 = spv.SLessThan %2, %3 : vector<4xi32> 766 767 ``` 768 }]; 769} 770 771// ----- 772 773def SPV_SLessThanEqualOp : SPV_LogicalBinaryOp<"SLessThanEqual", SPV_Integer, []> { 774 let summary = [{ 775 Signed-integer comparison if Operand 1 is less than or equal to Operand 776 2. 777 }]; 778 779 let description = [{ 780 Result Type must be a scalar or vector of Boolean type. 781 782 The type of Operand 1 and Operand 2 must be a scalar or vector of 783 integer type. They must have the same component width, and they must 784 have the same number of components as Result Type. 785 786 Results are computed per component. 787 788 <!-- End of AutoGen section --> 789 ``` 790 integer-scalar-vector-type ::= integer-type | 791 `vector<` integer-literal `x` integer-type `>` 792 sless-than-equal-op ::= ssa-id `=` `spv.SLessThanEqual` ssa-use, ssa-use 793 `:` integer-scalar-vector-type 794 ``` 795 #### Example: 796 797 ```mlir 798 %4 = spv.SLessThanEqual %0, %1 : i32 799 %5 = spv.SLessThanEqual %2, %3 : vector<4xi32> 800 801 ``` 802 }]; 803} 804 805// ----- 806 807def SPV_SelectOp : SPV_Op<"Select", 808 [NoSideEffect, AllTypesMatch<["true_value", "false_value", "result"]>]> { 809 let summary = [{ 810 Select between two objects. Before version 1.4, results are only 811 computed per component. 812 }]; 813 814 let description = [{ 815 Before version 1.4, Result Type must be a pointer, scalar, or vector. 816 817 The types of Object 1 and Object 2 must be the same as Result Type. 818 819 Condition must be a scalar or vector of Boolean type. 820 821 If Condition is a scalar and true, the result is Object 1. If Condition 822 is a scalar and false, the result is Object 2. 823 824 If Condition is a vector, Result Type must be a vector with the same 825 number of components as Condition and the result is a mix of Object 1 826 and Object 2: When a component of Condition is true, the corresponding 827 component in the result is taken from Object 1, otherwise it is taken 828 from Object 2. 829 830 <!-- End of AutoGen section --> 831 832 ``` 833 scalar-type ::= integer-type | float-type | boolean-type 834 select-object-type ::= scalar-type 835 | `vector<` integer-literal `x` scalar-type `>` 836 | pointer-type 837 select-condition-type ::= boolean-type 838 | `vector<` integer-literal `x` boolean-type `>` 839 select-op ::= ssa-id `=` `spv.Select` ssa-use, ssa-use, ssa-use 840 `:` select-condition-type `,` select-object-type 841 ``` 842 843 #### Example: 844 845 ```mlir 846 %3 = spv.Select %0, %1, %2 : i1, f32 847 %3 = spv.Select %0, %1, %2 : i1, vector<3xi32> 848 %3 = spv.Select %0, %1, %2 : vector<3xi1>, vector<3xf32> 849 ``` 850 }]; 851 852 let arguments = (ins 853 SPV_ScalarOrVectorOf<SPV_Bool>:$condition, 854 SPV_SelectType:$true_value, 855 SPV_SelectType:$false_value 856 ); 857 858 let results = (outs 859 SPV_SelectType:$result 860 ); 861 862 let builders = [ 863 OpBuilderDAG<(ins "Value":$cond, "Value":$trueValue, "Value":$falseValue)>]; 864 865 let assemblyFormat = [{ 866 operands attr-dict `:` type($condition) `,` type($result) 867 }]; 868} 869 870// ----- 871 872def SPV_UGreaterThanOp : SPV_LogicalBinaryOp<"UGreaterThan", SPV_Integer, []> { 873 let summary = [{ 874 Unsigned-integer comparison if Operand 1 is greater than Operand 2. 875 }]; 876 877 let description = [{ 878 Result Type must be a scalar or vector of Boolean type. 879 880 The type of Operand 1 and Operand 2 must be a scalar or vector of 881 integer type. They must have the same component width, and they must 882 have the same number of components as Result Type. 883 884 Results are computed per component. 885 886 <!-- End of AutoGen section --> 887 ``` 888 integer-scalar-vector-type ::= integer-type | 889 `vector<` integer-literal `x` integer-type `>` 890 ugreater-than-op ::= ssa-id `=` `spv.UGreaterThan` ssa-use, ssa-use 891 `:` integer-scalar-vector-type 892 ``` 893 #### Example: 894 895 ```mlir 896 %4 = spv.UGreaterThan %0, %1 : i32 897 %5 = spv.UGreaterThan %2, %3 : vector<4xi32> 898 899 ``` 900 }]; 901} 902 903// ----- 904 905def SPV_UGreaterThanEqualOp : SPV_LogicalBinaryOp<"UGreaterThanEqual", SPV_Integer, []> { 906 let summary = [{ 907 Unsigned-integer comparison if Operand 1 is greater than or equal to 908 Operand 2. 909 }]; 910 911 let description = [{ 912 Result Type must be a scalar or vector of Boolean type. 913 914 The type of Operand 1 and Operand 2 must be a scalar or vector of 915 integer type. They must have the same component width, and they must 916 have the same number of components as Result Type. 917 918 Results are computed per component. 919 920 <!-- End of AutoGen section --> 921 ``` 922 integer-scalar-vector-type ::= integer-type | 923 `vector<` integer-literal `x` integer-type `>` 924 ugreater-than-equal-op ::= ssa-id `=` `spv.UGreaterThanEqual` ssa-use, ssa-use 925 `:` integer-scalar-vector-type 926 ``` 927 #### Example: 928 929 ```mlir 930 %4 = spv.UGreaterThanEqual %0, %1 : i32 931 %5 = spv.UGreaterThanEqual %2, %3 : vector<4xi32> 932 933 ``` 934 }]; 935} 936 937// ----- 938 939def SPV_ULessThanOp : SPV_LogicalBinaryOp<"ULessThan", SPV_Integer, []> { 940 let summary = [{ 941 Unsigned-integer comparison if Operand 1 is less than Operand 2. 942 }]; 943 944 let description = [{ 945 Result Type must be a scalar or vector of Boolean type. 946 947 The type of Operand 1 and Operand 2 must be a scalar or vector of 948 integer type. They must have the same component width, and they must 949 have the same number of components as Result Type. 950 951 Results are computed per component. 952 953 <!-- End of AutoGen section --> 954 ``` 955 integer-scalar-vector-type ::= integer-type | 956 `vector<` integer-literal `x` integer-type `>` 957 uless-than-op ::= ssa-id `=` `spv.ULessThan` ssa-use, ssa-use 958 `:` integer-scalar-vector-type 959 ``` 960 #### Example: 961 962 ```mlir 963 %4 = spv.ULessThan %0, %1 : i32 964 %5 = spv.ULessThan %2, %3 : vector<4xi32> 965 966 ``` 967 }]; 968} 969 970// ----- 971 972def SPV_ULessThanEqualOp : 973 SPV_LogicalBinaryOp<"ULessThanEqual", SPV_Integer, []> { 974 let summary = [{ 975 Unsigned-integer comparison if Operand 1 is less than or equal to 976 Operand 2. 977 }]; 978 979 let description = [{ 980 Result Type must be a scalar or vector of Boolean type. 981 982 The type of Operand 1 and Operand 2 must be a scalar or vector of 983 integer type. They must have the same component width, and they must 984 have the same number of components as Result Type. 985 986 Results are computed per component. 987 988 <!-- End of AutoGen section --> 989 ``` 990 integer-scalar-vector-type ::= integer-type | 991 `vector<` integer-literal `x` integer-type `>` 992 uless-than-equal-op ::= ssa-id `=` `spv.ULessThanEqual` ssa-use, ssa-use 993 `:` integer-scalar-vector-type 994 ``` 995 #### Example: 996 997 ```mlir 998 %4 = spv.ULessThanEqual %0, %1 : i32 999 %5 = spv.ULessThanEqual %2, %3 : vector<4xi32> 1000 1001 ``` 1002 }]; 1003} 1004 1005#endif // SPIRV_LOGICAL_OPS 1006