Initial implementation of C-source-level &&-idiom recovery
[valgrind.git] / memcheck / tests / vbit-test / vbits.h
blobebeb33ad903e0f67e85313a720d9d789949fb82e
1 /* -*- mode: C; c-basic-offset: 3; -*- */
3 /*
4 This file is part of MemCheck, a heavyweight Valgrind tool for
5 detecting memory errors.
7 Copyright (C) 2012-2017 Florian Krohm
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.
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.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, see <http://www.gnu.org/licenses/>.
22 The GNU General Public License is contained in the file COPYING.
25 #ifndef VBITS_H
26 #define VBITS_H
28 #include <stdint.h>
29 #include <stdio.h>
30 #include <stdbool.h>
32 typedef uint64_t uint128_t[2];
33 typedef uint64_t uint256_t[4];
35 /* A type to represent V-bits */
36 typedef struct {
37 unsigned num_bits;
38 union {
39 uint8_t u1;
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;
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. */
53 typedef union {
54 uint8_t u1;
55 uint8_t u8;
56 uint16_t u16;
57 uint32_t u32;
58 uint64_t u64;
59 uint128_t u128;
60 uint256_t u256;
61 } value_t;
64 void print_vbits(FILE *, vbits_t);
65 vbits_t undefined_vbits(unsigned num_bits);
66 vbits_t undefined_vbits_BxE(unsigned int bits, unsigned int elements,
67 vbits_t v);
68 vbits_t undefined_vbits_BxE_rotate(unsigned int bits, unsigned int elements,
69 vbits_t vbits,
70 value_t value);
71 vbits_t undefined_vbits_128_even_element(unsigned int bits,
72 unsigned int elements, vbits_t v);
73 vbits_t undefined_vbits_64x2_transpose(vbits_t v);
74 vbits_t undefined_vbits_Narrow256_AtoB(unsigned int src_num_bits,
75 unsigned int result_num_bits,
76 vbits_t src1_v, value_t src1_value,
77 vbits_t src2_v, value_t src2_value,
78 bool sataurate);
79 vbits_t defined_vbits(unsigned num_bits);
80 int equal_vbits(vbits_t, vbits_t);
81 vbits_t truncate_vbits(vbits_t, unsigned num_bits);
82 vbits_t left_vbits(vbits_t, unsigned num_bits);
83 vbits_t or_vbits(vbits_t, vbits_t);
84 vbits_t and_vbits(vbits_t, vbits_t);
85 vbits_t concat_vbits(vbits_t, vbits_t);
86 vbits_t upper_vbits(vbits_t);
87 vbits_t sextend_vbits(vbits_t, unsigned num_bits);
88 vbits_t zextend_vbits(vbits_t, unsigned num_bits);
89 vbits_t onehot_vbits(unsigned bitno, unsigned num_bits);
90 vbits_t shl_vbits(vbits_t, unsigned amount);
91 vbits_t shr_vbits(vbits_t, unsigned amount);
92 vbits_t sar_vbits(vbits_t, unsigned amount);
93 int completely_defined_vbits(vbits_t);
94 vbits_t cmpord_vbits(unsigned v1_num_bits, unsigned v2_num_bits);
95 vbits_t cmp_eq_ne_vbits(vbits_t vbits1, vbits_t vbits2,
96 value_t val1, value_t val2);
97 vbits_t int_add_or_sub_vbits(int isAdd,
98 vbits_t vbits1, vbits_t vbits2,
99 value_t val1, value_t val2);
101 #endif // VBITS_H