blob: 479f4e43dfeb9d3562fb184f64ee4ec6bb7ea74d [file] [log] [blame]
Daniel Dunbar092a9dd2009-07-17 20:42:00 +00001//===-- X86AsmParser.cpp - Parse X86 assembly to MCInst instructions ------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Chris Lattner98986712010-01-14 22:21:20 +000010#include "llvm/Target/TargetAsmParser.h"
Daniel Dunbar4cb1e132009-07-18 23:03:22 +000011#include "X86.h"
Daniel Dunbardbd692a2009-07-20 20:01:54 +000012#include "llvm/ADT/SmallVector.h"
Daniel Dunbar1b6c0602010-02-10 21:19:28 +000013#include "llvm/ADT/StringSwitch.h"
Daniel Dunbar16cdcb32009-07-28 22:40:46 +000014#include "llvm/ADT/Twine.h"
Kevin Enderby9c656452009-09-10 20:51:44 +000015#include "llvm/MC/MCStreamer.h"
Daniel Dunbar8c2eebe2009-08-31 08:08:38 +000016#include "llvm/MC/MCExpr.h"
Daniel Dunbara027d222009-07-31 02:32:59 +000017#include "llvm/MC/MCInst.h"
Chris Lattnerc6ef2772010-01-22 01:44:57 +000018#include "llvm/MC/MCParser/MCAsmLexer.h"
19#include "llvm/MC/MCParser/MCAsmParser.h"
20#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
Daniel Dunbar16cdcb32009-07-28 22:40:46 +000021#include "llvm/Support/SourceMgr.h"
Daniel Dunbar092a9dd2009-07-17 20:42:00 +000022#include "llvm/Target/TargetRegistry.h"
23#include "llvm/Target/TargetAsmParser.h"
24using namespace llvm;
25
26namespace {
Benjamin Kramerc6b79ac2009-07-31 11:35:26 +000027struct X86Operand;
Daniel Dunbar16cdcb32009-07-28 22:40:46 +000028
29class X86ATTAsmParser : public TargetAsmParser {
30 MCAsmParser &Parser;
31
Daniel Dunbarf98bc632010-03-18 20:06:02 +000032protected:
33 unsigned Is64Bit : 1;
34
Daniel Dunbar16cdcb32009-07-28 22:40:46 +000035private:
Daniel Dunbar16cdcb32009-07-28 22:40:46 +000036 MCAsmParser &getParser() const { return Parser; }
37
38 MCAsmLexer &getLexer() const { return Parser.getLexer(); }
39
40 void Warning(SMLoc L, const Twine &Msg) { Parser.Warning(L, Msg); }
41
42 bool Error(SMLoc L, const Twine &Msg) { return Parser.Error(L, Msg); }
43
Chris Lattner29ef9a22010-01-15 18:51:29 +000044 bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc);
Daniel Dunbar16cdcb32009-07-28 22:40:46 +000045
Chris Lattner309264d2010-01-15 18:44:13 +000046 X86Operand *ParseOperand();
Chris Lattnereef6d782010-04-17 18:56:34 +000047 X86Operand *ParseMemOperand(unsigned SegReg, SMLoc StartLoc);
Kevin Enderby9c656452009-09-10 20:51:44 +000048
49 bool ParseDirectiveWord(unsigned Size, SMLoc L);
50
Daniel Dunbarf98bc632010-03-18 20:06:02 +000051 void InstructionCleanup(MCInst &Inst);
52
Daniel Dunbar0e2771f2009-07-29 00:02:19 +000053 /// @name Auto-generated Match Functions
Daniel Dunbarc918d602010-05-04 16:12:42 +000054 /// {
Daniel Dunbar0e2771f2009-07-29 00:02:19 +000055
Chris Lattner98986712010-01-14 22:21:20 +000056 bool MatchInstruction(const SmallVectorImpl<MCParsedAsmOperand*> &Operands,
Daniel Dunbar20927f22009-08-07 08:26:05 +000057 MCInst &Inst);
58
Daniel Dunbarc918d602010-05-04 16:12:42 +000059 bool MatchInstructionImpl(
60 const SmallVectorImpl<MCParsedAsmOperand*> &Operands, MCInst &Inst);
61
Daniel Dunbar0e2771f2009-07-29 00:02:19 +000062 /// }
Daniel Dunbar16cdcb32009-07-28 22:40:46 +000063
64public:
65 X86ATTAsmParser(const Target &T, MCAsmParser &_Parser)
66 : TargetAsmParser(T), Parser(_Parser) {}
67
Chris Lattnerf007e852010-01-14 21:32:45 +000068 virtual bool ParseInstruction(const StringRef &Name, SMLoc NameLoc,
Chris Lattner98986712010-01-14 22:21:20 +000069 SmallVectorImpl<MCParsedAsmOperand*> &Operands);
Kevin Enderby9c656452009-09-10 20:51:44 +000070
71 virtual bool ParseDirective(AsmToken DirectiveID);
Daniel Dunbar16cdcb32009-07-28 22:40:46 +000072};
Daniel Dunbarf98bc632010-03-18 20:06:02 +000073
74class X86_32ATTAsmParser : public X86ATTAsmParser {
75public:
76 X86_32ATTAsmParser(const Target &T, MCAsmParser &_Parser)
77 : X86ATTAsmParser(T, _Parser) {
78 Is64Bit = false;
79 }
80};
81
82class X86_64ATTAsmParser : public X86ATTAsmParser {
83public:
84 X86_64ATTAsmParser(const Target &T, MCAsmParser &_Parser)
85 : X86ATTAsmParser(T, _Parser) {
86 Is64Bit = true;
87 }
88};
89
Chris Lattner37dfdec2009-07-29 06:33:53 +000090} // end anonymous namespace
91
Sean Callanane9b466d2010-01-23 00:40:33 +000092/// @name Auto-generated Match Functions
93/// {
94
Chris Lattnerb8d6e982010-02-09 00:34:28 +000095static unsigned MatchRegisterName(StringRef Name);
Sean Callanane9b466d2010-01-23 00:40:33 +000096
97/// }
Chris Lattner37dfdec2009-07-29 06:33:53 +000098
99namespace {
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000100
101/// X86Operand - Instances of this class represent a parsed X86 machine
102/// instruction.
Chris Lattner45220a82010-01-14 21:20:55 +0000103struct X86Operand : public MCParsedAsmOperand {
Chris Lattner1f19f0f2010-01-15 19:06:59 +0000104 enum KindTy {
Daniel Dunbar20927f22009-08-07 08:26:05 +0000105 Token,
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000106 Register,
107 Immediate,
108 Memory
109 } Kind;
110
Chris Lattner29ef9a22010-01-15 18:51:29 +0000111 SMLoc StartLoc, EndLoc;
112
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000113 union {
114 struct {
Daniel Dunbar20927f22009-08-07 08:26:05 +0000115 const char *Data;
116 unsigned Length;
117 } Tok;
118
119 struct {
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000120 unsigned RegNo;
121 } Reg;
122
123 struct {
Daniel Dunbar8c2eebe2009-08-31 08:08:38 +0000124 const MCExpr *Val;
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000125 } Imm;
126
127 struct {
128 unsigned SegReg;
Daniel Dunbar8c2eebe2009-08-31 08:08:38 +0000129 const MCExpr *Disp;
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000130 unsigned BaseReg;
131 unsigned IndexReg;
132 unsigned Scale;
133 } Mem;
Daniel Dunbardbd692a2009-07-20 20:01:54 +0000134 };
Daniel Dunbar092a9dd2009-07-17 20:42:00 +0000135
Chris Lattner0a3c5a52010-01-15 19:33:43 +0000136 X86Operand(KindTy K, SMLoc Start, SMLoc End)
Chris Lattner1f19f0f2010-01-15 19:06:59 +0000137 : Kind(K), StartLoc(Start), EndLoc(End) {}
Daniel Dunbarc918d602010-05-04 16:12:42 +0000138
Chris Lattner1f19f0f2010-01-15 19:06:59 +0000139 /// getStartLoc - Get the location of the first token of this operand.
140 SMLoc getStartLoc() const { return StartLoc; }
141 /// getEndLoc - Get the location of the last token of this operand.
142 SMLoc getEndLoc() const { return EndLoc; }
143
Daniel Dunbar20927f22009-08-07 08:26:05 +0000144 StringRef getToken() const {
145 assert(Kind == Token && "Invalid access!");
146 return StringRef(Tok.Data, Tok.Length);
147 }
Daniel Dunbarc918d602010-05-04 16:12:42 +0000148 void setTokenValue(StringRef Value) {
149 assert(Kind == Token && "Invalid access!");
150 Tok.Data = Value.data();
151 Tok.Length = Value.size();
152 }
Daniel Dunbar20927f22009-08-07 08:26:05 +0000153
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000154 unsigned getReg() const {
155 assert(Kind == Register && "Invalid access!");
156 return Reg.RegNo;
157 }
Daniel Dunbara2edbab2009-07-28 20:47:52 +0000158
Daniel Dunbar8c2eebe2009-08-31 08:08:38 +0000159 const MCExpr *getImm() const {
Daniel Dunbar022e2a82009-07-31 20:53:16 +0000160 assert(Kind == Immediate && "Invalid access!");
161 return Imm.Val;
162 }
163
Daniel Dunbar8c2eebe2009-08-31 08:08:38 +0000164 const MCExpr *getMemDisp() const {
Daniel Dunbar022e2a82009-07-31 20:53:16 +0000165 assert(Kind == Memory && "Invalid access!");
166 return Mem.Disp;
167 }
168 unsigned getMemSegReg() const {
169 assert(Kind == Memory && "Invalid access!");
170 return Mem.SegReg;
171 }
172 unsigned getMemBaseReg() const {
173 assert(Kind == Memory && "Invalid access!");
174 return Mem.BaseReg;
175 }
176 unsigned getMemIndexReg() const {
177 assert(Kind == Memory && "Invalid access!");
178 return Mem.IndexReg;
179 }
180 unsigned getMemScale() const {
181 assert(Kind == Memory && "Invalid access!");
182 return Mem.Scale;
183 }
184
Daniel Dunbara3741fa2009-08-08 07:50:56 +0000185 bool isToken() const {return Kind == Token; }
Daniel Dunbar20927f22009-08-07 08:26:05 +0000186
187 bool isImm() const { return Kind == Immediate; }
188
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000189 bool isImmSExt8() const {
190 // Accept immediates which fit in 8 bits when sign extended, and
191 // non-absolute immediates.
192 if (!isImm())
193 return false;
194
Daniel Dunbar8c2eebe2009-08-31 08:08:38 +0000195 if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm())) {
196 int64_t Value = CE->getValue();
197 return Value == (int64_t) (int8_t) Value;
198 }
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000199
Daniel Dunbar8c2eebe2009-08-31 08:08:38 +0000200 return true;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000201 }
202
Daniel Dunbar1fe591d2010-05-20 20:20:39 +0000203 bool isImmSExt32() const {
204 // Accept immediates which fit in 32 bits when sign extended, and
205 // non-absolute immediates.
206 if (!isImm())
207 return false;
208
209 if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm())) {
210 int64_t Value = CE->getValue();
211 return Value == (int64_t) (int32_t) Value;
212 }
213
214 return true;
215 }
216
Daniel Dunbar20927f22009-08-07 08:26:05 +0000217 bool isMem() const { return Kind == Memory; }
218
Daniel Dunbarb834f5d2010-01-30 01:02:48 +0000219 bool isAbsMem() const {
220 return Kind == Memory && !getMemSegReg() && !getMemBaseReg() &&
Daniel Dunbar7b9147a2010-02-02 21:44:16 +0000221 !getMemIndexReg() && getMemScale() == 1;
Daniel Dunbarb834f5d2010-01-30 01:02:48 +0000222 }
223
Daniel Dunbarec2b1f12010-01-30 00:24:00 +0000224 bool isNoSegMem() const {
225 return Kind == Memory && !getMemSegReg();
226 }
227
Daniel Dunbar20927f22009-08-07 08:26:05 +0000228 bool isReg() const { return Kind == Register; }
229
Daniel Dunbar9c60f532010-02-13 00:17:21 +0000230 void addExpr(MCInst &Inst, const MCExpr *Expr) const {
231 // Add as immediates when possible.
232 if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Expr))
233 Inst.addOperand(MCOperand::CreateImm(CE->getValue()));
234 else
235 Inst.addOperand(MCOperand::CreateExpr(Expr));
236 }
237
Daniel Dunbar5c468e32009-08-10 21:00:45 +0000238 void addRegOperands(MCInst &Inst, unsigned N) const {
Daniel Dunbar20927f22009-08-07 08:26:05 +0000239 assert(N == 1 && "Invalid number of operands!");
240 Inst.addOperand(MCOperand::CreateReg(getReg()));
241 }
242
Daniel Dunbar5c468e32009-08-10 21:00:45 +0000243 void addImmOperands(MCInst &Inst, unsigned N) const {
Daniel Dunbar20927f22009-08-07 08:26:05 +0000244 assert(N == 1 && "Invalid number of operands!");
Daniel Dunbar9c60f532010-02-13 00:17:21 +0000245 addExpr(Inst, getImm());
Daniel Dunbar20927f22009-08-07 08:26:05 +0000246 }
247
Daniel Dunbar5c468e32009-08-10 21:00:45 +0000248 void addImmSExt8Operands(MCInst &Inst, unsigned N) const {
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000249 // FIXME: Support user customization of the render method.
250 assert(N == 1 && "Invalid number of operands!");
Daniel Dunbar9c60f532010-02-13 00:17:21 +0000251 addExpr(Inst, getImm());
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000252 }
253
Daniel Dunbar1fe591d2010-05-20 20:20:39 +0000254 void addImmSExt32Operands(MCInst &Inst, unsigned N) const {
255 // FIXME: Support user customization of the render method.
256 assert(N == 1 && "Invalid number of operands!");
257 addExpr(Inst, getImm());
258 }
259
Daniel Dunbar5c468e32009-08-10 21:00:45 +0000260 void addMemOperands(MCInst &Inst, unsigned N) const {
Daniel Dunbarec2b1f12010-01-30 00:24:00 +0000261 assert((N == 5) && "Invalid number of operands!");
Daniel Dunbar20927f22009-08-07 08:26:05 +0000262 Inst.addOperand(MCOperand::CreateReg(getMemBaseReg()));
263 Inst.addOperand(MCOperand::CreateImm(getMemScale()));
264 Inst.addOperand(MCOperand::CreateReg(getMemIndexReg()));
Daniel Dunbar9c60f532010-02-13 00:17:21 +0000265 addExpr(Inst, getMemDisp());
Daniel Dunbarec2b1f12010-01-30 00:24:00 +0000266 Inst.addOperand(MCOperand::CreateReg(getMemSegReg()));
267 }
Daniel Dunbar20927f22009-08-07 08:26:05 +0000268
Daniel Dunbarb834f5d2010-01-30 01:02:48 +0000269 void addAbsMemOperands(MCInst &Inst, unsigned N) const {
270 assert((N == 1) && "Invalid number of operands!");
271 Inst.addOperand(MCOperand::CreateExpr(getMemDisp()));
272 }
273
Daniel Dunbarec2b1f12010-01-30 00:24:00 +0000274 void addNoSegMemOperands(MCInst &Inst, unsigned N) const {
275 assert((N == 4) && "Invalid number of operands!");
Daniel Dunbarec2b1f12010-01-30 00:24:00 +0000276 Inst.addOperand(MCOperand::CreateReg(getMemBaseReg()));
277 Inst.addOperand(MCOperand::CreateImm(getMemScale()));
278 Inst.addOperand(MCOperand::CreateReg(getMemIndexReg()));
Daniel Dunbar9c60f532010-02-13 00:17:21 +0000279 addExpr(Inst, getMemDisp());
Daniel Dunbar20927f22009-08-07 08:26:05 +0000280 }
281
Chris Lattnerb4307b32010-01-15 19:28:38 +0000282 static X86Operand *CreateToken(StringRef Str, SMLoc Loc) {
283 X86Operand *Res = new X86Operand(Token, Loc, Loc);
Chris Lattner29ef9a22010-01-15 18:51:29 +0000284 Res->Tok.Data = Str.data();
285 Res->Tok.Length = Str.size();
Daniel Dunbar20927f22009-08-07 08:26:05 +0000286 return Res;
287 }
288
Chris Lattner29ef9a22010-01-15 18:51:29 +0000289 static X86Operand *CreateReg(unsigned RegNo, SMLoc StartLoc, SMLoc EndLoc) {
Chris Lattner1f19f0f2010-01-15 19:06:59 +0000290 X86Operand *Res = new X86Operand(Register, StartLoc, EndLoc);
Chris Lattner29ef9a22010-01-15 18:51:29 +0000291 Res->Reg.RegNo = RegNo;
Chris Lattner29ef9a22010-01-15 18:51:29 +0000292 return Res;
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000293 }
Daniel Dunbar20927f22009-08-07 08:26:05 +0000294
Chris Lattnerb4307b32010-01-15 19:28:38 +0000295 static X86Operand *CreateImm(const MCExpr *Val, SMLoc StartLoc, SMLoc EndLoc){
296 X86Operand *Res = new X86Operand(Immediate, StartLoc, EndLoc);
Chris Lattner29ef9a22010-01-15 18:51:29 +0000297 Res->Imm.Val = Val;
298 return Res;
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000299 }
Daniel Dunbar20927f22009-08-07 08:26:05 +0000300
Daniel Dunbarb834f5d2010-01-30 01:02:48 +0000301 /// Create an absolute memory operand.
302 static X86Operand *CreateMem(const MCExpr *Disp, SMLoc StartLoc,
303 SMLoc EndLoc) {
304 X86Operand *Res = new X86Operand(Memory, StartLoc, EndLoc);
305 Res->Mem.SegReg = 0;
306 Res->Mem.Disp = Disp;
307 Res->Mem.BaseReg = 0;
308 Res->Mem.IndexReg = 0;
Daniel Dunbar7b9147a2010-02-02 21:44:16 +0000309 Res->Mem.Scale = 1;
Daniel Dunbarb834f5d2010-01-30 01:02:48 +0000310 return Res;
311 }
312
313 /// Create a generalized memory operand.
Chris Lattner309264d2010-01-15 18:44:13 +0000314 static X86Operand *CreateMem(unsigned SegReg, const MCExpr *Disp,
315 unsigned BaseReg, unsigned IndexReg,
Chris Lattner0a3c5a52010-01-15 19:33:43 +0000316 unsigned Scale, SMLoc StartLoc, SMLoc EndLoc) {
Daniel Dunbarb834f5d2010-01-30 01:02:48 +0000317 // We should never just have a displacement, that should be parsed as an
318 // absolute memory operand.
Daniel Dunbarc09e4112009-07-31 22:22:54 +0000319 assert((SegReg || BaseReg || IndexReg) && "Invalid memory operand!");
320
Daniel Dunbar022e2a82009-07-31 20:53:16 +0000321 // The scale should always be one of {1,2,4,8}.
322 assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) &&
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000323 "Invalid scale!");
Chris Lattner0a3c5a52010-01-15 19:33:43 +0000324 X86Operand *Res = new X86Operand(Memory, StartLoc, EndLoc);
Chris Lattner29ef9a22010-01-15 18:51:29 +0000325 Res->Mem.SegReg = SegReg;
326 Res->Mem.Disp = Disp;
327 Res->Mem.BaseReg = BaseReg;
328 Res->Mem.IndexReg = IndexReg;
329 Res->Mem.Scale = Scale;
330 return Res;
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000331 }
332};
Daniel Dunbara3af3702009-07-20 18:55:04 +0000333
Chris Lattner37dfdec2009-07-29 06:33:53 +0000334} // end anonymous namespace.
Daniel Dunbara2edbab2009-07-28 20:47:52 +0000335
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000336
Chris Lattner29ef9a22010-01-15 18:51:29 +0000337bool X86ATTAsmParser::ParseRegister(unsigned &RegNo,
338 SMLoc &StartLoc, SMLoc &EndLoc) {
Chris Lattner23075742010-01-15 18:27:19 +0000339 RegNo = 0;
Sean Callanan18b83232010-01-19 21:44:56 +0000340 const AsmToken &TokPercent = Parser.getTok();
Kevin Enderby7b4608d2009-09-03 17:15:07 +0000341 assert(TokPercent.is(AsmToken::Percent) && "Invalid token kind!");
Chris Lattner29ef9a22010-01-15 18:51:29 +0000342 StartLoc = TokPercent.getLoc();
Sean Callananb9a25b72010-01-19 20:27:46 +0000343 Parser.Lex(); // Eat percent token.
Kevin Enderby7b4608d2009-09-03 17:15:07 +0000344
Sean Callanan18b83232010-01-19 21:44:56 +0000345 const AsmToken &Tok = Parser.getTok();
Kevin Enderby0d6cd002009-09-16 17:18:29 +0000346 if (Tok.isNot(AsmToken::Identifier))
347 return Error(Tok.getLoc(), "invalid register name");
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000348
Daniel Dunbar0e2771f2009-07-29 00:02:19 +0000349 // FIXME: Validate register for the current architecture; we have to do
350 // validation later, so maybe there is no need for this here.
Kevin Enderby7b4608d2009-09-03 17:15:07 +0000351 RegNo = MatchRegisterName(Tok.getString());
Chris Lattnerb8d6e982010-02-09 00:34:28 +0000352
Chris Lattnere16b0fc2010-02-09 00:49:22 +0000353 // Parse %st(1) and "%st" as "%st(0)"
354 if (RegNo == 0 && Tok.getString() == "st") {
355 RegNo = X86::ST0;
356 EndLoc = Tok.getLoc();
357 Parser.Lex(); // Eat 'st'
358
359 // Check to see if we have '(4)' after %st.
360 if (getLexer().isNot(AsmToken::LParen))
361 return false;
362 // Lex the paren.
363 getParser().Lex();
364
365 const AsmToken &IntTok = Parser.getTok();
366 if (IntTok.isNot(AsmToken::Integer))
367 return Error(IntTok.getLoc(), "expected stack index");
368 switch (IntTok.getIntVal()) {
369 case 0: RegNo = X86::ST0; break;
370 case 1: RegNo = X86::ST1; break;
371 case 2: RegNo = X86::ST2; break;
372 case 3: RegNo = X86::ST3; break;
373 case 4: RegNo = X86::ST4; break;
374 case 5: RegNo = X86::ST5; break;
375 case 6: RegNo = X86::ST6; break;
376 case 7: RegNo = X86::ST7; break;
377 default: return Error(IntTok.getLoc(), "invalid stack index");
378 }
379
380 if (getParser().Lex().isNot(AsmToken::RParen))
381 return Error(Parser.getTok().getLoc(), "expected ')'");
382
383 EndLoc = Tok.getLoc();
384 Parser.Lex(); // Eat ')'
385 return false;
386 }
387
Daniel Dunbar245f0582009-08-08 21:22:41 +0000388 if (RegNo == 0)
Daniel Dunbar0e2771f2009-07-29 00:02:19 +0000389 return Error(Tok.getLoc(), "invalid register name");
390
Chris Lattner29ef9a22010-01-15 18:51:29 +0000391 EndLoc = Tok.getLoc();
Sean Callananb9a25b72010-01-19 20:27:46 +0000392 Parser.Lex(); // Eat identifier token.
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000393 return false;
Daniel Dunbar092a9dd2009-07-17 20:42:00 +0000394}
395
Chris Lattner309264d2010-01-15 18:44:13 +0000396X86Operand *X86ATTAsmParser::ParseOperand() {
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000397 switch (getLexer().getKind()) {
398 default:
Chris Lattnereef6d782010-04-17 18:56:34 +0000399 // Parse a memory operand with no segment register.
400 return ParseMemOperand(0, Parser.getTok().getLoc());
Chris Lattner23075742010-01-15 18:27:19 +0000401 case AsmToken::Percent: {
Chris Lattnereef6d782010-04-17 18:56:34 +0000402 // Read the register.
Chris Lattner23075742010-01-15 18:27:19 +0000403 unsigned RegNo;
Chris Lattner29ef9a22010-01-15 18:51:29 +0000404 SMLoc Start, End;
405 if (ParseRegister(RegNo, Start, End)) return 0;
Chris Lattnereef6d782010-04-17 18:56:34 +0000406
407 // If this is a segment register followed by a ':', then this is the start
408 // of a memory reference, otherwise this is a normal register reference.
409 if (getLexer().isNot(AsmToken::Colon))
410 return X86Operand::CreateReg(RegNo, Start, End);
411
412
413 getParser().Lex(); // Eat the colon.
414 return ParseMemOperand(RegNo, Start);
Chris Lattner23075742010-01-15 18:27:19 +0000415 }
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000416 case AsmToken::Dollar: {
417 // $42 -> immediate.
Sean Callanan18b83232010-01-19 21:44:56 +0000418 SMLoc Start = Parser.getTok().getLoc(), End;
Sean Callananb9a25b72010-01-19 20:27:46 +0000419 Parser.Lex();
Daniel Dunbar8c2eebe2009-08-31 08:08:38 +0000420 const MCExpr *Val;
Chris Lattner54482b42010-01-15 19:39:23 +0000421 if (getParser().ParseExpression(Val, End))
Chris Lattner309264d2010-01-15 18:44:13 +0000422 return 0;
Chris Lattnerb4307b32010-01-15 19:28:38 +0000423 return X86Operand::CreateImm(Val, Start, End);
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000424 }
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000425 }
Daniel Dunbardbd692a2009-07-20 20:01:54 +0000426}
427
Chris Lattnereef6d782010-04-17 18:56:34 +0000428/// ParseMemOperand: segment: disp(basereg, indexreg, scale). The '%ds:' prefix
429/// has already been parsed if present.
430X86Operand *X86ATTAsmParser::ParseMemOperand(unsigned SegReg, SMLoc MemStart) {
431
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000432 // We have to disambiguate a parenthesized expression "(4+5)" from the start
433 // of a memory operand with a missing displacement "(%ebx)" or "(,%eax)". The
Chris Lattner75f265f2010-01-24 01:07:33 +0000434 // only way to do this without lookahead is to eat the '(' and see what is
435 // after it.
Daniel Dunbar8c2eebe2009-08-31 08:08:38 +0000436 const MCExpr *Disp = MCConstantExpr::Create(0, getParser().getContext());
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000437 if (getLexer().isNot(AsmToken::LParen)) {
Chris Lattner54482b42010-01-15 19:39:23 +0000438 SMLoc ExprEnd;
439 if (getParser().ParseExpression(Disp, ExprEnd)) return 0;
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000440
441 // After parsing the base expression we could either have a parenthesized
442 // memory address or not. If not, return now. If so, eat the (.
443 if (getLexer().isNot(AsmToken::LParen)) {
Daniel Dunbarc09e4112009-07-31 22:22:54 +0000444 // Unless we have a segment register, treat this as an immediate.
Chris Lattner309264d2010-01-15 18:44:13 +0000445 if (SegReg == 0)
Daniel Dunbarb834f5d2010-01-30 01:02:48 +0000446 return X86Operand::CreateMem(Disp, MemStart, ExprEnd);
Chris Lattner0a3c5a52010-01-15 19:33:43 +0000447 return X86Operand::CreateMem(SegReg, Disp, 0, 0, 1, MemStart, ExprEnd);
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000448 }
449
450 // Eat the '('.
Sean Callananb9a25b72010-01-19 20:27:46 +0000451 Parser.Lex();
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000452 } else {
453 // Okay, we have a '('. We don't know if this is an expression or not, but
454 // so we have to eat the ( to see beyond it.
Sean Callanan18b83232010-01-19 21:44:56 +0000455 SMLoc LParenLoc = Parser.getTok().getLoc();
Sean Callananb9a25b72010-01-19 20:27:46 +0000456 Parser.Lex(); // Eat the '('.
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000457
Kevin Enderby7b4608d2009-09-03 17:15:07 +0000458 if (getLexer().is(AsmToken::Percent) || getLexer().is(AsmToken::Comma)) {
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000459 // Nothing to do here, fall into the code below with the '(' part of the
460 // memory operand consumed.
461 } else {
Chris Lattnerb4307b32010-01-15 19:28:38 +0000462 SMLoc ExprEnd;
463
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000464 // It must be an parenthesized expression, parse it now.
Chris Lattnerb4307b32010-01-15 19:28:38 +0000465 if (getParser().ParseParenExpression(Disp, ExprEnd))
Chris Lattner309264d2010-01-15 18:44:13 +0000466 return 0;
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000467
468 // After parsing the base expression we could either have a parenthesized
469 // memory address or not. If not, return now. If so, eat the (.
470 if (getLexer().isNot(AsmToken::LParen)) {
Daniel Dunbarc09e4112009-07-31 22:22:54 +0000471 // Unless we have a segment register, treat this as an immediate.
Chris Lattner309264d2010-01-15 18:44:13 +0000472 if (SegReg == 0)
Daniel Dunbarb834f5d2010-01-30 01:02:48 +0000473 return X86Operand::CreateMem(Disp, LParenLoc, ExprEnd);
Chris Lattner0a3c5a52010-01-15 19:33:43 +0000474 return X86Operand::CreateMem(SegReg, Disp, 0, 0, 1, MemStart, ExprEnd);
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000475 }
476
477 // Eat the '('.
Sean Callananb9a25b72010-01-19 20:27:46 +0000478 Parser.Lex();
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000479 }
480 }
481
482 // If we reached here, then we just ate the ( of the memory operand. Process
483 // the rest of the memory operand.
Daniel Dunbar022e2a82009-07-31 20:53:16 +0000484 unsigned BaseReg = 0, IndexReg = 0, Scale = 1;
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000485
Chris Lattner29ef9a22010-01-15 18:51:29 +0000486 if (getLexer().is(AsmToken::Percent)) {
487 SMLoc L;
488 if (ParseRegister(BaseReg, L, L)) return 0;
489 }
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000490
491 if (getLexer().is(AsmToken::Comma)) {
Sean Callananb9a25b72010-01-19 20:27:46 +0000492 Parser.Lex(); // Eat the comma.
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000493
494 // Following the comma we should have either an index register, or a scale
495 // value. We don't support the later form, but we want to parse it
496 // correctly.
497 //
498 // Not that even though it would be completely consistent to support syntax
499 // like "1(%eax,,1)", the assembler doesn't.
Kevin Enderby7b4608d2009-09-03 17:15:07 +0000500 if (getLexer().is(AsmToken::Percent)) {
Chris Lattner29ef9a22010-01-15 18:51:29 +0000501 SMLoc L;
502 if (ParseRegister(IndexReg, L, L)) return 0;
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000503
504 if (getLexer().isNot(AsmToken::RParen)) {
505 // Parse the scale amount:
506 // ::= ',' [scale-expression]
Chris Lattner309264d2010-01-15 18:44:13 +0000507 if (getLexer().isNot(AsmToken::Comma)) {
Sean Callanan18b83232010-01-19 21:44:56 +0000508 Error(Parser.getTok().getLoc(),
Chris Lattner309264d2010-01-15 18:44:13 +0000509 "expected comma in scale expression");
510 return 0;
511 }
Sean Callananb9a25b72010-01-19 20:27:46 +0000512 Parser.Lex(); // Eat the comma.
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000513
514 if (getLexer().isNot(AsmToken::RParen)) {
Sean Callanan18b83232010-01-19 21:44:56 +0000515 SMLoc Loc = Parser.getTok().getLoc();
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000516
517 int64_t ScaleVal;
518 if (getParser().ParseAbsoluteExpression(ScaleVal))
Chris Lattner309264d2010-01-15 18:44:13 +0000519 return 0;
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000520
521 // Validate the scale amount.
Chris Lattner309264d2010-01-15 18:44:13 +0000522 if (ScaleVal != 1 && ScaleVal != 2 && ScaleVal != 4 && ScaleVal != 8){
523 Error(Loc, "scale factor in address must be 1, 2, 4 or 8");
524 return 0;
525 }
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000526 Scale = (unsigned)ScaleVal;
527 }
528 }
529 } else if (getLexer().isNot(AsmToken::RParen)) {
530 // Otherwise we have the unsupported form of a scale amount without an
531 // index.
Sean Callanan18b83232010-01-19 21:44:56 +0000532 SMLoc Loc = Parser.getTok().getLoc();
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000533
534 int64_t Value;
535 if (getParser().ParseAbsoluteExpression(Value))
Chris Lattner309264d2010-01-15 18:44:13 +0000536 return 0;
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000537
Chris Lattner309264d2010-01-15 18:44:13 +0000538 Error(Loc, "cannot have scale factor without index register");
539 return 0;
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000540 }
541 }
542
543 // Ok, we've eaten the memory operand, verify we have a ')' and eat it too.
Chris Lattner309264d2010-01-15 18:44:13 +0000544 if (getLexer().isNot(AsmToken::RParen)) {
Sean Callanan18b83232010-01-19 21:44:56 +0000545 Error(Parser.getTok().getLoc(), "unexpected token in memory operand");
Chris Lattner309264d2010-01-15 18:44:13 +0000546 return 0;
547 }
Sean Callanan18b83232010-01-19 21:44:56 +0000548 SMLoc MemEnd = Parser.getTok().getLoc();
Sean Callananb9a25b72010-01-19 20:27:46 +0000549 Parser.Lex(); // Eat the ')'.
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000550
Chris Lattner0a3c5a52010-01-15 19:33:43 +0000551 return X86Operand::CreateMem(SegReg, Disp, BaseReg, IndexReg, Scale,
552 MemStart, MemEnd);
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000553}
554
Chris Lattner98986712010-01-14 22:21:20 +0000555bool X86ATTAsmParser::
556ParseInstruction(const StringRef &Name, SMLoc NameLoc,
557 SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
Dan Gohmane5e4ff92010-05-20 16:16:00 +0000558 // The various flavors of pushf and popf use Requires<In32BitMode> and
559 // Requires<In64BitMode>, but the assembler doesn't yet implement that.
560 // For now, just do a manual check to prevent silent misencoding.
561 if (Is64Bit) {
562 if (Name == "popfl")
563 return Error(NameLoc, "popfl cannot be encoded in 64-bit mode");
564 else if (Name == "pushfl")
565 return Error(NameLoc, "pushfl cannot be encoded in 64-bit mode");
566 } else {
567 if (Name == "popfq")
568 return Error(NameLoc, "popfq cannot be encoded in 32-bit mode");
569 else if (Name == "pushfq")
570 return Error(NameLoc, "pushfq cannot be encoded in 32-bit mode");
571 }
572
Daniel Dunbar1b6c0602010-02-10 21:19:28 +0000573 // FIXME: Hack to recognize "sal..." and "rep..." for now. We need a way to
574 // represent alternative syntaxes in the .td file, without requiring
575 // instruction duplication.
576 StringRef PatchedName = StringSwitch<StringRef>(Name)
577 .Case("sal", "shl")
578 .Case("salb", "shlb")
579 .Case("sall", "shll")
580 .Case("salq", "shlq")
581 .Case("salw", "shlw")
582 .Case("repe", "rep")
583 .Case("repz", "rep")
584 .Case("repnz", "repne")
Dan Gohmane5e4ff92010-05-20 16:16:00 +0000585 .Case("pushf", Is64Bit ? "pushfq" : "pushfl")
586 .Case("popf", Is64Bit ? "popfq" : "popfl")
Daniel Dunbar1b6c0602010-02-10 21:19:28 +0000587 .Default(Name);
588 Operands.push_back(X86Operand::CreateToken(PatchedName, NameLoc));
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000589
590 if (getLexer().isNot(AsmToken::EndOfStatement)) {
Daniel Dunbar0db68f42009-08-11 05:00:25 +0000591
592 // Parse '*' modifier.
593 if (getLexer().is(AsmToken::Star)) {
Sean Callanan18b83232010-01-19 21:44:56 +0000594 SMLoc Loc = Parser.getTok().getLoc();
Chris Lattnerb4307b32010-01-15 19:28:38 +0000595 Operands.push_back(X86Operand::CreateToken("*", Loc));
Sean Callananb9a25b72010-01-19 20:27:46 +0000596 Parser.Lex(); // Eat the star.
Daniel Dunbar0db68f42009-08-11 05:00:25 +0000597 }
598
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000599 // Read the first operand.
Chris Lattner309264d2010-01-15 18:44:13 +0000600 if (X86Operand *Op = ParseOperand())
601 Operands.push_back(Op);
602 else
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000603 return true;
Chris Lattner309264d2010-01-15 18:44:13 +0000604
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000605 while (getLexer().is(AsmToken::Comma)) {
Sean Callananb9a25b72010-01-19 20:27:46 +0000606 Parser.Lex(); // Eat the comma.
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000607
608 // Parse and remember the operand.
Chris Lattner309264d2010-01-15 18:44:13 +0000609 if (X86Operand *Op = ParseOperand())
610 Operands.push_back(Op);
611 else
Daniel Dunbar16cdcb32009-07-28 22:40:46 +0000612 return true;
613 }
614 }
615
Daniel Dunbard5e77052010-03-13 00:47:29 +0000616 // FIXME: Hack to handle recognizing s{hr,ar,hl}? $1.
617 if ((Name.startswith("shr") || Name.startswith("sar") ||
618 Name.startswith("shl")) &&
619 Operands.size() == 3 &&
620 static_cast<X86Operand*>(Operands[1])->isImm() &&
621 isa<MCConstantExpr>(static_cast<X86Operand*>(Operands[1])->getImm()) &&
Daniel Dunbarf2de13f2010-03-20 22:36:38 +0000622 cast<MCConstantExpr>(static_cast<X86Operand*>(Operands[1])->getImm())->getValue() == 1) {
623 delete Operands[1];
Daniel Dunbard5e77052010-03-13 00:47:29 +0000624 Operands.erase(Operands.begin() + 1);
Daniel Dunbarf2de13f2010-03-20 22:36:38 +0000625 }
Daniel Dunbard5e77052010-03-13 00:47:29 +0000626
Chris Lattner98986712010-01-14 22:21:20 +0000627 return false;
Daniel Dunbara3af3702009-07-20 18:55:04 +0000628}
629
Kevin Enderby9c656452009-09-10 20:51:44 +0000630bool X86ATTAsmParser::ParseDirective(AsmToken DirectiveID) {
631 StringRef IDVal = DirectiveID.getIdentifier();
632 if (IDVal == ".word")
633 return ParseDirectiveWord(2, DirectiveID.getLoc());
634 return true;
635}
636
637/// ParseDirectiveWord
638/// ::= .word [ expression (, expression)* ]
639bool X86ATTAsmParser::ParseDirectiveWord(unsigned Size, SMLoc L) {
640 if (getLexer().isNot(AsmToken::EndOfStatement)) {
641 for (;;) {
642 const MCExpr *Value;
643 if (getParser().ParseExpression(Value))
644 return true;
645
Chris Lattneraaec2052010-01-19 19:46:13 +0000646 getParser().getStreamer().EmitValue(Value, Size, 0 /*addrspace*/);
Kevin Enderby9c656452009-09-10 20:51:44 +0000647
648 if (getLexer().is(AsmToken::EndOfStatement))
649 break;
650
651 // FIXME: Improve diagnostic.
652 if (getLexer().isNot(AsmToken::Comma))
653 return Error(L, "unexpected token in directive");
Sean Callananb9a25b72010-01-19 20:27:46 +0000654 Parser.Lex();
Kevin Enderby9c656452009-09-10 20:51:44 +0000655 }
656 }
657
Sean Callananb9a25b72010-01-19 20:27:46 +0000658 Parser.Lex();
Kevin Enderby9c656452009-09-10 20:51:44 +0000659 return false;
660}
661
Chris Lattnerb5505d02010-05-13 00:02:47 +0000662/// LowerMOffset - Lower an 'moffset' form of an instruction, which just has a
663/// imm operand, to having "rm" or "mr" operands with the offset in the disp
664/// field.
665static void LowerMOffset(MCInst &Inst, unsigned Opc, unsigned RegNo,
666 bool isMR) {
667 MCOperand Disp = Inst.getOperand(0);
668
669 // Start over with an empty instruction.
670 Inst = MCInst();
671 Inst.setOpcode(Opc);
672
673 if (!isMR)
674 Inst.addOperand(MCOperand::CreateReg(RegNo));
675
676 // Add the mem operand.
677 Inst.addOperand(MCOperand::CreateReg(0)); // Segment
678 Inst.addOperand(MCOperand::CreateImm(1)); // Scale
679 Inst.addOperand(MCOperand::CreateReg(0)); // IndexReg
680 Inst.addOperand(Disp); // Displacement
681 Inst.addOperand(MCOperand::CreateReg(0)); // BaseReg
682
683 if (isMR)
684 Inst.addOperand(MCOperand::CreateReg(RegNo));
685}
686
Daniel Dunbarf98bc632010-03-18 20:06:02 +0000687// FIXME: Custom X86 cleanup function to implement a temporary hack to handle
688// matching INCL/DECL correctly for x86_64. This needs to be replaced by a
689// proper mechanism for supporting (ambiguous) feature dependent instructions.
690void X86ATTAsmParser::InstructionCleanup(MCInst &Inst) {
691 if (!Is64Bit) return;
692
693 switch (Inst.getOpcode()) {
694 case X86::DEC16r: Inst.setOpcode(X86::DEC64_16r); break;
695 case X86::DEC16m: Inst.setOpcode(X86::DEC64_16m); break;
696 case X86::DEC32r: Inst.setOpcode(X86::DEC64_32r); break;
697 case X86::DEC32m: Inst.setOpcode(X86::DEC64_32m); break;
698 case X86::INC16r: Inst.setOpcode(X86::INC64_16r); break;
699 case X86::INC16m: Inst.setOpcode(X86::INC64_16m); break;
700 case X86::INC32r: Inst.setOpcode(X86::INC64_32r); break;
701 case X86::INC32m: Inst.setOpcode(X86::INC64_32m); break;
Chris Lattnerb5505d02010-05-13 00:02:47 +0000702
703 // moffset instructions are x86-32 only.
704 case X86::MOV8o8a: LowerMOffset(Inst, X86::MOV8rm , X86::AL , false); break;
705 case X86::MOV16o16a: LowerMOffset(Inst, X86::MOV16rm, X86::AX , false); break;
706 case X86::MOV32o32a: LowerMOffset(Inst, X86::MOV32rm, X86::EAX, false); break;
707 case X86::MOV8ao8: LowerMOffset(Inst, X86::MOV8mr , X86::AL , true); break;
708 case X86::MOV16ao16: LowerMOffset(Inst, X86::MOV16mr, X86::AX , true); break;
709 case X86::MOV32ao32: LowerMOffset(Inst, X86::MOV32mr, X86::EAX, true); break;
Daniel Dunbarf98bc632010-03-18 20:06:02 +0000710 }
711}
712
Daniel Dunbarc918d602010-05-04 16:12:42 +0000713bool
714X86ATTAsmParser::MatchInstruction(const SmallVectorImpl<MCParsedAsmOperand*>
715 &Operands,
716 MCInst &Inst) {
717 // First, try a direct match.
718 if (!MatchInstructionImpl(Operands, Inst))
719 return false;
720
721 // Ignore anything which is obviously not a suffix match.
722 if (Operands.size() == 0)
723 return true;
724 X86Operand *Op = static_cast<X86Operand*>(Operands[0]);
725 if (!Op->isToken() || Op->getToken().size() > 15)
726 return true;
727
728 // FIXME: Ideally, we would only attempt suffix matches for things which are
729 // valid prefixes, and we could just infer the right unambiguous
730 // type. However, that requires substantially more matcher support than the
731 // following hack.
732
733 // Change the operand to point to a temporary token.
734 char Tmp[16];
735 StringRef Base = Op->getToken();
736 memcpy(Tmp, Base.data(), Base.size());
737 Op->setTokenValue(StringRef(Tmp, Base.size() + 1));
738
739 // Check for the various suffix matches.
740 Tmp[Base.size()] = 'b';
741 bool MatchB = MatchInstructionImpl(Operands, Inst);
742 Tmp[Base.size()] = 'w';
743 bool MatchW = MatchInstructionImpl(Operands, Inst);
744 Tmp[Base.size()] = 'l';
745 bool MatchL = MatchInstructionImpl(Operands, Inst);
Daniel Dunbar04814492010-05-12 00:54:20 +0000746 Tmp[Base.size()] = 'q';
747 bool MatchQ = MatchInstructionImpl(Operands, Inst);
Daniel Dunbarc918d602010-05-04 16:12:42 +0000748
749 // Restore the old token.
750 Op->setTokenValue(Base);
751
752 // If exactly one matched, then we treat that as a successful match (and the
753 // instruction will already have been filled in correctly, since the failing
754 // matches won't have modified it).
Daniel Dunbar04814492010-05-12 00:54:20 +0000755 if (MatchB + MatchW + MatchL + MatchQ == 3)
Daniel Dunbarc918d602010-05-04 16:12:42 +0000756 return false;
757
Daniel Dunbarc918d602010-05-04 16:12:42 +0000758 // Otherwise, the match failed.
759 return true;
760}
761
762
Sean Callanane88f5522010-01-23 02:43:15 +0000763extern "C" void LLVMInitializeX86AsmLexer();
764
Daniel Dunbar092a9dd2009-07-17 20:42:00 +0000765// Force static initialization.
766extern "C" void LLVMInitializeX86AsmParser() {
Daniel Dunbarf98bc632010-03-18 20:06:02 +0000767 RegisterAsmParser<X86_32ATTAsmParser> X(TheX86_32Target);
768 RegisterAsmParser<X86_64ATTAsmParser> Y(TheX86_64Target);
Sean Callanane88f5522010-01-23 02:43:15 +0000769 LLVMInitializeX86AsmLexer();
Daniel Dunbar092a9dd2009-07-17 20:42:00 +0000770}
Daniel Dunbar0e2771f2009-07-29 00:02:19 +0000771
772#include "X86GenAsmMatcher.inc"