Debian Codegraph @

visa/iga/IGALibrary/IR/ImmVal.hpp

raw
1 /*========================== begin_copyright_notice ============================
2
3 Copyright (C) 2017-2021 Intel Corporation
4
5 SPDX-License-Identifier: MIT
6
7 ============================= end_copyright_notice ===========================*/
8
9 #ifndef _IGA_IMMVAL_HPP_
10 #define _IGA_IMMVAL_HPP_
11
12 #include <stdint.h>
13
14 namespace iga {
15 struct ImmVal {
16 enum class Kind {
17 UNDEF,
18 F16,
19 F32,
20 F64,
21
22 S8,
23 S16,
24 S32,
25 S64,
26
27 U8,
28 U16,
29 U32,
30 U64
31 };
32
33 union {
34 uint16_t f16;
35 float f32;
36 double f64;
37
38 int8_t s8;
39 int16_t s16;
40 int32_t s32;
41 int64_t s64;
42
43 uint8_t u8;
44 uint16_t u16;
45 uint32_t u32;
46 uint64_t u64 = 0;
47 };
48 Kind kind = Kind::UNDEF;
49
50 bool isS64() const { return kind == Kind::S64; }
51 bool isU64() const { return kind == Kind::U64; }
52 bool isI64() const { return isS64() || isU64(); }
53
54 ImmVal &operator=(uint8_t x);
55 ImmVal &operator=(int8_t x);
56 ImmVal &operator=(uint16_t x);
57 ImmVal &operator=(int16_t x);
58 ImmVal &operator=(uint32_t x);
59 ImmVal &operator=(int32_t x);
60 ImmVal &operator=(uint64_t x);
61 ImmVal &operator=(int64_t x);
62 ImmVal &operator=(float x);
63 ImmVal &operator=(double x);
64
65 void Abs();
66 void Negate();
67
68 void reset() { u64 = 0; }
69 }; // class ImmVal
70 } // namespace iga
71 #endif // _IGA_IMMVAL_HPP_