[PATCH] D25112: Don't randomly encode %rip where illegal
Douglas Katzman via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 30 11:13:45 PDT 2016
dougk created this revision.
dougk added a reviewer: niravd.
dougk added a subscriber: llvm-commits.
https://reviews.llvm.org/D25112
Files:
lib/Target/X86/AsmParser/X86AsmParser.cpp
test/MC/X86/x86_errors.s
Index: test/MC/X86/x86_errors.s
===================================================================
--- test/MC/X86/x86_errors.s
+++ test/MC/X86/x86_errors.s
@@ -74,3 +74,11 @@
// 32: error: register %dr8 is only available in 64-bit mode
movl %edx, %dr8
+
+// 32: error: register %rip is only available in 64-bit mode
+// 64: error: %rip can only be used as a base register
+mov %rip, %rax
+
+// 32: error: register %rax is only available in 64-bit mode
+// 64: error: %rip is not allowed as an index register
+mov (%rax,%rip), %rbx
Index: lib/Target/X86/AsmParser/X86AsmParser.cpp
===================================================================
--- lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1865,6 +1865,11 @@
SMRange(Start, End));
return nullptr;
}
+ if (RegNo == X86::RIP) {
+ Error(Start, "%rip can only be used as a base register",
+ SMRange(Start, End));
+ return nullptr;
+ }
// 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.
@@ -2045,6 +2050,14 @@
if (getLexer().is(AsmToken::Percent)) {
SMLoc L;
if (ParseRegister(IndexReg, L, L)) return nullptr;
+ if (BaseReg == X86::RIP) {
+ Error(IndexLoc, "%rip as base register can not have an index register");
+ return nullptr;
+ }
+ if (IndexReg == X86::RIP) {
+ Error(IndexLoc, "%rip is not allowed as an index register");
+ return nullptr;
+ }
if (getLexer().isNot(AsmToken::RParen)) {
// Parse the scale amount:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25112.73102.patch
Type: text/x-patch
Size: 1671 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160930/e43bf608/attachment.bin>
More information about the llvm-commits
mailing list