On Wednesday 28 May 2014, Matt Turner wrote: > On Tue, May 27, 2014 at 7:49 PM, Ian Romanick <i...@freedesktop.org> wrote: > > From: Ian Romanick <ian.d.roman...@intel.com> > > > > No change in the peak ir_variable memory usage in a trimmed apitrace of > > dota2 on 64-bit. > > > > No change in the peak ir_variable memory usage in a trimmed apitrace of > > dota2 on 32-bit. > > > > Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> > > --- > > src/glsl/ir.h | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/src/glsl/ir.h b/src/glsl/ir.h > > index 7faee74..bc02f6e 100644 > > --- a/src/glsl/ir.h > > +++ b/src/glsl/ir.h > > @@ -92,12 +92,13 @@ enum ir_node_type { > > */ > > class ir_instruction : public exec_node { > > private: > > - enum ir_node_type ir_type; > > + uint8_t ir_type; > > > > public: > > inline enum ir_node_type get_ir_type() const > > { > > - return this->ir_type; > > + STATIC_ASSERT(ir_type_max < 256); > > + return (enum ir_node_type) this->ir_type; > > } > > > > /** > > -- > > 1.8.1.4 > > Instead of doing this, you can mark the enum type with the PACKED > attribute. I did this in a similar change in i965 already. See > http://lists.freedesktop.org/archives/mesa-dev/2014-February/054643.html > > This way we still get enum type checking and warnings out of switch > statements and such.
C++11 lets you specify the underlying type of an enum by declaring it as: enum ir_node_type : uint8_t { ... }; If it's declared as 'enum class' it also becomes scoped and strongly typed, which may or may not be an advantage depending on how it's used. I don't know if the compiler can depend on C++11 though. Fredrik _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev