From 6912cb35947c3b15d7a928b5e45daba2c3d7eeec Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Fri, 1 Oct 2021 10:01:02 -0700 Subject: [PATCH] [spv-out] Move ExpressionPointer to back::spv::block, remove pub. --- src/back/spv/block.rs | 26 +++++++++++++++++++++----- src/back/spv/index.rs | 19 ------------------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/back/spv/block.rs b/src/back/spv/block.rs index 10e416cf10..ea5bed85ed 100644 --- a/src/back/spv/block.rs +++ b/src/back/spv/block.rs @@ -1,11 +1,8 @@ //! Implementations for `BlockContext` methods. use super::{ - index::{BoundsCheckResult, ExpressionPointer}, - make_local, - selection::Selection, - Block, BlockContext, Dimension, Error, Instruction, LocalType, LookupType, LoopContext, - ResultMember, Writer, WriterFlags, + index::BoundsCheckResult, make_local, selection::Selection, Block, BlockContext, Dimension, + Error, Instruction, LocalType, LookupType, LoopContext, ResultMember, Writer, WriterFlags, }; use crate::{arena::Handle, proc::TypeResolution}; use spirv::Word; @@ -19,6 +16,25 @@ fn get_dimension(type_inner: &crate::TypeInner) -> Dimension { } } +/// The results of emitting code for a left-hand-side expression. +/// +/// On success, `write_expression_pointer` returns one of these. +enum ExpressionPointer { + /// The pointer to the expression's value is available, as the value of the + /// expression with the given id. + Ready { pointer_id: Word }, + + /// The access expression must be conditional on the value of `condition`, a boolean + /// expression that is true if all indices are in bounds. If `condition` is true, then + /// `access` is an `OpAccessChain` instruction that will compute a pointer to the + /// expression's value. If `condition` is false, then executing `access` would be + /// undefined behavior. + Conditional { + condition: Word, + access: Instruction, + }, +} + impl Writer { // Flip Y coordinate to adjust for coordinate space difference // between SPIR-V and our IR. diff --git a/src/back/spv/index.rs b/src/back/spv/index.rs index f6b92b1d05..4192d3848e 100644 --- a/src/back/spv/index.rs +++ b/src/back/spv/index.rs @@ -3,25 +3,6 @@ use super::{selection::Selection, Block, BlockContext, Error, IdGenerator, Instruction, Word}; use crate::{arena::Handle, proc::BoundsCheckPolicy}; -/// The results of emitting code for a left-hand-side expression. -/// -/// On success, `write_expression_pointer` returns one of these. -pub(super) enum ExpressionPointer { - /// The pointer to the expression's value is available, as the value of the - /// expression with the given id. - Ready { pointer_id: Word }, - - /// The access expression must be conditional on the value of `condition`, a boolean - /// expression that is true if all indices are in bounds. If `condition` is true, then - /// `access` is an `OpAccessChain` instruction that will compute a pointer to the - /// expression's value. If `condition` is false, then executing `access` would be - /// undefined behavior. - Conditional { - condition: Word, - access: Instruction, - }, -} - /// The results of performing a bounds check. /// /// On success, `write_bounds_check` returns a value of this type.