llvm.org GIT mirror llvm / 151ad37
[MC] Support @ variants with directional labels The assembler parser common code supports recognizing symbol variants using the @ modifer. On PowerPC, it should also be possible to use (some of) those modifiers with directional labels, like "1f@l". This patch adds support for accepting symbol variants on directional labels as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184437 91177308-0d34-0410-b5e6-96231b3b80d8 Ulrich Weigand 7 years ago
2 changed file(s) with 19 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
804804 // Look for 'b' or 'f' following an Integer as a directional label
805805 if (Lexer.getKind() == AsmToken::Identifier) {
806806 StringRef IDVal = getTok().getString();
807 // Lookup the symbol variant if used.
808 std::pair Split = IDVal.split('@');
809 MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
810 if (Split.first.size() != IDVal.size()) {
811 Variant = MCSymbolRefExpr::getVariantKindForName(Split.second);
812 if (Variant == MCSymbolRefExpr::VK_Invalid) {
813 Variant = MCSymbolRefExpr::VK_None;
814 return TokError("invalid variant '" + Split.second + "'");
815 }
816 IDVal = Split.first;
817 }
807818 if (IDVal == "f" || IDVal == "b"){
808819 MCSymbol *Sym = Ctx.GetDirectionalLocalSymbol(IntVal,
809820 IDVal == "f" ? 1 : 0);
810 Res = MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_None,
811 getContext());
821 Res = MCSymbolRefExpr::Create(Sym, Variant, getContext());
812822 if (IDVal == "b" && Sym->isUndefined())
813823 return Error(Loc, "invalid reference to undefined symbol");
814824 EndLoc = Lexer.getTok().getEndLoc();
2727
2828 .set target5, 0x10000001
2929
30 1:
31 addi 1, 1, 2f-1b@l
32 addis 1, 1, 1b-2f@ha
33 2:
34
3035 .data
3136
3237 .quad v1
4853 # CHECK-NEXT: ]
4954 # CHECK-NEXT: Address: 0x0
5055 # CHECK-NEXT: Offset:
51 # CHECK-NEXT: Size: 32
56 # CHECK-NEXT: Size: 40
5257 # CHECK-NEXT: Link: 0
5358 # CHECK-NEXT: Info: 0
5459 # CHECK-NEXT: AddressAlignment: 4
5661 # CHECK-NEXT: SectionData (
5762 # CHECK-NEXT: 0000: 38211234 3C211234 38215678 3C211234
5863 # CHECK-NEXT: 0010: 38214444 3C211111 38218001 3C211001
64 # CHECK-NEXT: 0020: 38210008 3C210000
5965 # CHECK-NEXT: )
6066 # CHECK-NEXT: }
6167