16 changes: 16 additions & 0 deletions llvm/test/CodeGen/AArch64/tme-tstart.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; RUN: llc %s -o - | FileCheck %s

target triple = "aarch64-unknown-unknown-eabi"

define i64 @test_tstart() #0 {
%r = tail call i64 @llvm.aarch64.tstart()
ret i64 %r
}

declare i64 @llvm.aarch64.tstart() #1

attributes #0 = { "target-features"="+tme" }
attributes #1 = { nounwind }

; CHECK-LABEL: test_tstart
; CHECK: tstart x
16 changes: 16 additions & 0 deletions llvm/test/CodeGen/AArch64/tme-ttest.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; RUN: llc %s -o - | FileCheck %s

target triple = "aarch64-unknown-unknown-eabi"

define i64 @test_ttest() #0 {
%r = tail call i64 @llvm.aarch64.ttest()
ret i64 %r
}

declare i64 @llvm.aarch64.ttest() #1

attributes #0 = { "target-features"="+tme" }
attributes #1 = { nounwind }

; CHECK-LABEL: test_ttest
; CHECK: ttest x
47 changes: 47 additions & 0 deletions llvm/test/MC/AArch64/tme-error.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Tests for transactional memory extension instructions
// RUN: not llvm-mc -triple aarch64 -show-encoding -mattr=+tme < %s 2>&1 | FileCheck %s

tstart
// CHECK: error: too few operands for instruction
// CHECK-NEXT: tstart
tstart x4, x5
// CHECK: error: invalid operand for instruction
// CHECK-NEXT: tstart x4, x5
tstart x4, #1
// CHECK: error: invalid operand for instruction
// CHECK-NEXT: tstart x4, #1
tstart sp
// CHECK: error: invalid operand for instruction
// CHECK-NEXT: tstart sp

ttest
// CHECK: error: too few operands for instruction
// CHECK-NEXT: ttest
ttest x4, x5
// CHECK: error: invalid operand for instruction
// CHECK-NEXT: ttest x4, x5
ttest x4, #1
// CHECK: error: invalid operand for instruction
// CHECK-NEXT: ttest x4, #1
ttest sp
// CHECK: error: invalid operand for instruction
// CHECK-NEXT: ttest sp

tcommit x4
// CHECK: error: invalid operand for instruction
// CHECK-NEXT: tcommit x4
tcommit sp
// CHECK: error: invalid operand for instruction
// CHECK-NEXT: tcommit sp


tcancel
// CHECK: error: too few operands for instruction
// CHECK-NEXT tcancel
tcancel x0
// CHECK: error: immediate must be an integer in range [0, 65535]
// CHECK-NEXT tcancel
tcancel #65536
// CHECK: error: immediate must be an integer in range [0, 65535]
// CHECK-NEXT: tcancel #65536

24 changes: 24 additions & 0 deletions llvm/test/MC/AArch64/tme.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Tests for transaction memory extension instructions
//
// RUN: llvm-mc -triple aarch64 -show-encoding -mattr=+tme < %s | FileCheck %s
// RUN: not llvm-mc -triple aarch64 -show-encoding -mattr=-tme < %s 2>&1 | FileCheck %s --check-prefix=NOTME

tstart x3
ttest x4
tcommit
tcancel #0x1234

// CHECK: tstart x3 // encoding: [0x63,0x30,0x23,0xd5]
// CHECK: ttest x4 // encoding: [0x64,0x31,0x23,0xd5]
// CHECK: tcommit // encoding: [0x7f,0x30,0x03,0xd5]
// CHECK: tcancel #0x1234 // encoding: [0x80,0x46,0x62,0xd4]


// NOTME: instruction requires: tme
// NOTME-NEXT: tstart x3
// NOTME: instruction requires: tme
// NOTME-NEXT: ttest x4
// NOTME: instruction requires: tme
// NOTME-NEXT: tcommit
// NOTME: instruction requires: tme
// NOTME-NEXT: tcancel #0x1234
19 changes: 19 additions & 0 deletions llvm/test/MC/Disassembler/AArch64/tme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Tests for transaction memory extension instructions
# RUN: llvm-mc -triple=aarch64 -mattr=+tme -disassemble < %s | FileCheck %s
# RUN: not llvm-mc -triple=aarch64 -mattr=-tme -disassemble < %s 2>&1 | FileCheck %s --check-prefix=NOTME

[0x63,0x30,0x23,0xd5]
[0x64,0x31,0x23,0xd5]
[0x7f,0x30,0x03,0xd5]
[0x80,0x46,0x62,0xd4]

# CHECK: tstart x3
# CHECK: ttest x4
# CHECK: tcommit
# CHECK: tcancel #0x1234

# NOTEME: mrs
# NOTEME-NEXT: mrs
# NOTEME-NEXT: msr
# NOTME: warning: invalid instruction encoding
# NOTME-NEXT: [0x80,0x46,0x62,0xd4]
1 change: 1 addition & 0 deletions llvm/unittests/Support/TargetParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ TEST(TargetParserTest, AArch64ArchExtFeature) {
{"rcpc", "norcpc", "+rcpc", "-rcpc" },
{"rng", "norng", "+rand", "-rand"},
{"memtag", "nomemtag", "+mte", "-mte"},
{"tme", "notme", "+tme", "-tme"},
{"ssbs", "nossbs", "+ssbs", "-ssbs"},
{"sb", "nosb", "+sb", "-sb"},
{"predres", "nopredres", "+predres", "-predres"}
Expand Down