[llvm] [RISCV] Add HasStdExtH to hfence.gvma and hfence.vvma aliases (PR #207061)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 1 14:50:51 PDT 2026
https://github.com/topperc updated https://github.com/llvm/llvm-project/pull/207061
>From d464b426621259d534beeb22d6b13481c9148117 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Wed, 1 Jul 2026 12:12:52 -0700
Subject: [PATCH] [RISCV] Add HasStdExtH to hfence.gvma and hfence.vvma aliases
---
llvm/lib/Target/RISCV/RISCVInstrInfo.td | 2 ++
llvm/test/MC/RISCV/rv32h-invalid.s | 10 ++++++++++
2 files changed, 12 insertions(+)
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
index 7b72dfbbad91e..c136560532142 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -1159,11 +1159,13 @@ def : InstAlias<"csrrc $rd, $csr, $imm", (CSRRCI GPR:$rd, csr_sysreg:$csr, uimm5
def : InstAlias<"sfence.vma", (SFENCE_VMA X0, X0), 2>;
def : InstAlias<"sfence.vma $rs", (SFENCE_VMA GPR:$rs, X0)>;
+let Predicates = [HasStdExtH] in {
def : InstAlias<"hfence.gvma", (HFENCE_GVMA X0, X0), 2>;
def : InstAlias<"hfence.gvma $rs", (HFENCE_GVMA GPR:$rs, X0)>;
def : InstAlias<"hfence.vvma", (HFENCE_VVMA X0, X0), 2>;
def : InstAlias<"hfence.vvma $rs", (HFENCE_VVMA GPR:$rs, X0)>;
+}
// ntl.* hints are always available in the assembler and disassembler, even
// without enabling Zihintntl, per psABI decision
diff --git a/llvm/test/MC/RISCV/rv32h-invalid.s b/llvm/test/MC/RISCV/rv32h-invalid.s
index 3dcfea4898c26..5ce966bfe2b33 100644
--- a/llvm/test/MC/RISCV/rv32h-invalid.s
+++ b/llvm/test/MC/RISCV/rv32h-invalid.s
@@ -3,8 +3,18 @@
# RUN: not llvm-mc -triple riscv32 < %s 2>&1 \
# RUN: | FileCheck %s -check-prefixes=CHECK,CHECK-OFFSET
+hfence.gvma zero, zero # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'H' (Hypervisor)
+
+hfence.gvma zero # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'H' (Hypervisor)
+
+hfence.gvma # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'H' (Hypervisor)
+
hfence.vvma zero, zero # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'H' (Hypervisor)
+hfence.vvma zero # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'H' (Hypervisor)
+
+hfence.vvma # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'H' (Hypervisor)
+
hlv.h a0, 0(a1) # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'H' (Hypervisor)
hlv.wu a0, 0(a1) # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'H' (Hypervisor), RV64I Base Instruction Set
More information about the llvm-commits
mailing list