summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86
diff options
context:
space:
mode:
authorEhsan Akhgari <ehsan.akhgari@gmail.com>2014-09-22 02:21:35 +0000
committerEhsan Akhgari <ehsan.akhgari@gmail.com>2014-09-22 02:21:35 +0000
commitdb0e7061c6b45357f83b121d6b97f67104288993 (patch)
treec5f73cd942a6e19c567765be020e1c8f4bbe5ad1 /llvm/lib/Target/X86
parent12bbf7d922bb5485ef1a4af870d0c4516e5d3281 (diff)
downloadbcm5719-llvm-db0e7061c6b45357f83b121d6b97f67104288993.tar.gz
bcm5719-llvm-db0e7061c6b45357f83b121d6b97f67104288993.zip
ms-inline-asm: Add a sema callback for looking up label names
The implementation of the callback in clang's Sema will return an internal name for labels. Test Plan: Will be tested in clang. Reviewers: rnk Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D4587 llvm-svn: 218229
Diffstat (limited to 'llvm/lib/Target/X86')
-rw-r--r--llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 8014c3142e0..8fec1c3a49d 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1047,6 +1047,12 @@ std::unique_ptr<X86Operand> X86AsmParser::CreateMemForInlineAsm(
InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_SizeDirective, Start,
/*Len=*/0, Size));
}
+ if (!Info.InternalName.empty()) {
+ // Push a rewrite for replacing the identifier name with the internal name.
+ InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Label, Start,
+ End.getPointer() - Start.getPointer(),
+ Info.InternalName));
+ }
}
// When parsing inline assembly we set the base register to a non-zero value
@@ -1320,9 +1326,11 @@ bool X86AsmParser::ParseIntelIdentifier(const MCExpr *&Val,
Val = nullptr;
StringRef LineBuf(Identifier.data());
- SemaCallback->LookupInlineAsmIdentifier(LineBuf, Info, IsUnevaluatedOperand);
+ void *Result =
+ SemaCallback->LookupInlineAsmIdentifier(LineBuf, Info, IsUnevaluatedOperand);
const AsmToken &Tok = Parser.getTok();
+ SMLoc Loc = Tok.getLoc();
// Advance the token stream until the end of the current token is
// after the end of what the frontend claimed.
@@ -1334,9 +1342,17 @@ bool X86AsmParser::ParseIntelIdentifier(const MCExpr *&Val,
assert(End.getPointer() <= EndPtr && "frontend claimed part of a token?");
if (End.getPointer() == EndPtr) break;
}
+ Identifier = LineBuf;
+
+ // If the identifier lookup was unsuccessful, assume that we are dealing with
+ // a label.
+ if (!Result) {
+ Identifier = SemaCallback->LookupInlineAsmLabel(Identifier, getSourceManager(), Loc, false);
+ assert(Identifier.size() && "We should have an internal name here.");
+ Info.InternalName = Identifier;
+ }
// Create the symbol reference.
- Identifier = LineBuf;
MCSymbol *Sym = getContext().GetOrCreateSymbol(Identifier);
MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
Val = MCSymbolRefExpr::Create(Sym, Variant, getParser().getContext());
OpenPOWER on IntegriCloud