|
56 | 56 | #include "Frontend/OpenQASM3/OpenQASM3Frontend.h"
|
57 | 57 |
|
58 | 58 | #include <filesystem>
|
| 59 | +#include <fstream> |
59 | 60 | #include <string_view>
|
60 | 61 | #include <utility>
|
61 | 62 |
|
@@ -677,11 +678,28 @@ compile_(int argc, char const **argv, std::string *outputString,
|
677 | 678 |
|
678 | 679 | if (emitAction == Action::GenQEM) {
|
679 | 680 |
|
680 |
| - if (includeSourceInPayload && directInput) { |
681 |
| - if (inputType == InputType::QASM) |
682 |
| - payload->addFile("manifest/input.qasm", inputSource + "\n"); |
683 |
| - else if (inputType == InputType::MLIR) |
684 |
| - payload->addFile("manifest/input.mlir", inputSource + "\n"); |
| 681 | + if (includeSourceInPayload) { |
| 682 | + if (directInput) { |
| 683 | + if (inputType == InputType::QASM) |
| 684 | + payload->addFile("manifest/input.qasm", inputSource + "\n"); |
| 685 | + else if (inputType == InputType::MLIR) |
| 686 | + payload->addFile("manifest/input.mlir", inputSource + "\n"); |
| 687 | + else |
| 688 | + llvm_unreachable("Unhandled input file type"); |
| 689 | + } else { // just copy the input file |
| 690 | + std::ifstream fileStream(inputSource); |
| 691 | + std::stringstream fileSS; |
| 692 | + fileSS << fileStream.rdbuf(); |
| 693 | + |
| 694 | + if (inputType == InputType::QASM) |
| 695 | + payload->addFile("manifest/input.qasm", fileSS.str()); |
| 696 | + else if (inputType == InputType::MLIR) |
| 697 | + payload->addFile("manifest/input.mlir", fileSS.str()); |
| 698 | + else |
| 699 | + llvm_unreachable("Unhandled input file type"); |
| 700 | + |
| 701 | + fileStream.close(); |
| 702 | + } |
685 | 703 | }
|
686 | 704 |
|
687 | 705 | if (auto err = generateQEM_(target, std::move(payload), moduleOp, ostream))
|
|
0 commit comments