org.testifyproject.tukaani.xz.simple.SPARC Maven / Gradle / Ivy
/*
* BCJ filter for SPARC 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.testifyproject.tukaani.xz.simple;
public final class SPARC implements SimpleFilter {
private final boolean isEncoder;
private int pos;
public SPARC(boolean isEncoder, int startPos) {
this.isEncoder = isEncoder;
pos = startPos;
}
public int code(byte[] buf, int off, int len) {
int end = off + len - 4;
int i;
for (i = off; i <= end; i += 4) {
if ((buf[i] == 0x40 && (buf[i + 1] & 0xC0) == 0x00)
|| (buf[i] == 0x7F && (buf[i + 1] & 0xC0) == 0xC0)) {
int src = ((buf[i] & 0xFF) << 24)
| ((buf[i + 1] & 0xFF) << 16)
| ((buf[i + 2] & 0xFF) << 8)
| (buf[i + 3] & 0xFF);
src <<= 2;
int org.testifyproject.testifyprojectst;
if (isEncoder)
org.testifyproject.testifyprojectst = src + (pos + i - off);
else
org.testifyproject.testifyprojectst = src - (pos + i - off);
org.testifyproject.testifyprojectst >>>= 2;
org.testifyproject.testifyprojectst = (((0 - ((org.testifyproject.testifyprojectst >>> 22) & 1)) << 22) & 0x3FFFFFFF)
| (org.testifyproject.testifyprojectst & 0x3FFFFF) | 0x40000000;
buf[i] = (byte)(org.testifyproject.testifyprojectst >>> 24);
buf[i + 1] = (byte)(org.testifyproject.testifyprojectst >>> 16);
buf[i + 2] = (byte)(org.testifyproject.testifyprojectst >>> 8);
buf[i + 3] = (byte)org.testifyproject.testifyprojectst;
}
}
i -= off;
pos += i;
return i;
}
}