1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

teach the x86 asm parser how to handle segment prefixes

in memory operands.  rdar://7874844

llvm-svn: 101661
This commit is contained in:
Chris Lattner 2010-04-17 18:56:34 +00:00
parent a5798151a3
commit 65d1e40895
4 changed files with 22 additions and 15 deletions

View File

@ -14,7 +14,6 @@
#ifndef ASMPARSER_H
#define ASMPARSER_H
#include <vector>
#include "llvm/MC/MCParser/AsmLexer.h"
#include "llvm/MC/MCParser/AsmCond.h"
#include "llvm/MC/MCParser/MCAsmParser.h"
@ -22,6 +21,7 @@
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/ADT/StringMap.h"
#include <vector>
namespace llvm {
class AsmCond;

View File

@ -44,7 +44,7 @@ private:
bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc);
X86Operand *ParseOperand();
X86Operand *ParseMemOperand();
X86Operand *ParseMemOperand(unsigned SegReg, SMLoc StartLoc);
bool ParseDirectiveWord(unsigned Size, SMLoc L);
@ -368,14 +368,22 @@ bool X86ATTAsmParser::ParseRegister(unsigned &RegNo,
X86Operand *X86ATTAsmParser::ParseOperand() {
switch (getLexer().getKind()) {
default:
return ParseMemOperand();
// Parse a memory operand with no segment register.
return ParseMemOperand(0, Parser.getTok().getLoc());
case AsmToken::Percent: {
// FIXME: if a segment register, this could either be just the seg reg, or
// the start of a memory operand.
// Read the register.
unsigned RegNo;
SMLoc Start, End;
if (ParseRegister(RegNo, Start, End)) return 0;
// If this is a segment register followed by a ':', then this is the start
// of a memory reference, otherwise this is a normal register reference.
if (getLexer().isNot(AsmToken::Colon))
return X86Operand::CreateReg(RegNo, Start, End);
getParser().Lex(); // Eat the colon.
return ParseMemOperand(RegNo, Start);
}
case AsmToken::Dollar: {
// $42 -> immediate.
@ -389,12 +397,9 @@ X86Operand *X86ATTAsmParser::ParseOperand() {
}
}
/// ParseMemOperand: segment: disp(basereg, indexreg, scale)
X86Operand *X86ATTAsmParser::ParseMemOperand() {
SMLoc MemStart = Parser.getTok().getLoc();
// FIXME: If SegReg ':' (e.g. %gs:), eat and remember.
unsigned SegReg = 0;
/// ParseMemOperand: segment: disp(basereg, indexreg, scale). The '%ds:' prefix
/// has already been parsed if present.
X86Operand *X86ATTAsmParser::ParseMemOperand(unsigned SegReg, SMLoc MemStart) {
// We have to disambiguate a parenthesized expression "(4+5)" from the start
// of a memory operand with a missing displacement "(%ebx)" or "(,%eax)". The

View File

@ -55,4 +55,6 @@
# CHECK: call *4(%eax)
call *4(%eax)
# CHECK: movl %gs:8, %eax
movl %gs:8, %eax

View File

@ -28,7 +28,7 @@ endif
ifdef VERBOSE
RUNTESTFLAGS := $(VERBOSE)
LIT_ARGS := -v
LIT_ARGS := -v -j16
else
LIT_ARGS := -s -v
endif