CrossCompiler::Spirv CrossCompiler::hlslToSpirv(std::string hlslText) { auto program = glslang::TProgram(); auto entryPoints = getEntryPoints(hlslText); for (auto& stageEntries : entryPoints) { auto stage = toEShLanguage(stageEntries.first); for (auto name : stageEntries.second) { addShader(program, hlslText, stage, name); } } if (!program.link(messagesType)) throw std::exception(program.getInfoLog()); Spirv spirv; if (entryPoints["vs"].size() > 0) spirv.vs = getBinary(program, EShLanguage::EShLangVertex); if (entryPoints["ps"].size() > 0) spirv.ps = getBinary(program, EShLanguage::EShLangFragment); return spirv; }
std::ostream& Program::printTo(std::ostream& out) const { out << "PROGRAM { \n"; // print entry points out << "// Entry Points: \n\t"; out << join("\n\t", getEntryPoints(), print<deref<NodePtr>>()); out << "\n"; return out; }
core::ProgramPtr ConversionJob::execute(core::NodeManager& manager) { // extension initialization frontendExtensionInit(); // create a temporary manager core::NodeManager& tmpMgr = manager; // for performance we are just using the same manager // core::NodeManager tmpMgr; // not: due to the relevance of class-info-annotations no chaining of managers is allowed here // load and merge all files into a single translation unit auto unit = toIRTranslationUnit(tmpMgr); core::ProgramPtr res; if(unit.getEntryPoints().size() > 1) res = tu::resolveEntryPoints(tmpMgr, unit); else res = tu::toProgram(tmpMgr, unit); return execute(manager, res); }
void FrontEnd::decode(Prog* prog, bool decodeMain, const char *pname) { if (pname) {prog->setName(pname); std::cout<<"decode pname == "<<pname<<"\n"; } else {std::cout<<"decode pname==null\n";} if (!decodeMain) return; Boomerang::get()->alert_start_decode(pBF->getLimitTextLow(), pBF->getLimitTextHigh() - pBF->getLimitTextLow()); bool gotMain; ADDRESS a; a = getMainEntryPoint(gotMain); std::cout<< "start: " << a << " gotmain: " << (gotMain ? "true" : "false") << "\n"; if (VERBOSE) LOG << "start: " << a << " gotmain: " << (gotMain ? "true" : "false") << "\n"; if (a == NO_ADDRESS) { std::vector<ADDRESS> entrypoints = getEntryPoints(); for (std::vector<ADDRESS>::iterator it = entrypoints.begin(); it != entrypoints.end(); it++) decode(prog, *it); return; } decode(prog, a); prog->setEntryPoint(a); if (gotMain) { static const char *mainName[] = { "main", "WinMain", "DriverEntry" }; const char *name = pBF->SymbolByAddress(a); std::cout<<"Proc name "<<name<<"\n"; if (name == NULL) name = mainName[0]; for (size_t i = 0; i < sizeof(mainName)/sizeof(char*); i++) { if (!strcmp(name, mainName[i])) { Proc *proc = prog->findProc(a); if (proc == NULL) { if (VERBOSE) LOG << "no proc found for address " << a << "\n"; return; } FuncType *fty = dynamic_cast<FuncType*>(Type::getNamedType(name)); if (fty == NULL) LOG << "unable to find signature for known entrypoint " << name << "\n"; else { std::cout<<"Sig type:"<<fty->getSignature()->getReturns()[0]->type->prints(); proc->setSignature(fty->getSignature()->clone()); proc->getSignature()->setName(name); //proc->getSignature()->setFullSig(true); // Don't add or remove parameters proc->getSignature()->setForced(true); // Don't add or remove parameters } break; } } } return; }