Lines Matching +full:cap +full:- +full:std +full:- +full:ext
1 // Copyright (c) 2014-2020 The Khronos Group Inc.
40 // Returns true if the given string is a valid SPIR-V version.
41 bool validSpirvVersionString(const std::string s) { in validSpirvVersionString()
54 bool validSpirvVersionStringSpecifier(const std::string s) { in validSpirvVersionStringSpecifier()
61 bool IsLegacyDoublyEnabledInstruction(const std::string& instruction) { in IsLegacyDoublyEnabledInstruction()
62 static std::unordered_set<std::string> allowed = { in IsLegacyDoublyEnabledInstruction()
145 bool EnumValue::IsValid(OperandClass oc, const std::string& context) const in IsValid()
149 …std::cerr << "Error: " << context << " " << name << " \"version\" must be set, probably to \"None\… in IsValid()
152 …std::cerr << "Error: " << context << " " << name << " \"version\" is invalid: " << firstVersion <<… in IsValid()
156 …std::cerr << "Error: " << context << " " << name << " \"lastVersion\" is invalid: " << lastVersion… in IsValid()
162 // - A new capability should be guarded/enabled by the extension in IsValid()
163 // - A new instruction should be: in IsValid()
164 // - Guarded/enabled by a new capability. in IsValid()
165 // - Not enabled by *both* a capability and an extension. in IsValid()
168 // - Other enums fall into two cases: in IsValid()
180 std::cerr << "Error: " << context << " " << name << " is not usable: " in IsValid()
183 << std::endl; in IsValid()
189 // for example, OpTerminateInvocation is in SPIR-V 1.6 *and* enabled by an in IsValid()
195 std::cerr << "Error: " << context << " " << name << " is doubly-enabled: " in IsValid()
197 << "Guard it with a capability only." << std::endl; in IsValid()
208 std::cerr << "Error: " << context << " " << name << " is not usable: " in IsValid()
210 << "an extension. Guard it with an extension." << std::endl; in IsValid()
276 std::pair<bool, std::string> ReadFile(const std::string& path) in ReadFile()
278 std::ifstream fstream(path, std::ios::in); in ReadFile()
280 std::string contents; in ReadFile()
281 fstream.seekg(0, std::ios::end); in ReadFile()
283 fstream.seekg(0, std::ios::beg); in ReadFile()
284 contents.assign((std::istreambuf_iterator<char>(fstream)), in ReadFile()
285 std::istreambuf_iterator<char>()); in ReadFile()
286 return std::make_pair(true, contents); in ReadFile()
288 return std::make_pair(false, ""); in ReadFile()
298 ClassOptionality ToOperandClassAndOptionality(const std::string& operandKind, const std::string& qu… in ToOperandClassAndOptionality()
440 std::cerr << "Unhandled operand kind found: " << operandKind << std::endl; in ToOperandClassAndOptionality()
447 bool IsTypeOrResultId(const std::string& str, bool* isType, bool* isResult) in IsTypeOrResultId()
458 unsigned int NumberStringToBit(const std::string& str) in NumberStringToBit()
461 unsigned int value = (unsigned int)std::strtol(str.c_str(), &parseEnd, 16); in NumberStringToBit()
462 assert(!(value & (value - 1)) && "input number is not a power of 2"); in NumberStringToBit()
468 void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders) in jsonToSpirv()
480 std::string content; in jsonToSpirv()
481 std::tie(fileReadOk, content) = ReadFile(jsonPath); in jsonToSpirv()
483 std::cerr << "Failed to read JSON grammar file: " in jsonToSpirv()
484 << jsonPath << std::endl; in jsonToSpirv()
492 std::cerr << "Failed to parse JSON grammar:\n" in jsonToSpirv()
505 for (const auto& cap : caps) { in jsonToSpirv() local
506 result.emplace_back(cap.asString()); in jsonToSpirv()
518 for (const auto& ext : exts) { in jsonToSpirv() local
519 result.emplace_back(ext.asString()); in jsonToSpirv()
526 std::unordered_set<std::string> tags; // short-lived local for error checking below in jsonToSpirv()
532 … std::cerr << "Error: each instruction_printing_class requires a non-empty \"tag\"" << std::endl; in jsonToSpirv()
533 std::exit(1); in jsonToSpirv()
548 std::cerr << "Error: " << inst["opname"].asString() in jsonToSpirv()
549 << " requires a non-empty printing \"class\" tag" << std::endl; in jsonToSpirv()
550 std::exit(1); in jsonToSpirv()
555 std::cerr << "Error: " << inst["opname"].asString() in jsonToSpirv()
557 << std::endl; in jsonToSpirv()
558 std::exit(1); in jsonToSpirv()
561 const std::string name = inst["opname"].asString(); in jsonToSpirv()
567 std::cerr << "Error: " << name in jsonToSpirv()
569 << std::endl; in jsonToSpirv()
570 std::exit(1); in jsonToSpirv()
576 std::string version = inst["version"].asString(); in jsonToSpirv()
577 std::string lastVersion = inst["lastVersion"].asString(); in jsonToSpirv()
583 const std::string kind = operand["kind"].asString(); in jsonToSpirv()
584 const std::string quantifier = operand.get("quantifier", "").asString(); in jsonToSpirv()
585 const std::string doc = operand.get("name", "").asString(); in jsonToSpirv()
592 std::move(EnumValue(opcode, name, in jsonToSpirv()
593 … std::move(caps), std::move(version), std::move(lastVersion), std::move(exts), in jsonToSpirv()
594 std::move(operands))), in jsonToSpirv()
601 // Specific additional context-dependent operands in jsonToSpirv()
608 std::pair<unsigned, bool> result{0u,false}; in jsonToSpirv()
616 result.first = bit - 1; // This is the *shift* amount. in jsonToSpirv()
626 std::tie(value, skip_zero_in_bitfield) = getValue(enumerant); in jsonToSpirv()
634 std::cerr << "Error: " << source["kind"] << " enumerant " << enumerant["enumerant"] in jsonToSpirv()
636 << " but follows the enumerant with value " << maxValue << std::endl; in jsonToSpirv()
637 std::exit(1); in jsonToSpirv()
643 std::string version = enumerant["version"].asString(); in jsonToSpirv()
644 std::string lastVersion = enumerant["lastVersion"].asString(); in jsonToSpirv()
651 const std::string kind = param["kind"].asString(); in jsonToSpirv()
652 const std::string doc = param.get("name", "").asString(); in jsonToSpirv()
657 dest->emplace_back( in jsonToSpirv()
659 … std::move(caps), std::move(version), std::move(lastVersion), std::move(exts), std::move(params)); in jsonToSpirv()
664 const std::string& enumName, spv::OperandClass operandClass, in jsonToSpirv()
665 … spv::EnumValues* enumValues, const Json::Value& operandEnum, const std::string& category) { in jsonToSpirv()
669 …std::cerr << "Error: container for " << enumName << " operand_kind must not have a version field" … in jsonToSpirv()
673 const std::string errContext = "enum " + enumName; in jsonToSpirv()
684 const std::string enumName = operandEnum["kind"].asString(); in jsonToSpirv()
685 const std::string category = operandEnum["category"].asString(); in jsonToSpirv()
784 std::exit(1); in jsonToSpirv()