MC/X86 AsmMatcher: Fix a use after free spotted by d0k, and de-XFAIL

x86_32-encoding.s in on expectation of it passing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95806 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2010-02-10 21:19:28 +00:00
parent ac6dd79a55
commit 1b6c060591
2 changed files with 15 additions and 22 deletions

View File

@ -10,6 +10,7 @@
#include "llvm/Target/TargetAsmParser.h" #include "llvm/Target/TargetAsmParser.h"
#include "X86.h" #include "X86.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Twine.h" #include "llvm/ADT/Twine.h"
#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCExpr.h"
@ -492,24 +493,20 @@ X86Operand *X86ATTAsmParser::ParseMemOperand() {
bool X86ATTAsmParser:: bool X86ATTAsmParser::
ParseInstruction(const StringRef &Name, SMLoc NameLoc, ParseInstruction(const StringRef &Name, SMLoc NameLoc,
SmallVectorImpl<MCParsedAsmOperand*> &Operands) { SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
// FIXME: Hack to recognize "sal..." for now. We need a way to represent // FIXME: Hack to recognize "sal..." and "rep..." for now. We need a way to
// alternative syntaxes in the .td file, without requiring instruction // represent alternative syntaxes in the .td file, without requiring
// duplication. // instruction duplication.
if (Name.startswith("sal")) { StringRef PatchedName = StringSwitch<StringRef>(Name)
std::string Tmp = "shl" + Name.substr(3).str(); .Case("sal", "shl")
Operands.push_back(X86Operand::CreateToken(Tmp, NameLoc)); .Case("salb", "shlb")
} else { .Case("sall", "shll")
// FIXME: This is a hack. We eventually want to add a general pattern .Case("salq", "shlq")
// mechanism to be used in the table gen file for these assembly names that .Case("salw", "shlw")
// use the same opcodes. Also we should only allow the "alternate names" .Case("repe", "rep")
// for rep and repne with the instructions they can only appear with. .Case("repz", "rep")
StringRef PatchedName = Name; .Case("repnz", "repne")
if (Name == "repe" || Name == "repz") .Default(Name);
PatchedName = "rep"; Operands.push_back(X86Operand::CreateToken(PatchedName, NameLoc));
else if (Name == "repnz")
PatchedName = "repne";
Operands.push_back(X86Operand::CreateToken(PatchedName, NameLoc));
}
if (getLexer().isNot(AsmToken::EndOfStatement)) { if (getLexer().isNot(AsmToken::EndOfStatement)) {

View File

@ -1,9 +1,5 @@
// RUN: llvm-mc -triple i386-unknown-unknown --show-encoding %s | FileCheck %s // RUN: llvm-mc -triple i386-unknown-unknown --show-encoding %s | FileCheck %s
// FIXME: This is failing to match on linux currently, with some kind of match
// failure. I am investigating. - ddunbar
// XFAIL: linux
// CHECK: movb $127, 3735928559(%ebx,%ecx,8) // CHECK: movb $127, 3735928559(%ebx,%ecx,8)
// CHECK: encoding: [0xc6,0x84,0xcb,0xef,0xbe,0xad,0xde,0x7f] // CHECK: encoding: [0xc6,0x84,0xcb,0xef,0xbe,0xad,0xde,0x7f]
movb $0x7f,0xdeadbeef(%ebx,%ecx,8) movb $0x7f,0xdeadbeef(%ebx,%ecx,8)