Skip to content

Commit

Permalink
Merge with master.
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhaeubl committed Jul 6, 2022
2 parents 4b7a7ca + c2af925 commit a889540
Show file tree
Hide file tree
Showing 113 changed files with 3,606 additions and 3,099 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ jobs:
cat common.json |
jq -r '.deps.common.packages | to_entries[] | select(.key | startswith("pip:")) | (.key | split(":")[1]) + .value' |
xargs sudo pip install
${MX_PYTHON} -m pip install jsonschema==4.6.1
- name: Build GraalVM and run gate
env: ${{ matrix.env }}
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
package org.graalvm.compiler.asm.amd64;

import org.graalvm.compiler.asm.AbstractAddress;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.core.common.Stride;

import jdk.vm.ci.code.CodeUtil;
import jdk.vm.ci.code.Register;
Expand All @@ -39,7 +39,7 @@ public final class AMD64Address extends AbstractAddress {

private final Register base;
private final Register index;
private final Scale scale;
private final Stride stride;
private final int displacement;
private final Object displacementAnnotation;

Expand All @@ -56,7 +56,7 @@ public final class AMD64Address extends AbstractAddress {
* @param base the base register
*/
public AMD64Address(Register base) {
this(base, Register.None, Scale.Times1, 0);
this(base, Register.None, Stride.S1, 0);
}

/**
Expand All @@ -67,7 +67,7 @@ public AMD64Address(Register base) {
* @param displacement the displacement
*/
public AMD64Address(Register base, int displacement) {
this(base, Register.None, Scale.Times1, displacement);
this(base, Register.None, Stride.S1, displacement);
}

/**
Expand All @@ -76,10 +76,10 @@ public AMD64Address(Register base, int displacement) {
*
* @param base the base register
* @param index the index register
* @param scale the scaling factor
* @param stride the scaling factor
*/
public AMD64Address(Register base, Register index, Scale scale) {
this(base, index, scale, 0, null, -1);
public AMD64Address(Register base, Register index, Stride stride) {
this(base, index, stride, 0, null, -1);
}

/**
Expand All @@ -88,105 +88,40 @@ public AMD64Address(Register base, Register index, Scale scale) {
*
* @param base the base register
* @param index the index register
* @param scale the scaling factor
* @param stride the scaling factor
* @param displacement the displacement
*/
public AMD64Address(Register base, Register index, Scale scale, int displacement) {
this(base, index, scale, displacement, null, -1);
public AMD64Address(Register base, Register index, Stride stride, int displacement) {
this(base, index, stride, displacement, null, -1);
}

public AMD64Address(Register base, Register index, Scale scale, int displacement, Object displacementAnnotation) {
this(base, index, scale, displacement, displacementAnnotation, -1);
public AMD64Address(Register base, Register index, Stride stride, int displacement, Object displacementAnnotation) {
this(base, index, stride, displacement, displacementAnnotation, -1);
}

AMD64Address(Register base, Register index, Scale scale, int displacement, Object displacementAnnotation, int instructionStartPosition) {
AMD64Address(Register base, Register index, Stride stride, int displacement, Object displacementAnnotation, int instructionStartPosition) {
this.base = base;
this.index = index;
this.scale = scale;
this.stride = stride;
this.displacement = displacement;
this.displacementAnnotation = displacementAnnotation;
this.instructionStartPosition = instructionStartPosition;

assert scale != null;
assert stride != null;
}

/**
* A scaling factor used in the SIB addressing mode.
* Determines if the scaling factor {@code scale} is supported.
*/
public enum Scale {
Times1(1, 0),
Times2(2, 1),
Times4(4, 2),
Times8(8, 3);

Scale(int value, int log2) {
this.value = value;
this.log2 = log2;
}

/**
* The value (or multiplier) of this scale.
*/
public final int value;

/**
* The {@linkplain #value value} of this scale log 2.
*/
public final int log2;

/**
* Creates a {@link Scale} for the scaling factor in {@code scale}.
*
* @throws IllegalArgumentException if {@code scale} is an unsupported scaling factor
*/
public static Scale fromInt(int scale) {
switch (scale) {
case 1:
return Times1;
case 2:
return Times2;
case 4:
return Times4;
case 8:
return Times8;
default:
throw new IllegalArgumentException("Unsupported SIB addressing mode scaling factor: " + scale);
}
}

/**
* Creates a {@link Scale} for the log2 scaling factor {@code shift}.
*
* @throws IllegalArgumentException if {@code shift} is an unsupported scaling factor
*/
public static Scale fromShift(int shift) {
switch (shift) {
case 0:
return Times1;
case 1:
return Times2;
case 2:
return Times4;
case 3:
return Times8;
default:
throw GraalError.shouldNotReachHere("Unsupported SIB addressing mode scaling factor: " + (1 << shift));
}
}

/**
* Determines if the scaling factor {@code scale} is supported.
*/
public static boolean isScaleSupported(int scale) {
return CodeUtil.isPowerOf2(scale) && scale <= 8;
}
public static boolean isScaleSupported(int scale) {
return CodeUtil.isPowerOf2(scale) && scale <= 8;
}

/**
* Determines if the log2 scaling factor {@code shift} is supported.
*/
public static boolean isScaleShiftSupported(int shift) {
return shift >= 0 && shift <= 3;
}
/**
* Determines if the log2 scaling factor {@code shift} is supported.
*/
public static boolean isScaleShiftSupported(int shift) {
return shift >= 0 && shift <= 3;
}

@Override
Expand Down Expand Up @@ -233,8 +168,8 @@ public Register getIndex() {
/**
* @return Scaling factor for indexing, dependent on target operand size.
*/
public Scale getScale() {
return scale;
public Stride getScale() {
return stride;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
import java.util.EnumSet;

import org.graalvm.compiler.asm.Label;
import org.graalvm.compiler.asm.amd64.AMD64Address.Scale;
import org.graalvm.compiler.core.common.Stride;
import org.graalvm.compiler.asm.amd64.AVXKind.AVXSize;
import org.graalvm.compiler.core.common.calc.Condition;
import org.graalvm.compiler.debug.GraalError;
Expand Down Expand Up @@ -4764,7 +4764,7 @@ public AMD64Address makeAddress(Register base, int displacement) {

@Override
public AMD64Address getPlaceholder(int instructionStartPosition) {
return new AMD64Address(AMD64.rip, Register.None, Scale.Times1, 0, null, instructionStartPosition);
return new AMD64Address(AMD64.rip, Register.None, Stride.S1, 0, null, instructionStartPosition);
}

private void prefetchPrefix(AMD64Address src) {
Expand Down Expand Up @@ -4861,7 +4861,7 @@ public void clflushopt(AMD64Address adr) {
assert supportsCPUFeature("FLUSHOPT");
// adr should be base reg only with no index or offset
assert adr.getIndex().equals(Register.None) : adr;
assert adr.getScale().equals(Scale.Times1) : adr;
assert adr.getScale().equals(Stride.S1) : adr;
assert adr.getDisplacement() == 0 : adr;
// instruction prefix is 0x66
emitByte(0x66);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

import org.graalvm.collections.EconomicSet;
import org.graalvm.compiler.asm.Assembler;
import org.graalvm.compiler.asm.amd64.AMD64Address.Scale;
import org.graalvm.compiler.core.common.Stride;
import org.graalvm.compiler.asm.amd64.AVXKind.AVXSize;
import org.graalvm.compiler.debug.GraalError;

Expand Down Expand Up @@ -686,7 +686,7 @@ private void emitOperandHelper(int reg, AMD64Address addr, boolean force4Byte, i
Register base = addr.getBase();
Register index = addr.getIndex();

Scale scale = addr.getScale();
Stride stride = addr.getScale();
int disp = addr.getDisplacement();
Object dispAnnotation = addr.getDisplacementAnnotation();

Expand All @@ -710,7 +710,7 @@ private void emitOperandHelper(int reg, AMD64Address addr, boolean force4Byte, i
// [00 reg 100][ss index base]
assert !index.equals(rsp) : "illegal addressing mode";
emitByte(0x04 | regenc);
emitByte(scale.log2 << 6 | indexenc | baseenc);
emitByte(stride.log2 << 6 | indexenc | baseenc);
} else {
if (evexDisp8Scale > 1 && !overriddenForce4Byte) {
if (disp % evexDisp8Scale == 0) {
Expand All @@ -728,15 +728,15 @@ private void emitOperandHelper(int reg, AMD64Address addr, boolean force4Byte, i
// [01 reg 100][ss index base] imm8
assert !index.equals(rsp) : "illegal addressing mode";
emitByte(0x44 | regenc);
emitByte(scale.log2 << 6 | indexenc | baseenc);
emitByte(stride.log2 << 6 | indexenc | baseenc);
assert dispAnnotation == null;
emitByte(disp & 0xFF);
} else {
// [base + indexscale + disp32]
// [10 reg 100][ss index base] disp32
assert !index.equals(rsp) : "illegal addressing mode";
emitByte(0x84 | regenc);
emitByte(scale.log2 << 6 | indexenc | baseenc);
emitByte(stride.log2 << 6 | indexenc | baseenc);
emitDisplacementInt(disp, dispAnnotation);
}
}
Expand Down Expand Up @@ -814,7 +814,7 @@ private void emitOperandHelper(int reg, AMD64Address addr, boolean force4Byte, i
// [00 reg 100][ss index 101] disp32
assert !index.equals(rsp) : "illegal addressing mode";
emitByte(0x04 | regenc);
emitByte(scale.log2 << 6 | indexenc | 0x05);
emitByte(stride.log2 << 6 | indexenc | 0x05);
emitDisplacementInt(disp, dispAnnotation);
} else {
// [disp] ABSOLUTE
Expand Down
Loading

0 comments on commit a889540

Please sign in to comment.