triton_air/table_column.rs
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 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816
//! Enums that convert table column names into `usize` indices. Allows
//! addressing columns by name rather than their hard-to-remember index.
use std::hash::Hash;
use strum::Display;
use strum::EnumCount;
use strum::EnumIter;
use crate::table::AUX_CASCADE_TABLE_START;
use crate::table::AUX_HASH_TABLE_START;
use crate::table::AUX_JUMP_STACK_TABLE_START;
use crate::table::AUX_LOOKUP_TABLE_START;
use crate::table::AUX_OP_STACK_TABLE_START;
use crate::table::AUX_PROCESSOR_TABLE_START;
use crate::table::AUX_PROGRAM_TABLE_START;
use crate::table::AUX_RAM_TABLE_START;
use crate::table::AUX_U32_TABLE_START;
use crate::table::CASCADE_TABLE_START;
use crate::table::HASH_TABLE_START;
use crate::table::JUMP_STACK_TABLE_START;
use crate::table::LOOKUP_TABLE_START;
use crate::table::OP_STACK_TABLE_START;
use crate::table::PROCESSOR_TABLE_START;
use crate::table::PROGRAM_TABLE_START;
use crate::table::RAM_TABLE_START;
use crate::table::U32_TABLE_START;
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum ProgramMainColumn {
/// An instruction's address.
Address,
/// The (opcode of the) instruction.
Instruction,
/// How often an instruction has been executed.
LookupMultiplicity,
/// The index in the vector of length [`Rate`] that is to be absorbed in the Sponge
/// in order to compute the program's digest.
/// In other words:
/// [`Address`] modulo [`Rate`].
///
/// [`Address`]: ProgramMainColumn::Address
/// [`Rate`]: twenty_first::math::tip5::RATE
IndexInChunk,
/// The inverse-or-zero of [`Rate`] - 1 - [`IndexInChunk`].
/// Helper variable to guarantee [`IndexInChunk`]'s correct transition.
///
/// [`IndexInChunk`]: ProgramMainColumn::IndexInChunk
/// [`Rate`]: twenty_first::math::tip5::RATE
MaxMinusIndexInChunkInv,
/// Padding indicator for absorbing the program into the Sponge.
IsHashInputPadding,
/// Padding indicator for rows only required due to the dominating length of some other table.
IsTablePadding,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum ProgramAuxColumn {
/// The server part of the instruction lookup.
///
/// The counterpart to [`InstructionLookupClientLogDerivative`][client].
///
/// [client]: ProcessorAuxColumn::InstructionLookupClientLogDerivative
InstructionLookupServerLogDerivative,
/// An evaluation argument accumulating [`RATE`][rate] many instructions before
/// they are sent using [`SendChunkEvalArg`](ProgramAuxColumn::SendChunkRunningEvaluation).
/// Resets to zero after each chunk.
/// Relevant for program attestation.
///
/// [rate]: twenty_first::math::tip5::RATE
PrepareChunkRunningEvaluation,
/// An evaluation argument over all [`RATE`][rate]-sized chunks of instructions,
/// which are prepared in [`PrepareChunkEvalArg`][prep].
/// This bus is used for sending those chunks to the Hash Table.
/// Relevant for program attestation.
///
/// The counterpart to [`RcvChunkEvalArg`](HashAuxColumn::ReceiveChunkRunningEvaluation).
///
/// [rate]: twenty_first::math::tip5::RATE
/// [prep]: ProgramAuxColumn::PrepareChunkRunningEvaluation
SendChunkRunningEvaluation,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum ProcessorMainColumn {
CLK,
IsPadding,
IP,
CI,
NIA,
IB0,
IB1,
IB2,
IB3,
IB4,
IB5,
IB6,
JSP,
JSO,
JSD,
ST0,
ST1,
ST2,
ST3,
ST4,
ST5,
ST6,
ST7,
ST8,
ST9,
ST10,
ST11,
ST12,
ST13,
ST14,
ST15,
OpStackPointer,
HV0,
HV1,
HV2,
HV3,
HV4,
HV5,
/// The number of clock jump differences of magnitude `CLK` in all memory-like tables.
ClockJumpDifferenceLookupMultiplicity,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum ProcessorAuxColumn {
InputTableEvalArg,
OutputTableEvalArg,
InstructionLookupClientLogDerivative,
OpStackTablePermArg,
RamTablePermArg,
JumpStackTablePermArg,
/// For copying the hash function's input to the hash coprocessor.
HashInputEvalArg,
/// For copying the hash digest from the hash coprocessor.
HashDigestEvalArg,
/// For copying the RATE next to-be-absorbed to the hash coprocessor and the RATE squeezed
/// elements from the hash coprocessor, depending on the executed instruction.
SpongeEvalArg,
/// The (running sum of the) logarithmic derivative for the Lookup Argument with the U32 Table.
U32LookupClientLogDerivative,
/// The (running sum of the) logarithmic derivative for the clock jump difference Lookup
/// Argument with the memory-like tables.
ClockJumpDifferenceLookupServerLogDerivative,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum OpStackMainColumn {
CLK,
IB1ShrinkStack,
StackPointer,
FirstUnderflowElement,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum OpStackAuxColumn {
RunningProductPermArg,
/// The (running sum of the) logarithmic derivative for the clock jump difference Lookup
/// Argument with the Processor Table.
ClockJumpDifferenceLookupClientLogDerivative,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum RamMainColumn {
CLK,
/// Is [`INSTRUCTION_TYPE_READ`] for instruction `read_mem` and [`INSTRUCTION_TYPE_WRITE`]
/// for instruction `write_mem`. For padding rows, this is set to [`PADDING_INDICATOR`].
///
/// [`INSTRUCTION_TYPE_READ`]: crate::table::ram::INSTRUCTION_TYPE_READ
/// [`INSTRUCTION_TYPE_WRITE`]: crate::table::ram::INSTRUCTION_TYPE_WRITE
/// [`PADDING_INDICATOR`]: crate::table::ram::PADDING_INDICATOR
InstructionType,
RamPointer,
RamValue,
InverseOfRampDifference,
BezoutCoefficientPolynomialCoefficient0,
BezoutCoefficientPolynomialCoefficient1,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum RamAuxColumn {
RunningProductOfRAMP,
FormalDerivative,
BezoutCoefficient0,
BezoutCoefficient1,
RunningProductPermArg,
/// The (running sum of the) logarithmic derivative for the clock jump difference Lookup
/// Argument with the Processor Table.
ClockJumpDifferenceLookupClientLogDerivative,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum JumpStackMainColumn {
CLK,
CI,
JSP,
JSO,
JSD,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum JumpStackAuxColumn {
RunningProductPermArg,
/// The (running sum of the) logarithmic derivative for the clock jump difference Lookup
/// Argument with the Processor Table.
ClockJumpDifferenceLookupClientLogDerivative,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum HashMainColumn {
/// The indicator for the [`HashTableMode`][mode].
///
/// [mode]: crate::table::hash::HashTableMode
Mode,
/// The current instruction. Only relevant for [`Mode`][mode] [`Sponge`][mode_sponge]
/// in order to distinguish between the different Sponge instructions.
///
/// [mode]: HashMainColumn::Mode
/// [mode_sponge]: crate::table::hash::HashTableMode::Sponge
CI,
/// The number of the current round in the permutation. The round number evolves as
/// - 0 → 1 → 2 → 3 → 4 → 5 (→ 0) in [`Mode`][mode]s
/// [`ProgramHashing`][mode_prog_hash], [`Sponge`][mode_sponge] and [`Hash`][mode_hash],
/// - 0 → 0 in [`Mode`][mode] [`Sponge`][mode_sponge] if the current instruction [`CI`][ci] is
/// `sponge_init`, as an exception to above rule, and
/// - 0 → 0 in [`Mode`][mode] [`Pad`][mode_pad].
///
/// [ci]: HashMainColumn::CI
/// [mode]: HashMainColumn::Mode
/// [mode_prog_hash]: crate::table::hash::HashTableMode::ProgramHashing
/// [mode_sponge]: crate::table::hash::HashTableMode::Sponge
/// [mode_hash]: crate::table::hash::HashTableMode::Hash
/// [mode_pad]: crate::table::hash::HashTableMode::Pad
RoundNumber,
State0HighestLkIn,
State0MidHighLkIn,
State0MidLowLkIn,
State0LowestLkIn,
State1HighestLkIn,
State1MidHighLkIn,
State1MidLowLkIn,
State1LowestLkIn,
State2HighestLkIn,
State2MidHighLkIn,
State2MidLowLkIn,
State2LowestLkIn,
State3HighestLkIn,
State3MidHighLkIn,
State3MidLowLkIn,
State3LowestLkIn,
State0HighestLkOut,
State0MidHighLkOut,
State0MidLowLkOut,
State0LowestLkOut,
State1HighestLkOut,
State1MidHighLkOut,
State1MidLowLkOut,
State1LowestLkOut,
State2HighestLkOut,
State2MidHighLkOut,
State2MidLowLkOut,
State2LowestLkOut,
State3HighestLkOut,
State3MidHighLkOut,
State3MidLowLkOut,
State3LowestLkOut,
State4,
State5,
State6,
State7,
State8,
State9,
State10,
State11,
State12,
State13,
State14,
State15,
State0Inv,
State1Inv,
State2Inv,
State3Inv,
Constant0,
Constant1,
Constant2,
Constant3,
Constant4,
Constant5,
Constant6,
Constant7,
Constant8,
Constant9,
Constant10,
Constant11,
Constant12,
Constant13,
Constant14,
Constant15,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum HashAuxColumn {
/// The evaluation argument corresponding to receiving instructions in chunks of size
/// [`RATE`][rate]. The chunks are hashed in Sponge mode.
/// This allows program attestation.
///
/// The counterpart to [`SendChunkEvalArg`](ProgramAuxColumn::SendChunkRunningEvaluation).
///
/// [rate]: twenty_first::math::tip5::RATE
ReceiveChunkRunningEvaluation,
HashInputRunningEvaluation,
HashDigestRunningEvaluation,
SpongeRunningEvaluation,
CascadeState0HighestClientLogDerivative,
CascadeState0MidHighClientLogDerivative,
CascadeState0MidLowClientLogDerivative,
CascadeState0LowestClientLogDerivative,
CascadeState1HighestClientLogDerivative,
CascadeState1MidHighClientLogDerivative,
CascadeState1MidLowClientLogDerivative,
CascadeState1LowestClientLogDerivative,
CascadeState2HighestClientLogDerivative,
CascadeState2MidHighClientLogDerivative,
CascadeState2MidLowClientLogDerivative,
CascadeState2LowestClientLogDerivative,
CascadeState3HighestClientLogDerivative,
CascadeState3MidHighClientLogDerivative,
CascadeState3MidLowClientLogDerivative,
CascadeState3LowestClientLogDerivative,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum CascadeMainColumn {
/// Indicator for padding rows.
IsPadding,
/// The more significant bits of the lookup input.
LookInHi,
/// The less significant bits of the lookup input.
LookInLo,
/// The more significant bits of the lookup output.
LookOutHi,
/// The less significant bits of the lookup output.
LookOutLo,
/// The number of times the S-Box is evaluated, _i.e._, the value is looked up.
LookupMultiplicity,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum CascadeAuxColumn {
/// The (running sum of the) logarithmic derivative for the Lookup Argument with the Hash Table.
/// In every row, the sum accumulates `LookupMultiplicity / (X - Combo)` where `X` is a
/// verifier-supplied challenge and `Combo` is the weighted sum of
/// - `2^8·LookInHi + LookInLo`, and
/// - `2^8·LookOutHi + LookOutLo`
/// with weights supplied by the verifier.
HashTableServerLogDerivative,
/// The (running sum of the) logarithmic derivative for the Lookup Argument with the Lookup
/// Table. In every row, accumulates the two summands
/// - `1 / combo_hi` where `combo_hi` is the verifier-weighted combination of `LookInHi` and
/// `LookOutHi`, and
/// - `1 / combo_lo` where `combo_lo` is the verifier-weighted combination of `LookInLo` and
/// `LookOutLo`.
LookupTableClientLogDerivative,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum LookupMainColumn {
/// Indicator for padding rows.
IsPadding,
/// The lookup input.
LookIn,
/// The lookup output.
LookOut,
/// The number of times the value is looked up.
LookupMultiplicity,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum LookupAuxColumn {
/// The (running sum of the) logarithmic derivative for the Lookup Argument with the Cascade
/// Table. In every row, accumulates the summand `LookupMultiplicity / Combo` where `Combo` is
/// the verifier-weighted combination of `LookIn` and `LookOut`.
CascadeTableServerLogDerivative,
/// The running sum for the public evaluation argument of the Lookup Table.
/// In every row, accumulates `LookOut`.
PublicEvaluationArgument,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum U32MainColumn {
/// Marks the beginning of an independent section within the U32 table.
CopyFlag,
/// The number of bits that LHS and RHS have already been shifted by.
Bits,
/// The inverse-or-zero of the difference between
/// 1. the first disallowed number of bits to shift LHS and RHS by, _i.e.,_ 33, and
/// 2. the number of bits that LHS and RHS have already been shifted by.
BitsMinus33Inv,
/// Current Instruction, the instruction the processor is currently executing.
CI,
/// Left-hand side of the operation.
LHS,
/// The inverse-or-zero of LHS. Needed to check whether `LHS` is unequal to 0.
LhsInv,
/// Right-hand side of the operation.
RHS,
/// The inverse-or-zero of RHS. Needed to check whether `RHS` is unequal to 0.
RhsInv,
/// The result (or intermediate result) of the instruction requested by the processor.
Result,
/// The number of times the processor has executed the current instruction with the same
/// arguments.
LookupMultiplicity,
}
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
pub enum U32AuxColumn {
/// The (running sum of the) logarithmic derivative for the Lookup Argument with the
/// Processor Table.
LookupServerLogDerivative,
}
/// A trait for the columns of the master main table. This trait is implemented for all enums
/// relating to the main tables. This trait provides two methods:
/// - one to get the index of the column in the “local” main table, _i.e., not the master base
/// table, and
/// - one to get the index of the column in the master main table.
pub trait MasterMainColumn {
/// The index of the column in the “local” main table, _i.e., not the master base table.
fn main_index(&self) -> usize;
/// The index of the column in the master main table.
fn master_main_index(&self) -> usize;
}
impl MasterMainColumn for ProgramMainColumn {
#[inline]
fn main_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_main_index(&self) -> usize {
PROGRAM_TABLE_START + self.main_index()
}
}
impl MasterMainColumn for ProcessorMainColumn {
#[inline]
fn main_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_main_index(&self) -> usize {
PROCESSOR_TABLE_START + self.main_index()
}
}
impl MasterMainColumn for OpStackMainColumn {
#[inline]
fn main_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_main_index(&self) -> usize {
OP_STACK_TABLE_START + self.main_index()
}
}
impl MasterMainColumn for RamMainColumn {
#[inline]
fn main_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_main_index(&self) -> usize {
RAM_TABLE_START + self.main_index()
}
}
impl MasterMainColumn for JumpStackMainColumn {
#[inline]
fn main_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_main_index(&self) -> usize {
JUMP_STACK_TABLE_START + self.main_index()
}
}
impl MasterMainColumn for HashMainColumn {
#[inline]
fn main_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_main_index(&self) -> usize {
HASH_TABLE_START + self.main_index()
}
}
impl MasterMainColumn for CascadeMainColumn {
#[inline]
fn main_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_main_index(&self) -> usize {
CASCADE_TABLE_START + self.main_index()
}
}
impl MasterMainColumn for LookupMainColumn {
#[inline]
fn main_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_main_index(&self) -> usize {
LOOKUP_TABLE_START + self.main_index()
}
}
impl MasterMainColumn for U32MainColumn {
#[inline]
fn main_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_main_index(&self) -> usize {
U32_TABLE_START + self.main_index()
}
}
/// A trait for the columns in the master auxiliary table. This trait is implemented for all enums
/// relating to the auxiliary tables. The trait provides two methods:
/// - one to get the index of the column in the “local” auxiliary table, _i.e._, not the master
/// auxiliary table, and
/// - one to get the index of the column in the master auxiliary table.
pub trait MasterAuxColumn {
/// The index of the column in the “local” auxiliary table, _i.e._, not the master extension
/// table.
fn aux_index(&self) -> usize;
/// The index of the column in the master auxiliary table.
fn master_aux_index(&self) -> usize;
}
impl MasterAuxColumn for ProgramAuxColumn {
#[inline]
fn aux_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_aux_index(&self) -> usize {
AUX_PROGRAM_TABLE_START + self.aux_index()
}
}
impl MasterAuxColumn for ProcessorAuxColumn {
#[inline]
fn aux_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_aux_index(&self) -> usize {
AUX_PROCESSOR_TABLE_START + self.aux_index()
}
}
impl MasterAuxColumn for OpStackAuxColumn {
#[inline]
fn aux_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_aux_index(&self) -> usize {
AUX_OP_STACK_TABLE_START + self.aux_index()
}
}
impl MasterAuxColumn for RamAuxColumn {
#[inline]
fn aux_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_aux_index(&self) -> usize {
AUX_RAM_TABLE_START + self.aux_index()
}
}
impl MasterAuxColumn for JumpStackAuxColumn {
#[inline]
fn aux_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_aux_index(&self) -> usize {
AUX_JUMP_STACK_TABLE_START + self.aux_index()
}
}
impl MasterAuxColumn for HashAuxColumn {
#[inline]
fn aux_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_aux_index(&self) -> usize {
AUX_HASH_TABLE_START + self.aux_index()
}
}
impl MasterAuxColumn for CascadeAuxColumn {
#[inline]
fn aux_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_aux_index(&self) -> usize {
AUX_CASCADE_TABLE_START + self.aux_index()
}
}
impl MasterAuxColumn for LookupAuxColumn {
#[inline]
fn aux_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_aux_index(&self) -> usize {
AUX_LOOKUP_TABLE_START + self.aux_index()
}
}
impl MasterAuxColumn for U32AuxColumn {
#[inline]
fn aux_index(&self) -> usize {
(*self) as usize
}
#[inline]
fn master_aux_index(&self) -> usize {
AUX_U32_TABLE_START + self.aux_index()
}
}
#[cfg(test)]
mod tests {
use strum::IntoEnumIterator;
use super::*;
#[test]
fn master_main_table_is_contiguous() {
let mut expected_column_index = 0;
for column in ProgramMainColumn::iter() {
assert_eq!(expected_column_index, column.master_main_index());
expected_column_index += 1;
}
for column in ProcessorMainColumn::iter() {
assert_eq!(expected_column_index, column.master_main_index());
expected_column_index += 1;
}
for column in OpStackMainColumn::iter() {
assert_eq!(expected_column_index, column.master_main_index());
expected_column_index += 1;
}
for column in RamMainColumn::iter() {
assert_eq!(expected_column_index, column.master_main_index());
expected_column_index += 1;
}
for column in JumpStackMainColumn::iter() {
assert_eq!(expected_column_index, column.master_main_index());
expected_column_index += 1;
}
for column in HashMainColumn::iter() {
assert_eq!(expected_column_index, column.master_main_index());
expected_column_index += 1;
}
for column in CascadeMainColumn::iter() {
assert_eq!(expected_column_index, column.master_main_index());
expected_column_index += 1;
}
for column in LookupMainColumn::iter() {
assert_eq!(expected_column_index, column.master_main_index());
expected_column_index += 1;
}
for column in U32MainColumn::iter() {
assert_eq!(expected_column_index, column.master_main_index());
expected_column_index += 1;
}
}
#[test]
fn master_aux_table_is_contiguous() {
let mut expected_column_index = 0;
for column in ProgramAuxColumn::iter() {
assert_eq!(expected_column_index, column.master_aux_index());
expected_column_index += 1;
}
for column in ProcessorAuxColumn::iter() {
assert_eq!(expected_column_index, column.master_aux_index());
expected_column_index += 1;
}
for column in OpStackAuxColumn::iter() {
assert_eq!(expected_column_index, column.master_aux_index());
expected_column_index += 1;
}
for column in RamAuxColumn::iter() {
assert_eq!(expected_column_index, column.master_aux_index());
expected_column_index += 1;
}
for column in JumpStackAuxColumn::iter() {
assert_eq!(expected_column_index, column.master_aux_index());
expected_column_index += 1;
}
for column in HashAuxColumn::iter() {
assert_eq!(expected_column_index, column.master_aux_index());
expected_column_index += 1;
}
for column in CascadeAuxColumn::iter() {
assert_eq!(expected_column_index, column.master_aux_index());
expected_column_index += 1;
}
for column in LookupAuxColumn::iter() {
assert_eq!(expected_column_index, column.master_aux_index());
expected_column_index += 1;
}
for column in U32AuxColumn::iter() {
assert_eq!(expected_column_index, column.master_aux_index());
expected_column_index += 1;
}
}
}