| 297 | } |
| 298 | |
| 299 | bool Program::compileToLLVMBitcode(const amd_comgr_data_set_t compileInputs, |
| 300 | const std::vector<std::string>& options, |
| 301 | amd::option::Options* amdOptions, char* binaryData[], |
| 302 | size_t* binarySize, const bool link_dev_libs) { |
| 303 | amd_comgr_language_t langver = getCOMGRLanguage(isHIP(), *amdOptions); |
| 304 | if (langver == AMD_COMGR_LANGUAGE_NONE) { |
| 305 | return false; |
| 306 | } |
| 307 | |
| 308 | // Create the output data set |
| 309 | amd_comgr_action_info_t action{}; |
| 310 | amd_comgr_data_set_t output{}; |
| 311 | amd_comgr_data_set_t dataSetPCH{}; |
| 312 | amd_comgr_data_set_t input = compileInputs; |
| 313 | |
| 314 | bool hasAction = false; |
| 315 | bool hasOutput = false; |
| 316 | bool hasDataSetPCH = false; |
| 317 | |
| 318 | amd_comgr_status_t status = createAction(langver, options, &action, &hasAction); |
| 319 | |
| 320 | if (status == AMD_COMGR_STATUS_SUCCESS) { |
| 321 | status = amd::Comgr::create_data_set(&output); |
| 322 | } |
| 323 | |
| 324 | // Adding Precompiled Headers |
| 325 | if (status == AMD_COMGR_STATUS_SUCCESS) { |
| 326 | hasOutput = true; |
| 327 | status = amd::Comgr::create_data_set(&dataSetPCH); |
| 328 | } |
| 329 | |
| 330 | // Preprocess the source |
| 331 | // FIXME: This must happen before the precompiled headers are added, as they |
| 332 | // do not embed the source text of the header, and so reference paths in the |
| 333 | // filesystem which do not exist at runtime. |
| 334 | if (status == AMD_COMGR_STATUS_SUCCESS) { |
| 335 | hasDataSetPCH = true; |
| 336 | |
| 337 | if (amdOptions->isDumpFlagSet(amd::option::DUMP_I)) { |
| 338 | amd_comgr_data_set_t dataSetPreprocessor; |
| 339 | bool hasDataSetPreprocessor = false; |
| 340 | |
| 341 | status = amd::Comgr::create_data_set(&dataSetPreprocessor); |
| 342 | |
| 343 | if (status == AMD_COMGR_STATUS_SUCCESS) { |
| 344 | hasDataSetPreprocessor = true; |
| 345 | status = amd::Comgr::do_action(AMD_COMGR_ACTION_SOURCE_TO_PREPROCESSOR, action, input, |
| 346 | dataSetPreprocessor); |
| 347 | extractBuildLog(dataSetPreprocessor); |
| 348 | } |
| 349 | |
| 350 | if (status == AMD_COMGR_STATUS_SUCCESS) { |
| 351 | std::string outFileName = amdOptions->getDumpFileName(".i"); |
| 352 | status = |
| 353 | extractByteCodeBinary(dataSetPreprocessor, AMD_COMGR_DATA_KIND_SOURCE, outFileName); |
| 354 | } |
| 355 | |
| 356 | if (hasDataSetPreprocessor) { |
nothing calls this directly
no test coverage detected