1/* -*- mode: C; c-basic-offset: 3; -*- */ 2 3/* 4 This file is part of MemCheck, a heavyweight Valgrind tool for 5 detecting memory errors. 6 7 Copyright (C) 2012-2015 Florian Krohm 8 9 This program is free software; you can redistribute it and/or 10 modify it under the terms of the GNU General Public License as 11 published by the Free Software Foundation; either version 2 of the 12 License, or (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, but 15 WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 22 02111-1307, USA. 23 24 The GNU General Public License is contained in the file COPYING. 25*/ 26 27#ifndef VBITS_H 28#define VBITS_H 29 30#include <stdint.h> 31#include <stdio.h> 32 33typedef uint64_t uint128_t[2]; 34typedef uint64_t uint256_t[4]; 35 36/* A type to represent V-bits */ 37typedef struct { 38 unsigned num_bits; 39 union { 40 uint8_t u8; 41 uint16_t u16; 42 uint32_t u32; 43 uint64_t u64; 44 uint128_t u128; 45 uint256_t u256; 46 } bits; 47} vbits_t; 48 49 50/* A type large enough to hold any IRtype'd value. At this point 51 we do not expect to test with specific floating point values. 52 So we don't need to represent them. */ 53typedef union { 54 uint8_t u8; 55 uint16_t u16; 56 uint32_t u32; 57 uint64_t u64; 58 uint128_t u128; 59 uint256_t u256; 60} value_t; 61 62 63void print_vbits(FILE *, vbits_t); 64vbits_t undefined_vbits(unsigned num_bits); 65vbits_t defined_vbits(unsigned num_bits); 66int equal_vbits(vbits_t, vbits_t); 67vbits_t truncate_vbits(vbits_t, unsigned num_bits); 68vbits_t left_vbits(vbits_t, unsigned num_bits); 69vbits_t or_vbits(vbits_t, vbits_t); 70vbits_t and_vbits(vbits_t, vbits_t); 71vbits_t concat_vbits(vbits_t, vbits_t); 72vbits_t upper_vbits(vbits_t); 73vbits_t sextend_vbits(vbits_t, unsigned num_bits); 74vbits_t zextend_vbits(vbits_t, unsigned num_bits); 75vbits_t onehot_vbits(unsigned bitno, unsigned num_bits); 76vbits_t shl_vbits(vbits_t, unsigned amount); 77vbits_t shr_vbits(vbits_t, unsigned amount); 78vbits_t sar_vbits(vbits_t, unsigned amount); 79int completely_defined_vbits(vbits_t); 80vbits_t cmpord_vbits(unsigned v1_num_bits, unsigned v2_num_bits); 81 82#endif // VBITS_H 83