]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/patches/patch-18-llvm-r215811-arm-fpu-directive.diff
Merge xz 5.2.0.
[FreeBSD/FreeBSD.git] / contrib / llvm / patches / patch-18-llvm-r215811-arm-fpu-directive.diff
1 Pull in r215811 from upstream llvm trunk (by Nico Weber):
2
3   arm asm: Let .fpu enable instructions, PR20447.
4
5   I'm not very happy with duplicating the fpu->feature mapping in ARMAsmParser.cpp
6   and in clang's driver. See the bug for a patch that doesn't do that, and the
7   review thread [1] for why this duplication exists.
8
9   1: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140811/231052.html
10
11 This makes the .fpu directive work properly, so we can successfully
12 assemble several .S files using the directive, under lib/libc/arm.
13
14 Introduced here: http://svnweb.freebsd.org/changeset/base/275280
15
16 Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp
17 ===================================================================
18 --- lib/Target/ARM/AsmParser/ARMAsmParser.cpp
19 +++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp
20 @@ -8621,6 +8621,30 @@ bool ARMAsmParser::parseDirectiveCPU(SMLoc L) {
21    return false;
22  }
23  
24 +// FIXME: This is duplicated in getARMFPUFeatures() in
25 +// tools/clang/lib/Driver/Tools.cpp
26 +static const struct {
27 +  const unsigned Fpu;
28 +  const uint64_t Enabled;
29 +  const uint64_t Disabled;
30 +} Fpus[] = {
31 +      {ARM::VFP, ARM::FeatureVFP2, ARM::FeatureNEON},
32 +      {ARM::VFPV2, ARM::FeatureVFP2, ARM::FeatureNEON},
33 +      {ARM::VFPV3, ARM::FeatureVFP3, ARM::FeatureNEON},
34 +      {ARM::VFPV3_D16, ARM::FeatureVFP3 | ARM::FeatureD16, ARM::FeatureNEON},
35 +      {ARM::VFPV4, ARM::FeatureVFP4, ARM::FeatureNEON},
36 +      {ARM::VFPV4_D16, ARM::FeatureVFP4 | ARM::FeatureD16, ARM::FeatureNEON},
37 +      {ARM::FP_ARMV8, ARM::FeatureFPARMv8,
38 +       ARM::FeatureNEON | ARM::FeatureCrypto},
39 +      {ARM::NEON, ARM::FeatureNEON, 0},
40 +      {ARM::NEON_VFPV4, ARM::FeatureVFP4 | ARM::FeatureNEON, 0},
41 +      {ARM::NEON_FP_ARMV8, ARM::FeatureFPARMv8 | ARM::FeatureNEON,
42 +       ARM::FeatureCrypto},
43 +      {ARM::CRYPTO_NEON_FP_ARMV8,
44 +       ARM::FeatureFPARMv8 | ARM::FeatureNEON | ARM::FeatureCrypto, 0},
45 +      {ARM::SOFTVFP, 0, 0},
46 +};
47 +
48  /// parseDirectiveFPU
49  ///  ::= .fpu str
50  bool ARMAsmParser::parseDirectiveFPU(SMLoc L) {
51 @@ -8636,6 +8660,18 @@ bool ARMAsmParser::parseDirectiveFPU(SMLoc L) {
52      return false;
53    }
54  
55 +  for (const auto &Fpu : Fpus) {
56 +    if (Fpu.Fpu != ID)
57 +      continue;
58 +
59 +    // Need to toggle features that should be on but are off and that
60 +    // should off but are on.
61 +    unsigned Toggle = (Fpu.Enabled & ~STI.getFeatureBits()) |
62 +                      (Fpu.Disabled & STI.getFeatureBits());
63 +    setAvailableFeatures(ComputeAvailableFeatures(STI.ToggleFeature(Toggle)));
64 +    break;
65 +  }
66 +
67    getTargetStreamer().emitFPU(ID);
68    return false;
69  }
70 Index: test/MC/ARM/directive-fpu-instrs.s
71 ===================================================================
72 --- test/MC/ARM/directive-fpu-instrs.s
73 +++ test/MC/ARM/directive-fpu-instrs.s
74 @@ -0,0 +1,16 @@
75 +// RUN: llvm-mc -triple armv7-unknown-linux-gnueabi -mattr=+vfp3,+d16,-neon %s
76 +
77 +.fpu neon
78 +VAND d3, d5, d5
79 +vldr d21, [r7, #296]
80 +
81 +@ .thumb should not disable the prior .fpu neon
82 +.thumb
83 +
84 +vmov q4, q11 @ v4si
85 +str r6, [r7, #264]
86 +mov r6, r5
87 +vldr d21, [r7, #296]
88 +add r9, r7, #216
89 +
90 +fstmfdd sp!, {d8, d9, d10, d11, d12, d13, d14, d15}