Index: llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp =================================================================== --- llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp +++ llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp @@ -1114,14 +1114,29 @@ int64_t ASIVal = 0; std::unique_ptr Mask; - if (parseSparcAsmOperand(Mask) != MatchOperand_Success) { - Error(S, "malformed ASI tag"); - return MatchOperand_ParseFail; - } + if (parseSparcAsmOperand(Mask) == MatchOperand_Success) { + if (!Mask->isImm() || !Mask->getImm()->evaluateAsAbsolute(ASIVal) || + ASIVal < 0 || ASIVal > 255) { + Error(S, "invalid ASI number, must be between 0 and 255"); + return MatchOperand_ParseFail; + } + } else if (getLexer().getKind() == AsmToken::Hash) { + SMLoc TagStart = getLexer().peekTok(false).getLoc(); + Parser.Lex(); // Eat the '#'. + auto ASIName = Parser.getTok().getString(); + auto ASITag = SparcASITag::lookupASITagByName(ASIName); + if (!ASITag) + ASITag = SparcASITag::lookupASITagByAltName(ASIName); + Parser.Lex(); // Eat the identifier token. + + if (!ASITag) { + Error(TagStart, "unknown ASI tag"); + return MatchOperand_ParseFail; + } - if (!Mask->isImm() || !Mask->getImm()->evaluateAsAbsolute(ASIVal) || - ASIVal < 0 || ASIVal > 255) { - Error(S, "invalid ASI number, must be between 0 and 255"); + ASIVal = ASITag->Encoding; + } else { + Error(S, "malformed ASI tag"); return MatchOperand_ParseFail; } @@ -1230,7 +1245,8 @@ return MatchOperand_ParseFail; } - if (getLexer().is(AsmToken::Integer) || getLexer().is(AsmToken::LParen)) + if (getLexer().is(AsmToken::Integer) || getLexer().is(AsmToken::LParen) || + getLexer().is(AsmToken::Hash)) return parseASITag(Operands); return MatchOperand_Success; } Index: llvm/lib/Target/Sparc/CMakeLists.txt =================================================================== --- llvm/lib/Target/Sparc/CMakeLists.txt +++ llvm/lib/Target/Sparc/CMakeLists.txt @@ -10,6 +10,7 @@ tablegen(LLVM SparcGenInstrInfo.inc -gen-instr-info) tablegen(LLVM SparcGenMCCodeEmitter.inc -gen-emitter) tablegen(LLVM SparcGenRegisterInfo.inc -gen-register-info) +tablegen(LLVM SparcGenSearchableTables.inc -gen-searchable-tables) tablegen(LLVM SparcGenSubtargetInfo.inc -gen-subtarget) add_public_tablegen_target(SparcCommonTableGen) Index: llvm/lib/Target/Sparc/MCTargetDesc/SparcInstPrinter.cpp =================================================================== --- llvm/lib/Target/Sparc/MCTargetDesc/SparcInstPrinter.cpp +++ llvm/lib/Target/Sparc/MCTargetDesc/SparcInstPrinter.cpp @@ -246,5 +246,9 @@ void SparcInstPrinter::printASITag(const MCInst *MI, int opNum, const MCSubtargetInfo &STI, raw_ostream &O) { unsigned Imm = MI->getOperand(opNum).getImm(); - O << Imm; + auto ASITag = SparcASITag::lookupASITagByEncoding(Imm); + if (ASITag) + O << '#' << ASITag->Name; + else + O << Imm; } Index: llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.h =================================================================== --- llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.h +++ llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.h @@ -13,6 +13,7 @@ #ifndef LLVM_LIB_TARGET_SPARC_MCTARGETDESC_SPARCMCTARGETDESC_H #define LLVM_LIB_TARGET_SPARC_MCTARGETDESC_SPARCMCTARGETDESC_H +#include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" #include @@ -35,6 +36,18 @@ const MCTargetOptions &Options); std::unique_ptr createSparcELFObjectWriter(bool Is64Bit, uint8_t OSABI); + +// Defines symbolic names for Sparc v9 ASI tag names. +namespace SparcASITag { +struct ASITag { + const char *Name; + const char *AltName; + unsigned Encoding; +}; + +#define GET_ASITagsList_DECL +#include "SparcGenSearchableTables.inc" +} // end namespace SparcASITag } // End llvm namespace // Defines symbolic names for Sparc registers. This defines a mapping from Index: llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp =================================================================== --- llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp +++ llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp @@ -21,6 +21,13 @@ #include "llvm/MC/TargetRegistry.h" #include "llvm/Support/ErrorHandling.h" +namespace llvm { +namespace SparcASITag { +#define GET_ASITagsList_IMPL +#include "SparcGenSearchableTables.inc" +} // end namespace SparcASITag +} // end namespace llvm + using namespace llvm; #define GET_INSTRINFO_MC_DESC Index: llvm/lib/Target/Sparc/Sparc.td =================================================================== --- llvm/lib/Target/Sparc/Sparc.td +++ llvm/lib/Target/Sparc/Sparc.td @@ -69,6 +69,7 @@ // Register File, Calling Conv, Instruction Descriptions //===----------------------------------------------------------------------===// +include "SparcASITags.td" include "SparcRegisterInfo.td" include "SparcCallingConv.td" include "SparcSchedule.td" Index: llvm/lib/Target/Sparc/SparcASITags.td =================================================================== --- /dev/null +++ llvm/lib/Target/Sparc/SparcASITags.td @@ -0,0 +1,54 @@ +//===- SparcASITags.td -------------------------------------*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the symbolic operands permitted for various kinds of +// SPARCv9 ASI. +// +//===----------------------------------------------------------------------===// + +include "llvm/TableGen/SearchableTable.td" + +class ASITag op> { + string Name = name; + // A maximum of one alias is supported right now. + string AltName = alt_name; + bits<8> Encoding = op; +} + +def ASITagsList : GenericTable { + let FilterClass = "ASITag"; + let Fields = ["Name", "AltName", "Encoding"]; + + let PrimaryKey = [ "Encoding" ]; + let PrimaryKeyName = "lookupASITagByEncoding"; +} + +def lookupASITagByName : SearchIndex { + let Table = ASITagsList; + let Key = [ "Name" ]; +} + +def lookupASITagByAltName : SearchIndex { + let Table = ASITagsList; + let Key = [ "AltName" ]; +} + +def : ASITag<"ASI_N", "ASI_NUCLEUS", 0x4>; +def : ASITag<"ASI_N_L", "ASI_NUCLEUS_LITTLE", 0xC>; +def : ASITag<"ASI_AIUP", "ASI_AS_IF_USER_PRIMARY", 0x10>; +def : ASITag<"ASI_AIUS", "ASI_AS_IF_USER_SECONDARY", 0x11>; +def : ASITag<"ASI_AIUP_L", "ASI_AS_IF_USER_PRIMARY_LITTLE", 0x18>; +def : ASITag<"ASI_AIUS_L", "ASI_AS_IF_USER_SECONDARY_LITTLE", 0x19>; +def : ASITag<"ASI_P", "ASI_PRIMARY", 0x80>; +def : ASITag<"ASI_S", "ASI_SECONDARY", 0x81>; +def : ASITag<"ASI_PNF", "ASI_PRIMARY_NOFAULT", 0x82>; +def : ASITag<"ASI_SNF", "ASI_SECONDARY_NOFAULT", 0x83>; +def : ASITag<"ASI_P_L", "ASI_PRIMARY_LITTLE", 0x88>; +def : ASITag<"ASI_S_L", "ASI_SECONDARY_LITTLE", 0x89>; +def : ASITag<"ASI_PNF_L", "ASI_PRIMARY_NOFAULT_LITTLE", 0x8A>; +def : ASITag<"ASI_SNF_L", "ASI_SECONDARY_NOFAULT_LITTLE", 0x8B>; Index: llvm/test/MC/Disassembler/Sparc/sparc-mem.txt =================================================================== --- llvm/test/MC/Disassembler/Sparc/sparc-mem.txt +++ llvm/test/MC/Disassembler/Sparc/sparc-mem.txt @@ -12,7 +12,7 @@ # CHECK: ldsb [%g1], %o4 0xd8 0x48 0x40 0x00 -# CHECK: ldsba [%i0+%l6] 131, %o2 +# CHECK: ldsba [%i0+%l6] #ASI_SNF, %o2 0xd4 0xce 0x10 0x76 # CHECK: ldsh [%i0+%l6], %o2 @@ -27,7 +27,7 @@ # CHECK: ldsh [%g1], %o4 0xd8 0x50 0x40 0x00 -# CHECK: ldsha [%i0+%l6] 131, %o2 +# CHECK: ldsha [%i0+%l6] #ASI_SNF, %o2 0xd4 0xd6 0x10 0x76 # CHECK: ldub [%i0+%l6], %o2 @@ -42,7 +42,7 @@ # CHECK: ldub [%g1], %o2 0xd4 0x08 0x40 0x00 -# CHECK: lduba [%i0+%l6] 131, %o2 +# CHECK: lduba [%i0+%l6] #ASI_SNF, %o2 0xd4 0x8e 0x10 0x76 # CHECK: lduh [%i0+%l6], %o2 @@ -57,7 +57,7 @@ # CHECK: lduh [%g1], %o2 0xd4 0x10 0x40 0x00 -# CHECK: lduha [%i0+%l6] 131, %o2 +# CHECK: lduha [%i0+%l6] #ASI_SNF, %o2 0xd4 0x96 0x10 0x76 # CHECK: ld [%i0+%l6], %o2 @@ -72,7 +72,7 @@ # CHECK: ld [%g1], %o2 0xd4 0x00 0x40 0x00 -# CHECK: lda [%i0+%l6] 131, %o2 +# CHECK: lda [%i0+%l6] #ASI_SNF, %o2 0xd4 0x86 0x10 0x76 # CHECK: ld [%i0+%l6], %f2 @@ -87,7 +87,7 @@ # CHECK: ld [%g1], %f2 0xc5 0x00 0x40 0x00 -# CHECK: lda [%i0+%l6] 131, %f2 +# CHECK: lda [%i0+%l6] #ASI_SNF, %f2 0xc5 0x86 0x10 0x76 # CHECK: ldd [%i0+%l6], %f2 @@ -102,7 +102,7 @@ # CHECK: ldd [%g1], %f2 0xc5 0x18 0x40 0x00 -# CHECK: ldda [%i0+%l6] 131, %f2 +# CHECK: ldda [%i0+%l6] #ASI_SNF, %f2 0xc5 0x9e 0x10 0x76 # CHECK: ldq [%i0+%l6], %f4 @@ -153,7 +153,7 @@ # CHECK: stb %o2, [%g1] 0xd4 0x28 0x40 0x00 -# CHECK: stba %o2, [%i0+%l6] 131 +# CHECK: stba %o2, [%i0+%l6] #ASI_SNF 0xd4 0xae 0x10 0x76 # CHECK: sth %o2, [%i0+%l6] @@ -168,7 +168,7 @@ # CHECK: sth %o2, [%g1] 0xd4 0x30 0x40 0x00 -# CHECK: stha %o2, [%i0+%l6] 131 +# CHECK: stha %o2, [%i0+%l6] #ASI_SNF 0xd4 0xb6 0x10 0x76 # CHECK: st %o2, [%i0+%l6] @@ -183,7 +183,7 @@ # CHECK: st %o2, [%g1] 0xd4 0x20 0x40 0x00 -# CHECK: sta %o2, [%i0+%l6] 131 +# CHECK: sta %o2, [%i0+%l6] #ASI_SNF 0xd4 0xa6 0x10 0x76 # CHECK: st %f2, [%i0+%l6] @@ -198,7 +198,7 @@ # CHECK: st %f2, [%g1] 0xc5 0x20 0x40 0x00 -# CHECK: sta %f2, [%i0+%l6] 131 +# CHECK: sta %f2, [%i0+%l6] #ASI_SNF 0xc5 0xa6 0x10 0x76 # CHECK: std %f2, [%i0+%l6] @@ -213,7 +213,7 @@ # CHECK: std %f2, [%g1] 0xc5 0x38 0x40 0x00 -# CHECK: stda %f2, [%i0+%l6] 131 +# CHECK: stda %f2, [%i0+%l6] #ASI_SNF 0xc5 0xbe 0x10 0x76 # CHECK: stq %f4, [%i0+%l6] @@ -252,10 +252,10 @@ # CHECK: swap [%g1], %o2 0xd4 0x78 0x40 0x00 -# CHECK: swapa [%i0+%l6] 131, %o2 +# CHECK: swapa [%i0+%l6] #ASI_SNF, %o2 0xd4 0xfe 0x10 0x76 -# CHECK: swapa [%g1] 131, %o2 +# CHECK: swapa [%g1] #ASI_SNF, %o2 0xd4 0xf8 0x50 0x60 # CHECK: ldd [%i0+%l6], %o2 @@ -282,7 +282,7 @@ # CHECK: std %o2, [%g1] 0xd4 0x38 0x40 0x00 -# CHECK: stda %o2, [%i0+%l6] 131 +# CHECK: stda %o2, [%i0+%l6] #ASI_SNF 0xd4 0xbe 0x10 0x76 # CHECK: ldstub [%i0+%l6], %o2 @@ -297,10 +297,10 @@ # CHECK: ldstub [%g1], %o2 0xd4 0x68 0x40 0x00 -# CHECK: ldstuba [%i0+%l6] 131, %o2 +# CHECK: ldstuba [%i0+%l6] #ASI_SNF, %o2 0xd4 0xee 0x10 0x76 -# CHECK: ldstuba [%g1] 131, %o2 +# CHECK: ldstuba [%g1] #ASI_SNF, %o2 0xd4 0xe8 0x50 0x60 # CHECK: flush %g1+%g2 Index: llvm/test/MC/Sparc/sparc-atomic-instructions.s =================================================================== --- llvm/test/MC/Sparc/sparc-atomic-instructions.s +++ llvm/test/MC/Sparc/sparc-atomic-instructions.s @@ -10,10 +10,10 @@ ! CHECK: swap [%i0+32], %o2 ! encoding: [0xd4,0x7e,0x20,0x20] swap [%i0+32], %o2 - ! CHECK: swapa [%i0+%l6] 131, %o2 ! encoding: [0xd4,0xfe,0x10,0x76] + ! CHECK: swapa [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0xfe,0x10,0x76] swapa [%i0+%l6] 131, %o2 - ! CHECK: swapa [%i0+%l6] 131, %o2 ! encoding: [0xd4,0xfe,0x10,0x76] + ! CHECK: swapa [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0xfe,0x10,0x76] swapa [%i0+%l6] (130+1), %o2 ! CHECK: ldstub [%i0+40], %g1 ! encoding: [0xc2,0x6e,0x20,0x28] @@ -22,8 +22,8 @@ ! CHECK: ldstub [%i0+%i2], %g1 ! encoding: [0xc2,0x6e,0x00,0x1a] ldstub [%i0+%i2], %g1 - ! CHECK: ldstuba [%i0+%i2] 131, %g1 ! encoding: [0xc2,0xee,0x10,0x7a] + ! CHECK: ldstuba [%i0+%i2] #ASI_SNF, %g1 ! encoding: [0xc2,0xee,0x10,0x7a] ldstuba [%i0+%i2] 131, %g1 - ! CHECK: ldstuba [%i0+%i2] 131, %g1 ! encoding: [0xc2,0xee,0x10,0x7a] + ! CHECK: ldstuba [%i0+%i2] #ASI_SNF, %g1 ! encoding: [0xc2,0xee,0x10,0x7a] ldstuba [%i0+%i2] (130+1), %g1 Index: llvm/test/MC/Sparc/sparc-mem-instructions.s =================================================================== --- llvm/test/MC/Sparc/sparc-mem-instructions.s +++ llvm/test/MC/Sparc/sparc-mem-instructions.s @@ -7,9 +7,9 @@ ldsb [%i0 + 32], %o2 ! CHECK: ldsb [%g1], %o4 ! encoding: [0xd8,0x48,0x40,0x00] ldsb [%g1], %o4 - ! CHECK: ldsba [%i0+%l6] 131, %o2 ! encoding: [0xd4,0xce,0x10,0x76] + ! CHECK: ldsba [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0xce,0x10,0x76] ldsba [%i0 + %l6] 131, %o2 - ! CHECK: ldsba [%i0+%l6] 131, %o2 ! encoding: [0xd4,0xce,0x10,0x76] + ! CHECK: ldsba [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0xce,0x10,0x76] ldsba [%i0 + %l6] (130+1), %o2 ! CHECK: ldsh [%i0+%l6], %o2 ! encoding: [0xd4,0x56,0x00,0x16] @@ -18,9 +18,9 @@ ldsh [%i0 + 32], %o2 ! CHECK: ldsh [%g1], %o4 ! encoding: [0xd8,0x50,0x40,0x00] ldsh [%g1], %o4 - ! CHECK: ldsha [%i0+%l6] 131, %o2 ! encoding: [0xd4,0xd6,0x10,0x76] + ! CHECK: ldsha [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0xd6,0x10,0x76] ldsha [%i0 + %l6] 131, %o2 - ! CHECK: ldsha [%i0+%l6] 131, %o2 ! encoding: [0xd4,0xd6,0x10,0x76] + ! CHECK: ldsha [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0xd6,0x10,0x76] ldsha [%i0 + %l6] (130+1), %o2 ! CHECK: ldub [%i0+%l6], %o2 ! encoding: [0xd4,0x0e,0x00,0x16] @@ -29,9 +29,9 @@ ldub [%i0 + 32], %o2 ! CHECK: ldub [%g1], %o2 ! encoding: [0xd4,0x08,0x40,0x00] ldub [%g1], %o2 - ! CHECK: lduba [%i0+%l6] 131, %o2 ! encoding: [0xd4,0x8e,0x10,0x76] + ! CHECK: lduba [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0x8e,0x10,0x76] lduba [%i0 + %l6] 131, %o2 - ! CHECK: lduba [%i0+%l6] 131, %o2 ! encoding: [0xd4,0x8e,0x10,0x76] + ! CHECK: lduba [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0x8e,0x10,0x76] lduba [%i0 + %l6] (130+1), %o2 ! CHECK: lduh [%i0+%l6], %o2 ! encoding: [0xd4,0x16,0x00,0x16] @@ -40,9 +40,9 @@ lduh [%i0 + 32], %o2 ! CHECK: lduh [%g1], %o2 ! encoding: [0xd4,0x10,0x40,0x00] lduh [%g1], %o2 - ! CHECK: lduha [%i0+%l6] 131, %o2 ! encoding: [0xd4,0x96,0x10,0x76] + ! CHECK: lduha [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0x96,0x10,0x76] lduha [%i0 + %l6] 131, %o2 - ! CHECK: lduha [%i0+%l6] 131, %o2 ! encoding: [0xd4,0x96,0x10,0x76] + ! CHECK: lduha [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0x96,0x10,0x76] lduha [%i0 + %l6] (130+1), %o2 ! CHECK: ld [%i0+%l6], %o2 ! encoding: [0xd4,0x06,0x00,0x16] @@ -51,9 +51,9 @@ ld [%i0 + 32], %o2 ! CHECK: ld [%g1], %o2 ! encoding: [0xd4,0x00,0x40,0x00] ld [%g1], %o2 - ! CHECK: lda [%i0+%l6] 131, %o2 ! encoding: [0xd4,0x86,0x10,0x76] + ! CHECK: lda [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0x86,0x10,0x76] lda [%i0 + %l6] 131, %o2 - ! CHECK: lda [%i0+%l6] 131, %o2 ! encoding: [0xd4,0x86,0x10,0x76] + ! CHECK: lda [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0x86,0x10,0x76] lda [%i0 + %l6] (130+1), %o2 ! CHECK: ldd [%i0+%l6], %o2 ! encoding: [0xd4,0x1e,0x00,0x16] @@ -62,9 +62,9 @@ ldd [%i0 + 32], %o2 ! CHECK: ldd [%g1], %o2 ! encoding: [0xd4,0x18,0x40,0x00] ldd [%g1], %o2 - ! CHECK: ldda [%i0+%l6] 131, %o2 ! encoding: [0xd4,0x9e,0x10,0x76] + ! CHECK: ldda [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0x9e,0x10,0x76] ldda [%i0 + %l6] 131, %o2 - ! CHECK: ldda [%i0+%l6] 131, %o2 ! encoding: [0xd4,0x9e,0x10,0x76] + ! CHECK: ldda [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0x9e,0x10,0x76] ldda [%i0 + %l6] (130+1), %o2 ! CHECK: stb %o2, [%i0+%l6] ! encoding: [0xd4,0x2e,0x00,0x16] @@ -77,17 +77,17 @@ stub %o2, [%g1] ! CHECK: stb %o2, [%g1] ! encoding: [0xd4,0x28,0x40,0x00] stsb %o2, [%g1] - ! CHECK: stba %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xae,0x10,0x76] + ! CHECK: stba %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xae,0x10,0x76] stba %o2, [%i0 + %l6] 131 - ! CHECK: stba %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xae,0x10,0x76] + ! CHECK: stba %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xae,0x10,0x76] stba %o2, [%i0 + %l6] (130+1) - ! CHECK: stba %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xae,0x10,0x76] + ! CHECK: stba %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xae,0x10,0x76] stuba %o2, [%i0 + %l6] 131 - ! CHECK: stba %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xae,0x10,0x76] + ! CHECK: stba %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xae,0x10,0x76] stuba %o2, [%i0 + %l6] (130+1) - ! CHECK: stba %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xae,0x10,0x76] + ! CHECK: stba %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xae,0x10,0x76] stsba %o2, [%i0 + %l6] 131 - ! CHECK: stba %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xae,0x10,0x76] + ! CHECK: stba %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xae,0x10,0x76] stsba %o2, [%i0 + %l6] (130+1) ! CHECK: sth %o2, [%i0+%l6] ! encoding: [0xd4,0x36,0x00,0x16] @@ -100,17 +100,17 @@ stuh %o2, [%g1] ! CHECK: sth %o2, [%g1] ! encoding: [0xd4,0x30,0x40,0x00] stsh %o2, [%g1] - ! CHECK: stha %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xb6,0x10,0x76] + ! CHECK: stha %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xb6,0x10,0x76] stha %o2, [%i0 + %l6] 131 - ! CHECK: stha %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xb6,0x10,0x76] + ! CHECK: stha %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xb6,0x10,0x76] stha %o2, [%i0 + %l6] (130+1) - ! CHECK: stha %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xb6,0x10,0x76] + ! CHECK: stha %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xb6,0x10,0x76] stuha %o2, [%i0 + %l6] 131 - ! CHECK: stha %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xb6,0x10,0x76] + ! CHECK: stha %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xb6,0x10,0x76] stuha %o2, [%i0 + %l6] (130+1) - ! CHECK: stha %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xb6,0x10,0x76] + ! CHECK: stha %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xb6,0x10,0x76] stsha %o2, [%i0 + %l6] 131 - ! CHECK: stha %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xb6,0x10,0x76] + ! CHECK: stha %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xb6,0x10,0x76] stsha %o2, [%i0 + %l6] (130+1) ! CHECK: st %o2, [%i0+%l6] ! encoding: [0xd4,0x26,0x00,0x16] @@ -119,9 +119,9 @@ st %o2, [%i0 + 32] ! CHECK: st %o2, [%g1] ! encoding: [0xd4,0x20,0x40,0x00] st %o2, [%g1] - ! CHECK: sta %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xa6,0x10,0x76] + ! CHECK: sta %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xa6,0x10,0x76] sta %o2, [%i0 + %l6] 131 - ! CHECK: sta %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xa6,0x10,0x76] + ! CHECK: sta %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xa6,0x10,0x76] sta %o2, [%i0 + %l6] (130+1) ! CHECK: std %o2, [%i0+%l6] ! encoding: [0xd4,0x3e,0x00,0x16] @@ -130,9 +130,9 @@ std %o2, [%i0 + 32] ! CHECK: std %o2, [%g1] ! encoding: [0xd4,0x38,0x40,0x00] std %o2, [%g1] - ! CHECK: stda %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xbe,0x10,0x76] + ! CHECK: stda %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xbe,0x10,0x76] stda %o2, [%i0 + %l6] 131 - ! CHECK: stda %o2, [%i0+%l6] 131 ! encoding: [0xd4,0xbe,0x10,0x76] + ! CHECK: stda %o2, [%i0+%l6] #ASI_SNF ! encoding: [0xd4,0xbe,0x10,0x76] stda %o2, [%i0 + %l6] (130+1) ! CHECK: flush %g1+%g2 ! encoding: [0x81,0xd8,0x40,0x02] Index: llvm/test/MC/Sparc/sparcv9-atomic-instructions.s =================================================================== --- llvm/test/MC/Sparc/sparcv9-atomic-instructions.s +++ llvm/test/MC/Sparc/sparcv9-atomic-instructions.s @@ -24,10 +24,10 @@ ! CHECK: casl [%i0], %l6, %o2 ! encoding: [0xd5,0xe6,0x11,0x16] casl [%i0], %l6, %o2 - ! CHECK: casa [%i0] 128, %l6, %o2 ! encoding: [0xd5,0xe6,0x10,0x16] + ! CHECK: casa [%i0] #ASI_P, %l6, %o2 ! encoding: [0xd5,0xe6,0x10,0x16] casa [%i0] 0x80, %l6, %o2 - ! CHECK: casa [%i0] 128, %l6, %o2 ! encoding: [0xd5,0xe6,0x10,0x16] + ! CHECK: casa [%i0] #ASI_P, %l6, %o2 ! encoding: [0xd5,0xe6,0x10,0x16] casa [%i0] (0x40+0x40), %l6, %o2 ! CHECK: casa [%i0] %asi, %l6, %o2 ! encoding: [0xd5,0xe6,0x20,0x16] @@ -39,10 +39,10 @@ ! CHECK: casxl [%i0], %l6, %o2 ! encoding: [0xd5,0xf6,0x11,0x16] casxl [%i0], %l6, %o2 - ! CHECK: casxa [%i0] 128, %l6, %o2 ! encoding: [0xd5,0xf6,0x10,0x16] + ! CHECK: casxa [%i0] #ASI_P, %l6, %o2 ! encoding: [0xd5,0xf6,0x10,0x16] casxa [%i0] 0x80, %l6, %o2 - ! CHECK: casxa [%i0] 128, %l6, %o2 ! encoding: [0xd5,0xf6,0x10,0x16] + ! CHECK: casxa [%i0] #ASI_P, %l6, %o2 ! encoding: [0xd5,0xf6,0x10,0x16] casxa [%i0] (0x40+0x40), %l6, %o2 ! CHECK: casxa [%i0] %asi, %l6, %o2 ! encoding: [0xd5,0xf6,0x20,0x16] Index: llvm/test/MC/Sparc/sparcv9-instructions.s =================================================================== --- llvm/test/MC/Sparc/sparcv9-instructions.s +++ llvm/test/MC/Sparc/sparcv9-instructions.s @@ -50,11 +50,11 @@ lduw [%g1], %o2 ! V8: error: invalid instruction mnemonic ! V8-NEXT: lduwa [%i0 + %l6] 131, %o2 - ! V9: lda [%i0+%l6] 131, %o2 ! encoding: [0xd4,0x86,0x10,0x76] + ! V9: lda [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0x86,0x10,0x76] lduwa [%i0 + %l6] 131, %o2 ! V8: error: invalid instruction mnemonic ! V8-NEXT: lduwa [%i0 + %l6] (130+1), %o2 - ! V9: lda [%i0+%l6] 131, %o2 ! encoding: [0xd4,0x86,0x10,0x76] + ! V9: lda [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0x86,0x10,0x76] lduwa [%i0 + %l6] (130+1), %o2 ! V9: ldsw [%i0+%l6], %o2 ! encoding: [0xd4,0x46,0x00,0x16] @@ -63,9 +63,9 @@ ldsw [%i0 + 32], %o2 ! V9: ldsw [%g1], %o2 ! encoding: [0xd4,0x40,0x40,0x00] ldsw [%g1], %o2 - ! V9: ldswa [%i0+%l6] 131, %o2 ! encoding: [0xd4,0xc6,0x10,0x76] + ! V9: ldswa [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0xc6,0x10,0x76] ldswa [%i0 + %l6] 131, %o2 - ! V9: ldswa [%i0+%l6] 131, %o2 ! encoding: [0xd4,0xc6,0x10,0x76] + ! V9: ldswa [%i0+%l6] #ASI_SNF, %o2 ! encoding: [0xd4,0xc6,0x10,0x76] ldswa [%i0 + %l6] (130+1), %o2 ! V8: error: instruction requires a CPU feature not currently enabled @@ -141,9 +141,9 @@ ! V9: ldx [%g2+%i5], %fsr ! encoding: [0xc3,0x08,0x80,0x1d] ldx [%g2 + %i5],%fsr - ! V9: ldxa [%g2+%i5] 131, %g0 ! encoding: [0xc0,0xd8,0x90,0x7d] + ! V9: ldxa [%g2+%i5] #ASI_SNF, %g0 ! encoding: [0xc0,0xd8,0x90,0x7d] ldxa [%g2 + %i5] 131, %g0 - ! V9: ldxa [%g2+%i5] 131, %g0 ! encoding: [0xc0,0xd8,0x90,0x7d] + ! V9: ldxa [%g2+%i5] #ASI_SNF, %g0 ! encoding: [0xc0,0xd8,0x90,0x7d] ldxa [%g2 + %i5] (130+1), %g0 ! V8: error: instruction requires a CPU feature not currently enabled @@ -156,9 +156,9 @@ ! V9: stx %fsr, [%g2+%i5] ! encoding: [0xc3,0x28,0x80,0x1d] stx %fsr,[%g2 + %i5] - ! V9: stxa %g0, [%g2+%i5] 131 ! encoding: [0xc0,0xf0,0x90,0x7d] + ! V9: stxa %g0, [%g2+%i5] #ASI_SNF ! encoding: [0xc0,0xf0,0x90,0x7d] stxa %g0, [%g2 + %i5] 131 - ! V9: stxa %g0, [%g2+%i5] 131 ! encoding: [0xc0,0xf0,0x90,0x7d] + ! V9: stxa %g0, [%g2+%i5] #ASI_SNF ! encoding: [0xc0,0xf0,0x90,0x7d] stxa %g0, [%g2 + %i5] (130+1) ! V8: error: instruction requires a CPU feature not currently enabled @@ -506,6 +506,12 @@ ! V9: stxa %g0, [%g2+5] %asi ! encoding: [0xc0,0xf0,0xa0,0x05] stxa %g0, [%g2 + 5] %asi + !! Also make sure named ASI tags are parsed properly. + ! V9: ldxa [%g2+%i5] #ASI_SNF, %g0 ! encoding: [0xc0,0xd8,0x90,0x7d] + ldxa [%g2 + %i5] #ASI_SNF, %g0 + ! V9: stxa %g0, [%g2+%i5] #ASI_SNF ! encoding: [0xc0,0xf0,0x90,0x7d] + stxa %g0, [%g2 + %i5] #ASI_SNF + ! V8: error: instruction requires a CPU feature not currently enabled ! V8-NEXT: prefetch [ %i1 + 0xf80 ], 1 ! V9: prefetch [%i1+3968], 1 ! encoding: [0xc3,0x6e,0x6f,0x80]