mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-27 23:51:56 +00:00
[AArch64][v8.5A] Add speculation barrier to AArch64 instruction set
This is a new barrier which limits speculative execution of the instructions following it. Patch by Pablo Barrio! Differential revision: https://reviews.llvm.org/D52476 llvm-svn: 343211
This commit is contained in:
parent
0c05bdea2b
commit
e481f1d95a
@ -211,6 +211,9 @@ def FeatureFRInt3264 : SubtargetFeature<"fptoint", "HasFRInt3264", "true",
|
||||
"Enable FRInt[32|64][Z|X] instructions that round a floating-point number to "
|
||||
"an integer (in FP format) forcing it to fit into a 32- or 64-bit int" >;
|
||||
|
||||
def FeatureSpecCtrl : SubtargetFeature<"specctrl", "HasSpecCtrl", "true",
|
||||
"Enable speculation control barrier" >;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Architectures.
|
||||
//
|
||||
@ -229,7 +232,7 @@ def HasV8_4aOps : SubtargetFeature<"v8.4a", "HasV8_4aOps", "true",
|
||||
|
||||
def HasV8_5aOps : SubtargetFeature<
|
||||
"v8.5a", "HasV8_5aOps", "true", "Support ARM v8.5a instructions",
|
||||
[HasV8_4aOps, FeatureAltFPCmp, FeatureFRInt3264]
|
||||
[HasV8_4aOps, FeatureAltFPCmp, FeatureFRInt3264, FeatureSpecCtrl]
|
||||
>;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -66,6 +66,8 @@ def HasAltNZCV : Predicate<"Subtarget->hasAlternativeNZCV()">,
|
||||
AssemblerPredicate<"FeatureAltFPCmp", "altnzcv">;
|
||||
def HasFRInt3264 : Predicate<"Subtarget->hasFRInt3264()">,
|
||||
AssemblerPredicate<"FeatureFRInt3264", "frint3264">;
|
||||
def HasSpecCtrl : Predicate<"Subtarget->hasSpecCtrl()">,
|
||||
AssemblerPredicate<"FeatureSpecCtrl", "specctrl">;
|
||||
def IsLE : Predicate<"Subtarget->isLittleEndian()">;
|
||||
def IsBE : Predicate<"!Subtarget->isLittleEndian()">;
|
||||
def UseAlternateSExtLoadCVTF32
|
||||
@ -627,9 +629,17 @@ def AXFLAG : PstateWriteSimple<(ins), "axflag", "">, Sched<[WriteSys]> {
|
||||
let Unpredictable{11-8} = 0b1111;
|
||||
let Inst{7-5} = 0b010;
|
||||
}
|
||||
|
||||
} // HasAltNZCV
|
||||
|
||||
|
||||
// Armv8.5-A speculation barrier
|
||||
def SB : SimpleSystemI<0, (ins), "sb", "">, Sched<[]> {
|
||||
let Inst{20-5} = 0b0001100110000111;
|
||||
let Unpredictable{11-8} = 0b1111;
|
||||
let Predicates = [HasSpecCtrl];
|
||||
let hasSideEffects = 1;
|
||||
}
|
||||
|
||||
def : InstAlias<"clrex", (CLREX 0xf)>;
|
||||
def : InstAlias<"isb", (ISB 0xf)>;
|
||||
|
||||
|
@ -97,6 +97,7 @@ protected:
|
||||
// Armv8.5-A Extensions
|
||||
bool HasAlternativeNZCV = false;
|
||||
bool HasFRInt3264 = false;
|
||||
bool HasSpecCtrl = false;
|
||||
|
||||
// HasZeroCycleRegMove - Has zero-cycle register mov instructions.
|
||||
bool HasZeroCycleRegMove = false;
|
||||
@ -312,6 +313,7 @@ public:
|
||||
bool hasAggressiveFMA() const { return HasAggressiveFMA; }
|
||||
bool hasAlternativeNZCV() const { return HasAlternativeNZCV; }
|
||||
bool hasFRInt3264() const { return HasFRInt3264; }
|
||||
bool hasSpecCtrl() { return HasSpecCtrl; }
|
||||
|
||||
bool isLittleEndian() const { return IsLittle; }
|
||||
|
||||
|
11
llvm/test/MC/AArch64/armv8.5a-specctrl.s
Normal file
11
llvm/test/MC/AArch64/armv8.5a-specctrl.s
Normal file
@ -0,0 +1,11 @@
|
||||
// RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=+specctrl < %s | FileCheck %s
|
||||
// RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=+v8.5a < %s | FileCheck %s
|
||||
// RUN: not llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=-specctrl < %s 2>&1 | FileCheck %s --check-prefix=NOSB
|
||||
|
||||
// Flag manipulation
|
||||
sb
|
||||
|
||||
// CHECK: sb // encoding: [0xff,0x30,0x03,0xd5]
|
||||
|
||||
// NOSB: instruction requires: specctrl
|
||||
// NOSB-NEXT: sb
|
9
llvm/test/MC/Disassembler/AArch64/armv8.5a-specctrl.txt
Normal file
9
llvm/test/MC/Disassembler/AArch64/armv8.5a-specctrl.txt
Normal file
@ -0,0 +1,9 @@
|
||||
# RUN: llvm-mc -triple=aarch64-none-linux-gnu -mattr=+specctrl -disassemble < %s | FileCheck %s
|
||||
# RUN: llvm-mc -triple=aarch64-none-linux-gnu -mattr=+v8.5a -disassemble < %s | FileCheck %s
|
||||
# RUN: llvm-mc -triple=aarch64-none-linux-gnu -mattr=-specctrl -disassemble < %s 2>&1 | FileCheck %s --check-prefix=NOSB
|
||||
|
||||
# New reg
|
||||
0xff 0x30 0x03 0xd5
|
||||
|
||||
# CHECK: sb
|
||||
# NOSB: msr S0_3_C3_C0_7, xzr
|
Loading…
Reference in New Issue
Block a user