[llvm] [llvm][MC] Add public getAllProcessorFeatures() (PR #66582)

Balint Cristian via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 16 10:45:32 PDT 2023


https://github.com/cbalint13 created https://github.com/llvm/llvm-project/pull/66582

This patch add a public ```getAllProcessorFeatures()``` accessor to the private [ProcFeatures](https://github.com/llvm/llvm-project/blob/release/17.x/llvm/include/llvm/MC/MCSubtargetInfo.h#L80) array  of [MCSubtargetInfo](https://github.com/llvm/llvm-project/blob/release/17.x/llvm/include/llvm/MC/MCSubtargetInfo.h#L76) class.

 * Currently there is no way to list all features of the subtarget, except toggling or checking it's pinned flags. 
 * It is very useful to know all the possible flags of subtarget cpu and this simple public accessor can provide it.

The proposed accessor here is inline with  [getAllProcessorDescriptions()](https://github.com/llvm/llvm-project/blob/release/17.x/llvm/include/llvm/MC/MCSubtargetInfo.h#L233-L235) for the [ProcDesc](https://github.com/llvm/llvm-project/blob/release/17.x/llvm/include/llvm/MC/MCSubtargetInfo.h#L81) subarchitecture details.

The targeted private array type [ProcFeatures](https://github.com/llvm/llvm-project/blob/release/17.x/llvm/include/llvm/MC/MCSubtargetInfo.h#L35-L39) also contains human readable information about the features. This data originates from tablegen architecture description.


>From 17a5260be1e78ee205b0dd818d61f28066293014 Mon Sep 17 00:00:00 2001
From: Balint Cristian <cristian.balint at gmail.com>
Date: Sat, 16 Sep 2023 20:11:25 +0300
Subject: [PATCH] [llvm][MC] Add public getAllProcessorFeatures()

Signed-off-by: Balint Cristian <cristian.balint at gmail.com>
---
 llvm/include/llvm/MC/MCSubtargetInfo.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/llvm/include/llvm/MC/MCSubtargetInfo.h b/llvm/include/llvm/MC/MCSubtargetInfo.h
index c1533ac8d0059f5..e3cf0b6cd5c756f 100644
--- a/llvm/include/llvm/MC/MCSubtargetInfo.h
+++ b/llvm/include/llvm/MC/MCSubtargetInfo.h
@@ -234,6 +234,10 @@ class MCSubtargetInfo {
     return ProcDesc;
   }
 
+  ArrayRef<SubtargetFeatureKV> getAllProcessorFeatures() const {
+    return ProcFeatures;
+  }
+
   virtual unsigned getHwMode() const { return 0; }
 
   /// Return the cache size in bytes for the given level of cache.



More information about the llvm-commits mailing list