From 3e9bf4c0d05f149b3fa3d78127cdaf623f5bdd3c Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sat, 27 Dec 2014 18:11:00 +0000 Subject: [PATCH] [x86] Assert on invalid immediates in the instruction printer for cmp.ps/pd/ss/sd instead of truncating the immediate. The assembly parser and instruction selection shouldn't generate invalid immediates. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224886 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp | 6 ++++-- lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp b/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp index 88c0f193941..db6948518c5 100644 --- a/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp +++ b/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp @@ -112,13 +112,15 @@ static void printSSEAVXCC(int64_t Imm, raw_ostream &O) { void X86ATTInstPrinter::printSSECC(const MCInst *MI, unsigned Op, raw_ostream &O) { - int64_t Imm = MI->getOperand(Op).getImm() & 0x7; + int64_t Imm = MI->getOperand(Op).getImm(); + assert((Imm & 0x7) == Imm); // Ensure valid immediate. printSSEAVXCC(Imm, O); } void X86ATTInstPrinter::printAVXCC(const MCInst *MI, unsigned Op, raw_ostream &O) { - int64_t Imm = MI->getOperand(Op).getImm() & 0x1f; + int64_t Imm = MI->getOperand(Op).getImm(); + assert((Imm & 0x1f) == Imm); // Ensure valid immediate. printSSEAVXCC(Imm, O); } diff --git a/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp b/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp index f5fd9845d90..449445df7d2 100644 --- a/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp +++ b/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp @@ -90,13 +90,15 @@ static void printSSEAVXCC(int64_t Imm, raw_ostream &O) { void X86IntelInstPrinter::printSSECC(const MCInst *MI, unsigned Op, raw_ostream &O) { - int64_t Imm = MI->getOperand(Op).getImm() & 0x7; + int64_t Imm = MI->getOperand(Op).getImm(); + assert((Imm & 0x7) == Imm); // Ensure valid immediate. printSSEAVXCC(Imm, O); } void X86IntelInstPrinter::printAVXCC(const MCInst *MI, unsigned Op, raw_ostream &O) { - int64_t Imm = MI->getOperand(Op).getImm() & 0x1f; + int64_t Imm = MI->getOperand(Op).getImm(); + assert((Imm & 0x1f) == Imm); // Ensure valid immediate. printSSEAVXCC(Imm, O); } -- 2.34.1