From: Oliver Stannard Date: Wed, 4 Oct 2017 09:18:07 +0000 (+0000) Subject: [ARM, Asm] Change grammar of immediate operand diagnostics X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7426522d8b7fac42a8c5197c6a29792612c49cc4;p=llvm [ARM, Asm] Change grammar of immediate operand diagnostics Currently, our diagnostics for assembly operands are not consistent. Some start with (for example) "immediate operand must be ...", and some with "operand must be an immediate ...". I think the latter form is preferable for a few reasons: * It's unambiguous that it is referring to the expected type of operand, not the type the user provided. For example, the user could provide an register operand, and get a message taking about an operand is if it is already an immediate, just not in the accepted range. * It allows us to have a consistent style once we add diagnostics for operands that could take two forms, for example a label or pc-relative memory operand. Differential revision: https://reviews.llvm.org/D36689 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314887 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/ARM/ARMInstrInfo.td b/lib/Target/ARM/ARMInstrInfo.td index da34ebdfeee..af065441ec7 100644 --- a/lib/Target/ARM/ARMInstrInfo.td +++ b/lib/Target/ARM/ARMInstrInfo.td @@ -460,13 +460,13 @@ def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{ class ImmAsmOperand : AsmOperandClass { let RenderMethod = "addImmOperands"; let PredicateMethod = "isImmediate<" # Low # "," # High # ">"; - let DiagnosticString = "immediate operand must be in the range [" # Low # "," # High # "]"; + let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]"; } class ImmAsmOperandMinusOne : AsmOperandClass { let PredicateMethod = "isImmediate<" # Low # "," # High # ">"; let DiagnosticType = "ImmRange" # Low # "_" # High; - let DiagnosticString = "immediate operand must be in the range [" # Low # "," # High # "]"; + let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]"; } // Operands that are part of a memory addressing mode. @@ -837,7 +837,7 @@ def imm256_65535_expr : Operand { /// imm24b - True if the 32-bit immediate is encodable in 24 bits. def Imm24bitAsmOperand: ImmAsmOperand<0,0xffffff> { let Name = "Imm24bit"; - let DiagnosticString = "immediate operand must be in the range [0,0xffffff]"; + let DiagnosticString = "operand must be an immediate in the range [0,0xffffff]"; } def imm24b : Operand, ImmLeaf= 0 && Imm <= 0xffffff; diff --git a/test/MC/ARM/basic-arm-instructions-v8.1a.s b/test/MC/ARM/basic-arm-instructions-v8.1a.s index bd9a16aac18..ad766135e33 100644 --- a/test/MC/ARM/basic-arm-instructions-v8.1a.s +++ b/test/MC/ARM/basic-arm-instructions-v8.1a.s @@ -196,10 +196,10 @@ //CHECK-ERROR: error: too few operands for instruction //CHECK-ERROR: setpan //CHECK-ERROR: ^ -//CHECK-ERROR: error: immediate operand must be in the range [0,1] +//CHECK-ERROR: error: operand must be an immediate in the range [0,1] //CHECK-ERROR: setpan #-1 //CHECK-ERROR: ^ -//CHECK-ERROR: error: immediate operand must be in the range [0,1] +//CHECK-ERROR: error: operand must be an immediate in the range [0,1] //CHECK-ERROR: setpan #2 //CHECK-ERROR: ^ diff --git a/test/MC/ARM/diagnostics.s b/test/MC/ARM/diagnostics.s index 9b24633c61e..0f697e6b367 100644 --- a/test/MC/ARM/diagnostics.s +++ b/test/MC/ARM/diagnostics.s @@ -94,7 +94,7 @@ bkpt #65536 @ CHECK-ERRORS: error: invalid instruction, any one of the following would fix this: -@ CHECK-ERRORS: note: immediate operand must be in the range [0,65535] +@ CHECK-ERRORS: note: operand must be an immediate in the range [0,65535] @ CHECK-ERRORS: note: too many operands for instruction @ CHECK-ERRORS: bkpt #65536 @ CHECK-ERRORS: ^ @@ -103,11 +103,11 @@ hlt #65536 hlt #-1 @CHECK-ERRORS-V7: error: invalid instruction -@CHECK-ERRORS-V8: error: immediate operand must be in the range [0,65535] +@CHECK-ERRORS-V8: error: operand must be an immediate in the range [0,65535] @CHECK-ERRORS: hlt #65536 @CHECK-ERRORS: ^ @CHECK-ERRORS-V7: error: invalid instruction -@CHECK-ERRORS-V8: error: immediate operand must be in the range [0,65535] +@CHECK-ERRORS-V8: error: operand must be an immediate in the range [0,65535] @CHECK-ERRORS: hlt #-1 @CHECK-ERRORS: ^ @@ -129,10 +129,10 @@ cdp2 p7, #2, c1, c1, c1, #8 cdp2 p7, #1, c1, c1, c1, #8 -@ CHECK-ERRORS-V7: error: immediate operand must be in the range [0,7] -@ CHECK-ERRORS-V7: error: immediate operand must be in the range [0,7] -@ CHECK-ERRORS-V7: error: immediate operand must be in the range [0,7] -@ CHECK-ERRORS-V7: error: immediate operand must be in the range [0,7] +@ CHECK-ERRORS-V7: error: operand must be an immediate in the range [0,7] +@ CHECK-ERRORS-V7: error: operand must be an immediate in the range [0,7] +@ CHECK-ERRORS-V7: error: operand must be an immediate in the range [0,7] +@ CHECK-ERRORS-V7: error: operand must be an immediate in the range [0,7] @ CHECK-ERRORS-V8: error: invalid instruction @ CHECK-ERRORS-V8: error: invalid instruction @ CHECK-ERRORS-V8: error: invalid instruction @@ -142,10 +142,10 @@ dbg #-1 dbg #16 -@ CHECK-ERRORS-V7: error: immediate operand must be in the range [0,15] -@ CHECK-ERRORS-V7: error: immediate operand must be in the range [0,15] -@ CHECK-ERRORS-V8: error: immediate operand must be in the range [0,15] -@ CHECK-ERRORS-V8: error: immediate operand must be in the range [0,15] +@ CHECK-ERRORS-V7: error: operand must be an immediate in the range [0,15] +@ CHECK-ERRORS-V7: error: operand must be an immediate in the range [0,15] +@ CHECK-ERRORS-V8: error: operand must be an immediate in the range [0,15] +@ CHECK-ERRORS-V8: error: operand must be an immediate in the range [0,15] @ Double-check that we're synced up with the right diagnostics. @ CHECK-ERRORS: dbg #16 @ CHECK-ERRORS: ^ @@ -157,14 +157,14 @@ mcr2 p7, #1, r5, c1, c1, #8 mcrr p7, #16, r5, r4, c1 mcrr2 p7, #16, r5, r4, c1 -@ CHECK-ERRORS: immediate operand must be in the range [0,7] -@ CHECK-ERRORS: immediate operand must be in the range [0,7] -@ CHECK-ERRORS-V7: immediate operand must be in the range [0,7] -@ CHECK-ERRORS-V7: immediate operand must be in the range [0,7] +@ CHECK-ERRORS: operand must be an immediate in the range [0,7] +@ CHECK-ERRORS: operand must be an immediate in the range [0,7] +@ CHECK-ERRORS-V7: operand must be an immediate in the range [0,7] +@ CHECK-ERRORS-V7: operand must be an immediate in the range [0,7] @ CHECK-ERRORS-V8: invalid instruction @ CHECK-ERRORS-V8: too many operands for instruction -@ CHECK-ERRORS: immediate operand must be in the range [0,15] -@ CHECK-ERRORS-V7: immediate operand must be in the range [0,15] +@ CHECK-ERRORS: operand must be an immediate in the range [0,15] +@ CHECK-ERRORS-V7: operand must be an immediate in the range [0,15] @ CHECK-ERRORS-V8: invalid instruction @ p10 and p11 are reserved for NEON @@ -198,14 +198,14 @@ mrc2 p14, #0, r1, c1, c2, #9 mrrc p7, #16, r5, r4, c1 mrrc2 p7, #17, r5, r4, c1 -@ CHECK-ERRORS: immediate operand must be in the range [0,7] -@ CHECK-ERRORS: immediate operand must be in the range [0,7] -@ CHECK-ERRORS-V7: immediate operand must be in the range [0,7] +@ CHECK-ERRORS: operand must be an immediate in the range [0,7] +@ CHECK-ERRORS: operand must be an immediate in the range [0,7] +@ CHECK-ERRORS-V7: operand must be an immediate in the range [0,7] @ CHECK-ERRORS-V8: invalid instruction -@ CHECK-ERRORS-V7: immediate operand must be in the range [0,7] +@ CHECK-ERRORS-V7: operand must be an immediate in the range [0,7] @ CHECK-ERRORS-V8: too many operands for instruction -@ CHECK-ERRORS: immediate operand must be in the range [0,15] -@ CHECK-ERRORS-V7: immediate operand must be in the range [0,15] +@ CHECK-ERRORS: operand must be an immediate in the range [0,15] +@ CHECK-ERRORS-V7: operand must be an immediate in the range [0,15] @ CHECK-ERRORS-V8: invalid instruction @ Shifter operand validation for PKH instructions. @@ -263,10 +263,10 @@ ssat r8, #1, r10, lsl fred ssat r8, #1, r10, lsl #fred -@ CHECK-ERRORS: error: immediate operand must be in the range [1,32] +@ CHECK-ERRORS: error: operand must be an immediate in the range [1,32] @ CHECK-ERRORS: ssat r8, #0, r10, lsl #8 @ CHECK-ERRORS: ^ -@ CHECK-ERRORS: error: immediate operand must be in the range [1,32] +@ CHECK-ERRORS: error: operand must be an immediate in the range [1,32] @ CHECK-ERRORS: ssat r8, #33, r10, lsl #8 @ CHECK-ERRORS: ^ @ CHECK-ERRORS: error: 'lsr' shift amount must be in range [0,31] @@ -295,10 +295,10 @@ ssat16 r2, #0, r7 ssat16 r3, #17, r5 -@ CHECK-ERRORS: error: immediate operand must be in the range [1,16] +@ CHECK-ERRORS: error: operand must be an immediate in the range [1,16] @ CHECK-ERRORS: ssat16 r2, #0, r7 @ CHECK-ERRORS: ^ -@ CHECK-ERRORS: error: immediate operand must be in the range [1,16] +@ CHECK-ERRORS: error: operand must be an immediate in the range [1,16] @ CHECK-ERRORS: ssat16 r3, #17, r5 @ CHECK-ERRORS: ^ @@ -313,7 +313,7 @@ @ Out of range immediate on SVC svc #0x1000000 -@ CHECK-ERRORS: error: immediate operand must be in the range [0,0xffffff] +@ CHECK-ERRORS: error: operand must be an immediate in the range [0,0xffffff] @ CHECK-ERRORS: svc #0x1000000 @ CHECK-ERRORS: ^ diff --git a/test/MC/ARM/invalid-hint-arm.s b/test/MC/ARM/invalid-hint-arm.s index 49a2e5c7c59..b1921781aef 100644 --- a/test/MC/ARM/invalid-hint-arm.s +++ b/test/MC/ARM/invalid-hint-arm.s @@ -3,6 +3,6 @@ hint #240 hint #1000 -@ CHECK: error: immediate operand must be in the range [0,239] -@ CHECK: error: immediate operand must be in the range [0,239] +@ CHECK: error: operand must be an immediate in the range [0,239] +@ CHECK: error: operand must be an immediate in the range [0,239] diff --git a/test/MC/ARM/invalid-hint-thumb.s b/test/MC/ARM/invalid-hint-thumb.s index a68a0c6aa05..05a7d1221b3 100644 --- a/test/MC/ARM/invalid-hint-thumb.s +++ b/test/MC/ARM/invalid-hint-thumb.s @@ -6,10 +6,10 @@ hint #1000 @ FIXME: set the subclasses of the operand classes so that we only get one error for each. @ CHECK: error: invalid instruction, any one of the following would fix this: -@ CHECK: note: immediate operand must be in the range [0,239] -@ CHECK: note: immediate operand must be in the range [0,15] +@ CHECK: note: operand must be an immediate in the range [0,239] +@ CHECK: note: operand must be an immediate in the range [0,15] @ CHECK: error: invalid instruction, any one of the following would fix this: -@ CHECK: note: immediate operand must be in the range [0,239] -@ CHECK: note: immediate operand must be in the range [0,15] +@ CHECK: note: operand must be an immediate in the range [0,239] +@ CHECK: note: operand must be an immediate in the range [0,15] diff --git a/test/MC/ARM/lsl-zero-errors.s b/test/MC/ARM/lsl-zero-errors.s index f6cf9aaa2b8..fe5846503c1 100644 --- a/test/MC/ARM/lsl-zero-errors.s +++ b/test/MC/ARM/lsl-zero-errors.s @@ -61,7 +61,7 @@ // CHECK-NONARM-NEXT: mov r0, pc, lsl #0 // CHECK-NONARM: invalid operand for instruction // CHECK-NONARM: invalid operand for instruction -// CHECK-NONARM: immediate operand must be in the range [256,65535] +// CHECK-NONARM: operand must be an immediate in the range [256,65535] // CHECK-NONARM: error: invalid instruction, any one of the following would fix this: // CHECK-NONARM-NEXT: mov pc, pc, lsl #0 // CHECK-NONARM: invalid operand for instruction diff --git a/test/MC/ARM/negative-immediates-thumb1-fail.s b/test/MC/ARM/negative-immediates-thumb1-fail.s index 8b52ff2ef96..bc09bd3e790 100644 --- a/test/MC/ARM/negative-immediates-thumb1-fail.s +++ b/test/MC/ARM/negative-immediates-thumb1-fail.s @@ -6,22 +6,22 @@ ADDs r1, r0, #0xFFFFFFF5 # CHECK: error: invalid instruction, any one of the following would fix this: # CHECK-DAG: note: instruction requires: thumb2 # CHECK-DAG: note: invalid operand for instruction -# CHECK-DAG: note: immediate operand must be in the range [0,7] +# CHECK-DAG: note: operand must be an immediate in the range [0,7] ADDs r0, #0xFFFFFEFF # CHECK: error: invalid instruction, any one of the following would fix this: # CHECK-DAG: note: invalid operand for instruction -# CHECK-DAG: note: immediate operand must be in the range [0,255] +# CHECK-DAG: note: operand must be an immediate in the range [0,255] SUBs r1, r0, #0xFFFFFFF5 # CHECK: error: invalid instruction, any one of the following would fix this: # CHECK-DAG: note: invalid operand for instruction -# CHECK-DAG: note: immediate operand must be in the range [0,7] +# CHECK-DAG: note: operand must be an immediate in the range [0,7] SUBs r0, #0xFFFFFEFF # CHECK: error: invalid instruction, any one of the following would fix this: # CHECK-DAG: note: invalid operand for instruction -# CHECK-DAG: note: immediate operand must be in the range [0,255] +# CHECK-DAG: note: operand must be an immediate in the range [0,255] ORRs r0, r1, #0xFFFFFF00 # CHECK: error: invalid instruction, any one of the following would fix this: diff --git a/test/MC/ARM/t2-modified-immediate-fixup-error2.s b/test/MC/ARM/t2-modified-immediate-fixup-error2.s index 2ec2f7ed4d5..ffed9399f30 100644 --- a/test/MC/ARM/t2-modified-immediate-fixup-error2.s +++ b/test/MC/ARM/t2-modified-immediate-fixup-error2.s @@ -9,10 +9,10 @@ @ CHECK: error: invalid instruction, any one of the following would fix this: @ CHECK: note: instruction requires: arm-mode @ CHECK: note: invalid operand for instruction -@ CHECK: note: immediate operand must be in the range [256,65535] +@ CHECK: note: operand must be an immediate in the range [256,65535] mov r0, :lower16: sym0 @ CHECK: error: invalid instruction, any one of the following would fix this: @ CHECK: note: instruction requires: arm-mode @ CHECK: note: invalid operand for instruction -@ CHECK: note: immediate operand must be in the range [256,65535] +@ CHECK: note: operand must be an immediate in the range [256,65535] .equ sym0, 0x01abcdef diff --git a/test/MC/ARM/thumb-diagnostics.s b/test/MC/ARM/thumb-diagnostics.s index e1045a5e623..91b8a2b276d 100644 --- a/test/MC/ARM/thumb-diagnostics.s +++ b/test/MC/ARM/thumb-diagnostics.s @@ -17,7 +17,7 @@ @ CHECK-ERRORS: note: instruction requires: arm-mode @ CHECK-ERRORS: note: instruction requires: thumb2 @ CHECK-ERRORS: note: invalid operand for instruction -@ CHECK-ERRORS: note: immediate operand must be in the range [0,7] +@ CHECK-ERRORS: note: operand must be an immediate in the range [0,7] @ CHECK-ERRORS: note: no flag-preserving variant of this instruction available @ Instructions which require v6+ for both registers to be low regs. @@ -38,7 +38,7 @@ @ CHECK-ERRORS: error: invalid instruction, any one of the following would fix this: @ CHECK-ERRORS: asrs r2, r3, #33 @ CHECK-ERRORS: ^ -@ CHECK-ERRORS: note: immediate operand must be in the range [1,32] +@ CHECK-ERRORS: note: operand must be an immediate in the range [1,32] @ CHECK-ERRORS: note: too many operands for instruction @ Out of range immediates for BKPT instruction. @@ -48,13 +48,13 @@ @ CHECK-ERRORS: bkpt #256 @ CHECK-ERRORS: ^ @ CHECK-ERRORS: note: instruction requires: arm-mode -@ CHECK-ERRORS: note: immediate operand must be in the range [0,255] +@ CHECK-ERRORS: note: operand must be an immediate in the range [0,255] @ CHECK-ERRORS: note: too many operands for instruction @ CHECK-ERRORS: error: invalid instruction, any one of the following would fix this: @ CHECK-ERRORS: bkpt #-1 @ CHECK-ERRORS: ^ -@ CHECK-ERRORS: note: immediate operand must be in the range [0,255] +@ CHECK-ERRORS: note: operand must be an immediate in the range [0,255] @ CHECK-ERRORS: note: too many operands for instruction @ Out of range immediates for v8 HLT instruction. @@ -67,11 +67,11 @@ @CHECK-ERRORS-V8: hlt #64 @CHECK-ERRORS-V8: ^ @CHECK-ERRORS-V8: note: instruction requires: arm-mode -@CHECK-ERRORS-V8: immediate operand must be in the range [0,63] +@CHECK-ERRORS-V8: operand must be an immediate in the range [0,63] @CHECK-ERRORS: error: invalid instruction @CHECK-ERRORS: hlt #-1 @CHECK-ERRORS: ^ -@CHECK-ERRORS-V8: error: immediate operand must be in the range [0,63] +@CHECK-ERRORS-V8: error: operand must be an immediate in the range [0,63] @CHECK-ERRORS-V8: hlt #-1 @CHECK-ERRORS-V8: ^ @@ -178,12 +178,12 @@ @ CHECK-ERRORS: error: invalid instruction, any one of the following would fix this: @ CHECK-ERRORS: lsls r4, r5, #-1 @ CHECK-ERRORS: ^ -@ CHECK-ERRORS: note: immediate operand must be in the range [0,31] +@ CHECK-ERRORS: note: operand must be an immediate in the range [0,31] @ CHECK-ERRORS: note: too many operands for instruction @ CHECK-ERRORS: error: invalid instruction, any one of the following would fix this: @ CHECK-ERRORS: lsls r4, r5, #32 @ CHECK-ERRORS: ^ -@ CHECK-ERRORS: note: immediate operand must be in the range [0,31] +@ CHECK-ERRORS: note: operand must be an immediate in the range [0,31] @ CHECK-ERRORS: note: too many operands for instruction @ Mismatched source/destination operands for MUL instruction. @@ -219,14 +219,14 @@ @ Out of range immediate for SVC instruction. svc #-1 svc #256 -@ CHECK-ERRORS: error: immediate operand must be in the range [0,255] +@ CHECK-ERRORS: error: operand must be an immediate in the range [0,255] @ CHECK-ERRORS: svc #-1 @ CHECK-ERRORS: ^ @ CHECK-ERRORS: error: invalid instruction, any one of the following would fix this: @ CHECK-ERRORS: svc #256 @ CHECK-ERRORS: ^ @ CHECK-ERRORS: note: instruction requires: arm-mode -@ CHECK-ERRORS: note: immediate operand must be in the range [0,255] +@ CHECK-ERRORS: note: operand must be an immediate in the range [0,255] @ Out of range immediate for ADD SP instructions diff --git a/test/MC/ARM/thumb2-diagnostics.s b/test/MC/ARM/thumb2-diagnostics.s index 9e601b5d799..32a00a75255 100644 --- a/test/MC/ARM/thumb2-diagnostics.s +++ b/test/MC/ARM/thumb2-diagnostics.s @@ -39,14 +39,14 @@ mrc2 p14, #0, r1, c1, c2, #9 mrrc p7, #16, r5, r4, c1 mrrc2 p7, #17, r5, r4, c1 -@ CHECK-ERRORS: immediate operand must be in the range [0,7] -@ CHECK-ERRORS: immediate operand must be in the range [0,7] -@ CHECK-ERRORS-V7: immediate operand must be in the range [0,7] -@ CHECK-ERRORS-V7: immediate operand must be in the range [0,7] +@ CHECK-ERRORS: operand must be an immediate in the range [0,7] +@ CHECK-ERRORS: operand must be an immediate in the range [0,7] +@ CHECK-ERRORS-V7: operand must be an immediate in the range [0,7] +@ CHECK-ERRORS-V7: operand must be an immediate in the range [0,7] @ CHECK-ERRORS-V8: invalid instruction @ CHECK-ERRORS-V8: too many operands for instruction -@ CHECK-ERRORS: immediate operand must be in the range [0,15] -@ CHECK-ERRORS-V7: immediate operand must be in the range [0,15] +@ CHECK-ERRORS: operand must be an immediate in the range [0,15] +@ CHECK-ERRORS-V7: operand must be an immediate in the range [0,15] @ CHECK-ERRORS-V8: invalid instruction isb #-1 diff --git a/test/MC/ARM/udf-arm-diagnostics.s b/test/MC/ARM/udf-arm-diagnostics.s index 71a1e387eeb..514b6d1a946 100644 --- a/test/MC/ARM/udf-arm-diagnostics.s +++ b/test/MC/ARM/udf-arm-diagnostics.s @@ -13,7 +13,7 @@ undefined: udf #65536 -@ CHECK: error: immediate operand must be in the range [0,65535] +@ CHECK: error: operand must be an immediate in the range [0,65535] @ CHECK: udf #65536 @ CHECK: ^ diff --git a/test/MC/ARM/udf-thumb-2-diagnostics.s b/test/MC/ARM/udf-thumb-2-diagnostics.s index e8e7f7859af..b27de51a313 100644 --- a/test/MC/ARM/udf-thumb-2-diagnostics.s +++ b/test/MC/ARM/udf-thumb-2-diagnostics.s @@ -15,13 +15,13 @@ undefined: @ CHECK: error: invalid instruction, any one of the following would fix this: @ CHECK: note: instruction requires: arm-mode -@ CHECK: note: immediate operand must be in the range [0,255] +@ CHECK: note: operand must be an immediate in the range [0,255] @ CHECK: udf #256 @ CHECK: ^ udf.w #65536 -@ CHECK: error: immediate operand must be in the range [0,65535] +@ CHECK: error: operand must be an immediate in the range [0,65535] @ CHECK: udf.w #65536 @ CHECK: ^ diff --git a/test/MC/ARM/udf-thumb-diagnostics.s b/test/MC/ARM/udf-thumb-diagnostics.s index 4d45dfaa1bc..b2ae2a18a26 100644 --- a/test/MC/ARM/udf-thumb-diagnostics.s +++ b/test/MC/ARM/udf-thumb-diagnostics.s @@ -13,7 +13,7 @@ undefined: udf #256 -@ CHECK: error: immediate operand must be in the range [0,255] +@ CHECK: error: operand must be an immediate in the range [0,255] @ CHECK: udf #256 @ CHECK: ^