[llvm] [ARM][MC] Gate Thumb hvc alias on virtualization (PR #193532)
Mark Murray via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 22 09:41:12 PDT 2026
https://github.com/MarkMurrayARM created https://github.com/llvm/llvm-project/pull/193532
None
>From 5cbeed013c15316eafee810be39bec5342429191 Mon Sep 17 00:00:00 2001
From: Mark Murray <mark.murray at arm.com>
Date: Tue, 21 Apr 2026 10:08:55 +0100
Subject: [PATCH] [ARM][MC] Gate Thumb hvc alias on virtualization
---
llvm/lib/Target/ARM/ARMInstrThumb2.td | 4 +++-
llvm/test/MC/ARM/thumb-hvc-virt-diagnostics.s | 19 +++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/MC/ARM/thumb-hvc-virt-diagnostics.s
diff --git a/llvm/lib/Target/ARM/ARMInstrThumb2.td b/llvm/lib/Target/ARM/ARMInstrThumb2.td
index 4f0cea8b00aac..e79adb370798e 100644
--- a/llvm/lib/Target/ARM/ARMInstrThumb2.td
+++ b/llvm/lib/Target/ARM/ARMInstrThumb2.td
@@ -4347,7 +4347,9 @@ def t2HVC : T2XI <(outs), (ins imm0_65535:$imm16), IIC_Br, "hvc.w\t$imm16", []>,
}
// Alias for HVC without the ".w" optional width specifier
-def : t2InstAlias<"hvc\t$imm16", (t2HVC imm0_65535:$imm16)>;
+def : t2InstAlias<"hvc\t$imm16", (t2HVC imm0_65535:$imm16)> {
+ let Predicates = [IsThumb2, HasVirtualization];
+}
//===----------------------------------------------------------------------===//
// Non-Instruction Patterns
diff --git a/llvm/test/MC/ARM/thumb-hvc-virt-diagnostics.s b/llvm/test/MC/ARM/thumb-hvc-virt-diagnostics.s
new file mode 100644
index 0000000000000..8d0f8c5d49691
--- /dev/null
+++ b/llvm/test/MC/ARM/thumb-hvc-virt-diagnostics.s
@@ -0,0 +1,19 @@
+@ RUN: llvm-mc -triple thumbv7-eabi -mattr=+virtualization -show-encoding %s | FileCheck %s --check-prefix=CHECK
+@ RUN: not llvm-mc -triple thumbv7-eabi -mcpu=cortex-a9 %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOVIRT
+
+ .syntax unified
+ .text
+ .thumb
+
+ hvc #0
+ hvc.w #0
+
+@ CHECK: hvc.w #0 @ encoding: [0xe0,0xf7,0x00,0x80]
+@ CHECK: hvc.w #0 @ encoding: [0xe0,0xf7,0x00,0x80]
+
+@ CHECK-NOVIRT: error: instruction requires: virtualization-extensions
+@ CHECK-NOVIRT: hvc #0
+@ CHECK-NOVIRT: ^
+@ CHECK-NOVIRT: error: instruction requires: virtualization-extensions
+@ CHECK-NOVIRT: hvc.w #0
+@ CHECK-NOVIRT: ^
More information about the llvm-commits
mailing list