1 #include "ARMBaseInstrInfo.h"
2 #include "ARMSubtarget.h"
3 #include "ARMTargetMachine.h"
4 #include "llvm/Support/TargetRegistry.h"
5 #include "llvm/Support/TargetSelect.h"
6 #include "llvm/Target/TargetMachine.h"
7 #include "llvm/Target/TargetOptions.h"
9 #include "gtest/gtest.h"
13 // Test for instructions that aren't immediately obviously valid within a
14 // tail-predicated loop. This should be marked up in their tablegen
15 // descriptions. Currently the horizontal vector operations are tagged.
16 // TODO Add instructions that perform:
21 TEST(MachineInstrInvalidTailPredication
, IsCorrect
) {
22 LLVMInitializeARMTargetInfo();
23 LLVMInitializeARMTarget();
24 LLVMInitializeARMTargetMC();
26 auto TT(Triple::normalize("thumbv8.1m.main-arm-none-eabi"));
28 const Target
*T
= TargetRegistry::lookupTarget(TT
, Error
);
34 TargetOptions Options
;
35 auto TM
= std::unique_ptr
<LLVMTargetMachine
>(
36 static_cast<LLVMTargetMachine
*>(
37 T
->createTargetMachine(TT
, "generic", "", Options
, None
, None
,
38 CodeGenOpt::Default
)));
39 auto MII
= TM
->getMCInstrInfo();
43 auto IsInvalidTPOpcode
= [](unsigned Opcode
) {
57 case MVE_VADDVs8no_acc
:
58 case MVE_VADDVs16no_acc
:
59 case MVE_VADDVs32no_acc
:
60 case MVE_VADDVu8no_acc
:
61 case MVE_VADDVu16no_acc
:
62 case MVE_VADDVu32no_acc
:
63 case MVE_VADDLVs32no_acc
:
64 case MVE_VADDLVu32no_acc
:
65 case MVE_VADDLVs32acc
:
66 case MVE_VADDLVu32acc
:
73 case MVE_VMLADAVaxs16
:
74 case MVE_VMLADAVaxs32
:
85 case MVE_VMLALDAVas16
:
86 case MVE_VMLALDAVas32
:
87 case MVE_VMLALDAVau16
:
88 case MVE_VMLALDAVau32
:
89 case MVE_VMLALDAVaxs16
:
90 case MVE_VMLALDAVaxs32
:
95 case MVE_VMLALDAVxs16
:
96 case MVE_VMLALDAVxs32
:
100 case MVE_VMLSDAVaxs16
:
101 case MVE_VMLSDAVaxs32
:
102 case MVE_VMLSDAVaxs8
:
106 case MVE_VMLSDAVxs16
:
107 case MVE_VMLSDAVxs32
:
109 case MVE_VMLSLDAVas16
:
110 case MVE_VMLSLDAVas32
:
111 case MVE_VMLSLDAVaxs16
:
112 case MVE_VMLSLDAVaxs32
:
113 case MVE_VMLSLDAVs16
:
114 case MVE_VMLSLDAVs32
:
115 case MVE_VMLSLDAVxs16
:
116 case MVE_VMLSLDAVxs32
:
117 case MVE_VRMLALDAVHas32
:
118 case MVE_VRMLALDAVHau32
:
119 case MVE_VRMLALDAVHaxs32
:
120 case MVE_VRMLALDAVHs32
:
121 case MVE_VRMLALDAVHu32
:
122 case MVE_VRMLALDAVHxs32
:
123 case MVE_VRMLSLDAVHas32
:
124 case MVE_VRMLSLDAVHaxs32
:
125 case MVE_VRMLSLDAVHs32
:
126 case MVE_VRMLSLDAVHxs32
:
131 case MVE_VMAXNMAVf16
:
132 case MVE_VMINNMAVf16
:
133 case MVE_VMAXNMAVf32
:
134 case MVE_VMINNMAVf32
:
159 for (unsigned i
= 0; i
< ARM::INSTRUCTION_LIST_END
; ++i
) {
160 uint64_t Flags
= MII
->get(i
).TSFlags
;
161 bool Invalid
= (Flags
& ARMII::InvalidForTailPredication
) != 0;
162 ASSERT_EQ(IsInvalidTPOpcode(i
), Invalid
)
164 << ": mismatched expectation for tail-predicated safety\n";