]> granicus.if.org Git - llvm/commitdiff
[ARM, Asm] Change grammar of immediate operand diagnostics
authorOliver Stannard <oliver.stannard@arm.com>
Wed, 4 Oct 2017 09:18:07 +0000 (09:18 +0000)
committerOliver Stannard <oliver.stannard@arm.com>
Wed, 4 Oct 2017 09:18:07 +0000 (09:18 +0000)
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

13 files changed:
lib/Target/ARM/ARMInstrInfo.td
test/MC/ARM/basic-arm-instructions-v8.1a.s
test/MC/ARM/diagnostics.s
test/MC/ARM/invalid-hint-arm.s
test/MC/ARM/invalid-hint-thumb.s
test/MC/ARM/lsl-zero-errors.s
test/MC/ARM/negative-immediates-thumb1-fail.s
test/MC/ARM/t2-modified-immediate-fixup-error2.s
test/MC/ARM/thumb-diagnostics.s
test/MC/ARM/thumb2-diagnostics.s
test/MC/ARM/udf-arm-diagnostics.s
test/MC/ARM/udf-thumb-2-diagnostics.s
test/MC/ARM/udf-thumb-diagnostics.s

index da34ebdfeeefd448d68a43e2539ffa53236c80e6..af065441ec7da4fb9019114bda83ab49b1d633b0 100644 (file)
@@ -460,13 +460,13 @@ def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
 class ImmAsmOperand<int Low, int High> : 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<int Low, int High> : 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<i32> {
 /// 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<i32>, ImmLeaf<i32, [{
   return Imm >= 0 && Imm <= 0xffffff;
index bd9a16aac18cc342796746d3b63e8b9fe29cc57c..ad766135e33f29ab1b4262d34649732288e97352 100644 (file)
 //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:         ^
 
index 9b24633c61e3231c76379d4076fc5552128d6775..0f697e6b3672fe2ee6aab574604d810c6887ccd2 100644 (file)
@@ -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:              ^
         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:             ^
 
         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
         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:     ^
         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
         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.
         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]
        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:                    ^
 
 
         @ 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:       ^
 
index 49a2e5c7c59fe17d1c173c760c0df6cf9ae459a3..b1921781aef28a0bede7b043655680ea18917f48 100644 (file)
@@ -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]
 
index a68a0c6aa0507f46db8d351d37de157c9730166f..05a7d1221b39cb0ec56facff586d6fd1534531dc 100644 (file)
@@ -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]
 
index f6cf9aaa2b8eb31ecc3abe9081c946a912800729..fe5846503c1a84875cd1d0f774d8dbd3cf331060 100644 (file)
@@ -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
index 8b52ff2ef961d142f28004495ec9d9e9f3df2c50..bc09bd3e790b5dfdc056f331982150919bef078b 100644 (file)
@@ -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:
index 2ec2f7ed4d51ebe91a56a4f0b1d2cafc7cfd8ce4..ffed9399f3090ac505fffeb8710b99f90913b663 100644 (file)
@@ -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
index e1045a5e623face7d7b35405de1e09cc0ddb8820..91b8a2b276d8440994ce0c856f59eadc7ad4e31a 100644 (file)
@@ -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.
 @ 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.
 @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:              ^
 
 @ 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.
 @ 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
index 9e601b5d799eac535e74eb8eade023dc0b0c5ecd..32a00a75255f7ff77b2d88740e11e29f8bca10e1 100644 (file)
         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
index 71a1e387eebbc88d86171ed899e4a9e2f5d7b985..514b6d1a94687b25d70027542133164a0b84cf10 100644 (file)
@@ -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:           ^
 
index e8e7f7859aff86109d0309aec0cb445e2952b4c6..b27de51a313230726f3205f8cc2c48581b5f9ccc 100644 (file)
@@ -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:             ^
 
index 4d45dfaa1bccdda3f62ee3ec97ce3c636c7083cb..b2ae2a18a2610d18a43f8d6371173022bbc61c18 100644 (file)
@@ -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:           ^