-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel_compiler.cpp
More file actions
34 lines (25 loc) · 821 Bytes
/
kernel_compiler.cpp
File metadata and controls
34 lines (25 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
int main(int argc, char* argv[]) {
if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " <input_ir_file> <output_file>" << std::endl;
return 1;
}
std::ifstream inFile(argv[1]);
if (!inFile.is_open()) {
std::cerr << "Error: Could not open input file " << argv[1] << std::endl;
return 1;
}
std::string content((std::istreambuf_iterator<char>(inFile)),
std::istreambuf_iterator<char>());
inFile.close();
// Simulate compilation by adding a comment
std::string compiled_text = "// COMPILED BY KERNEL COMPILER\n";
compiled_text += content;
std::ofstream outFile(argv[2]);
outFile << compiled_text;
outFile.close();
return 0;
}