Index: lib/Target/AArch64/AArch64InstrFormats.td =================================================================== --- lib/Target/AArch64/AArch64InstrFormats.td +++ lib/Target/AArch64/AArch64InstrFormats.td @@ -234,6 +234,13 @@ // Operand Definitions. // +class AsmImmRange : AsmOperandClass { + let Name = "Imm" # Low # "_" # High; + let DiagnosticType = "InvalidImm" # Low # "_" # High; + let RenderMethod = "addImmOperands"; + let PredicateMethod = "isImmInRange<" # Low # "," # High # ">"; +} + // ADR[P] instruction labels. def AdrpOperand : AsmOperandClass { let Name = "AdrpLabel"; @@ -287,6 +294,10 @@ let ParserMatchClass = UImm6Operand; } +def uimm16 : Operand, ImmLeaf= 0 && Imm < 65536;}]>{ + let ParserMatchClass = AsmImmRange<0, 65535>; +} + def SImm9Operand : SImmOperand<9>; def simm9 : Operand, ImmLeaf= -256 && Imm < 256; }]> { let ParserMatchClass = SImm9Operand; @@ -447,13 +458,6 @@ let DecoderMethod = "DecodeSImm<4>"; } -class AsmImmRange : AsmOperandClass { - let Name = "Imm" # Low # "_" # High; - let DiagnosticType = "InvalidImm" # Low # "_" # High; - let RenderMethod = "addImmOperands"; - let PredicateMethod = "isImmInRange<" # Low # "," # High # ">"; -} - def Imm1_8Operand : AsmImmRange<1, 8>; def Imm1_16Operand : AsmImmRange<1, 16>; def Imm1_32Operand : AsmImmRange<1, 32>; @@ -708,11 +712,10 @@ } // imm0_65535 predicate - True if the immediate is in the range [0,65535]. -def Imm0_65535Operand : AsmImmRange<0, 65535>; def imm0_65535 : Operand, ImmLeaf { - let ParserMatchClass = Imm0_65535Operand; + let ParserMatchClass = AsmImmRange<0, 65535>; let PrintMethod = "printImmHex"; } @@ -1937,7 +1940,7 @@ //--- def movimm32_imm : Operand { - let ParserMatchClass = Imm0_65535Operand; + let ParserMatchClass = AsmImmRange<0, 65535>; let EncoderMethod = "getMoveWideImmOpValue"; let PrintMethod = "printImm"; } @@ -4084,6 +4087,20 @@ let Predicates = [HasFPARMv8] in { +//--- +// UDF : Permanently UNDEFINED instructions. Format: Opc = 0x0000, 16 bit imm. +//-- +let hasSideEffects = 1, isTrap = 1, mayLoad = 0, mayStore = 0 in { +class UDFType opc, string asm> + : I<(outs), (ins uimm16:$imm), + asm, "\t$imm", "", []>, + Sched<[]> { + bits<16> imm; + let Inst{31-16} = opc; + let Inst{15-0} = imm; +} +} + //--- // Floating point to integer conversion //--- Index: lib/Target/AArch64/AArch64InstrInfo.td =================================================================== --- lib/Target/AArch64/AArch64InstrInfo.td +++ lib/Target/AArch64/AArch64InstrInfo.td @@ -1618,6 +1618,8 @@ def : InstAlias<"dcps2", (DCPS2 0)>; def : InstAlias<"dcps3", (DCPS3 0)>; +def UDF : UDFType<0, "udf">; + //===----------------------------------------------------------------------===// // Load instructions. //===----------------------------------------------------------------------===// Index: test/MC/AArch64/udf.s =================================================================== --- /dev/null +++ test/MC/AArch64/udf.s @@ -0,0 +1,9 @@ +# RUN: llvm-mc -assemble -show-encoding -triple=aarch64- %s | FileCheck %s +# CHECK: .text +# CHECK-NEXT: udf #0 // encoding: [0x00,0x00,0x00,0x00] +# CHECK-NEXT: udf #513 // encoding: [0x01,0x02,0x00,0x00] +# CHECK-NEXT: udf #65535 // encoding: [0xff,0xff,0x00,0x00] +.text +udf 0 +udf 513 +udf 65535 \ No newline at end of file Index: test/MC/AArch64/udf_not.s =================================================================== --- /dev/null +++ test/MC/AArch64/udf_not.s @@ -0,0 +1,7 @@ +# RUN: not llvm-mc -assemble -show-encoding -triple=aarch64- %s 2>&1 | FileCheck %s +udf 65536 +udf -1 +udf -768 +# CHECK:{{.*}} immediate must be an integer in range [0, 65535]. +# CHECK:{{.*}} immediate must be an integer in range [0, 65535]. +# CHECK:{{.*}} immediate must be an integer in range [0, 65535]. \ No newline at end of file Index: test/MC/Disassembler/AArch64/udf.txt =================================================================== --- /dev/null +++ test/MC/Disassembler/AArch64/udf.txt @@ -0,0 +1,18 @@ +# RUN: llvm-mc -arch aarch64 -disassemble -o - %s | FileCheck %s +# RUN: llvm-mc -arch aarch64 -disassemble -o - %s | \ +# RUN: llvm-mc -assemble -filetype=obj -arch aarch64 -o - | \ +# RUN: llvm-objdump -r -d --triple=arm64- - | \ +# RUN: FileCheck %s -check-prefix=OBJ +[0x00,0x00,0x00,0x00] +[0x01,0x02,0x00,0x00] +[0xff,0xff,0x00,0x00] +# CHECK: .text +# CHECK-NEXT: udf #0 +# CHECK-NEXT: udf #513 +# CHECK-NEXT: udf #65535 + +#OBJ: Disassembly of section .text: +#OBJ-NEXT: $x.0: +#OBJ-NEXT: 0: 00 00 00 00 udf #0 +#OBJ-NEXT: 4: 01 02 00 00 udf #513 +#OBJ-NEXT: 8: ff ff 00 00 udf #65535 \ No newline at end of file