[llvm] [Mips][nanoMIPS] Add initial nanoMIPS target support (PR #223032)
Jiaxun Yang via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 06:05:32 PDT 2026
================
@@ -0,0 +1,217 @@
+//===- MipsCP0RegisterMap.h - Co-processor register names -------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file defines the mapping between MIPS CP0 register names and their
+/// (register, select) encodings.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIB_TARGET_MIPS_MIPSCP0REGMAP_H
+#define LLVM_LIB_TARGET_MIPS_MIPSCP0REGMAP_H
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace llvm {
+
+struct CP0SelRegister {
+ StringRef Name;
+ int RegNum;
+ int Select;
+};
+
+class MipsCP0SelMap {
+ DenseMap<unsigned, int> EncIndexMap;
+ StringMap<int> NameIndexMap;
+
+public:
+ int getEncIndexMap(unsigned Reg) {
+ auto It = EncIndexMap.find(Reg);
+ return It != EncIndexMap.end() ? It->second : -1;
+ }
+
+ int getNameIndexMap(StringRef Name) {
+ auto It = NameIndexMap.find(Name);
+ return It != NameIndexMap.end() ? It->second : -1;
+ }
+
+ MipsCP0SelMap() {
+ static const struct CP0SelRegister Regs[] = {{"index", 0, 0},
----------------
FlyGoat wrote:
I believe this should be derived from `MipsRegisterInfo.td` rather than hardcoded here.
https://github.com/llvm/llvm-project/pull/223032
More information about the llvm-commits
mailing list