All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.tukaani.xz.simple.IA64 Maven / Gradle / Ivy
/*
* BCJ filter for Itanium (IA-64) instructions
*
* Authors: Lasse Collin
* Igor Pavlov
*
* This file has been put into the public domain.
* You can do whatever you want with this file.
*/
package org.tukaani.xz.simple;
public final class IA64 implements SimpleFilter {
private static final int[] BRANCH_TABLE = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
4, 4, 6, 6, 0, 0, 7, 7,
4, 4, 0, 0, 4, 4, 0, 0 };
private final boolean isEncoder;
private int pos;
public IA64(boolean isEncoder, int startPos) {
this.isEncoder = isEncoder;
pos = startPos;
}
public int code(byte[] buf, int off, int len) {
int end = off + len - 16;
int i;
for (i = off; i <= end; i += 16) {
int instrTemplate = buf[i] & 0x1F;
int mask = BRANCH_TABLE[instrTemplate];
for (int slot = 0, bitPos = 5; slot < 3; ++slot, bitPos += 41) {
if (((mask >>> slot) & 1) == 0)
continue;
int bytePos = bitPos >>> 3;
int bitRes = bitPos & 7;
long instr = 0;
for (int j = 0; j < 6; ++j)
instr |= (buf[i + bytePos + j] & 0xFFL) << (8 * j);
long instrNorm = instr >>> bitRes;
if (((instrNorm >>> 37) & 0x0F) != 0x05
|| ((instrNorm >>> 9) & 0x07) != 0x00)
continue;
int src = (int)((instrNorm >>> 13) & 0x0FFFFF);
src |= ((int)(instrNorm >>> 36) & 1) << 20;
src <<= 4;
int dest;
if (isEncoder)
dest = src + (pos + i - off);
else
dest = src - (pos + i - off);
dest >>>= 4;
instrNorm &= ~(0x8FFFFFL << 13);
instrNorm |= (dest & 0x0FFFFFL) << 13;
instrNorm |= (dest & 0x100000L) << (36 - 20);
instr &= (1 << bitRes) - 1;
instr |= instrNorm << bitRes;
for (int j = 0; j < 6; ++j)
buf[i + bytePos + j] = (byte)(instr >>> (8 * j));
}
}
i -= off;
pos += i;
return i;
}
}