1 /*
   2  * Copyright (c) 2013, Red Hat Inc.
   3  * All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  */
  21 
  22 #ifndef _IMMEDIATE_H
  23 #define _IMMEDIATE_H
  24 
  25 #include <sys/types.h>
  26 
  27 /*
  28  * functions to map backwards and forwards between logical or floating
  29  * point immediates and their corresponding encodings. the mapping
  30  * from encoding to immediate is required by the simulator. the reverse
  31  * mapping is required by the OpenJDK assembler.
  32  *
  33  * a logical immediate value supplied to or returned from a map lookup
  34  * is always 64 bits. this is sufficient for looking up 32 bit
  35  * immediates or their encodings since a 32 bit immediate has the same
  36  * encoding as the 64 bit immediate produced by concatenating the
  37  * immediate with itself.
  38  *
  39  * a logical immediate encoding is 13 bits N:immr:imms (3 fields of
  40  * widths 1:6:6 -- see the arm spec). they appear as bits [22:10] of a
  41  * logical immediate instruction. encodings are supplied and returned
  42  * as 32 bit values. if a given 13 bit immediate has no corresponding
  43  * encoding then a map lookup will return 0xffffffff.
  44  */
  45 
  46 u_int64_t logical_immediate_for_encoding(u_int32_t encoding);
  47 u_int32_t encoding_for_logical_immediate(u_int64_t immediate);
  48 u_int64_t fp_immediate_for_encoding(u_int32_t imm8, int is_dp);
  49 u_int32_t encoding_for_fp_immediate(float immediate);
  50 
  51 #endif // _IMMEDIATE_H