]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/patches/patch-22-llvm-r223147-arm-cpu-directive.diff
Add llvm patches corresponding to r276211 and r276223.
[FreeBSD/FreeBSD.git] / contrib / llvm / patches / patch-22-llvm-r223147-arm-cpu-directive.diff
1 Pull in r223147, r223255 and r223390 from upstream llvm trunk (by Roman
2 Divacky):
3
4   Introduce CPUStringIsValid() into MCSubtargetInfo and use it for ARM
5   .cpu parsing.
6
7   Previously .cpu directive in ARM assembler didnt switch to the new
8   CPU and therefore acted as a nop. This implemented real action for
9   .cpu and eg. allows to assembler FreeBSD kernel with -integrated-as.
10
11   Change the name to be in style.
12
13   Add a FIXME as requested by Renato Golin.
14
15 Introduced here: http://svnweb.freebsd.org/changeset/base/275654
16
17 Index: include/llvm/MC/MCSubtargetInfo.h
18 ===================================================================
19 --- include/llvm/MC/MCSubtargetInfo.h
20 +++ include/llvm/MC/MCSubtargetInfo.h
21 @@ -132,6 +132,15 @@ class MCSubtargetInfo {
22  
23    /// Initialize an InstrItineraryData instance.
24    void initInstrItins(InstrItineraryData &InstrItins) const;
25 +
26 +  /// Check whether the CPU string is valid.
27 +  bool isCPUStringValid(StringRef CPU) {
28 +    auto Found = std::find_if(ProcDesc.begin(), ProcDesc.end(),
29 +                              [=](const SubtargetFeatureKV &KV) {
30 +                                return CPU == KV.Key; 
31 +                              });
32 +    return Found != ProcDesc.end();
33 +  }
34  };
35  
36  } // End llvm namespace
37 Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp
38 ===================================================================
39 --- lib/Target/ARM/AsmParser/ARMAsmParser.cpp
40 +++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp
41 @@ -8618,6 +8618,20 @@ bool ARMAsmParser::parseDirectiveEabiAttr(SMLoc L)
42  bool ARMAsmParser::parseDirectiveCPU(SMLoc L) {
43    StringRef CPU = getParser().parseStringToEndOfStatement().trim();
44    getTargetStreamer().emitTextAttribute(ARMBuildAttrs::CPU_name, CPU);
45 +
46 +  if (!STI.isCPUStringValid(CPU)) {
47 +    Error(L, "Unknown CPU name");
48 +    return false;
49 +  }
50 +
51 +  // FIXME: This switches the CPU features globally, therefore it might
52 +  // happen that code you would not expect to assemble will. For details
53 +  // see: http://llvm.org/bugs/show_bug.cgi?id=20757
54 +  STI.InitMCProcessorInfo(CPU, "");
55 +  STI.InitCPUSchedModel(CPU);
56 +  unsigned FB = ComputeAvailableFeatures(STI.getFeatureBits());
57 +  setAvailableFeatures(FB);
58 +
59    return false;
60  }
61  
62 Index: test/MC/ARM/cpu-test.s
63 ===================================================================
64 --- test/MC/ARM/cpu-test.s
65 +++ test/MC/ARM/cpu-test.s
66 @@ -0,0 +1,13 @@
67 +// RUN: not llvm-mc -o - -triple arm-gnueabi-freebsd11.0 < %s > %t 2> %t2
68 +// RUN: FileCheck %s < %t
69 +// RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t2
70 +
71 +// CHECK: .cpu cortex-a8
72 +.cpu cortex-a8
73 +// CHECK: dsb     sy
74 +dsb
75 +.cpu arm9       
76 +// CHECK-ERROR: error: instruction requires: data-barriers
77 +dsb
78 +// CHECK-ERROR: error: Unknown CPU name
79 +.cpu foobar