llvm.org GIT mirror llvm / efa951c
[X86] Simplify immediate range checking code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249979 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 5 years ago
2 changed file(s) with 13 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
1212 namespace llvm {
1313
1414 inline bool isImmSExti16i8Value(uint64_t Value) {
15 return (( Value <= 0x000000000000007FULL)||
16 (0x000000000000FF80ULL <= Value && Value <= 0x000000000000FFFFULL)||
17 (0xFFFFFFFFFFFFFF80ULL <= Value && Value <= 0xFFFFFFFFFFFFFFFFULL));
15 return isInt<8>(Value) ||
16 (isUInt<16>(Value) && isInt<8>(static_cast(Value)));
1817 }
1918
2019 inline bool isImmSExti32i8Value(uint64_t Value) {
21 return (( Value <= 0x000000000000007FULL)||
22 (0x00000000FFFFFF80ULL <= Value && Value <= 0x00000000FFFFFFFFULL)||
23 (0xFFFFFFFFFFFFFF80ULL <= Value && Value <= 0xFFFFFFFFFFFFFFFFULL));
20 return isInt<8>(Value) ||
21 (isUInt<32>(Value) && isInt<8>(static_cast(Value)));
2422 }
2523
2624 inline bool isImmSExti64i8Value(uint64_t Value) {
27 return (( Value <= 0x000000000000007FULL)||
28 (0xFFFFFFFFFFFFFF80ULL <= Value && Value <= 0xFFFFFFFFFFFFFFFFULL));
25 return isInt<8>(Value);
2926 }
3027
3128 inline bool isImmSExti64i32Value(uint64_t Value) {
32 return (( Value <= 0x000000007FFFFFFFULL)||
33 (0xFFFFFFFF80000000ULL <= Value && Value <= 0xFFFFFFFFFFFFFFFFULL));
29 return isInt<32>(Value);
3430 }
3531
3632 inline bool isImmUnsignedi8Value(uint64_t Value) {
37 return (( Value <= 0x00000000000000FFULL)||
38 (0xFFFFFFFFFFFFFF80ULL <= Value && Value <= 0xFFFFFFFFFFFFFFFFULL));
33 return isUInt<8>(Value) || isInt<8>(Value);
3934 }
4035
4136 } // End of namespace llvm
866866 }]>;
867867
868868
869 def i16immSExt8 : ImmLeaf;
870 def i32immSExt8 : ImmLeaf;
871 def i64immSExt8 : ImmLeaf; }]>;
869 def i16immSExt8 : ImmLeaf(Imm); }]>;
870 def i32immSExt8 : ImmLeaf(Imm); }]>;
871 def i64immSExt8 : ImmLeaf(Imm); }]>;
872872
873873 // If we have multiple users of an immediate, it's much smaller to reuse
874874 // the register, rather than encode the immediate in every instruction.
905905 }]>;
906906
907907
908 def i64immSExt32 : ImmLeafImm == (int32_t)Imm; }]>;
908 def i64immSExt32 : ImmLeafisInt<32>(Imm); }]>;
909909
910910
911911 // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit
912912 // unsigned field.
913 def i64immZExt32 : ImmLeaf(uint64_t)Imm == (uint32_t)Imm; }]>;
913 def i64immZExt32 : ImmLeafisUInt<32>(Imm); }]>;
914914
915915 def i64immZExt32SExt8 : ImmLeaf
916 return (uint64_t)Imm == (uint32_t)Imm && (int32_t)Imm == (int8_t)Imm;
916 return isUInt<32>(Imm) && isInt<8>(static_cast(Imm));
917917 }]>;
918918
919919 // Helper fragments for loads.