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