summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-07-31 09:27:07 +0000
committerMartin Storsjo <martin@martin.st>2018-07-31 09:27:07 +0000
commit293079f2dec1f505fac48b31417ebd734e9d410d (patch)
tree406de298fae3ce6cc7efa035022ec788d9fd8af7 /llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
parentaf18947f0a38dd7385479732474d4865e68fa7a8 (diff)
downloadbcm5719-llvm-293079f2dec1f505fac48b31417ebd734e9d410d.tar.gz
bcm5719-llvm-293079f2dec1f505fac48b31417ebd734e9d410d.zip
[ARM] Allow automatically deducing the thumb instruction size for .inst
This matches GAS, that allows unsuffixed .inst for thumb. Differential Revision: https://reviews.llvm.org/D49937 llvm-svn: 338357
Diffstat (limited to 'llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp')
-rw-r--r--llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index ed706ab7a29..a5fbbbf26be 100644
--- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -10012,8 +10012,8 @@ bool ARMAsmParser::parseDirectiveInst(SMLoc Loc, char Suffix) {
case 'w':
break;
default:
- return Error(Loc, "cannot determine Thumb instruction size, "
- "use inst.n/inst.w instead");
+ Width = 0;
+ break;
}
} else {
if (Suffix)
@@ -10029,6 +10029,7 @@ bool ARMAsmParser::parseDirectiveInst(SMLoc Loc, char Suffix) {
return Error(Loc, "expected constant expression");
}
+ char CurSuffix = Suffix;
switch (Width) {
case 2:
if (Value->getValue() > 0xffff)
@@ -10039,11 +10040,21 @@ bool ARMAsmParser::parseDirectiveInst(SMLoc Loc, char Suffix) {
return Error(Loc, StringRef(Suffix ? "inst.w" : "inst") +
" operand is too big");
break;
+ case 0:
+ // Thumb mode, no width indicated. Guess from the opcode, if possible.
+ if (Value->getValue() < 0xe800)
+ CurSuffix = 'n';
+ else if (Value->getValue() >= 0xe8000000)
+ CurSuffix = 'w';
+ else
+ return Error(Loc, "cannot determine Thumb instruction size, "
+ "use inst.n/inst.w instead");
+ break;
default:
llvm_unreachable("only supported widths are 2 and 4");
}
- getTargetStreamer().emitInst(Value->getValue(), Suffix);
+ getTargetStreamer().emitInst(Value->getValue(), CurSuffix);
return false;
};
OpenPOWER on IntegriCloud