OpenASIP 2.2
Loading...
Searching...
No Matches
riscv-tdgen.cc
Go to the documentation of this file.
1/*
2 Copyright (C) 2024 Tampere University.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18/**
19 * @file riscv-tdgen.cc
20 *
21 * LLVM target definition generator driver for RISC-V
22 *
23 * @author Kari Hepola 2024 (kari.hepola@tuni.fi)
24 * @note rating: red
25 */
26
27#include <iostream>
28#include <fstream>
29#include <assert.h>
30#include "RISCVTDGen.hh"
31#include "Machine.hh"
32
33/**
34 * riscv-tdgen main function.
35 *
36 * Generates a RISC-V custom extension target definition file for LLVM
37 */
38int main(int argc, char* argv[]) {
39 std::string outputDir;
40 std::string adfPath;
41
42 // Check if the correct number of arguments is provided
43 if (argc != 5) {
44 std::cout << "Usage: riscv-tdgen" << std::endl
45 << " -o Output directory." << std::endl
46 << " -a ADF path." << std::endl;
47 return EXIT_FAILURE;
48 }
49
50 // Parse command-line arguments
51 for (int i = 1; i < argc; i += 2) {
52 if (std::strcmp(argv[i], "-o") == 0) {
53 outputDir = argv[i + 1];
54 } else if (std::strcmp(argv[i], "-a") == 0) {
55 adfPath = argv[i + 1];
56 }
57 }
58
60 assert(mach != NULL);
61
62 RISCVTDGen tdgen(*mach);
63 tdgen.generateBackend(outputDir);
64 delete mach;
65
66 return EXIT_SUCCESS;
67}
68
#define assert(condition)
virtual void generateBackend(const std::string &path) const
static Machine * loadFromADF(const std::string &adfFileName)
Definition Machine.cc:899
int main(int argc, char *argv[])