Index: lib/Target/ARM/ARM.td =================================================================== --- lib/Target/ARM/ARM.td +++ lib/Target/ARM/ARM.td @@ -83,6 +83,10 @@ def FeatureV7Clrex : SubtargetFeature<"v7clrex", "HasV7Clrex", "true", "Has v7 clrex instruction">; +def FeatureDFB : SubtargetFeature<"dfb", "HasFullDataBarrier", "true", + "Has full data barrier (dfb) instruction">; + + def FeatureAcquireRelease : SubtargetFeature<"acquire-release", "HasAcquireRelease", "true", "Has v8 acquire/release (lda/ldaex " @@ -617,6 +621,7 @@ def ARMv8r : Architecture<"armv8-r", "ARMv8r", [HasV8Ops, FeatureRClass, FeatureDB, + FeatureDFB, FeatureDSP, FeatureCRC, FeatureMP, Index: lib/Target/ARM/ARMInstrInfo.td =================================================================== --- lib/Target/ARM/ARMInstrInfo.td +++ lib/Target/ARM/ARMInstrInfo.td @@ -278,6 +278,9 @@ def HasDB : Predicate<"Subtarget->hasDataBarrier()">, AssemblerPredicate<"FeatureDB", "data-barriers">; +def HasDFB : Predicate<"Subtarget->hasFullDataBarrier()">, + AssemblerPredicate<"FeatureDFB", + "full-data-barrier">; def HasV7Clrex : Predicate<"Subtarget->hasV7Clrex()">, AssemblerPredicate<"FeatureV7Clrex", "v7 clrex">; @@ -4804,6 +4807,12 @@ let Inst{31-4} = 0xf57ff06; let Inst{3-0} = opt; } + +def DFB : AInoP<(outs), (ins), MiscFrm, NoItinerary, + "dfb", "", []>, + Requires<[IsARM, HasDFB]> , Sched<[WriteALU]> { + let Inst{31-0} = 0xf57ff04c; +} } let usesCustomInserter = 1, Defs = [CPSR] in { Index: lib/Target/ARM/ARMInstrThumb2.td =================================================================== --- lib/Target/ARM/ARMInstrThumb2.td +++ lib/Target/ARM/ARMInstrThumb2.td @@ -3191,6 +3191,12 @@ let Inst{31-4} = 0xf3bf8f6; let Inst{3-0} = opt; } + +def t2DFB : T2I<(outs), (ins), NoItinerary, + "dfb", "", []>, + Requires<[IsThumb, HasDFB]>, Sched<[WriteALU]> { + let Inst{31-0} = 0xf3bf8f4c; +} } class T2I_ldrex opcod, dag oops, dag iops, AddrMode am, int sz, Index: lib/Target/ARM/ARMSubtarget.h =================================================================== --- lib/Target/ARM/ARMSubtarget.h +++ lib/Target/ARM/ARMSubtarget.h @@ -236,6 +236,10 @@ /// instructions. bool HasDataBarrier = false; + /// HasFullDataBarrier - True if the subtarget supports DFB data barrier + /// instruction. + bool HasFullDataBarrier = false; + /// HasV7Clrex - True if the subtarget supports CLREX instructions bool HasV7Clrex = false; @@ -544,6 +548,7 @@ bool hasDivideInThumbMode() const { return HasHardwareDivideInThumb; } bool hasDivideInARMMode() const { return HasHardwareDivideInARM; } bool hasDataBarrier() const { return HasDataBarrier; } + bool hasFullDataBarrier() const { return HasFullDataBarrier; } bool hasV7Clrex() const { return HasV7Clrex; } bool hasAcquireRelease() const { return HasAcquireRelease; } Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp =================================================================== --- lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -5581,11 +5581,11 @@ CanAcceptPredicationCode = Mnemonic != "cdp2" && Mnemonic != "clrex" && Mnemonic != "mcr2" && Mnemonic != "mcrr2" && Mnemonic != "mrc2" && Mnemonic != "mrrc2" && - Mnemonic != "dmb" && Mnemonic != "dsb" && Mnemonic != "isb" && - Mnemonic != "pld" && Mnemonic != "pli" && Mnemonic != "pldw" && - Mnemonic != "ldc2" && Mnemonic != "ldc2l" && Mnemonic != "stc2" && - Mnemonic != "stc2l" && !Mnemonic.startswith("rfe") && - !Mnemonic.startswith("srs"); + Mnemonic != "dmb" && Mnemonic != "dfb" && Mnemonic != "dsb" && + Mnemonic != "isb" && Mnemonic != "pld" && Mnemonic != "pli" && + Mnemonic != "pldw" && Mnemonic != "ldc2" && Mnemonic != "ldc2l" && + Mnemonic != "stc2" && Mnemonic != "stc2l" && + !Mnemonic.startswith("rfe") && !Mnemonic.startswith("srs"); } else if (isThumbOne()) { if (hasV6MOps()) CanAcceptPredicationCode = Mnemonic != "movs"; Index: test/MC/ARM/dfb-neg.s =================================================================== --- /dev/null +++ test/MC/ARM/dfb-neg.s @@ -0,0 +1,10 @@ +@ RUN: not llvm-mc -triple armv8-none-eabi -mcpu=cortex-r52 -mattr=-dfb -show-encoding < %s 2>&1 | FileCheck %s +@ RUN: not llvm-mc -triple thumbv8-none-eabi -mcpu=cortex-r52 -mattr=-dfb -show-encoding < %s 2>&1 | FileCheck %s + + dfb +@ CHECK: error: instruction requires: full-data-barrier + + dfb sy + dfb #0 +@ CHECK: error: invalid instruction +@ CHECK: error: invalid instruction Index: test/MC/ARM/dfb.s =================================================================== --- /dev/null +++ test/MC/ARM/dfb.s @@ -0,0 +1,6 @@ +@ RUN: llvm-mc -triple armv8-none-eabi -mcpu=cortex-r52 -show-encoding < %s | FileCheck %s --check-prefix=CHECK-ARM +@ RUN: llvm-mc -triple thumbv8-none-eabi -mcpu=cortex-r52 -show-encoding < %s | FileCheck %s --check-prefix=CHECK-THUMB + + dfb +@ CHECK-ARM: dfb @ encoding: [0x4c,0xf0,0x7f,0xf5] +@ CHECK-THUMB: dfb @ encoding: [0xbf,0xf3,0x4c,0x8f] Index: test/MC/Disassembler/ARM/dfb-arm.txt =================================================================== --- /dev/null +++ test/MC/Disassembler/ARM/dfb-arm.txt @@ -0,0 +1,7 @@ +# SDCOMP-27699: DFB on ARMv8-R +# RUN: llvm-mc -disassemble -triple armv8-none-eabi -mcpu=cortex-r52 -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DFB +# RUN: llvm-mc -disassemble -triple armv8-none-eabi -mcpu=cortex-r52 -mattr=-dfb -show-encoding < %s | FileCheck %s --check-prefix=CHECK-NODFB + +# CHECK-DFB: dfb @ encoding: [0x4c,0xf0,0x7f,0xf5] +# CHECK-NODFB: dsb #0xc @ encoding: [0x4c,0xf0,0x7f,0xf5] +[0x4c,0xf0,0x7f,0xf5] Index: test/MC/Disassembler/ARM/dfb-thumb.txt =================================================================== --- /dev/null +++ test/MC/Disassembler/ARM/dfb-thumb.txt @@ -0,0 +1,7 @@ +# SDCOMP-27699: DFB on ARMv8-R +# RUN: llvm-mc -disassemble -triple thumbv8-none-eabi -mcpu=cortex-r52 -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DFB +# RUN: llvm-mc -disassemble -triple thumbv8-none-eabi -mcpu=cortex-r52 -mattr=-dfb -show-encoding < %s | FileCheck %s --check-prefix=CHECK-NODFB + +# CHECK-DFB: dfb @ encoding: [0xbf,0xf3,0x4c,0x8f] +# CHECK-NODFB: dsb #0xc @ encoding: [0xbf,0xf3,0x4c,0x8f] +[0xbf,0xf3,0x4c,0x8f]