Commit 37fb3b33 authored by David Spickett's avatar David Spickett
Browse files

[AsmParser] Make generic directives and aliases case insensitive.

GCC will accept any case for assembler directives.
For example ".abort" and ".ABORT" (even ".aBoRt")
are equivalent.

https://sourceware.org/binutils/docs/as/Pseudo-Ops.html#Pseudo-Ops
"The names are case insensitive for most targets,
and usually written in lower case."

Change llvm-mc to accept any case for generic directives
or aliases of those directives.

This for Bugzilla #39527.

Differential Revision: https://reviews.llvm.org/D72686
parent fe3bb8ec
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -199,7 +199,7 @@ public:
  }

  void addAliasForDirective(StringRef Directive, StringRef Alias) override {
    DirectiveKindMap[Directive] = DirectiveKindMap[Alias];
    DirectiveKindMap[Directive.lower()] = DirectiveKindMap[Alias.lower()];
  }

  /// @name MCAsmParser Interface
@@ -1750,7 +1750,7 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
  // have to do this so that .endif isn't skipped in a ".if 0" block for
  // example.
  StringMap<DirectiveKind>::const_iterator DirKindIt =
      DirectiveKindMap.find(IDVal);
      DirectiveKindMap.find(IDVal.lower());
  DirectiveKind DirKind = (DirKindIt == DirectiveKindMap.end())

                              ? DK_NO_DIRECTIVE
@@ -5320,6 +5320,12 @@ bool AsmParser::parseDirectiveEndIf(SMLoc DirectiveLoc) {
}

void AsmParser::initializeDirectiveKindMap() {
  /* Lookup will be done with the directive
   * converted to lower case, so all these
   * keys should be lower case.
   * (target specific directives are handled
   *  elsewhere)
   */
  DirectiveKindMap[".set"] = DK_SET;
  DirectiveKindMap[".equ"] = DK_EQU;
  DirectiveKindMap[".equiv"] = DK_EQUIV;
+16 −0
Original line number Diff line number Diff line
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s

# CHECK: .byte 65
        .ascii "A"
# CHECK: .byte 66
        .ASCII "B"
# CHECK: .byte 67
        .aScIi "C"

# Note: using 2byte because it is an alias
# CHECK: .short 4660
        .2byte 0x1234
# CHECK: .short 4661
        .2BYTE 0x1235
# CHECK: .short 4662
        .2bYtE 0x1236