llvm.org GIT mirror llvm / b161955
Make ARM hint ranges consistent, and add tests for these ranges git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193238 91177308-0d34-0410-b5e6-96231b3b80d8 Artyom Skrobov 6 years ago
9 changed file(s) with 63 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
676676 let ParserMatchClass = Imm0_63AsmOperand;
677677 }
678678
679 /// imm0_239 predicate - Immediate in the range [0,239].
680 def Imm0_239AsmOperand : ImmAsmOperand {
681 let Name = "Imm0_239";
682 let DiagnosticType = "ImmRange0_239";
683 }
684 def imm0_239 : Operand, ImmLeaf= 0 && Imm < 240; }]> {
685 let ParserMatchClass = Imm0_239AsmOperand;
686 }
687
679688 /// imm0_255 predicate - Immediate in the range [0,255].
680689 def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
681690 def imm0_255 : Operand, ImmLeaf= 0 && Imm < 256; }]> {
16691678 [(ARMcallseq_start timm:$amt)]>;
16701679 }
16711680
1672 def HINT : AI<(outs), (ins imm0_255:$imm), MiscFrm, NoItinerary,
1681 def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary,
16731682 "hint", "\t$imm", []>, Requires<[IsARM, HasV6]> {
16741683 bits<8> imm;
16751684 let Inst{27-8} = 0b00110010000011110000;
279279 let Predicates = [IsThumb, HasV6M];
280280 }
281281
282 def : tHintAlias<"hint$p $imm", (tHINT imm0_15:$imm, pred:$p)>;
283282 def : tHintAlias<"nop$p", (tHINT 0, pred:$p)>; // A8.6.110
284283 def : tHintAlias<"yield$p", (tHINT 1, pred:$p)>; // A8.6.410
285284 def : tHintAlias<"wfe$p", (tHINT 2, pred:$p)>; // A8.6.408
36523652
36533653 // A6.3.4 Branches and miscellaneous control
36543654 // Table A6-14 Change Processor State, and hint instructions
3655 def t2HINT : T2I<(outs), (ins imm0_255:$imm), NoItinerary, "hint.w", "\t$imm",[]> {
3656 bits<3> imm;
3655 def t2HINT : T2I<(outs), (ins imm0_239:$imm), NoItinerary, "hint", ".w\t$imm",[]> {
3656 bits<8> imm;
36573657 let Inst{31-3} = 0b11110011101011111000000000000;
3658 let Inst{2-0} = imm;
3659 }
3660
3661 def : t2InstAlias<"hint$p.w $imm", (t2HINT imm0_255:$imm, pred:$p)>;
3658 let Inst{7-0} = imm;
3659 }
3660
3661 def : t2InstAlias<"hint$p $imm", (t2HINT imm0_239:$imm, pred:$p)>;
36623662 def : t2InstAlias<"nop$p.w", (t2HINT 0, pred:$p)>;
36633663 def : t2InstAlias<"yield$p.w", (t2HINT 1, pred:$p)>;
36643664 def : t2InstAlias<"wfe$p.w", (t2HINT 2, pred:$p)>;
702702 // explicitly exclude zero. we want that to use the normal 0_508 version.
703703 return ((Value & 3) == 0) && Value > 0 && Value <= 508;
704704 }
705 bool isImm0_239() const {
706 if (!isImm()) return false;
707 const MCConstantExpr *CE = dyn_cast(getImm());
708 if (!CE) return false;
709 int64_t Value = CE->getValue();
710 return Value >= 0 && Value < 240;
711 }
705712 bool isImm0_255() const {
706713 if (!isImm()) return false;
707714 const MCConstantExpr *CE = dyn_cast(getImm());
77217728 if (ErrorLoc == SMLoc()) ErrorLoc = IDLoc;
77227729 return Error(ErrorLoc, "immediate operand must be in the range [0,15]");
77237730 }
7731 case Match_ImmRange0_239: {
7732 SMLoc ErrorLoc = ((ARMOperand*)Operands[ErrorInfo])->getStartLoc();
7733 if (ErrorLoc == SMLoc()) ErrorLoc = IDLoc;
7734 return Error(ErrorLoc, "immediate operand must be in the range [0,239]");
7735 }
77247736 }
77257737
77267738 llvm_unreachable("Implement any new match types added!");
29272927 hint #2
29282928 hint #1
29292929 hint #0
2930 hint #255
2930 hintgt #239
29312931
29322932 @ CHECK: wfe @ encoding: [0x02,0xf0,0x20,0xe3]
29332933 @ CHECK: wfehi @ encoding: [0x02,0xf0,0x20,0x83]
29402940 @ CHECK: wfe @ encoding: [0x02,0xf0,0x20,0xe3]
29412941 @ CHECK: yield @ encoding: [0x01,0xf0,0x20,0xe3]
29422942 @ CHECK: nop @ encoding: [0x00,0xf0,0x20,0xe3]
2943 @ CHECK: hint #255 @ encoding: [0xff,0xf0,0x20,0xe3]
2943 @ CHECK: hintgt #239 @ encoding: [0xef,0xf0,0x20,0xc3]
36023602 hint #1
36033603 hint #0
36043604
3605 itet lt
3606 hintlt #15
3607 hintge #16
3608 hintlt #239
3609
36053610 @ CHECK: wfe @ encoding: [0x20,0xbf]
36063611 @ CHECK: wfi @ encoding: [0x30,0xbf]
36073612 @ CHECK: yield @ encoding: [0x10,0xbf]
36203625 @ CHECK: yield @ encoding: [0x10,0xbf]
36213626 @ CHECK: nop @ encoding: [0x00,0xbf]
36223627
3628 @ CHECK: itet lt @ encoding: [0xb6,0xbf]
3629 @ CHECK: hintlt #15 @ encoding: [0xf0,0xbf]
3630 @ CHECK: hintge.w #16 @ encoding: [0xaf,0xf3,0x10,0x80]
3631 @ CHECK: hintlt.w #239 @ encoding: [0xaf,0xf3,0xef,0x80]
3632
36233633 @------------------------------------------------------------------------------
36243634 @ Unallocated wide/narrow hints
36253635 @------------------------------------------------------------------------------
0 @ RUN: not llvm-mc -triple=armv7-apple-darwin -mcpu=cortex-a8 < %s 2>&1 | FileCheck %s
1
2 hint #240
3 hint #1000
4
5 @ CHECK: error: immediate operand must be in the range [0,239]
6 @ CHECK: error: immediate operand must be in the range [0,239]
7
0 @ RUN: not llvm-mc -triple=thumbv7-apple-darwin -mcpu=cortex-a8 < %s 2>&1 | FileCheck %s
1
2 hint #240
3 hint #1000
4
5 @ CHECK: error: immediate operand must be in the range [0,239]
6 @ CHECK: error: immediate operand must be in the range [0,239]
7
27092709 #------------------------------------------------------------------------------
27102710 # Unallocated hints (They execute as NOPs, but software must not use them.)
27112711 #------------------------------------------------------------------------------
2712
2713 [0x60 0xbf]
27142712 # CHECK: hint #6
2715
2713 # CHECK: hint.w #6
2714 # CHECK: hint.w #102
2715
2716 0x60 0xbf
2717 0xaf 0xf3 0x06 0x80
2718 0xaf 0xf3 0x66 0x80
2719