src/hotspot/cpu/aarch64/immediate_aarch64.cpp
changeset 57565 01bca26734bb
parent 47216 71c04702a3d5
equal deleted inserted replaced
57564:0a8436eda2fa 57565:01bca26734bb
    21  * questions.
    21  * questions.
    22  *
    22  *
    23  */
    23  */
    24 
    24 
    25 #include <stdlib.h>
    25 #include <stdlib.h>
    26 #include "decode_aarch64.hpp"
       
    27 #include "immediate_aarch64.hpp"
    26 #include "immediate_aarch64.hpp"
    28 
    27 
    29 // there are at most 2^13 possible logical immediate encodings
    28 // there are at most 2^13 possible logical immediate encodings
    30 // however, some combinations of immr and imms are invalid
    29 // however, some combinations of immr and imms are invalid
    31 static const unsigned  LI_TABLE_SIZE = (1 << 13);
    30 static const unsigned  LI_TABLE_SIZE = (1 << 13);
    67 static inline u_int64_t ones(int N)
    66 static inline u_int64_t ones(int N)
    68 {
    67 {
    69   return (N == 64 ? (u_int64_t)-1UL : ((1UL << N) - 1));
    68   return (N == 64 ? (u_int64_t)-1UL : ((1UL << N) - 1));
    70 }
    69 }
    71 
    70 
       
    71 /*
       
    72  * bit twiddling helpers for instruction decode
       
    73  */
       
    74 
       
    75 // 32 bit mask with bits [hi,...,lo] set
       
    76 static inline u_int32_t mask32(int hi = 31, int lo = 0)
       
    77 {
       
    78   int nbits = (hi + 1) - lo;
       
    79   return ((1 << nbits) - 1) << lo;
       
    80 }
       
    81 
       
    82 static inline u_int64_t mask64(int hi = 63, int lo = 0)
       
    83 {
       
    84   int nbits = (hi + 1) - lo;
       
    85   return ((1L << nbits) - 1) << lo;
       
    86 }
       
    87 
       
    88 // pick bits [hi,...,lo] from val
       
    89 static inline u_int32_t pick32(u_int32_t val, int hi = 31, int lo = 0)
       
    90 {
       
    91   return (val & mask32(hi, lo));
       
    92 }
       
    93 
       
    94 // pick bits [hi,...,lo] from val
       
    95 static inline u_int64_t pick64(u_int64_t val, int hi = 31, int lo = 0)
       
    96 {
       
    97   return (val & mask64(hi, lo));
       
    98 }
       
    99 
       
   100 // mask [hi,lo] and shift down to start at bit 0
       
   101 static inline u_int32_t pickbits32(u_int32_t val, int hi = 31, int lo = 0)
       
   102 {
       
   103   return (pick32(val, hi, lo) >> lo);
       
   104 }
       
   105 
       
   106 // mask [hi,lo] and shift down to start at bit 0
       
   107 static inline u_int64_t pickbits64(u_int64_t val, int hi = 63, int lo = 0)
       
   108 {
       
   109   return (pick64(val, hi, lo) >> lo);
       
   110 }
       
   111 
    72 // result<0> to val<N>
   112 // result<0> to val<N>
    73 static inline u_int64_t pickbit(u_int64_t val, int N)
   113 static inline u_int64_t pickbit(u_int64_t val, int N)
    74 {
   114 {
    75   return pickbits64(val, N, N);
   115   return pickbits64(val, N, N);
    76 }
   116 }
    77 
   117 
       
   118 static inline u_int32_t uimm(u_int32_t val, int hi, int lo)
       
   119 {
       
   120   return pickbits32(val, hi, lo);
       
   121 }
    78 
   122 
    79 // SPEC bits(M*N) Replicate(bits(M) x, integer N);
   123 // SPEC bits(M*N) Replicate(bits(M) x, integer N);
    80 // this is just an educated guess
   124 // this is just an educated guess
    81 
   125 
    82 u_int64_t replicate(u_int64_t bits, int nbits, int count)
   126 u_int64_t replicate(u_int64_t bits, int nbits, int count)