diff options
| author | Oliver Stannard <oliver.stannard@arm.com> | 2018-09-27 13:41:14 +0000 |
|---|---|---|
| committer | Oliver Stannard <oliver.stannard@arm.com> | 2018-09-27 13:41:14 +0000 |
| commit | 382c935c4231eaf7b820cb207c9fbd0c50505181 (patch) | |
| tree | 81ba99a637c7e3d276a3412ccfb615ca47adc7d1 /llvm/lib | |
| parent | 7860c5fe4e80970101f3f4901a673d6c47a532bb (diff) | |
| download | bcm5719-llvm-382c935c4231eaf7b820cb207c9fbd0c50505181.tar.gz bcm5719-llvm-382c935c4231eaf7b820cb207c9fbd0c50505181.zip | |
[ARM][v8.5A] Add speculation barrier to ARM & Thumb instruction sets
This is a new barrier which limits speculative execution of the
instructions following it.
Patch by Pablo Barrio!
Differential revision: https://reviews.llvm.org/D52477
llvm-svn: 343213
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/ARM/ARM.td | 7 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/ARMInstrInfo.td | 12 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/ARMInstrThumb2.td | 8 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/ARMSubtarget.h | 4 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 3 |
5 files changed, 32 insertions, 2 deletions
diff --git a/llvm/lib/Target/ARM/ARM.td b/llvm/lib/Target/ARM/ARM.td index f1a82ca18e8..fc23495ebf3 100644 --- a/llvm/lib/Target/ARM/ARM.td +++ b/llvm/lib/Target/ARM/ARM.td @@ -363,6 +363,11 @@ def FeatureNoPostRASched : SubtargetFeature<"disable-postra-scheduler", def FeatureUseAA : SubtargetFeature<"use-aa", "UseAA", "true", "Use alias analysis during codegen">; +// Armv8.5-A extensions + +def FeatureSpecCtrl : SubtargetFeature<"specctrl", "HasSpecCtrl", "true", + "Enable speculation control barrier" >; + //===----------------------------------------------------------------------===// // ARM architecture class // @@ -454,7 +459,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]>; + [HasV8_4aOps, FeatureSpecCtrl]>; //===----------------------------------------------------------------------===// // ARM Processor subtarget features. diff --git a/llvm/lib/Target/ARM/ARMInstrInfo.td b/llvm/lib/Target/ARM/ARMInstrInfo.td index adb4f65ee93..e063ffdc36b 100644 --- a/llvm/lib/Target/ARM/ARMInstrInfo.td +++ b/llvm/lib/Target/ARM/ARMInstrInfo.td @@ -391,6 +391,10 @@ let RecomputePerFunction = 1 in { def GenExecuteOnly : Predicate<"Subtarget->genExecuteOnly()">; +// Armv8.5-A extensions +def HasSpecCtrl : Predicate<"Subtarget->hasSpecCtrl()">, + AssemblerPredicate<"FeatureSpecCtrl", "specctrl">; + //===----------------------------------------------------------------------===// // ARM Flag Definitions. @@ -4875,6 +4879,14 @@ def TSB : AInoP<(outs), (ins tsb_opt:$opt), MiscFrm, NoItinerary, } +// Armv8.5-A speculation barrier +def SB : AInoP<(outs), (ins), MiscFrm, NoItinerary, "sb", "", []>, + Requires<[IsARM, HasSpecCtrl]>, Sched<[]> { + let Inst{31-0} = 0xf57ff070; + let Unpredictable = 0x000fff0f; + let hasSideEffects = 1; +} + let usesCustomInserter = 1, Defs = [CPSR] in { // Pseudo instruction that combines movs + predicated rsbmi diff --git a/llvm/lib/Target/ARM/ARMInstrThumb2.td b/llvm/lib/Target/ARM/ARMInstrThumb2.td index 95195e85c4e..39525a3e28f 100644 --- a/llvm/lib/Target/ARM/ARMInstrThumb2.td +++ b/llvm/lib/Target/ARM/ARMInstrThumb2.td @@ -3231,6 +3231,14 @@ def t2TSB : T2I<(outs), (ins tsb_opt:$opt), NoItinerary, } } +// Armv8.5-A speculation barrier +def t2SB : Thumb2XI<(outs), (ins), AddrModeNone, 4, NoItinerary, "sb", "", []>, + Requires<[IsThumb2, HasSpecCtrl]>, Sched<[]> { + let Inst{31-0} = 0xf3bf8f70; + let Unpredictable = 0x000f2f0f; + let hasSideEffects = 1; +} + class T2I_ldrex<bits<4> opcod, dag oops, dag iops, AddrMode am, int sz, InstrItinClass itin, string opc, string asm, string cstr, list<dag> pattern, bits<4> rt2 = 0b1111> diff --git a/llvm/lib/Target/ARM/ARMSubtarget.h b/llvm/lib/Target/ARM/ARMSubtarget.h index 1e84d3141d5..b06c35ff1ac 100644 --- a/llvm/lib/Target/ARM/ARMSubtarget.h +++ b/llvm/lib/Target/ARM/ARMSubtarget.h @@ -416,6 +416,9 @@ protected: /// UseSjLjEH - If true, the target uses SjLj exception handling (e.g. iOS). bool UseSjLjEH = false; + /// Has speculation barrier + bool HasSpecCtrl = false; + /// Implicitly convert an instruction to a different one if its immediates /// cannot be encoded. For example, ADD r0, r1, #FFFFFFFF -> SUB r0, r1, #1. bool NegativeImmediates = true; @@ -625,6 +628,7 @@ public: bool hasDSP() const { return HasDSP; } bool useNaClTrap() const { return UseNaClTrap; } bool useSjLjEH() const { return UseSjLjEH; } + bool hasSpecCtrl() const { return HasSpecCtrl; } bool genLongCalls() const { return GenLongCalls; } bool genExecuteOnly() const { return GenExecuteOnly; } diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 3e44014d29e..c5b2d2d5968 100644 --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -5720,7 +5720,8 @@ void ARMAsmParser::getMnemonicAcceptInfo(StringRef Mnemonic, StringRef FullInst, Mnemonic == "vmovx" || Mnemonic == "vins" || Mnemonic == "vudot" || Mnemonic == "vsdot" || Mnemonic == "vcmla" || Mnemonic == "vcadd" || - Mnemonic == "vfmal" || Mnemonic == "vfmsl") { + Mnemonic == "vfmal" || Mnemonic == "vfmsl" || + Mnemonic == "sb") { // These mnemonics are never predicable CanAcceptPredicationCode = false; } else if (!isThumb()) { |

