summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86/AsmParser
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2019-08-07 05:34:27 +0000
committerCraig Topper <craig.topper@intel.com>2019-08-07 05:34:27 +0000
commit29688f4da0b62e760dcd65d607aa9a56cb1557e0 (patch)
tree293a2cc5eb55bffe628ebba214b1c5562757c15c /llvm/lib/Target/X86/AsmParser
parent989679c3711a239c73057fb5446eef937935f4ba (diff)
downloadbcm5719-llvm-29688f4da0b62e760dcd65d607aa9a56cb1557e0.tar.gz
bcm5719-llvm-29688f4da0b62e760dcd65d607aa9a56cb1557e0.zip
[X86] Limit vpermil2pd/vpermil2ps immediates to 4 bits in the assembly parser.
The upper 4 bits of the immediate byte are used to encode a register. We need to limit the explicit immediate to fit in the remaining 4 bits. Fixes PR42899. llvm-svn: 368123
Diffstat (limited to 'llvm/lib/Target/X86/AsmParser')
-rw-r--r--llvm/lib/Target/X86/AsmParser/X86AsmParserCommon.h4
-rw-r--r--llvm/lib/Target/X86/AsmParser/X86Operand.h9
2 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParserCommon.h b/llvm/lib/Target/X86/AsmParser/X86AsmParserCommon.h
index 5bc979d1f18..e9be28ca77b 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParserCommon.h
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParserCommon.h
@@ -35,6 +35,10 @@ inline bool isImmUnsignedi8Value(uint64_t Value) {
return isUInt<8>(Value) || isInt<8>(Value);
}
+inline bool isImmUnsignedi4Value(uint64_t Value) {
+ return isUInt<4>(Value);
+}
+
} // End of namespace llvm
#endif
diff --git a/llvm/lib/Target/X86/AsmParser/X86Operand.h b/llvm/lib/Target/X86/AsmParser/X86Operand.h
index a771ba36631..591e6f4102f 100644
--- a/llvm/lib/Target/X86/AsmParser/X86Operand.h
+++ b/llvm/lib/Target/X86/AsmParser/X86Operand.h
@@ -260,6 +260,15 @@ struct X86Operand final : public MCParsedAsmOperand {
return isImmSExti64i32Value(CE->getValue());
}
+ bool isImmUnsignedi4() const {
+ if (!isImm()) return false;
+ // If this isn't a constant expr, just assume it fits and let relaxation
+ // handle it.
+ const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm());
+ if (!CE) return true;
+ return isImmUnsignedi4Value(CE->getValue());
+ }
+
bool isImmUnsignedi8() const {
if (!isImm()) return false;
// If this isn't a constant expr, just assume it fits and let relaxation
OpenPOWER on IntegriCloud