Skip to content

Commit c28f21f

Browse files
committed
[RISCV] Split code that tablegen needs out of RISCVISAInfo.
This introduces a new file, RISCVISAUtils.cpp and moves the reset of RISCVISAInfo to the TargetParser library. This will allow us to generate part of RISCVISAInfo.cpp using tablegen.
1 parent 07b1177 commit c28f21f

File tree

26 files changed

+204
-161
lines changed

26 files changed

+204
-161
lines changed

clang/lib/Basic/Targets/RISCV.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "clang/Basic/TargetInfo.h"
1717
#include "clang/Basic/TargetOptions.h"
1818
#include "llvm/Support/Compiler.h"
19-
#include "llvm/Support/RISCVISAInfo.h"
19+
#include "llvm/TargetParser/RISCVISAInfo.h"
2020
#include "llvm/TargetParser/Triple.h"
2121
#include <optional>
2222

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@
6868
#include "llvm/Support/CommandLine.h"
6969
#include "llvm/Support/ConvertUTF.h"
7070
#include "llvm/Support/ErrorHandling.h"
71-
#include "llvm/Support/RISCVISAInfo.h"
7271
#include "llvm/Support/TimeProfiler.h"
7372
#include "llvm/Support/xxhash.h"
73+
#include "llvm/TargetParser/RISCVISAInfo.h"
7474
#include "llvm/TargetParser/Triple.h"
7575
#include "llvm/TargetParser/X86TargetParser.h"
7676
#include <optional>

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@
8787
#include "llvm/Support/PrettyStackTrace.h"
8888
#include "llvm/Support/Process.h"
8989
#include "llvm/Support/Program.h"
90-
#include "llvm/Support/RISCVISAInfo.h"
9190
#include "llvm/Support/Regex.h"
9291
#include "llvm/Support/StringSaver.h"
9392
#include "llvm/Support/VirtualFileSystem.h"
9493
#include "llvm/Support/raw_ostream.h"
9594
#include "llvm/TargetParser/Host.h"
95+
#include "llvm/TargetParser/RISCVISAInfo.h"
9696
#include <cstdlib> // ::getenv
9797
#include <map>
9898
#include <memory>

clang/lib/Driver/ToolChains/Arch/RISCV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#include "clang/Driver/Options.h"
1616
#include "llvm/Option/ArgList.h"
1717
#include "llvm/Support/Error.h"
18-
#include "llvm/Support/RISCVISAInfo.h"
1918
#include "llvm/Support/raw_ostream.h"
2019
#include "llvm/TargetParser/Host.h"
20+
#include "llvm/TargetParser/RISCVISAInfo.h"
2121
#include "llvm/TargetParser/RISCVTargetParser.h"
2222

2323
using namespace clang::driver;

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@
5454
#include "llvm/Support/FileSystem.h"
5555
#include "llvm/Support/Path.h"
5656
#include "llvm/Support/Process.h"
57-
#include "llvm/Support/RISCVISAInfo.h"
5857
#include "llvm/Support/YAMLParser.h"
5958
#include "llvm/TargetParser/ARMTargetParserCommon.h"
6059
#include "llvm/TargetParser/Host.h"
6160
#include "llvm/TargetParser/LoongArchTargetParser.h"
61+
#include "llvm/TargetParser/RISCVISAInfo.h"
6262
#include "llvm/TargetParser/RISCVTargetParser.h"
6363
#include <cctype>
6464

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "llvm/Frontend/Debug/Options.h"
1616
#include "llvm/Support/FileSystem.h"
1717
#include "llvm/Support/Path.h"
18-
#include "llvm/Support/RISCVISAInfo.h"
18+
#include "llvm/TargetParser/RISCVISAInfo.h"
1919
#include "llvm/TargetParser/RISCVTargetParser.h"
2020

2121
#include <cassert>

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
#include "llvm/Option/ArgList.h"
3131
#include "llvm/Support/CodeGen.h"
3232
#include "llvm/Support/Path.h"
33-
#include "llvm/Support/RISCVISAInfo.h"
3433
#include "llvm/Support/VirtualFileSystem.h"
34+
#include "llvm/TargetParser/RISCVISAInfo.h"
3535
#include "llvm/TargetParser/TargetParser.h"
3636
#include <system_error>
3737

clang/tools/driver/cc1_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "llvm/Support/ManagedStatic.h"
4040
#include "llvm/Support/Path.h"
4141
#include "llvm/Support/Process.h"
42-
#include "llvm/Support/RISCVISAInfo.h"
4342
#include "llvm/Support/Signals.h"
4443
#include "llvm/Support/TargetSelect.h"
4544
#include "llvm/Support/TimeProfiler.h"
@@ -48,6 +47,7 @@
4847
#include "llvm/Target/TargetMachine.h"
4948
#include "llvm/TargetParser/AArch64TargetParser.h"
5049
#include "llvm/TargetParser/ARMTargetParser.h"
50+
#include "llvm/TargetParser/RISCVISAInfo.h"
5151
#include <cstdio>
5252

5353
#ifdef CLANG_HAVE_RLIMITS

lld/ELF/Arch/RISCV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include "llvm/Support/LEB128.h"
1616
#include "llvm/Support/RISCVAttributeParser.h"
1717
#include "llvm/Support/RISCVAttributes.h"
18-
#include "llvm/Support/RISCVISAInfo.h"
1918
#include "llvm/Support/TimeProfiler.h"
19+
#include "llvm/TargetParser/RISCVISAInfo.h"
2020

2121
using namespace llvm;
2222
using namespace llvm::object;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//===-- RISCVISAUtils.h - RISC-V ISA Utilities ------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// Utilities shared by TableGen and RISCVISAInfo.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_SUPPORT_RISCVISAUTILS_H
14+
#define LLVM_SUPPORT_RISCVISAUTILS_H
15+
16+
#include "llvm/ADT/StringRef.h"
17+
#include <string>
18+
19+
namespace llvm {
20+
21+
namespace RISCVISAUtils {
22+
constexpr StringLiteral AllStdExts = "mafdqlcbkjtpvnh";
23+
24+
/// Represents the major and version number components of a RISC-V extension.
25+
struct ExtensionVersion {
26+
unsigned Major;
27+
unsigned Minor;
28+
};
29+
30+
bool compareExtension(const std::string &LHS, const std::string &RHS);
31+
32+
/// Helper class for OrderedExtensionMap.
33+
struct ExtensionComparator {
34+
bool operator()(const std::string &LHS, const std::string &RHS) const {
35+
return compareExtension(LHS, RHS);
36+
}
37+
};
38+
} // namespace RISCVISAUtils
39+
40+
} // namespace llvm
41+
42+
#endif

0 commit comments

Comments
 (0)