Create spv_language_capabilities_t and widen capabilities fields.
authorDejan Mircevski <deki@google.com>
Wed, 30 Sep 2015 14:35:26 +0000 (10:35 -0400)
committerDavid Neto <dneto@google.com>
Mon, 26 Oct 2015 16:55:33 +0000 (12:55 -0400)
If this is acceptable, I'll do a wholesale switch of operand and opcode
definitions to capability bitfields.

include/libspirv/libspirv.h

index 05af914..5feecdc 100644 (file)
@@ -85,6 +85,12 @@ extern "C" {
 
 #define SPV_OPERAND_INVALID_RESULT_ID_INDEX -1
 
+// Transforms spv::Capability into a mask for use in bitfields.  Should really
+// be a constexpr inline function, but some important versions of MSVC don't
+// support that yet.  Different from SPV_BIT, which doesn't guarantee 64-bit
+// values.
+#define SPV_CAPABILITY_AS_MASK(capability) (uint64_t(1) << (capability))
+
 // Enumerations
 
 typedef enum spv_generator_t {
@@ -269,7 +275,7 @@ typedef struct spv_opcode_desc_t {
   const char *name;
   const Op opcode;
   const uint32_t flags;         // Bitfield of spv_opcode_flags_t
-  const uint32_t capabilities;  // spv_language_capabilities_t
+  const uint64_t capabilities;  // Bitfield of SPV_CAPABILITY_AS_MASK(spv::Capability)
   // operandTypes[0..numTypes-1] describe logical operands for the instruction.
   // The operand types include result id and result-type id, followed by
   // the types of arguments.
@@ -291,7 +297,7 @@ typedef struct spv_operand_desc_t {
   const char *name;
   const uint32_t value;
   const uint32_t flags;                       // Bitfield of spv_opcode_flags_t
-  const uint32_t capabilities;                // spv_language_capabilities_t
+  const uint64_t capabilities;                // Bitfield of SPV_CAPABILITY_AS_MASK(spv::Capability)
   const spv_operand_type_t operandTypes[16];  // TODO: Smaller/larger?
 } spv_operand_desc_t;