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 { 16 struct ImmVal { 17 enum class Kind { 18 UNDEF, 19 F16, 20 F32, 21 F64, 22 23 S8, 24 S16, 25 S32, 26 S64, 27 28 U8, 29 U16, 30 U32, 31 U64 32 }; 33 34 union { 35 // TODO: may be able to reduce to 32-bits and 64-bits 36 uint16_t f16; 37 float f32; 38 double f64; 39 40 int8_t s8; 41 int16_t s16; 42 int32_t s32; 43 int64_t s64; 44 45 uint8_t u8; 46 uint16_t u16; 47 uint32_t u32; 48 uint64_t u64 = 0; 49 }; 50 Kind kind = Kind::UNDEF; 51 isS64iga::ImmVal52 bool isS64() const {return kind == Kind::S64;} isU64iga::ImmVal53 bool isU64() const {return kind == Kind::U64;} isI64iga::ImmVal54 bool isI64() const {return isS64() || isU64();} 55 56 ImmVal& operator=(uint8_t x); 57 ImmVal& operator=(int8_t x); 58 ImmVal& operator=(uint16_t x); 59 ImmVal& operator=(int16_t x); 60 ImmVal& operator=(uint32_t x); 61 ImmVal& operator=(int32_t x); 62 ImmVal& operator=(uint64_t x); 63 ImmVal& operator=(int64_t x); 64 ImmVal& operator=(float x); 65 ImmVal& operator=(double x); 66 67 void Abs(); 68 void Negate(); 69 }; // class ImmVal 70 } // namespace iga 71 #endif // _IGA_IMMVAL_HPP_ 72