MCPcopy Create free account
hub / github.com/ROCm/clr / compileImpl

Method compileImpl

rocclr/device/devprogram.cpp:515–655  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513}
514
515bool Program::compileImpl(const std::string& sourceCode,
516 const std::vector<const std::string*>& headers,
517 const char** headerIncludeNames, amd::option::Options* options) {
518 const char* xLang = options->oVariables->XLang;
519 if (xLang != nullptr) {
520 if (strcmp(xLang, "asm") == 0) {
521 clBinary()->elfOut()->addSection(amd::Elf::SOURCE, sourceCode.data(), sourceCode.size());
522 return true;
523 } else if (!strcmp(xLang, "cl")) {
524 buildLog_ += "Unsupported language: \"" + std::string(xLang) + "\".\n";
525 return false;
526 }
527 }
528
529 // add CL source to input data set
530 amd_comgr_data_set_t inputs;
531
532 if (amd::Comgr::create_data_set(&inputs) != AMD_COMGR_STATUS_SUCCESS) {
533 buildLog_ += "Error: COMGR fails to create output buffer for LLVM bitcode.\n";
534 return false;
535 }
536
537 if (addCodeObjData(sourceCode.c_str(), sourceCode.length(), AMD_COMGR_DATA_KIND_SOURCE,
538 "CompileSource", &inputs) != AMD_COMGR_STATUS_SUCCESS) {
539 buildLog_ += "Error: COMGR fails to create data from source.\n";
540 amd::Comgr::destroy_data_set(inputs);
541 return false;
542 }
543
544 std::vector<std::string> driverOptions;
545 // Set the -O#
546 std::ostringstream optLevel;
547 optLevel << "-O" << options->oVariables->OptLevel;
548 driverOptions.push_back(optLevel.str());
549
550 if (!isHIP()) {
551 driverOptions.insert(driverOptions.end(), options->clangOptions.begin(),
552 options->clangOptions.end());
553 // TODO: Can this be fixed at the source? options->llvmOptions is a flat
554 // string, but should really be a vector of strings.
555 std::vector<std::string> splitLlvmOptions =
556 splitSpaceSeparatedString(options->llvmOptions.c_str());
557 driverOptions.insert(driverOptions.end(), splitLlvmOptions.begin(), splitLlvmOptions.end());
558 }
559
560 std::vector<std::string> processedOptions = ProcessOptions(options);
561 driverOptions.insert(driverOptions.end(), processedOptions.begin(), processedOptions.end());
562
563 // Set whole program mode
564 driverOptions.push_back("-mllvm");
565 driverOptions.push_back("-amdgpu-prelink");
566
567 if (!device().settings().enableWgpMode_) {
568 driverOptions.push_back("-mcumode");
569 }
570
571 if (device().settings().lcWavefrontSize64_) {
572 driverOptions.push_back("-mwavefrontsize64");

Callers

nothing calls this directly

Calls 15

addCodeObjDataFunction · 0.85
to_stringFunction · 0.85
getOCLSourceHashFunction · 0.85
getOCLOptionsHashFunction · 0.85
addSectionMethod · 0.80
elfOutMethod · 0.80
emptyMethod · 0.80
isDumpFlagSetMethod · 0.80
getDumpFileNameMethod · 0.80
saveSOURCEMethod · 0.80
saveLLVMIRMethod · 0.80

Tested by

no test coverage detected