aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/X86/AsmParser/X86AsmParser.cpp
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-10-02 21:49:07 +0000
committerChad Rosier <mcrosier@apple.com>2012-10-02 21:49:07 +0000
commit95707c90ccb7309df76ea7f3f0b81495e4f7d0e6 (patch)
tree5bc9a7456e36c5cfae9d81b51f699292366c3da3 /lib/Target/X86/AsmParser/X86AsmParser.cpp
parent27cb347d0e765175efb2c4d388bcbba84cf1b95e (diff)
[ms-inline asm] Add basic support for wildcard MCParsedAsmOperands. This type
of operand is specific to MS-style inline assembly and should not be generated when parsing normal assembly. The purpose of the wildcard operands are to allow the AsmParser to match multiple instructions (i.e., MCInsts) to a given ms-style asm statement. For the time being the matcher just returns the first match. This patch only implements wildcard matches for memory operands. Support for register wildcards will be added in the near future. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165057 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/AsmParser/X86AsmParser.cpp')
-rw-r--r--lib/Target/X86/AsmParser/X86AsmParser.cpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 704d5f9426..2f78b16e44 100644
--- a/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -158,7 +158,8 @@ struct X86Operand : public MCParsedAsmOperand {
Token,
Register,
Immediate,
- Memory
+ Memory,
+ MSAsmWildcard
} Kind;
SMLoc StartLoc, EndLoc;
@@ -185,6 +186,10 @@ struct X86Operand : public MCParsedAsmOperand {
unsigned Scale;
unsigned Size;
} Mem;
+
+ struct {
+ unsigned Size;
+ } MSAsm;
};
X86Operand(KindTy K, SMLoc Start, SMLoc End)
@@ -318,25 +323,32 @@ struct X86Operand : public MCParsedAsmOperand {
bool isMem() const { return Kind == Memory; }
bool isMem8() const {
- return Kind == Memory && (!Mem.Size || Mem.Size == 8);
+ return (Kind == Memory && (!Mem.Size || Mem.Size == 8)) ||
+ (Kind == MSAsmWildcard && MSAsm.Size == 8);
}
bool isMem16() const {
- return Kind == Memory && (!Mem.Size || Mem.Size == 16);
+ return (Kind == Memory && (!Mem.Size || Mem.Size == 16)) ||
+ (Kind == MSAsmWildcard && MSAsm.Size == 16);
}
bool isMem32() const {
- return Kind == Memory && (!Mem.Size || Mem.Size == 32);
+ return (Kind == Memory && (!Mem.Size || Mem.Size == 32)) ||
+ (Kind == MSAsmWildcard && MSAsm.Size == 32);
}
bool isMem64() const {
- return Kind == Memory && (!Mem.Size || Mem.Size == 64);
+ return (Kind == Memory && (!Mem.Size || Mem.Size == 64)) ||
+ (Kind == MSAsmWildcard && MSAsm.Size == 64);
}
bool isMem80() const {
- return Kind == Memory && (!Mem.Size || Mem.Size == 80);
+ return (Kind == Memory && (!Mem.Size || Mem.Size == 80)) ||
+ (Kind == MSAsmWildcard && MSAsm.Size == 80);
}
bool isMem128() const {
- return Kind == Memory && (!Mem.Size || Mem.Size == 128);
+ return (Kind == Memory && (!Mem.Size || Mem.Size == 128)) ||
+ (Kind == MSAsmWildcard && MSAsm.Size == 128);
}
bool isMem256() const {
- return Kind == Memory && (!Mem.Size || Mem.Size == 256);
+ return (Kind == Memory && (!Mem.Size || Mem.Size == 256)) ||
+ (Kind == MSAsmWildcard && MSAsm.Size == 256);
}
bool isMemVX32() const {
@@ -363,6 +375,12 @@ struct X86Operand : public MCParsedAsmOperand {
bool isReg() const { return Kind == Register; }
+ bool isMSAsmWildcard() const { return Kind == MSAsmWildcard; }
+ void setMSAsmWildcard(unsigned Size) {
+ Kind = MSAsmWildcard;
+ this->MSAsm.Size = Size;
+ }
+
void addExpr(MCInst &Inst, const MCExpr *Expr) const {
// Add as immediates when possible.
if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Expr))