Home | History | Annotate | Download | only in source
      1 // Copyright (c) 2015-2016 The Khronos Group Inc.
      2 //
      3 // Permission is hereby granted, free of charge, to any person obtaining a
      4 // copy of this software and/or associated documentation files (the
      5 // "Materials"), to deal in the Materials without restriction, including
      6 // without limitation the rights to use, copy, modify, merge, publish,
      7 // distribute, sublicense, and/or sell copies of the Materials, and to
      8 // permit persons to whom the Materials are furnished to do so, subject to
      9 // the following conditions:
     10 //
     11 // The above copyright notice and this permission notice shall be included
     12 // in all copies or substantial portions of the Materials.
     13 //
     14 // MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
     15 // KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
     16 // SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
     17 //    https://www.khronos.org/registry/
     18 //
     19 // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
     22 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
     23 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
     24 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
     25 // MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
     26 
     27 #ifndef LIBSPIRV_TEXT_H_
     28 #define LIBSPIRV_TEXT_H_
     29 
     30 #include <string>
     31 
     32 #include "operand.h"
     33 #include "spirv-tools/libspirv.h"
     34 #include "spirv_constant.h"
     35 
     36 typedef enum spv_literal_type_t {
     37   SPV_LITERAL_TYPE_INT_32,
     38   SPV_LITERAL_TYPE_INT_64,
     39   SPV_LITERAL_TYPE_UINT_32,
     40   SPV_LITERAL_TYPE_UINT_64,
     41   SPV_LITERAL_TYPE_FLOAT_32,
     42   SPV_LITERAL_TYPE_FLOAT_64,
     43   SPV_LITERAL_TYPE_STRING,
     44   SPV_FORCE_32_BIT_ENUM(spv_literal_type_t)
     45 } spv_literal_type_t;
     46 
     47 typedef struct spv_literal_t {
     48   spv_literal_type_t type;
     49   union value_t {
     50     int32_t i32;
     51     int64_t i64;
     52     uint32_t u32;
     53     uint64_t u64;
     54     float f;
     55     double d;
     56   } value;
     57   std::string str;  // Special field for literal string.
     58 } spv_literal_t;
     59 
     60 // Converts the given text string to a number/string literal and writes the
     61 // result to *literal. String literals must be surrounded by double-quotes ("),
     62 // which are then stripped.
     63 spv_result_t spvTextToLiteral(const char* text, spv_literal_t* literal);
     64 
     65 #endif  // LIBSPIRV_TEXT_H_
     66