[llvm] [RISCV] Collect function features in AsmPrinter before emission (#76231) (PR #76437)

Andreu Carminati via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 28 05:27:29 PST 2023


================
@@ -363,13 +370,23 @@ bool RISCVAsmPrinter::emitDirectiveOptionArch() {
   return false;
 }
 
+bool RISCVAsmPrinter::doInitialization(Module &M) {
+
+  CommonSTI->setFeatureBits(TM.getMCSubtargetInfo()->getFeatureBits());
+  return AsmPrinter::doInitialization(M);
+}
+
 bool RISCVAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   STI = &MF.getSubtarget<RISCVSubtarget>();
   RISCVTargetStreamer &RTS =
       static_cast<RISCVTargetStreamer &>(*OutStreamer->getTargetStreamer());
 
   bool EmittedOptionArch = emitDirectiveOptionArch();
 
+  // Collect flags from this function.
+  CommonSTI->setFeatureBits(CommonSTI->getFeatureBits() |
----------------
andcarminati wrote:

Hi @kito-cheng, thank you for this point, makes sense. I will include in this PR a mechanism to exclude invalid feature bit combinations.

https://github.com/llvm/llvm-project/pull/76437


More information about the llvm-commits mailing list