Home | History | Annotate | Download | only in vbit-test
      1 /* -*- mode: C; c-basic-offset: 3; -*- */
      2 
      3 #ifndef VBITS_H
      4 #define VBITS_H
      5 
      6 #include <stdint.h>
      7 #include <stdio.h>
      8 
      9 typedef uint64_t uint128_t[2];
     10 typedef uint64_t uint256_t[4];
     11 
     12 /* A type to represent V-bits */
     13 typedef struct {
     14    unsigned num_bits;
     15    union {
     16       uint8_t   u8;
     17       uint16_t  u16;
     18       uint32_t  u32;
     19       uint64_t  u64;
     20       uint128_t u128;
     21       uint256_t u256;
     22    } bits;
     23 } vbits_t;
     24 
     25 
     26 /* A type large enough to hold any IRtype'd value. At this point
     27    we do not expect to test with specific floating point values.
     28    So we don't need to represent them. */
     29 typedef union {
     30    uint8_t   u8;
     31    uint16_t  u16;
     32    uint32_t  u32;
     33    uint64_t  u64;
     34    uint128_t u128;
     35    uint256_t u256;
     36 } value_t;
     37 
     38 
     39 void    print_vbits(FILE *, vbits_t);
     40 vbits_t undefined_vbits(unsigned num_bits);
     41 vbits_t defined_vbits(unsigned num_bits);
     42 int     equal_vbits(vbits_t, vbits_t);
     43 vbits_t truncate_vbits(vbits_t, unsigned num_bits);
     44 vbits_t left_vbits(vbits_t, unsigned num_bits);
     45 vbits_t or_vbits(vbits_t, vbits_t);
     46 vbits_t and_vbits(vbits_t, vbits_t);
     47 vbits_t concat_vbits(vbits_t, vbits_t);
     48 vbits_t upper_vbits(vbits_t);
     49 vbits_t sextend_vbits(vbits_t, unsigned num_bits);
     50 vbits_t zextend_vbits(vbits_t, unsigned num_bits);
     51 vbits_t onehot_vbits(unsigned bitno, unsigned num_bits);
     52 vbits_t shl_vbits(vbits_t, unsigned amount);
     53 vbits_t shr_vbits(vbits_t, unsigned amount);
     54 vbits_t sar_vbits(vbits_t, unsigned amount);
     55 int     completely_defined_vbits(vbits_t);
     56 vbits_t cmpord_vbits(unsigned v1_num_bits, unsigned v2_num_bits);
     57 
     58 #endif // VBITS_H
     59