[PATCH] D54618: [MSP430] Add support for .refsym directive
Anton Korobeynikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 16 01:53:14 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347041: [MSP430] Add support for .refsym directive (authored by asl, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D54618
Files:
llvm/trunk/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp
llvm/trunk/test/MC/MSP430/refsym.s
Index: llvm/trunk/test/MC/MSP430/refsym.s
===================================================================
--- llvm/trunk/test/MC/MSP430/refsym.s
+++ llvm/trunk/test/MC/MSP430/refsym.s
@@ -0,0 +1,14 @@
+# RUN: llvm-mc -filetype=obj -triple=msp430 %s | llvm-readobj -t - | FileCheck %s
+
+foo:
+ .refsym __hook
+
+; CHECK: Symbol {
+; CHECK: Name: __hook (30)
+; CHECK-NEXT: Value: 0x0
+; CHECK-NEXT: Size: 0
+; CHECK-NEXT: Binding: Global (0x1)
+; CHECK-NEXT: Type: None (0x0)
+; CHECK-NEXT: Other: 0
+; CHECK-NEXT: Section: Undefined (0x0)
+; CHECK-NEXT: }
Index: llvm/trunk/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp
===================================================================
--- llvm/trunk/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp
+++ llvm/trunk/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp
@@ -51,6 +51,7 @@
SMLoc NameLoc, OperandVector &Operands) override;
bool ParseDirective(AsmToken DirectiveID) override;
+ bool ParseDirectiveRefSym(AsmToken DirectiveID);
unsigned validateTargetOperandClass(MCParsedAsmOperand &Op,
unsigned Kind) override;
@@ -407,14 +408,26 @@
return false;
}
+bool MSP430AsmParser::ParseDirectiveRefSym(AsmToken DirectiveID) {
+ StringRef Name;
+ if (getParser().parseIdentifier(Name))
+ return TokError("expected identifier in directive");
+
+ MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
+ getStreamer().EmitSymbolAttribute(Sym, MCSA_Global);
+ return false;
+}
+
bool MSP430AsmParser::ParseDirective(AsmToken DirectiveID) {
StringRef IDVal = DirectiveID.getIdentifier();
if (IDVal.lower() == ".long") {
ParseLiteralValues(4, DirectiveID.getLoc());
} else if (IDVal.lower() == ".word" || IDVal.lower() == ".short") {
ParseLiteralValues(2, DirectiveID.getLoc());
} else if (IDVal.lower() == ".byte") {
ParseLiteralValues(1, DirectiveID.getLoc());
+ } else if (IDVal.lower() == ".refsym") {
+ return ParseDirectiveRefSym(DirectiveID);
}
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54618.174341.patch
Type: text/x-patch
Size: 2091 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181116/11fe7c14/attachment.bin>
More information about the llvm-commits
mailing list