[x86] Add assembly parser bounds checking to the immediate value for cmpss/cmpsd...
[opencl/llvm.git] / lib / Target / X86 / AsmParser / X86AsmParserCommon.h
1 //===-- X86AsmParserCommon.h - Common functions for X86AsmParser ---------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_LIB_TARGET_X86_ASMPARSER_X86ASMPARSERCOMMON_H
11 #define LLVM_LIB_TARGET_X86_ASMPARSER_X86ASMPARSERCOMMON_H
13 namespace llvm {
15 inline bool isImmSExti16i8Value(uint64_t Value) {
16   return ((                                  Value <= 0x000000000000007FULL)||
17           (0x000000000000FF80ULL <= Value && Value <= 0x000000000000FFFFULL)||
18           (0xFFFFFFFFFFFFFF80ULL <= Value && Value <= 0xFFFFFFFFFFFFFFFFULL));
19 }
21 inline bool isImmSExti32i8Value(uint64_t Value) {
22   return ((                                  Value <= 0x000000000000007FULL)||
23           (0x00000000FFFFFF80ULL <= Value && Value <= 0x00000000FFFFFFFFULL)||
24           (0xFFFFFFFFFFFFFF80ULL <= Value && Value <= 0xFFFFFFFFFFFFFFFFULL));
25 }
27 inline bool isImmSExti64i8Value(uint64_t Value) {
28   return ((                                  Value <= 0x000000000000007FULL)||
29           (0xFFFFFFFFFFFFFF80ULL <= Value && Value <= 0xFFFFFFFFFFFFFFFFULL));
30 }
32 inline bool isImmSExti64i32Value(uint64_t Value) {
33   return ((                                  Value <= 0x000000007FFFFFFFULL)||
34           (0xFFFFFFFF80000000ULL <= Value && Value <= 0xFFFFFFFFFFFFFFFFULL));
35 }
37 inline bool isImmUnsignedi8Value(uint64_t Value) {
38   return ((                                  Value <= 0x00000000000000FFULL)||
39           (0xFFFFFFFFFFFFFF80ULL <= Value && Value <= 0xFFFFFFFFFFFFFFFFULL));
40 }
42 } // End of namespace llvm
44 #endif