1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00

[mips][ias] Range check uimm8 operands

Summary:

Reviewers: vkalintiris

Subscribers: llvm-commits, dsanders

Differential Revision: http://reviews.llvm.org/D15226

llvm-svn: 255018
This commit is contained in:
Daniel Sanders 2015-12-08 14:42:10 +00:00
parent 70956ab343
commit a6473a3e90
5 changed files with 16 additions and 6 deletions

View File

@ -3650,6 +3650,9 @@ bool MipsAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
case Match_UImm6_0:
return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
"expected 6-bit unsigned immediate");
case Match_UImm8_0:
return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
"expected 8-bit unsigned immediate");
}
llvm_unreachable("Implement any new match types added!");

View File

@ -394,8 +394,10 @@ class ConstantUImmAsmOperandClass<int Bits, list<AsmOperandClass> Supers = [],
let DiagnosticType = "UImm" # Bits # "_" # Offset;
}
def ConstantUImm8AsmOperandClass
: ConstantUImmAsmOperandClass<8, []>;
def ConstantUImm6AsmOperandClass
: ConstantUImmAsmOperandClass<6, []>;
: ConstantUImmAsmOperandClass<6, [ConstantUImm8AsmOperandClass]>;
def ConstantUImm5Plus32AsmOperandClass
: ConstantUImmAsmOperandClass<5, [ConstantUImm6AsmOperandClass], 32>;
def ConstantUImm5Plus32NormalizeAsmOperandClass
@ -512,7 +514,7 @@ def uimmz : Operand<i32> {
}
// Unsigned Operands
foreach I = {1, 2, 3, 4, 5, 6} in
foreach I = {1, 2, 3, 4, 5, 6, 8} in
def uimm # I : Operand<i32> {
let PrintMethod = "printUnsignedImm";
let ParserMatchClass =

View File

@ -78,10 +78,6 @@ def uimm6_ptr : Operand<iPTR> {
let PrintMethod = "printUnsignedImm8";
}
def uimm8 : Operand<i32> {
let PrintMethod = "printUnsignedImm8";
}
def simm5 : Operand<i32>;
def vsplat_uimm1 : Operand<vAny> {

View File

@ -37,6 +37,9 @@
sat_u.w $w31, $w31, 32 # CHECK: :[[@LINE]]:25: error: expected 5-bit unsigned immediate
sat_u.d $w31, $w31, -1 # CHECK: :[[@LINE]]:25: error: expected 6-bit unsigned immediate
sat_u.d $w31, $w31, 64 # CHECK: :[[@LINE]]:25: error: expected 6-bit unsigned immediate
shf.b $w19, $w30, -1 # CHECK: :[[@LINE]]:23: error: expected 8-bit unsigned immediate
shf.h $w17, $w8, -1 # CHECK: :[[@LINE]]:22: error: expected 8-bit unsigned immediate
shf.w $w14, $w3, -1 # CHECK: :[[@LINE]]:22: error: expected 8-bit unsigned immediate
sldi.b $w0, $w29[-1] # CHECK: :[[@LINE]]:22: error: expected 4-bit unsigned immediate
sldi.b $w0, $w29[16] # CHECK: :[[@LINE]]:22: error: expected 4-bit unsigned immediate
sldi.d $w4, $w12[-1] # CHECK: :[[@LINE]]:22: error: expected 1-bit unsigned immediate

View File

@ -35,6 +35,12 @@
sat_u.w $w31, $w31, 32 # CHECK: :[[@LINE]]:25: error: expected 5-bit unsigned immediate
sat_u.d $w31, $w31, -1 # CHECK: :[[@LINE]]:25: error: expected 6-bit unsigned immediate
sat_u.d $w31, $w31, 64 # CHECK: :[[@LINE]]:25: error: expected 6-bit unsigned immediate
shf.b $w19, $w30, -1 # CHECK: :[[@LINE]]:23: error: expected 8-bit unsigned immediate
shf.b $w19, $w30, 256 # CHECK: :[[@LINE]]:23: error: expected 8-bit unsigned immediate
shf.h $w17, $w8, -1 # CHECK: :[[@LINE]]:22: error: expected 8-bit unsigned immediate
shf.h $w17, $w8, 256 # CHECK: :[[@LINE]]:22: error: expected 8-bit unsigned immediate
shf.w $w14, $w3, -1 # CHECK: :[[@LINE]]:22: error: expected 8-bit unsigned immediate
shf.w $w14, $w3, 256 # CHECK: :[[@LINE]]:22: error: expected 8-bit unsigned immediate
sldi.b $w0, $w29[-1] # CHECK: :[[@LINE]]:22: error: expected 4-bit unsigned immediate
sldi.b $w0, $w29[16] # CHECK: :[[@LINE]]:22: error: expected 4-bit unsigned immediate
sldi.d $w4, $w12[-1] # CHECK: :[[@LINE]]:22: error: expected 1-bit unsigned immediate