[llvm-commits] [llvm] r74568 - /llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp
Daniel Dunbar
daniel at zuster.org
Tue Jun 30 16:02:44 PDT 2009
Author: ddunbar
Date: Tue Jun 30 18:02:44 2009
New Revision: 74568
URL: http://llvm.org/viewvc/llvm-project?rev=74568&view=rev
Log:
llvm-mc: Accept relocatable expressions when parsing displacements and
immediates.
Modified:
llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp
Modified: llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp?rev=74568&r1=74567&r2=74568&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp (original)
+++ llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp Tue Jun 30 18:02:44 2009
@@ -30,13 +30,12 @@
} Reg;
struct {
- // FIXME: Should be a general expression.
- int64_t Val;
+ MCValue Val;
} Imm;
struct {
unsigned SegReg;
- int64_t Disp; // FIXME: Should be a general expression.
+ MCValue Disp;
unsigned BaseReg;
unsigned Scale;
unsigned ScaleReg;
@@ -49,13 +48,13 @@
Res.Reg.RegNo = RegNo;
return Res;
}
- static X86Operand CreateImm(int64_t Val) {
+ static X86Operand CreateImm(MCValue Val) {
X86Operand Res;
Res.Kind = Immediate;
Res.Imm.Val = Val;
return Res;
}
- static X86Operand CreateMem(unsigned SegReg, int64_t Disp, unsigned BaseReg,
+ static X86Operand CreateMem(unsigned SegReg, MCValue Disp, unsigned BaseReg,
unsigned Scale, unsigned ScaleReg) {
X86Operand Res;
Res.Kind = Memory;
@@ -86,12 +85,13 @@
case asmtok::Dollar: {
// $42 -> immediate.
Lexer.Lex();
- int64_t Val;
- if (ParseAbsoluteExpression(Val))
- return TokError("expected integer constant");
- Op = X86Operand::CreateReg(Val);
+ MCValue Val;
+ if (ParseRelocatableExpression(Val))
+ return true;
+ Op = X86Operand::CreateImm(Val);
return false;
- case asmtok::Star:
+ }
+ case asmtok::Star: {
Lexer.Lex(); // Eat the star.
if (Lexer.is(asmtok::Register)) {
@@ -116,9 +116,9 @@
// of a memory operand with a missing displacement "(%ebx)" or "(,%eax)". The
// only way to do this without lookahead is to eat the ( and see what is after
// it.
- int64_t Disp = 0;
+ MCValue Disp = MCValue::get(0, 0, 0);
if (Lexer.isNot(asmtok::LParen)) {
- if (ParseAbsoluteExpression(Disp)) return true;
+ if (ParseRelocatableExpression(Disp)) return true;
// After parsing the base expression we could either have a parenthesized
// memory address or not. If not, return now. If so, eat the (.
@@ -139,7 +139,7 @@
// memory operand consumed.
} else {
// It must be an parenthesized expression, parse it now.
- if (ParseAbsoluteExpression(Disp))
+ if (ParseRelocatableExpression(Disp))
return true;
// After parsing the base expression we could either have a parenthesized
More information about the llvm-commits
mailing list