glsl: Switch ast_type_qualifier to a 128-bit bitset.

This should end the drought of bits in the ast_type_qualifier object.
The bitset_t type works pretty much as a drop-in replacement for the
current uint64_t bitset.

The only catch is that the bitset_t type as defined in the previous
commit doesn't have a trivial constructor (because it has a
user-defined constructor), so it cannot be used as union member
without providing a user-defined constructor for the union (which
causes it in turn to be non-trivially constructible).  This annoyance
could be easily addressed in C++11 by declaring the default
constructor of bitset_t to be the implicitly defined one -- IMO one
more reason to drop support for GCC 4.2-4.3.

The other minor change was required because glsl_parser_extras.cpp was
hard-coding the type of bitset temporaries as uint64_t, which (unlike
would have been the case if the uint64_t had been replaced with
e.g. an __int128) would otherwise have caused a build failure, because
the boolean conversion operator of bitset_t is marked explicit (if
C++11 is available), so the bitset won't be silently truncated down to
1 bit in order to use it to initialize the uint64_t temporaries
(yikes).

Reviewed-by: Plamena Manolova <plamena.manolova@intel.com>
This commit is contained in:
Francisco Jerez 2018-02-12 14:18:15 -08:00
parent bdbc2ffa42
commit ba79a90fb5
3 changed files with 9 additions and 4 deletions

View File

@ -28,6 +28,7 @@
#include "list.h"
#include "glsl_parser_extras.h"
#include "compiler/glsl_types.h"
#include "util/bitset.h"
struct _mesa_glsl_parse_state;
@ -473,8 +474,11 @@ enum {
struct ast_type_qualifier {
DECLARE_RALLOC_CXX_OPERATORS(ast_type_qualifier);
DECLARE_BITSET_T(bitset_t, 128);
union flags {
flags() : i(0) {}
union {
struct {
unsigned invariant:1;
unsigned precise:1;
@ -636,7 +640,7 @@ struct ast_type_qualifier {
q;
/** \brief Set of flags, accessed as a bitmask. */
uint64_t i;
bitset_t i;
} flags;
/** Precision of the type (highp/medium/lowp). */

View File

@ -96,6 +96,7 @@ static bool match_layout_qualifier(const char *s1, const char *s2,
%parse-param {struct _mesa_glsl_parse_state *state}
%union {
YYSTYPE() {}
int n;
int64_t n64;
float real;

View File

@ -1011,7 +1011,7 @@ _mesa_ast_process_interface_block(YYLTYPE *locp,
"an instance name are not allowed");
}
uint64_t interface_type_mask;
ast_type_qualifier::bitset_t interface_type_mask;
struct ast_type_qualifier temp_type_qualifier;
/* Get a bitmask containing only the in/out/uniform/buffer
@ -1030,7 +1030,7 @@ _mesa_ast_process_interface_block(YYLTYPE *locp,
* production rule guarantees that only one bit will be set (and
* it will be in/out/uniform).
*/
uint64_t block_interface_qualifier = q.flags.i;
ast_type_qualifier::bitset_t block_interface_qualifier = q.flags.i;
block->default_layout.flags.i |= block_interface_qualifier;