aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/utils')
-rw-r--r--llvm/utils/TableGen/Common/CodeGenTarget.cpp37
-rw-r--r--llvm/utils/gn/secondary/lld/ELF/BUILD.gn1
2 files changed, 20 insertions, 18 deletions
diff --git a/llvm/utils/TableGen/Common/CodeGenTarget.cpp b/llvm/utils/TableGen/Common/CodeGenTarget.cpp
index 96829a1..e8286d2 100644
--- a/llvm/utils/TableGen/Common/CodeGenTarget.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenTarget.cpp
@@ -28,8 +28,8 @@
#include <tuple>
using namespace llvm;
-cl::OptionCategory AsmParserCat("Options for -gen-asm-parser");
-cl::OptionCategory AsmWriterCat("Options for -gen-asm-writer");
+static cl::OptionCategory AsmParserCat("Options for -gen-asm-parser");
+static cl::OptionCategory AsmWriterCat("Options for -gen-asm-writer");
static cl::opt<unsigned>
AsmParserNum("asmparsernum", cl::init(0),
@@ -64,9 +64,9 @@ StringRef llvm::getEnumName(MVT::SimpleValueType T) {
std::string llvm::getQualifiedName(const Record *R) {
std::string Namespace;
if (R->getValue("Namespace"))
- Namespace = std::string(R->getValueAsString("Namespace"));
+ Namespace = R->getValueAsString("Namespace").str();
if (Namespace.empty())
- return std::string(R->getName());
+ return R->getName().str();
return Namespace + "::" + R->getName().str();
}
@@ -166,14 +166,15 @@ CodeGenRegBank &CodeGenTarget::getRegBank() const {
const CodeGenRegisterClass *CodeGenTarget::getSuperRegForSubReg(
const ValueTypeByHwMode &ValueTy, CodeGenRegBank &RegBank,
const CodeGenSubRegIndex *SubIdx, bool MustBeAllocatable) const {
- std::vector<CodeGenRegisterClass *> Candidates;
+ std::vector<const CodeGenRegisterClass *> Candidates;
auto &RegClasses = RegBank.getRegClasses();
// Try to find a register class which supports ValueTy, and also contains
// SubIdx.
- for (CodeGenRegisterClass &RC : RegClasses) {
+ for (const CodeGenRegisterClass &RC : RegClasses) {
// Is there a subclass of this class which contains this subregister index?
- CodeGenRegisterClass *SubClassWithSubReg = RC.getSubClassWithSubReg(SubIdx);
+ const CodeGenRegisterClass *SubClassWithSubReg =
+ RC.getSubClassWithSubReg(SubIdx);
if (!SubClassWithSubReg)
continue;
@@ -261,39 +262,40 @@ void CodeGenTarget::ReadInstructions() const {
// Parse the instructions defined in the .td file.
for (const Record *R : Insts) {
- Instructions[R] = std::make_unique<CodeGenInstruction>(R);
- if (Instructions[R]->isVariableLengthEncoding())
+ auto &Inst = Instructions[R];
+ Inst = std::make_unique<CodeGenInstruction>(R);
+ if (Inst->isVariableLengthEncoding())
HasVariableLengthEncodings = true;
}
}
static const CodeGenInstruction *GetInstByName(
- const char *Name,
+ StringRef Name,
const DenseMap<const Record *, std::unique_ptr<CodeGenInstruction>> &Insts,
const RecordKeeper &Records) {
const Record *Rec = Records.getDef(Name);
const auto I = Insts.find(Rec);
if (!Rec || I == Insts.end())
- PrintFatalError(Twine("Could not find '") + Name + "' instruction!");
+ PrintFatalError("Could not find '" + Name + "' instruction!");
return I->second.get();
}
static const char *FixedInstrs[] = {
#define HANDLE_TARGET_OPCODE(OPC) #OPC,
#include "llvm/Support/TargetOpcodes.def"
- nullptr};
+};
unsigned CodeGenTarget::getNumFixedInstructions() {
- return std::size(FixedInstrs) - 1;
+ return std::size(FixedInstrs);
}
/// Return all of the instructions defined by the target, ordered by
/// their enum value.
void CodeGenTarget::ComputeInstrsByEnum() const {
const auto &Insts = getInstructions();
- for (const char *const *p = FixedInstrs; *p; ++p) {
- const CodeGenInstruction *Instr = GetInstByName(*p, Insts, Records);
+ for (const char *Name : FixedInstrs) {
+ const CodeGenInstruction *Instr = GetInstByName(Name, Insts, Records);
assert(Instr && "Missing target independent instruction");
assert(Instr->Namespace == "TargetOpcode" && "Bad namespace");
InstrsByEnum.push_back(Instr);
@@ -324,9 +326,8 @@ void CodeGenTarget::ComputeInstrsByEnum() const {
});
// Assign an enum value to each instruction according to the sorted order.
- unsigned Num = 0;
- for (const CodeGenInstruction *Inst : InstrsByEnum)
- Inst->EnumVal = Num++;
+ for (const auto &[Idx, Inst] : enumerate(InstrsByEnum))
+ Inst->EnumVal = Idx;
}
/// isLittleEndianEncoding - Return whether this target encodes its instruction
diff --git a/llvm/utils/gn/secondary/lld/ELF/BUILD.gn b/llvm/utils/gn/secondary/lld/ELF/BUILD.gn
index d903725..d23b979 100644
--- a/llvm/utils/gn/secondary/lld/ELF/BUILD.gn
+++ b/llvm/utils/gn/secondary/lld/ELF/BUILD.gn
@@ -42,6 +42,7 @@ static_library("ELF") {
"Arch/SystemZ.cpp",
"Arch/X86.cpp",
"Arch/X86_64.cpp",
+ "BPSectionOrderer.cpp",
"CallGraphSort.cpp",
"DWARF.cpp",
"Driver.cpp",