llvm.org GIT mirror llvm / c5db03f
[ARM] Allow automatically deducing the thumb instruction size for .inst This matches GAS, that allows unsuffixed .inst for thumb. Differential Revision: https://reviews.llvm.org/D49937 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338357 91177308-0d34-0410-b5e6-96231b3b80d8 Martin Storsjo 2 years ago
3 changed file(s) with 31 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
1001110011 case 'w':
1001210012 break;
1001310013 default:
10014 return Error(Loc, "cannot determine Thumb instruction size, "
10015 "use inst.n/inst.w instead");
10014 Width = 0;
10015 break;
1001610016 }
1001710017 } else {
1001810018 if (Suffix)
1002810028 return Error(Loc, "expected constant expression");
1002910029 }
1003010030
10031 char CurSuffix = Suffix;
1003110032 switch (Width) {
1003210033 case 2:
1003310034 if (Value->getValue() > 0xffff)
1003810039 return Error(Loc, StringRef(Suffix ? "inst.w" : "inst") +
1003910040 " operand is too big");
1004010041 break;
10042 case 0:
10043 // Thumb mode, no width indicated. Guess from the opcode, if possible.
10044 if (Value->getValue() < 0xe800)
10045 CurSuffix = 'n';
10046 else if (Value->getValue() >= 0xe8000000)
10047 CurSuffix = 'w';
10048 else
10049 return Error(Loc, "cannot determine Thumb instruction size, "
10050 "use inst.n/inst.w instead");
10051 break;
1004110052 default:
1004210053 llvm_unreachable("only supported widths are 2 and 4");
1004310054 }
1004410055
10045 getTargetStreamer().emitInst(Value->getValue(), Suffix);
10056 getTargetStreamer().emitInst(Value->getValue(), CurSuffix);
1004610057 return false;
1004710058 };
1004810059
0 @ RUN: llvm-mc %s -triple armv7-linux-gnueabi -filetype asm -o - \
1 @ RUN: | FileCheck %s
2 @ RUN: llvm-mc %s -triple armebv7-linux-gnueabi -filetype asm -o - \
3 @ RUN: | FileCheck %s
4
5 .syntax unified
6 .thumb
7
8 .align 2
9 .global inst_n
10 .type inst_n,%function
11 inst_n:
12 @ bx lr, mov.w r0, #42
13 .inst 0x4770, 0xf04f002a
14 @ CHECK: .inst.n 0x4770
15 @ CHECK: .inst.w 0xf04f002a
77 .global suffixes_required_in_thumb
88 .type suffixes_required_in_thumb,%function
99 suffixes_required_in_thumb:
10 .inst 0x0000
10 .inst 0xff00
1111 @ CHECK-ERROR: cannot determine Thumb instruction size, use inst.n/inst.w instead
1212